Cafu Engine
ChildFrame.hpp
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_MODELEDITOR_CHILD_FRAME_HPP_INCLUDED
8 #define CAFU_MODELEDITOR_CHILD_FRAME_HPP_INCLUDED
9 
10 #include "../CommandHistory.hpp"
11 #include "ElementTypes.hpp"
12 #include "wx/docmdi.h"
13 #include "wx/aui/framemanager.h"
14 
15 
16 class ParentFrameT;
17 
18 
19 namespace ModelEditor
20 {
21  class AnimInspectorT;
22  class ChannelInspectorT;
23  class ElementsPanelT;
24  class GuiFixInspectorT;
25  class JointInspectorT;
26  class JointsHierarchyT;
27  class MeshInspectorT;
28  class ModelDocumentT;
29  class ScenePropGridT;
30  class SceneView3DT;
31  class SubmodelsPanelT;
32  class TransformDialogT;
33 
34 
35  class ChildFrameT : public wxMDIChildFrame
36  {
37  public:
38 
39  /// The constructor for creating a new model editor child frame.
40  /// @param Parent The applications parent frame.
41  /// @param FileName The file name of the document being edited.
42  /// @param ModelDoc This frames model document. The frame becomes the owner of the document, i.e. it is responsible for destructing it.
43  /// (Document is created externally so that this constructor doesn't fail on doc creation failure.)
44  ChildFrameT(ParentFrameT* Parent, const wxString& FileName, ModelDocumentT* ModelDoc);
45 
46  /// The destructor.
47  ~ChildFrameT();
48 
49  /// [...]
50  /// All(!) commands for modifying the document must be submitted via this method.
51  bool SubmitCommand(CommandT* Command);
52 
53  /// Creates a new skin, calls SubmitCommand() accordingly and returns its result.
54  bool SubmitNewSkin();
55 
56  /// Creates a new GUI fixture, calls SubmitCommand() accordingly and returns its result.
57  bool SubmitNewGuiFixture();
58 
59  /// Imports animation sequences from a user selected file, calls SubmitCommand() accordingly and returns its result.
60  bool SubmitImportAnims();
61 
62  /// Creates a new animation channel, calls SubmitCommand() accordingly and returns its result.
63  bool SubmitNewChannel();
64 
65  /// Saves the model under the known or a new file name.
66  /// @param AskForFileName Whether the method should ask the user to enter a new file name, used for "Save as...".
67  /// @returns whether the file was successfully saved.
68  bool Save(bool AskForFileName=false);
69 
70  /// This method shows or hides the pane of the detail inspector that is related to the given list view.
71  /// The method does nothing if the given list view is not the joints hierarchy, the meshes list, the anims list or the GUI fixtures list.
72  void ShowRelatedInspector(wxWindow* List, bool DoShow=true);
73 
74  /// Returns the type of the most recently used (clicked) model element.
75  const ModelElementTypeT GetLastUsedType() const { return m_LastUsedType; }
76 
77  /// Sets the type of the most recently used (clicked) model element.
78  void SetLastUsedType(ModelElementTypeT Type) { wxASSERT(Type<6); m_LastUsedType=Type; }
79 
80  ModelDocumentT* GetModelDoc() const { return m_ModelDoc; }
81  ScenePropGridT* GetScenePropGrid() const { return m_ScenePropGrid; }
82 
83 
84  private:
85 
86  /// Saves all the materials that are not hand-crafted when the model is saved.
87  void SaveMaterials(const wxString& OldBaseName, const wxString& BaseName);
88 
89  /// Shows or hides the given AUI pane.
90  void PaneToggleShow(wxAuiPaneInfo& PaneInfo);
91 
92  /// Returns a string with all the LoD models loaded with the main model.
93  wxString GetLodModelsString() const;
94 
95  wxString m_FileName;
96  ModelDocumentT* m_ModelDoc;
97  CommandHistoryT m_History; ///< The command history.
98  unsigned long m_LastSavedAtCommandNr;
99  ModelElementTypeT m_LastUsedType; ///< The type of the most recently used (clicked) model element.
100 
101  ParentFrameT* m_Parent;
102  wxMenu* m_FileMenu;
103  wxMenu* m_EditMenu;
104 
105  wxAuiManager m_AUIManager;
106  SceneView3DT* m_SceneView3D;
107  JointsHierarchyT* m_JointsHierarchy;
108  JointInspectorT* m_JointInspector;
109  ElementsPanelT* m_MeshesList;
110  MeshInspectorT* m_MeshInspector;
111  ElementsPanelT* m_SkinsList;
112  wxStaticText* m_SkinInspector;
113  ElementsPanelT* m_GuiFixturesList;
114  GuiFixInspectorT* m_GuiFixtureInspector;
115  ElementsPanelT* m_AnimsList;
116  AnimInspectorT* m_AnimInspector;
117  ElementsPanelT* m_ChannelsList;
118  ChannelInspectorT* m_ChannelInspector;
119  ScenePropGridT* m_ScenePropGrid;
120  SubmodelsPanelT* m_SubmodelsPanel;
121  wxStaticText* m_DlodModelsList;
122  TransformDialogT* m_TransformDialog;
123 
124 
125  enum
126  {
127  ID_MENU_FILE_CLOSE=wxID_HIGHEST+1+2000,
128  ID_MENU_FILE_SAVE,
129  ID_MENU_FILE_SAVEAS,
130 
131  ID_MENU_VIEW_AUIPANE_JOINTS_HIERARCHY,
132  ID_MENU_VIEW_AUIPANE_JOINT_INSPECTOR,
133  ID_MENU_VIEW_AUIPANE_MESHES_LIST,
134  ID_MENU_VIEW_AUIPANE_MESH_INSPECTOR,
135  ID_MENU_VIEW_AUIPANE_SKINS_LIST,
136  ID_MENU_VIEW_AUIPANE_SKIN_INSPECTOR,
137  ID_MENU_VIEW_AUIPANE_GUIFIXTURES_LIST,
138  ID_MENU_VIEW_AUIPANE_GUIFIXTURE_INSPECTOR,
139  ID_MENU_VIEW_AUIPANE_ANIMS_LIST,
140  ID_MENU_VIEW_AUIPANE_ANIM_INSPECTOR,
141  ID_MENU_VIEW_AUIPANE_CHANNELS_LIST,
142  ID_MENU_VIEW_AUIPANE_CHANNEL_INSPECTOR,
143  ID_MENU_VIEW_AUIPANE_SCENE_SETUP,
144  ID_MENU_VIEW_AUIPANE_SUBMODELS_LIST,
145  ID_MENU_VIEW_AUIPANE_DLOD_MODELS_LIST,
146  ID_MENU_VIEW_AUIPANE_TRANSFORM_DIALOG,
147  ID_MENU_VIEW_LOAD_DEFAULT_PERSPECTIVE,
148  ID_MENU_VIEW_LOAD_USER_PERSPECTIVE,
149  ID_MENU_VIEW_SAVE_USER_PERSPECTIVE,
150 
151  ID_MENU_MODEL_ANIM_SKIP_BACKWARD,
152  ID_MENU_MODEL_ANIM_PLAY,
153  ID_MENU_MODEL_ANIM_PAUSE,
154  ID_MENU_MODEL_ANIM_SKIP_FORWARD,
155  ID_MENU_MODEL_TRANSFORM,
156  ID_MENU_MODEL_SKIN_ADD,
157  ID_MENU_MODEL_GUIFIXTURE_ADD,
158  ID_MENU_MODEL_ANIM_IMPORT,
159  ID_MENU_MODEL_CHANNEL_ADD,
160  ID_MENU_MODEL_LOAD_SUBMODEL,
161  ID_MENU_MODEL_UNLOAD_SUBMODELS
162  };
163 
164  void OnMenuFile(wxCommandEvent& CE);
165  void OnMenuFileUpdate(wxUpdateUIEvent& UE);
166  void OnMenuUndoRedo(wxCommandEvent& CE);
167  void OnMenuUndoRedoUpdate(wxUpdateUIEvent& UE);
168  void OnMenuEdit(wxCommandEvent& CE);
169  void OnMenuEditUpdate(wxUpdateUIEvent& UE);
170  void OnMenuView(wxCommandEvent& CE);
171  void OnMenuViewUpdate(wxUpdateUIEvent& UE);
172  void OnMenuModel(wxCommandEvent& CE);
173  void OnMenuModelUpdate(wxUpdateUIEvent& UE);
174  void OnClose(wxCloseEvent& CE);
175 
176  DECLARE_EVENT_TABLE()
177  };
178 }
179 
180 #endif
bool Save(bool AskForFileName=false)
Saves the model under the known or a new file name.
Definition: ChildFrame.cpp:512
Definition: ChildFrame.hpp:35
void SetLastUsedType(ModelElementTypeT Type)
Sets the type of the most recently used (clicked) model element.
Definition: ChildFrame.hpp:78
bool SubmitNewSkin()
Creates a new skin, calls SubmitCommand() accordingly and returns its result.
Definition: ChildFrame.cpp:342
void ShowRelatedInspector(wxWindow *List, bool DoShow=true)
This method shows or hides the pane of the detail inspector that is related to the given list view...
Definition: ChildFrame.cpp:670
This class represents the CaWE parent (main) frame.
Definition: ParentFrame.hpp:33
~ChildFrameT()
The destructor.
Definition: ChildFrame.cpp:315
const ModelElementTypeT GetLastUsedType() const
Returns the type of the most recently used (clicked) model element.
Definition: ChildFrame.hpp:75
Definition: CommandHistory.hpp:13
ChildFrameT(ParentFrameT *Parent, const wxString &FileName, ModelDocumentT *ModelDoc)
The constructor for creating a new model editor child frame.
Definition: ChildFrame.cpp:61
Definition: DialogTransform.hpp:14
bool SubmitNewGuiFixture()
Creates a new GUI fixture, calls SubmitCommand() accordingly and returns its result.
Definition: ChildFrame.cpp:354
bool SubmitNewChannel()
Creates a new animation channel, calls SubmitCommand() accordingly and returns its result...
Definition: ChildFrame.cpp:417
bool SubmitImportAnims()
Imports animation sequences from a user selected file, calls SubmitCommand() accordingly and returns ...
Definition: ChildFrame.cpp:365
bool SubmitCommand(CommandT *Command)
[...] All(!) commands for modifying the document must be submitted via this method.
Definition: ChildFrame.cpp:330
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
Definition: ModelDocument.hpp:30