Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / particle_tree_ctrl.h
blob4f92adc34a14542986bc77107eec1bd93ee0bb88
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #if !defined(AFX_PARTICLE_TREE_CTRL_H__9A55D046_3E95_49CC_99AC_8A4F268EDD33__INCLUDED_)
19 #define AFX_PARTICLE_TREE_CTRL_H__9A55D046_3E95_49CC_99AC_8A4F268EDD33__INCLUDED_
21 #if _MSC_VER > 1000
22 #pragma once
23 #endif
26 #include "nel/misc/matrix.h"
28 #include "nel/3d/ps_particle.h"
29 #include "nel/3d/ps_edit.h"
30 #include "nel/3d/ps_located.h"
32 #include "particle_workspace.h"
34 #include <algorithm>
35 #include <memory>
37 class CParticleDlg;
38 class CParticleWorkspace;
41 namespace NL3D
43 class CParticleSystem;
44 class CParticleSystemModel;
50 /////////////////////////////////////////////////////////////////////////////
51 // CParticleTreeCtrl window
53 class CParticleTreeCtrl : public CTreeCtrl, public CParticleWorkspace::IModificationCallback
56 // Construction
57 public:
58 CParticleTreeCtrl(CParticleDlg *);
59 virtual ~CParticleTreeCtrl();
60 // Attributes
61 public:
63 // Operations
64 public:
66 // Overrides
67 // ClassWizard generated virtual function overrides
68 //{{AFX_VIRTUAL(CParticleTreeCtrl)
69 public:
70 virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
71 //}}AFX_VIRTUAL
73 // build the whole tree from a workspace
74 void buildTreeFromWorkSpace(CParticleWorkspace &ws);
75 /** build a portion of the tree using the given particle system
76 * \return root of the built tree
78 HTREEITEM buildTreeFromPS(CParticleWorkspace::CNode &node, HTREEITEM rootHandle, HTREEITEM prevSibling = TVI_LAST);
79 /// Add a node from the given lcoated
80 void createNodeFromLocated(NL3D::CPSLocated *loc, HTREEITEM rootHandle);
81 /// Add a node from the given located bindable
82 void createNodeFromLocatedBindable(NL3D::CPSLocatedBindable *lb, HTREEITEM rootHandle);
83 // rebuild the located instance in the tree (after loading for example)
84 void rebuildLocatedInstance(CParticleWorkspace::CNode &node);
85 /// suppress located instance item, so that they don't have higher index than the new size
86 void suppressLocatedInstanceNbItem(CParticleWorkspace::CNode &node, uint32 newSize);
88 void init(void);
89 // move the current element by using the given matrix
90 void moveElement(const NLMISC::CMatrix &mat);
91 // get the matrix of the current element being selected, or identity if there's none
92 NLMISC::CMatrix getElementMatrix(void) const;
93 // reset the list of node in the tree (but don't delete the tree)
94 void reset();
96 CParticleDlg *getParticleDlg() const { return _ParticleDlg; }
97 protected:
98 //{{AFX_MSG(CParticleTreeCtrl)
99 afx_msg void OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
100 afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
101 afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
102 afx_msg void OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
103 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
104 afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
105 afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
106 //}}AFX_MSG
108 CImageList _ImageList; // the image list containing the icons
111 // the dialog that contain us
112 CParticleDlg *_ParticleDlg;
114 public:
115 /** this struct is used to identify the type of each node
117 struct CNodeType
119 enum { located, particleSystem, locatedBindable, locatedInstance, workspace } Type;
120 union
122 CParticleWorkspace *WS;
123 NL3D::CPSLocated *Loc;
124 NL3D::CPSLocatedBindable *Bind;
125 CParticleWorkspace::CNode *PS;
127 // for the located instance type, this is the index of the instance
128 uint32 LocatedInstanceIndex;
129 // build node for a workspace
130 CNodeType(CParticleWorkspace *ws) { nlassert(ws); WS = ws; Type = workspace; }
131 // build node for a located
132 CNodeType(NL3D::CPSLocated *loc) { nlassert(loc); Loc = loc; Type = located; }
133 // build node for an instance of a located
134 CNodeType(NL3D::CPSLocated *loc, uint32 index)
136 nlassert(loc);
137 Loc = loc;
138 Type = locatedInstance;
139 LocatedInstanceIndex = index;
141 CNodeType(CParticleWorkspace::CNode *node)
143 PS = node;
144 Type = particleSystem;
146 CNodeType(NL3D::CPSLocatedBindable *lb) { Bind = lb; Type = locatedBindable; }
148 // Get the ps that owns that node (or NULL if it is a worspace)
149 NL3D::CParticleSystem *getOwnerPS() const;
152 void setViewFilenameFlag(bool enabled);
153 bool getViewFilenameFlag() const { return _ViewFilenameFlag; }
154 // Update caption of a node
155 void updateCaption(CParticleWorkspace::CNode &node);
156 private:
157 // instanciate a located in the given system , and return its nodetype and htreeitem
158 std::pair<CNodeType *, HTREEITEM> createLocated(NL3D::CParticleSystem *ps, HTREEITEM headItem);
159 // Compute caption to display for a particle system
160 std::string computeCaption(CParticleWorkspace::CNode &node);
161 // Compute caption to display for a workspace
162 std::string computeCaption(CParticleWorkspace &workspace);
163 // Compute a node caption from its filename, username & modified state
164 std::string computeCaption(const std::string &path, const std::string &userName, bool modified);
166 // Allow user to insert multiple PS in the workspace (prompt a file dialog to chose them)
167 void insertNewPS(CParticleWorkspace &pws);
168 // allow user to create a new particle system in the workspace
169 void createNewPS(CParticleWorkspace &pws);
170 // remove part of the tree and the associated CNodeType objects. IMPORTANT : DOES NOT update the matching elements in the ps that is being edited.
171 void removeTreePart(HTREEITEM root);
172 // get tree item from its matching CNodeType object
173 HTREEITEM getTreeItem(CNodeType *nt) const;
174 // get a tree item from a workspace node
175 HTREEITEM getTreeItem(CParticleWorkspace::CNode *node) const;
176 // Get the parent node in the workspace for the given element in the tree
177 CParticleWorkspace::CNode *getOwnerNode(CNodeType *nt) const;
178 // the last ps that had a selected instance in it
179 NLMISC::CRefPtr<NL3D::CParticleSystem> _LastClickedPS;
180 // Update right pane to edit the given element
181 void updateRightPane(CNodeType &nt);
182 // Matching infos for each nodes in the CTreeCtrl
183 std::vector<CNodeType *> _NodeTypes;
185 CUniquePtr<NL3D::CPSLocated> _LocatedCopy;
186 CUniquePtr<NL3D::CPSLocatedBindable> _LocatedBindableCopy;
188 DECLARE_MESSAGE_MAP()
189 // from CParticleWorkspace::IModificationCallback
190 virtual void nodeModifiedFlagChanged(CParticleWorkspace::CNode &node);
191 // from CParticleWorkspace::IModificationCallback
192 virtual void workspaceModifiedFlagChanged(CParticleWorkspace &ws);
193 // from CParticleWorkspace::IModificationCallback
194 virtual void nodeSkelParentChanged(CParticleWorkspace::CNode &node);
196 HTREEITEM _LastActiveNode;
198 bool _ViewFilenameFlag;
199 public:
200 // Update currently active node. Its node in the tree is displayed with bold characters.
201 void setActiveNode(CParticleWorkspace::CNode *node);
202 void touchPSState(CNodeType *nt);
203 void sortWorkspace(CParticleWorkspace &ws, CParticleWorkspace::ISort &sorter);
204 // delete the current selected node, and update the edited ps acoordingly
205 void deleteSelection();
206 void expandRoot();
207 void updateAllCaptions();
208 void removeAllPS(CParticleWorkspace &ws);
211 /////////////////////////////////////////////////////////////////////////////
213 //{{AFX_INSERT_LOCATION}}
214 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
216 #endif // !defined(AFX_PARTICLE_TREE_CTRL_H__9A55D046_3E95_49CC_99AC_8A4F268EDD33__INCLUDED_)