Cafu Engine
ToolOptionsBars.hpp
Go to the documentation of this file.
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_TOOL_OPTIONS_BARS_HPP_INCLUDED
8 #define CAFU_TOOL_OPTIONS_BARS_HPP_INCLUDED
9 
10 /// \file
11 /// This file contains the declarations of the tool options bars.
12 /// The bars are all derived from wxPanels, and add only little functionality.
13 /// Having them as separate classes makes many things a lot cleaner and clearer, though.
14 
15 // Turn off bogus warnings that occur with VC11's static code analysis.
16 // (Should move this to a better place though, e.g. some `compat.h` file...)
17 #if defined(_WIN32) && defined(_MSC_VER)
18  // warning C6011: dereferencing NULL pointer <name>
19  #pragma warning(disable:6011)
20 #endif
21 
22 #include "wx/wx.h"
23 #include "wx/spinctrl.h"
24 
25 
26 class ToolClipT;
27 class MapDocumentT;
28 class ToolMorphT;
29 class wxSpinEvent;
30 
31 
32 /// The options bar for the Selection tool.
33 class OptionsBar_SelectionToolT : public wxPanel
34 {
35  public:
36 
37  /// The constructor.
38  /// @param Parent is the parent window of this panel.
39  OptionsBar_SelectionToolT(wxWindow* Parent);
40 
41 
42  private:
43 
44  wxCheckBox* m_AutoGroupEntities; ///< The "auto-group entities" checkbox.
45 };
46 
47 
48 /// The options bar for the Camera tool.
49 class OptionsBar_CameraToolT : public wxPanel
50 {
51  public:
52 
53  /// The constructor.
54  OptionsBar_CameraToolT(wxWindow* Parent);
55 };
56 
57 
58 /// The options bar for the New Brush tool.
59 class OptionsBar_NewBrushToolT : public wxPanel
60 {
61  public:
62 
64  {
65  const char* Name;
66  unsigned long NrOfFaces;
67  unsigned long NrOfFacesMin;
68  unsigned long NrOfFacesMax;
69  };
70 
71  /// The constructor.
72  OptionsBar_NewBrushToolT(wxWindow* Parent);
73 
74  const int GetNrOfFaces () const { return m_NrOfFacesSpinControl->GetValue(); }
75  const int GetBrushIndex() const { return m_BrushPrimitiveChoice->GetSelection(); }
76 
77 
78  private:
79 
80  wxChoice* m_BrushPrimitiveChoice; ///< The wxChoice for the current brush primitive.
81  wxSpinCtrl* m_NrOfFacesSpinControl; ///< The wxSpinCtrl for the number of faces of the brush primitive.
82 
83  /// The event handlers.
84  void OnSelChangeBrushPrimitives(wxCommandEvent& Event);
85  void OnSpinCtrlNrOfFaces (wxSpinEvent& Event);
86 
87  /// IDs for the controls whose events we are interested in.
88  enum
89  {
90  ID_CHOICE_BRUSH_PRIMITIVES=wxID_HIGHEST+1,
91  ID_SPINCTRL_NR_OF_FACES
92  };
93 
94  DECLARE_EVENT_TABLE()
95 };
96 
97 
98 /// The options bar for the New Entity tool.
99 class OptionsBar_NewEntityToolT : public wxPanel
100 {
101  public:
102 
103  /// The constructor.
104  /// @param Parent is the parent window of this panel.
105  /// @param MapDoc is a reference to our document.
106  OptionsBar_NewEntityToolT(wxWindow* Parent, MapDocumentT& MapDoc);
107 };
108 
109 
110 /// The options bar for the New Bezier Patch tool.
111 class OptionsBar_NewBezierPatchToolT : public wxPanel
112 {
113  public:
114 
115  /// The constructor.
116  OptionsBar_NewBezierPatchToolT(wxWindow* Parent, MapDocumentT& MapDoc);
117 
118  unsigned long GetPatchResX() const;
119  unsigned long GetPatchResY() const;
120  bool WithConvexEndCaps() const { return m_CheckConvex ->GetValue(); }
121  bool WithConcaveEndCaps() const { return m_CheckConcave->GetValue(); }
122 
123  wxChoice* m_ChoicePatchType;
124  wxSpinCtrl* m_SpinCtrlSubdivsHorz;
125  wxSpinCtrl* m_SpinCtrlSubdivsVert;
126 
127 
128  private:
129 
130  MapDocumentT& m_MapDoc; ///< A reference to our document.
131  // wxChoice* m_ChoicePatchType;
132  wxChoice* m_ChoicePatchResX;
133  wxChoice* m_ChoicePatchResY;
134  // wxSpinCtrl* m_SpinCtrlSubdivsHorz;
135  // wxSpinCtrl* m_SpinCtrlSubdivsVert;
136  wxCheckBox* m_CheckConvex;
137  wxCheckBox* m_CheckConcave;
138 
139  void OnPatchTypeChoice(wxCommandEvent& Event); ///< Handles events that occur when a patch type is choosen from the patch type choice box.
140 
141  /// IDs for the controls whose events we are interested in.
142  enum
143  {
144  ID_PATCHTYPE,
145  ID_SUBDIVSHORZ,
146  ID_SUBDIVSVERT
147  };
148 
149  DECLARE_EVENT_TABLE()
150 };
151 
152 
153 /// The options bar for the New Terrain tool.
154 class OptionsBar_NewTerrainToolT : public wxPanel
155 {
156  public:
157 
158  /// The constructor.
159  OptionsBar_NewTerrainToolT(wxWindow* Parent, MapDocumentT& MapDoc);
160 
161  wxComboBox* m_ComboBoxHeightmapName; /// The heightmap name combobox: "a text field plus the MRU list". It is maintained by the MapTerrainT helper.
162  wxCheckBox* m_CheckBoxAddWallsAndCeil; /// The New Terrain tool should add walls and a ceiling if this is checked.
163  wxCheckBox* m_CheckBoxAddFloor; /// The New Terrain tool should add a floor if this is checked.
164 
165 
166  private:
167 
168  /// A reference to our document.
169  MapDocumentT& m_MapDoc;
170 
171  /// The Browse button event handler.
172  void OnButtonBrowse(wxCommandEvent& Event);
173 
174  /// IDs for the controls whose events we are interested in.
175  enum
176  {
177  ID_BUTTON_BROWSE=wxID_HIGHEST+1,
178  };
179 
180  DECLARE_EVENT_TABLE()
181 };
182 
183 
184 /// The options bar for the New Decal tool.
185 class OptionsBar_NewDecalToolT : public wxPanel
186 {
187  public:
188 
189  /// The constructor.
190  OptionsBar_NewDecalToolT(wxWindow* Parent);
191 };
192 
193 
194 /// The options bar for the Edit Face Properties tool.
195 class OptionsBar_EditFacePropsToolT : public wxPanel
196 {
197  public:
198 
199  /// The constructor.
200  OptionsBar_EditFacePropsToolT(wxWindow* Parent);
201 };
202 
203 
204 /// The options bar for the Clip Brushes tool.
205 class OptionsBar_ClipBrushesToolT : public wxPanel
206 {
207  public:
208 
209  /// This enumeration describes the clip mode of the clip brushes tool.
210  enum ClipModeT { KeepFront, KeepBack, KeepBoth };
211 
212 
213  /// The constructor.
214  OptionsBar_ClipBrushesToolT(wxWindow* Parent, ToolClipT& ToolClipBrushes);
215 
216  /// Returns the current clip mode.
217  ClipModeT GetClipMode() const;
218 
219  /// Switches to the next clip mode, and wraps if necessary.
220  /// This also calls the NoteClipModeChanged() method of the m_ToolClipBrushes
221  /// (as if the user had changed the clip mode manually).
222  void CycleClipMode();
223 
224 
225  private:
226 
227  ToolClipT& m_ToolClipBrushes; ///< Our clip brushes tool.
228  wxRadioButton* m_RB_ClipModeKeepFront; ///< The wxRadioButton for keeping the front part.
229  wxRadioButton* m_RB_ClipModeKeepBack; ///< The wxRadioButton for keeping the back part.
230  wxRadioButton* m_RB_ClipModeKeepBoth; ///< The wxRadioButton for keeping both parts.
231 
232  /// The event handler.
233  void OnSelChangeClipMode(wxCommandEvent& CE);
234 
235  /// IDs for the controls whose events we are interested in.
236  enum
237  {
238  ID_RB_CLIPMODE_KEEP_FRONT=wxID_HIGHEST+1,
239  ID_RB_CLIPMODE_KEEP_BACK,
240  ID_RB_CLIPMODE_KEEP_BOTH
241  };
242 
243  DECLARE_EVENT_TABLE()
244 };
245 
246 
247 /// The options bar for the Edit Vertices tool.
248 class OptionsBar_EditVerticesToolT : public wxPanel
249 {
250  public:
251 
252  enum EditModeT { EditVertices, EditEdges, EditBoth };
253 
254 
255  /// The constructor.
256  OptionsBar_EditVerticesToolT(wxWindow* Parent, ToolMorphT& ToolEditVertices);
257 
258  /// Returns the current edit mode.
259  EditModeT GetEditMode() const;
260 
261  /// Returns true if the current edit mode is EditVertices or EditBoth.
262  bool IsEditingVertices() const;
263 
264  /// Returns true if the current edit mode is EditEdges or EditBoth.
265  bool IsEditingEdges() const;
266 
267  /// Switches to the next edit mode, and wraps if necessary.
268  /// This also calls the NoteEditModeChanged() method of the m_ToolEditVertices
269  /// (as if the user had changed the edit mode manually).
270  void CycleEditMode();
271 
272 
273  private:
274 
275  ToolMorphT& m_ToolEditVertices; ///< Our edit vertices tool.
276  wxRadioButton* m_RB_EditModeVertices; ///< The wxRadioButton for editing the vertices.
277  wxRadioButton* m_RB_EditModeEdges; ///< The wxRadioButton for editing the edges.
278  wxRadioButton* m_RB_EditModeBoth; ///< The wxRadioButton for editing both the vertices and edges.
279 
280  /// The event handler.
281  void OnSelChangeEditMode(wxCommandEvent& CE);
282 
283  /// The "Insert Vertex" button event handler.
284  void OnButtonInsertVertex(wxCommandEvent& Event);
285 
286  /// IDs for the controls whose events we are interested in.
287  enum
288  {
289  ID_RB_EDITMODE_VERTICES=wxID_HIGHEST+1,
290  ID_RB_EDITMODE_EDGES,
291  ID_RB_EDITMODE_BOTH,
292  ID_BUTTON_INSERT_VERTEX
293  };
294 
295  DECLARE_EVENT_TABLE()
296 };
297 
298 #endif
Definition: ToolClip.hpp:20
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
OptionsBar_SelectionToolT(wxWindow *Parent)
The constructor.
Definition: ToolOptionsBars.cpp:19
OptionsBar_NewBrushToolT(wxWindow *Parent)
The constructor.
Definition: ToolOptionsBars.cpp:86
wxCheckBox * m_CheckBoxAddFloor
The New Terrain tool should add walls and a ceiling if this is checked.
Definition: ToolOptionsBars.hpp:163
The options bar for the New Bezier Patch tool.
Definition: ToolOptionsBars.hpp:111
OptionsBar_CameraToolT(wxWindow *Parent)
The constructor.
Definition: ToolOptionsBars.cpp:56
The options bar for the Selection tool.
Definition: ToolOptionsBars.hpp:33
The options bar for the Clip Brushes tool.
Definition: ToolOptionsBars.hpp:205
OptionsBar_EditFacePropsToolT(wxWindow *Parent)
The constructor.
Definition: ToolOptionsBars.cpp:416
wxCheckBox * m_CheckBoxAddWallsAndCeil
The heightmap name combobox: "a text field plus the MRU list". It is maintained by the MapTerrainT he...
Definition: ToolOptionsBars.hpp:162
OptionsBar_EditVerticesToolT(wxWindow *Parent, ToolMorphT &ToolEditVertices)
The constructor.
Definition: ToolOptionsBars.cpp:506
The options bar for the New Brush tool.
Definition: ToolOptionsBars.hpp:59
OptionsBar_NewBezierPatchToolT(wxWindow *Parent, MapDocumentT &MapDoc)
The constructor.
Definition: ToolOptionsBars.cpp:176
This class represents the "Edit Vertices" / "Morph" tool.
Definition: ToolMorph.hpp:33
ClipModeT GetClipMode() const
Returns the current clip mode.
Definition: ToolOptionsBars.cpp:472
OptionsBar_NewTerrainToolT(wxWindow *Parent, MapDocumentT &MapDoc)
The constructor.
Definition: ToolOptionsBars.cpp:338
OptionsBar_NewDecalToolT(wxWindow *Parent)
The constructor.
Definition: ToolOptionsBars.cpp:404
The options bar for the Camera tool.
Definition: ToolOptionsBars.hpp:49
The options bar for the New Entity tool.
Definition: ToolOptionsBars.hpp:99
EditModeT GetEditMode() const
Returns the current edit mode.
Definition: ToolOptionsBars.cpp:549
void CycleEditMode()
Switches to the next edit mode, and wraps if necessary.
Definition: ToolOptionsBars.cpp:562
OptionsBar_ClipBrushesToolT(wxWindow *Parent, ToolClipT &ToolClipBrushes)
The constructor.
Definition: ToolOptionsBars.cpp:435
The options bar for the New Terrain tool.
Definition: ToolOptionsBars.hpp:154
The options bar for the Edit Face Properties tool.
Definition: ToolOptionsBars.hpp:195
The options bar for the New Decal tool.
Definition: ToolOptionsBars.hpp:185
Definition: ToolOptionsBars.hpp:63
bool IsEditingVertices() const
Returns true if the current edit mode is EditVertices or EditBoth.
Definition: ToolOptionsBars.cpp:558
bool IsEditingEdges() const
Returns true if the current edit mode is EditEdges or EditBoth.
Definition: ToolOptionsBars.cpp:559
ClipModeT
This enumeration describes the clip mode of the clip brushes tool.
Definition: ToolOptionsBars.hpp:210
OptionsBar_NewEntityToolT(wxWindow *Parent, MapDocumentT &MapDoc)
The constructor.
Definition: ToolOptionsBars.cpp:152
The options bar for the Edit Vertices tool.
Definition: ToolOptionsBars.hpp:248
void CycleClipMode()
Switches to the next clip mode, and wraps if necessary.
Definition: ToolOptionsBars.cpp:481