Salome HOME
The external feature should be executed manually in order to return first result.
[modules/shaper.git] / src / PartSet / PartSet_DataTreeModel.h
index cb71be87a8056a078f28e6c6a620dcf33a83bca5..0fa8f6380b5c145f3add8221916d1326f03cdda0 100644 (file)
@@ -8,6 +8,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Session.h>
 
 #include <QAbstractItemModel>
 #include <QColor>
@@ -21,11 +22,7 @@ class PARTSET_EXPORT PartSet_FeaturesModel : public QAbstractItemModel
  public:
    /// Constructor
    /// \param theParent a parent object
-  PartSet_FeaturesModel(QObject* theParent)
-      : QAbstractItemModel(theParent),
-        myItemsColor(Qt::black)
-  {
-  }
+  PartSet_FeaturesModel(QObject* theParent);
 
   //! Returns Feature object by the given Model index.
   //! Returns 0 if the given index is not index of a feature
@@ -69,28 +66,34 @@ class PartSet_PartModel : public PartSet_FeaturesModel
  public:
    /// Constructor
    /// \param theParent a parent object
-  PartSet_PartModel(QObject* theParent)
-      : PartSet_FeaturesModel(theParent)
-  {
-  }
+  PartSet_PartModel(QObject* theParent);
+   /// Destructor 
+  ~PartSet_PartModel();
 
   /// Set part id
   /// \param theId a new id
-  void setPartId(int theId)
+  void setPart(FeaturePtr thePart)
   {
-    myId = theId;
+    myPart = thePart;
   }
 
+  /// Returns Id of the part
+  FeaturePtr part() const { return myPart; }
+
   //! Returns true if the given document is a sub-document of this tree
   //! \param theDoc a document to check
   virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
 
-  //! Return a Part object
-  virtual ResultPartPtr part() const = 0;
+  /// Returns position of the part in history 
+  int position() const 
+  {
+    DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+    return aRootDoc->index(myPart);
+  }
 
  protected:
   //! Id of the current part object in the document
-  int myId;
+  FeaturePtr myPart;
 };
 
 #endif