]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
<Type>Ptr definitiomns added
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 19 May 2014 10:43:37 +0000 (14:43 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 19 May 2014 10:43:37 +0000 (14:43 +0400)
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_PluginManager.h
src/XGUI/XGUI_Constants.h
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_PartDataModel.h

index 187654cd88c4aab6afdc2e1866bf37aa91156621..f8dd2289673e932f53d9d01a26df8e5acee9c17b 100644 (file)
@@ -70,4 +70,7 @@ protected:
   {}
 };
 
+typedef boost::shared_ptr<ModelAPI_Data> DataPtr;
+
+
 #endif
index 311745a16e24b69c22fc67d981fdcccc19032944..cc188d9d4d6b366daefb0a2b90d3edf6b95eb866 100644 (file)
@@ -91,4 +91,9 @@ protected:
   {}
 };
 
+
+//! Pointer on document object
+typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;
+
+
 #endif
index 1dd7b12dbfbf4803602e312167bca7197cad6332..eb4ba54f992dc60664127fa71ba529a540dea8c8 100644 (file)
@@ -70,4 +70,8 @@ protected:
   friend class Model_Document;
 };
 
+//! Pointer on feature object
+typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;
+
+
 #endif
index 64240ce38b63a274007d598aea7fc91a8b24cca6..55ee0952733f50dbe8943d7c11f347b41e46414b 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "ModelAPI_Feature.h"
 
+#include <boost/shared_ptr.hpp>
+
 /**\class ModelAPI_Object
  * \ingroup DataModel
  * \brief Represents the result of some feature in the object browser
@@ -30,4 +32,7 @@ public:
   MODELAPI_EXPORT virtual void setName(std::string theName) = 0;
 };
 
+
+typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;
+
 #endif
index ef3fa80df5c0a489ece2004a08e5b99c5ecd6f47..47c42562ffdcd87682973ccdd152d595593a0290 100644 (file)
@@ -58,4 +58,7 @@ protected:
   friend class Model_Document;
 };
 
+typedef boost::shared_ptr<ModelAPI_PluginManager> PluginManagerPtr;
+
+
 #endif
index 9255b5239a74016f26abb017a85749228f0fbca7..02f0001c1482f2e6c5509f4f2c4689ff92856018 100644 (file)
@@ -10,9 +10,6 @@
 typedef QList<int> QIntList;       //!< list of int values
 typedef QList<short> QShortList;     //!< list of short int values
 typedef QList<double> QDoubleList;    //!< list of double values
-
-//! Pointer on feature object
-typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;
 typedef QList<FeaturePtr> QFeatureList; //!< List of features
 
 namespace XGUI
index be711129293bb2f8bb55932384b19ce906f0c7d4..42c609dac5f2c382b948a2cf30a2a80c7fa411a6 100644 (file)
@@ -6,6 +6,8 @@
 #include "XGUI_Constants.h"
 
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
+
 #include <QAbstractItemModel>
 #include <QColor>
 
@@ -16,7 +18,7 @@
 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
 {
 public:
-  XGUI_FeaturesModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+  XGUI_FeaturesModel(const DocumentPtr& theDocument, QObject* theParent):
       QAbstractItemModel(theParent), myDocument(theDocument), myItemsColor(Qt::black) {}
 
   //! Returns Feature object by the given Model index.
@@ -24,7 +26,7 @@ public:
   virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+  virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
@@ -46,13 +48,13 @@ protected:
 class XGUI_PartModel : public XGUI_FeaturesModel
 {
 public:
-  XGUI_PartModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+  XGUI_PartModel(const DocumentPtr& theDocument, QObject* theParent):
       XGUI_FeaturesModel(theDocument, theParent) {}
 
   void setPartId(int theId) { myId = theId; }
 
   //! Returns true if the given document is a sub-document of this tree
-  virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
+  virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
 
   //! Return a Part object
   virtual FeaturePtr part() const = 0;
index fc55498462b07b665eaf7d84d542130e5fb6e702..2ce2c5a26ffc773a40cde820cfc84b9cb513bdb8 100644 (file)
@@ -6,11 +6,12 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Object.h>
 
 #include <QIcon>
 #include <QBrush>
 
-XGUI_TopDataModel::XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_TopDataModel::XGUI_TopDataModel(const DocumentPtr& theDocument, QObject* theParent)
   : XGUI_FeaturesModel(theDocument, theParent)
 {
 }
@@ -30,7 +31,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
       return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
     case ParamObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+        FeaturePtr aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
         if (aFeature)
           return aFeature->data()->getName().c_str();
       } 
@@ -38,7 +39,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
         return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
     case ConstructObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
@@ -149,7 +150,7 @@ FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
 }
 
 
-QModelIndex XGUI_TopDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const FeaturePtr& theFeature) const
 {
   QString aGroup(theFeature->getGroup().c_str());
 
@@ -173,7 +174,7 @@ QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
 //******************************************************************
 //******************************************************************
 //******************************************************************
-XGUI_PartDataModel::XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_PartDataModel::XGUI_PartDataModel(const DocumentPtr& theDocument, QObject* theParent)
   : XGUI_PartModel(theDocument, theParent)
 {
 }
@@ -191,7 +192,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     switch (theIndex.internalId()) {
     case MyRoot:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+        FeaturePtr aFeature = myDocument->feature(PARTS_GROUP, myId);
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
@@ -203,22 +204,19 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
     case ParamObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = 
-          featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+        FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
     case ConstructObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = 
-          featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
     case HistoryObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = 
-          featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+        FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
@@ -242,8 +240,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       }
     case HistoryObject:
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = 
-          featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+        FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
         if (aFeature)
           return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
       }
@@ -341,12 +338,15 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const
 }
 
 
-boost::shared_ptr<ModelAPI_Document> XGUI_PartDataModel::featureDocument() const
+DocumentPtr XGUI_PartDataModel::featureDocument() const
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+  FeaturePtr aFeature = myDocument->feature(PARTS_GROUP, myId);
+  ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+  if (aObject)
+    return aObject->featureRef()->data()->docRef("PartDocument")->value();
   return aFeature->data()->docRef("PartDocument")->value();
 }
-
 FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
 {
   switch (theIndex.internalId()) {
@@ -366,13 +366,13 @@ FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
   return FeaturePtr();
 }
 
-bool XGUI_PartDataModel::hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const
+bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
 {
   return (featureDocument() == theDoc);
 }
 
 
-QModelIndex XGUI_PartDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const
 {
   QString aGroup(theFeature->getGroup().c_str());
 
index 0c857f95b83e153507b30e3d9da30a9e56370ebc..a44dfb03ca5d22f869bdd67f944985816c6ca1ff 100644 (file)
@@ -14,7 +14,7 @@ class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
 {
   Q_OBJECT
 public:
-  XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+  XGUI_TopDataModel(const DocumentPtr& theDocument, QObject* theParent);
   virtual ~XGUI_TopDataModel();
 
   // Reimpl from QAbstractItemModel
@@ -37,7 +37,7 @@ public:
   virtual FeaturePtr feature(const QModelIndex& theIndex) const;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
+  virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
@@ -63,7 +63,7 @@ class XGUI_PartDataModel : public XGUI_PartModel
 {
   Q_OBJECT
 public:
-  XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+  XGUI_PartDataModel(const DocumentPtr& theDocument, QObject* theParent);
   virtual ~XGUI_PartDataModel();
 
   // Reimpl from QAbstractItemModel
@@ -86,10 +86,10 @@ public:
   virtual FeaturePtr feature(const QModelIndex& theIndex) const;
 
   //! Returns true if the given document is a sub-document of this tree
-  virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const;
+  virtual bool hasDocument(const DocumentPtr& theDoc) const;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
+  virtual QModelIndex findParent(const FeaturePtr& theFeature) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
@@ -98,7 +98,7 @@ public:
   virtual FeaturePtr part() const;
 
 private: 
-  boost::shared_ptr<ModelAPI_Document> featureDocument() const;
+  DocumentPtr featureDocument() const;
 
   //! Types of QModelIndexes
   enum DataIds {