Salome HOME
Apply warning icon to folder only in case if it is not expanded
[modules/shaper.git] / src / PartSet / PartSet_TreeNodes.h
index f3a596ecdffc9bd97268f0394a2954a85210a2bc..5961121e99e4acd9f62bdfa15c060ee612f57049 100644 (file)
@@ -24,6 +24,7 @@
 #include "PartSet.h"
 
 #include <ModuleBase_ITreeNode.h>
+#include <ModelAPI_Feature.h>
 
 
 /**
@@ -46,16 +47,17 @@ public:
 class PartSet_ObjectNode : public PartSet_TreeNode
 {
 public:
-  enum VisibilityState {
-    NoneState,
-    Visible,
-    SemiVisible,
-    Hidden
-  };
-
   PartSet_ObjectNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent = 0)
     : PartSet_TreeNode(theParent), myObject(theObj) {}
 
+  static std::string typeId()
+  {
+    static std::string myType = "Object";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
+
   /// Returns the node representation according to theRole.
   virtual QVariant data(int theColumn, int theRole) const;
 
@@ -65,12 +67,31 @@ public:
   /// Returns object referenced by the node (can be null)
   virtual ObjectPtr object() const { return myObject; }
 
+  /// Sets an object to the node
+  /// theObj a new object
+  void setObject(ObjectPtr theObj) { myObject = theObj; }
+
+  virtual VisibilityState visibilityState() const;
+
   /// Updates sub-nodes of the node
-  virtual void update() {}
+  virtual void update();
 
-  VisibilityState getVisibilityState() const;
+  /// Process creation of objects.
+  /// \param theObjects a list of created objects
+  /// \return a list of nodes which corresponds to the created objects
+  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
 
-private:
+  /// Process deletion of objects.
+  /// \param theDoc a document where objects were deleted
+  /// \param theGroup a name of group where objects were deleted
+  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
+
+  /// Returns number of sub-objects of the current object
+  virtual int numberOfSubs() const;
+
+  virtual ObjectPtr subObject(int theId) const;
+
+protected:
   ObjectPtr myObject;
 };
 
@@ -92,7 +113,13 @@ public:
 
   PartSet_FolderNode(ModuleBase_ITreeNode* theParent, FolderType theType);
 
-  virtual ~PartSet_FolderNode();
+  static std::string typeId()
+  {
+    static std::string myType = "Folder";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
 
   /// Returns the node representation according to theRole.
   virtual QVariant data(int theColumn, int theRole) const;
@@ -129,6 +156,8 @@ public:
 private:
   std::string groupName() const;
 
+  ModuleBase_ITreeNode* createNode(const ObjectPtr& theObj);
+
   FolderType myType;
 };
 
@@ -174,7 +203,14 @@ class PartSet_RootNode : public PartSet_FeatureFolderNode
 {
 public:
   PartSet_RootNode();
-  virtual ~PartSet_RootNode();
+
+  static std::string typeId()
+  {
+    static std::string myType = "PartSetRoot";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
 
   /// Updates sub-nodes of the node
   virtual void update();
@@ -209,7 +245,13 @@ class PartSet_PartRootNode : public PartSet_FeatureFolderNode
 public:
   PartSet_PartRootNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent);
 
-  virtual ~PartSet_PartRootNode();
+  static std::string typeId()
+  {
+    static std::string myType = "PartRoot";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
 
   /// Returns object referenced by the node (can be null)
   virtual ObjectPtr object() const { return myObject; }
@@ -241,6 +283,8 @@ protected:
 
   virtual int numberOfFolders() const;
 
+  virtual void deleteChildren();
+
 private:
   PartSet_FolderNode* myParamsFolder;
   PartSet_FolderNode* myConstrFolder;
@@ -251,4 +295,72 @@ private:
   ObjectPtr myObject;
 };
 
-#endif
\ No newline at end of file
+/////////////////////////////////////////////////////////////////////
+/**
+* \ingroup Modules
+* Implementation of a folder which corresponds to ModelAPI_Folder object
+*/
+class PartSet_ObjectFolderNode : public PartSet_ObjectNode
+{
+public:
+  PartSet_ObjectFolderNode(const ObjectPtr& theObj, ModuleBase_ITreeNode* theParent)
+    : PartSet_ObjectNode(theObj, theParent) {}
+
+  static std::string typeId()
+  {
+    static std::string myType = "ObjectFolder";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
+
+  /// Updates sub-nodes of the node
+  virtual void update();
+
+  /// Process creation of objects.
+  /// \param theObjects a list of created objects
+  /// \return a list of nodes which corresponds to the created objects
+  virtual QTreeNodesList objectCreated(const QObjectPtrList& theObjects);
+
+  /// Process deletion of objects.
+  /// \param theDoc a document where objects were deleted
+  /// \param theGroup a name of group where objects were deleted
+  virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
+};
+
+
+/////////////////////////////////////////////////////////////////////
+/**
+* \ingroup Modules
+* Implementation of a node for compsolid representation
+*/
+class PartSet_StepNode : public PartSet_TreeNode
+{
+public:
+  PartSet_StepNode(ModelAPI_Entity* theEnt, ModuleBase_ITreeNode* theParent) :
+    PartSet_TreeNode(theParent), myEntity(theEnt) {}
+
+  static std::string typeId()
+  {
+    static std::string myType = "FieldStep";
+    return myType;
+  }
+
+  virtual std::string type() const { return typeId(); }
+
+  /// Returns the node representation according to theRole.
+  virtual QVariant data(int theColumn, int theRole) const;
+
+  ModelAPI_Entity* entity() const {
+    return myEntity;
+  }
+
+  void setEntity(ModelAPI_Entity* theEnt) {
+    myEntity = theEnt;
+  }
+
+private:
+  ModelAPI_Entity* myEntity;
+};
+
+#endif