Salome HOME
Update code documentation
[modules/shaper.git] / src / XGUI / XGUI_DataTreeModel.h
index 359fbdabdeac434cef82644fa682ff003daa2c80..fb28e59f8406154317e05ff487e3527ef13c7482 100644 (file)
@@ -1,57 +1,96 @@
-
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
 #ifndef XGUI_DataTreeModel_H
 #define XGUI_DataTreeModel_H
 
+#include "XGUI.h"
+
 #include <ModelAPI_Document.h>
-#include <QAbstractItemModel>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
 
-#include "XGUI_Constants.h"
+#include <QAbstractItemModel>
+#include <QColor>
 
 /**\class XGUI_FeaturesModel
  * \ingroup GUI
  * \brief Abstaract class of model object which operates with features data.
  */
-class XGUI_FeaturesModel : public QAbstractItemModel
+class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
 {
-public:
-  XGUI_FeaturesModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
-      QAbstractItemModel(theParent), myDocument(theDocument) {}
+ public:
+   /// Constructor
+   /// \param theParent a parent object
+  XGUI_FeaturesModel(QObject* theParent)
+      : QAbstractItemModel(theParent),
+        myItemsColor(Qt::black)
+  {
+  }
 
   //! Returns Feature object by the given Model index.
   //! Returns 0 if the given index is not index of a feature
-  virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
+  /// \param theIndex a model index
+  virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
+
+  //! Returns QModelIndex which corresponds to the given feature
+  //! If the feature is not found then index is not valid
+  virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
 
   //! Returns index corresponded to the group
+  //! \param theGroup a group name
   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
 
-protected:
-  std::shared_ptr<ModelAPI_Document> myDocument;
+  //! Set color of items
+  void setItemsColor(const QColor& theColor)
+  {
+    myItemsColor = theColor;
+  }
+
+  //! Returns color of items
+  QColor itemsColor() const
+  {
+    return myItemsColor;
+  }
+
+ protected:
+   /// Color of items
+  QColor myItemsColor;
 };
 
-
 /**\class XGUI_PartModel
  * \ingroup GUI
  * \brief Abstaract class of model object which operates with parts data.
  */
 class XGUI_PartModel : public XGUI_FeaturesModel
 {
-public:
-  XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
-      XGUI_FeaturesModel(theDocument, theParent) {}
-
-  void setPartId(int theId) { myId = theId; }
+ public:
+   /// Constructor
+   /// \param theParent a parent object
+  XGUI_PartModel(QObject* theParent)
+      : XGUI_FeaturesModel(theParent)
+  {
+  }
+
+  /// Set part id
+  /// \param theId a new id
+  void setPartId(int theId)
+  {
+    myId = theId;
+  }
 
   //! Returns true if the given document is a sub-document of this tree
-  virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
+  //! \param theDoc a document to check
+  virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
 
-protected:
+  //! Return a Part object
+  virtual ResultPartPtr part() const = 0;
+
+ protected:
   //! Id of the current part object in the document
   int myId;
 };
 
-
-#endif
\ No newline at end of file
+#endif