SHAPER  9.12.0
PartSet_TreeNodes.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef PartSet_TreeNodes_H
21 #define PartSet_TreeNodes_H
22 
23 #include "PartSet.h"
24 
25 #include <ModuleBase_ITreeNode.h>
26 #include <ModelAPI_Feature.h>
27 
28 
34 {
35 public:
36  PartSet_TreeNode(ModuleBase_ITreeNode* theParent = 0) : ModuleBase_ITreeNode(theParent) {}
37 
39  virtual QVariant data(int theColumn, int theRole) const;
40 
41  // Returns color of the Item when it is active
42  virtual QColor activeItemColor() const;
43 };
44 
50 {
51 public:
52  PartSet_ObjectNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent = 0)
53  : PartSet_TreeNode(theParent), myObject(theObj) {}
54 
55  static std::string typeId()
56  {
57  static std::string myType = "Object";
58  return myType;
59  }
60 
61  virtual std::string type() const { return typeId(); }
62 
64  virtual QVariant data(int theColumn, int theRole) const;
65 
67  virtual Qt::ItemFlags flags(int theColumn) const;
68 
70  virtual ObjectPtr object() const { return myObject; }
71 
74  void setObject(ObjectPtr theObj) { myObject = theObj; }
75 
76  virtual VisibilityState visibilityState() const;
77 
79  virtual void update();
80 
84  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
85 
89  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
90 
92  virtual int numberOfSubs() const;
93 
94  virtual ObjectPtr subObject(int theId) const;
95 
96  // Returns color of the Item when it is active
97  virtual QColor activeItemColor() const;
98 
99 protected:
100  ObjectPtr myObject;
101 };
102 
108 {
109 public:
110  enum FolderType {
111  ParametersFolder,
112  ConstructionFolder,
113  PartsFolder,
114  ResultsFolder,
115  FieldsFolder,
116  GroupsFolder
117  };
118 
119  PartSet_FolderNode(ModuleBase_ITreeNode* theParent, FolderType theType);
120 
121  static std::string typeId()
122  {
123  static std::string myType = "Folder";
124  return myType;
125  }
126 
127  virtual std::string type() const { return typeId(); }
128 
130  virtual QVariant data(int theColumn, int theRole) const;
131 
133  virtual Qt::ItemFlags flags(int theColumn) const;
134 
136  virtual void update();
137 
141  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
142 
146  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
147 
148  QString name() const;
149 
154  virtual ModuleBase_ITreeNode* findParent(const DocumentPtr& theDoc, QString theGroup)
155  {
156  if ((theDoc == document()) && (theGroup.toStdString() == groupName()))
157  return this;
158  return 0;
159  }
160 
161 private:
162  std::string groupName() const;
163 
164  ModuleBase_ITreeNode* createNode(const ObjectPtr& theObj);
165 
166  FolderType myType;
167 };
168 
170 
175 {
176 public:
177  PartSet_FeatureFolderNode(ModuleBase_ITreeNode* theParent = 0) : PartSet_TreeNode(theParent) {}
178 
182  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
183 
187  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
188 
193  virtual ModuleBase_ITreeNode* findParent(const DocumentPtr& theDoc, QString theGroup);
194 
195 protected:
196  virtual ModuleBase_ITreeNode* createNode(const ObjectPtr& theObj) = 0;
197 
198  virtual int numberOfFolders() const { return 0; }
199 };
200 
201 
203 
208 {
209 public:
211 
212  static std::string typeId()
213  {
214  static std::string myType = "PartSetRoot";
215  return myType;
216  }
217 
218  virtual std::string type() const { return typeId(); }
219 
221  virtual void update();
222 
223  virtual ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
224 
226  virtual DocumentPtr document() const;
227 
228  void setWorkshop(ModuleBase_IWorkshop* theWork) { myWorkshop = theWork; }
229 
230 protected:
231  virtual ModuleBase_ITreeNode* createNode(const ObjectPtr& theObj);
232 
233  virtual int numberOfFolders() const { return 3; }
234 
235 private:
236  PartSet_FolderNode* myParamsFolder;
237  PartSet_FolderNode* myConstrFolder;
238  PartSet_FolderNode* myPartsFolder;
239 
240  ModuleBase_IWorkshop* myWorkshop;
241 };
242 
244 
249 {
250 public:
251  PartSet_PartRootNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent);
252 
253  static std::string typeId()
254  {
255  static std::string myType = "PartRoot";
256  return myType;
257  }
258 
259  virtual std::string type() const { return typeId(); }
260 
262  virtual ObjectPtr object() const { return myObject; }
263 
265  virtual DocumentPtr document() const;
266 
268  virtual void update();
269 
271  virtual QVariant data(int theColumn, int theRole) const;
272 
274  virtual Qt::ItemFlags flags(int theColumn) const;
275 
279  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
280 
284  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
285 
286 protected:
287  virtual ModuleBase_ITreeNode* createNode(const ObjectPtr& theObj);
288 
289  virtual int numberOfFolders() const;
290 
291  virtual void deleteChildren();
292 
293 private:
294  PartSet_FolderNode* myParamsFolder;
295  PartSet_FolderNode* myConstrFolder;
296  PartSet_FolderNode* myResultsFolder;
297  PartSet_FolderNode* myFieldsFolder;
298  PartSet_FolderNode* myGroupsFolder;
299 
300  ObjectPtr myObject;
301 };
302 
304 
309 {
310 public:
311  PartSet_ObjectFolderNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent)
312  : PartSet_ObjectNode(theObj, theParent) {}
313 
314  static std::string typeId()
315  {
316  static std::string myType = "ObjectFolder";
317  return myType;
318  }
319 
320  virtual std::string type() const { return typeId(); }
321 
323  virtual void update();
324 
328  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
329 
333  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
334 
336  virtual QVariant data(int theColumn, int theRole) const;
337 };
338 
339 
341 
346 {
347 public:
348  PartSet_StepNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent) :
349  PartSet_ObjectNode(theObj, theParent) {}
350 
351  static std::string typeId()
352  {
353  static std::string myType = "FieldStep";
354  return myType;
355  }
356 
357  virtual std::string type() const { return typeId(); }
358 
360  virtual QVariant data(int theColumn, int theRole) const;
361 
362  virtual VisibilityState visibilityState() const;
363 };
364 
365 #endif
Definition: ModuleBase_ITreeNode.h:44
ModuleBase_ITreeNode(ModuleBase_ITreeNode *theParent=0)
Default constructor.
Definition: ModuleBase_ITreeNode.h:54
virtual DocumentPtr document() const
Returns document object of the sub-tree. Has to be reimplemented in sub-tree root object.
Definition: ModuleBase_ITreeNode.h:144
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
A base class for root folders.
Definition: PartSet_TreeNodes.h:175
virtual QTreeNodesList objectCreated(const QObjectPtrList &theObjects)
Process creation of objects.
Definition: PartSet_TreeNodes.cpp:671
virtual QTreeNodesList objectsDeleted(const DocumentPtr &theDoc, const QString &theGroup)
Process deletion of objects.
Definition: PartSet_TreeNodes.cpp:721
virtual ModuleBase_ITreeNode * findParent(const DocumentPtr &theDoc, QString theGroup)
Returns a node which belongs to the given document and contains objects of the given group.
Definition: PartSet_TreeNodes.cpp:767
Implementation of aFolder node in data tree.
Definition: PartSet_TreeNodes.h:108
virtual Qt::ItemFlags flags(int theColumn) const
Returns properties flag of the item.
Definition: PartSet_TreeNodes.cpp:514
virtual QTreeNodesList objectCreated(const QObjectPtrList &theObjects)
Process creation of objects.
Definition: PartSet_TreeNodes.cpp:594
virtual void update()
Updates sub-nodes of the node.
Definition: PartSet_TreeNodes.cpp:535
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:463
virtual QTreeNodesList objectsDeleted(const DocumentPtr &theDoc, const QString &theGroup)
Process deletion of objects.
Definition: PartSet_TreeNodes.cpp:636
virtual ModuleBase_ITreeNode * findParent(const DocumentPtr &theDoc, QString theGroup)
Returns a node which belongs to the given document and contains objects of the given group.
Definition: PartSet_TreeNodes.h:154
Implementation of a folder which corresponds to ModelAPI_Folder object.
Definition: PartSet_TreeNodes.h:309
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:1236
virtual QTreeNodesList objectCreated(const QObjectPtrList &theObjects)
Process creation of objects.
Definition: PartSet_TreeNodes.cpp:1156
virtual QTreeNodesList objectsDeleted(const DocumentPtr &theDoc, const QString &theGroup)
Process deletion of objects.
Definition: PartSet_TreeNodes.cpp:1190
virtual void update()
Updates sub-nodes of the node.
Definition: PartSet_TreeNodes.cpp:1098
Implementation of a node for object repesentation.
Definition: PartSet_TreeNodes.h:50
virtual ObjectPtr object() const
Returns object referenced by the node (can be null)
Definition: PartSet_TreeNodes.h:70
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:107
virtual void update()
Updates sub-nodes of the node.
Definition: PartSet_TreeNodes.cpp:261
virtual QTreeNodesList objectsDeleted(const DocumentPtr &theDoc, const QString &theGroup)
Process deletion of objects.
Definition: PartSet_TreeNodes.cpp:395
void setObject(ObjectPtr theObj)
Sets an object to the node theObj a new object.
Definition: PartSet_TreeNodes.h:74
virtual QTreeNodesList objectCreated(const QObjectPtrList &theObjects)
Process creation of objects.
Definition: PartSet_TreeNodes.cpp:342
virtual int numberOfSubs() const
Returns number of sub-objects of the current object.
Definition: PartSet_TreeNodes.cpp:227
virtual Qt::ItemFlags flags(int theColumn) const
Returns properties flag of the item.
Definition: PartSet_TreeNodes.cpp:159
virtual VisibilityState visibilityState() const
Returns visibilitystate of the node in viewer 3d.
Definition: PartSet_TreeNodes.cpp:183
Implementation of Root node of a Part document in data tree.
Definition: PartSet_TreeNodes.h:249
virtual void update()
Updates sub-nodes of the node.
Definition: PartSet_TreeNodes.cpp:902
virtual QTreeNodesList objectCreated(const QObjectPtrList &theObjects)
Process creation of objects.
Definition: PartSet_TreeNodes.cpp:1051
virtual DocumentPtr document() const
Returns document object of the sub-tree.
Definition: PartSet_TreeNodes.cpp:984
virtual Qt::ItemFlags flags(int theColumn) const
Returns properties flag of the item.
Definition: PartSet_TreeNodes.cpp:1020
virtual QTreeNodesList objectsDeleted(const DocumentPtr &theDoc, const QString &theGroup)
Process deletion of objects.
Definition: PartSet_TreeNodes.cpp:1073
virtual void deleteChildren()
deletes all children nodes (called in destructor.)
Definition: PartSet_TreeNodes.cpp:890
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:992
virtual ObjectPtr object() const
Returns object referenced by the node (can be null)
Definition: PartSet_TreeNodes.h:262
Implementation of Root node in data tree.
Definition: PartSet_TreeNodes.h:208
virtual ModuleBase_IWorkshop * workshop() const
Returns workshop object. Has to be reimplemented in a root node.
Definition: PartSet_TreeNodes.h:223
virtual DocumentPtr document() const
Returns document object of the sub-tree.
Definition: PartSet_TreeNodes.cpp:854
virtual void update()
Updates sub-nodes of the node.
Definition: PartSet_TreeNodes.cpp:803
Implementation of a node for compsolid representation.
Definition: PartSet_TreeNodes.h:346
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:1250
virtual VisibilityState visibilityState() const
Returns visibilitystate of the node in viewer 3d.
Definition: PartSet_TreeNodes.cpp:1262
Implementation of base node for the module data tree.
Definition: PartSet_TreeNodes.h:34
virtual QVariant data(int theColumn, int theRole) const
Returns the node representation according to theRole.
Definition: PartSet_TreeNodes.cpp:83