]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Migration on new model architecture
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Jul 2014 07:49:38 +0000 (11:49 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Jul 2014 07:49:38 +0000 (11:49 +0400)
13 files changed:
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_ResultPart.h
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_Tools.cpp
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_PartDataModel.h

index 1fd59452594c3eb8036027ee4dd9648a307b353a..59c0e453743776ac0ad624b931c5e9211cb4866c 100644 (file)
@@ -33,6 +33,9 @@ public:
   static std::string group()
     {static std::string MY_GROUP = "Features"; return MY_GROUP;}
 
+  /// Returns the group identifier of this result
+  virtual std::string groupName() { return group(); }
+
   /// Request for initialization of data model of the feature: adding all attributes
   virtual void initAttributes() = 0;
 
index 04a281b8f985d5809c972762e78e097c7c7237e1..9079883933ae2be6ee557374e53d1f4b11f94e92 100644 (file)
@@ -40,6 +40,9 @@ public:
   virtual boost::shared_ptr<ModelAPI_Document> document()
     {return myDoc;}
 
+  /// Returns the group identifier of this object
+  virtual std::string groupName() = 0;
+
 protected:
   /// Sets the data manager of an object (document does)
   virtual void setData(boost::shared_ptr<ModelAPI_Data> theData) 
index 01fa9dde96fedb09e6bce02e314f8950bd65280e..97077b11d8435faa8820cb2c90b6905157e1edce 100644 (file)
@@ -22,7 +22,7 @@ public:
   //virtual boost::shared_ptr<ModelAPI_Feature> owner() = 0;
 
   /// Returns the group identifier of this result
-  virtual std::string groupName() = 0;
+  //virtual std::string groupName() = 0;
 };
 
 //! Pointer on feature object
index c922b1ef429bbf9d4967a67638667a6311754de5..4e3058b6b9d8b9e63166950ab337a31c94251a58 100644 (file)
@@ -30,6 +30,6 @@ public:
 };
 
 //! Pointer on feature object
-typedef boost::shared_ptr<ModelAPI_ResultPart> ResultPart;
+typedef boost::shared_ptr<ModelAPI_ResultPart> ResultPartPtr;
 
 #endif
index 1b357fadb927e1e004dc916812cbad2f170ee863..1b597c4dccfe5d409aa689dad0acf7933f7d2069 100644 (file)
@@ -42,23 +42,26 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
   {
     const ModelAPI_ObjectUpdatedMessage* aUpdMsg = 
       dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
-    std::set<FeaturePtr > aFeatures = aUpdMsg->features();
-    std::set<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+    std::set<ObjectPtr > aFeatures = aUpdMsg->features();
+    std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      FeaturePtr aFeature = *anIt;
-      if (myModule->workshop()->displayer()->isVisible(aFeature) ||
-          aType == EVENT_OBJECT_CREATED) {
-        myModule->visualizePreview(aFeature, true, false);
-        //if (aType == EVENT_OBJECT_CREATED)
-          myModule->activateFeature(aFeature, true);
+      ObjectPtr aObject = *anIt;
+      ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+      if (aResult) {
+        if (myModule->workshop()->displayer()->isVisible(aResult) ||
+            aType == EVENT_OBJECT_CREATED) {
+          myModule->visualizePreview(aResult, true, false);
+          //if (aType == EVENT_OBJECT_CREATED)
+          myModule->activateFeature(aResult, true);
+        }
       }
     }
     myModule->workshop()->displayer()->updateViewer();
   }
   if (aType == EVENT_OBJECT_DELETED)
   {
-    const ModelAPI_FeatureDeletedMessage* aDelMsg = 
-      dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
+    const ModelAPI_ObjectDeletedMessage* aDelMsg = 
+      dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
 
     std::set<std::string> aGroups = aDelMsg->groups();
index d1d5d409b42d33d6fef7bc2c638862227450ed61..dc9e868f3ffcec01e43ab51e0792a6cb04b11e3a 100644 (file)
@@ -148,7 +148,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
   FeaturePtr aFeature;
   if (!theSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
-    aFeature = aPrs.feature();
+    aFeature = aPrs.result();
   }
   else
     aFeature = feature(); // for the widget distance only
@@ -192,7 +192,7 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
   if ((myPreSelection.size() > 0) && myActiveWidget) {
     const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
     ModuleBase_WidgetValueFeature aValue;
-    aValue.setFeature(aPrs.feature());
+    aValue.setFeature(aPrs.result());
     if (myActiveWidget->setValue(&aValue)) {
       myPreSelection.remove(aPrs);
       emit activateNextWidget(myActiveWidget);
index 468eb635c558ace6f0fe60dffdb2694109af33c3..6705c0e6cb1e4acc084bb74181a433988416a377 100644 (file)
@@ -73,11 +73,11 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
                                              const std::list<ModuleBase_ViewerPrs>& theSelected,
                                              const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  FeaturePtr aFeature;
+  ResultPtr aFeature;
   if (!theHighlighted.empty())
-    aFeature = theHighlighted.front().feature();
+    aFeature = theHighlighted.front().result();
   if (!aFeature && !theSelected.empty()) // changed for a constrain
-    aFeature = theSelected.front().feature();
+    aFeature = theSelected.front().result();
 
   if (!aFeature || aFeature != feature())
   {
@@ -88,7 +88,7 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
     if(aHasShift && !theHighlighted.empty()) {
       QFeatureList aSelected;
       aSelected.push_back(feature());
-      aSelected.push_back(theHighlighted.front().feature());
+      aSelected.push_back(theHighlighted.front().result());
       emit setSelection(aSelected);
     }
     else if (aFeature) {
index aa3ac235adbfa32483ccfc0b404d306195136c0b..24a726a90df03bf938282248b2ab5637556dc8c4 100644 (file)
@@ -152,17 +152,17 @@ FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theVie
   ModuleBase_ViewerPrs aPrs;
   for (; anIt != aLast; anIt++) {
     aPrs = *anIt;
-    if (!aPrs.feature())
+    if (!aPrs.result())
       continue;
     boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.feature());
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.result());
     if (!aSketchFeature)
       continue;
     double aDelta = aSketchFeature->distanceToPoint(
                                boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
     if (aMinDelta < 0 || aMinDelta > aDelta) {
       aMinDelta = aDelta;
-      aDeltaFeature = aPrs.feature();
+      aDeltaFeature = aPrs.result();
     }
   }
   return aDeltaFeature;
index 1e187ed71941d435e15ac3706e8c6e73b2ac384a..ece7040f69617f665973ccc33c1bf428f8f1922e 100644 (file)
@@ -23,14 +23,14 @@ public:
 
   //! Returns Feature object by the given Model index.
   //! Returns 0 if the given index is not index of a feature
-  virtual ObjectPtr feature(const QModelIndex& theIndex) const = 0;
+  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 featureIndex(const ObjectPtr& theFeature) const = 0;
+  virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
 
   //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const ObjectPtr& theFeature) const = 0;
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
@@ -60,7 +60,7 @@ public:
   virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
 
   //! Return a Part object
-  virtual ObjectPtr part() const = 0;
+  virtual ResultPartPtr part() const = 0;
 
 protected:
   //! Id of the current part object in the document
index 7857bd7a41724ba2985fd82db59a256268687030..4290124700348d99a7854aa3988c92276451aefe 100644 (file)
@@ -7,6 +7,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_ResultPart.h>
 #include <Model_Events.h>
 #include <ModelAPI_Object.h>
 
@@ -48,15 +49,15 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
 
   // Created object event *******************
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
-    const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    std::set<FeaturePtr> aFeatures = aUpdMsg->features();
+    const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    std::set<ObjectPtr> aFeatures = aUpdMsg->features();
 
-    std::set<FeaturePtr>::const_iterator aIt;
+    std::set<ObjectPtr>::const_iterator aIt;
     for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
-      FeaturePtr aFeature = (*aIt);
+      ObjectPtr aFeature = (*aIt);
       DocumentPtr aDoc = aFeature->document();
       if (aDoc == aRootDoc) {  // If root objects
-        if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Update only Parts group
+        if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group
           // Add a new part
           int aStart = myPartModels.size();
           XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
@@ -88,7 +89,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     }
   // Deleted object event ***********************
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
-    const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
+    const Model_ObjectDeletedMessage* aUpdMsg = dynamic_cast<const Model_ObjectDeletedMessage*>(theMessage);
     DocumentPtr aDoc = aUpdMsg->document();
     std::set<std::string> aGroups = aUpdMsg->groups();
 
@@ -96,7 +97,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
       std::string aGroup = (*aIt);
       if (aDoc == aRootDoc) {  // If root objects
-        if (aGroup.compare(PARTS_GROUP) == 0) { // Updsate only Parts group
+        if (aGroup.compare(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group
           int aStart = myPartModels.size() - 1;
           removeSubModel(aStart);
           removeRow(aStart, partFolderNode());
@@ -130,8 +131,8 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     }
   // Deleted object event ***********************
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
-    //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    //FeaturePtr aFeature = aUpdMsg->feature();
+    //const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
+    //ObjectPtr aFeature = aUpdMsg->feature();
     //DocumentPtr aDoc = aFeature->document();
     
     // TODO: Identify the necessary index by the modified feature
@@ -151,7 +152,7 @@ void XGUI_DocumentDataModel::rebuildDataTree()
   beginResetModel();
   clearModelIndexes();
 
-  int aNbParts = aRootDoc->size(PARTS_GROUP);
+  int aNbParts = aRootDoc->size(ModelAPI_ResultPart::group());
   if (myPartModels.size() != aNbParts) { // resize internal models
     while (myPartModels.size() > aNbParts) {
       delete myPartModels.last();
@@ -192,13 +193,13 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole)
     {
       int aOffset = historyOffset();
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      FeaturePtr aFeature = aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+      ObjectPtr aFeature = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
       if (!aFeature)
         return QVariant();
       switch (theRole) {
       case Qt::DisplayRole:
         if (aFeature)
-          return aFeature->data()->getName().c_str();
+          return aFeature->data()->name().c_str();
         else 
           return QVariant();
       case Qt::DecorationRole:
@@ -236,7 +237,7 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
     // Size of external models
     int aVal = historyOffset();
     // Plus history size
-    aVal += aRootDoc->size(FEATURES_GROUP);
+    aVal += aRootDoc->size(ModelAPI_Feature::group());
     return aVal;
   }
   if (theParent.internalId() == PartsFolder) {
@@ -357,18 +358,18 @@ void XGUI_DocumentDataModel::clearModelIndexes()
   myIndexes.clear();
 }
 
-FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const
 {
   if (theIndex.internalId() == PartsFolder)
-    return FeaturePtr();
+    return ObjectPtr();
   if (theIndex.internalId() == HistoryNode) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
     int aOffset = historyOffset();
-    return aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+    return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
   }
   QModelIndex* aIndex = toSourceModelIndex(theIndex);
   if (!isSubModel(aIndex->model())) 
-    return FeaturePtr();
+    return ObjectPtr();
 
   const XGUI_FeaturesModel* aModel = dynamic_cast<const XGUI_FeaturesModel*>(aIndex->model());
   return aModel->feature(*aIndex);
@@ -474,11 +475,11 @@ bool XGUI_DocumentDataModel::activatedIndex(const QModelIndex& theIndex)
   return false;
 }
 
-FeaturePtr XGUI_DocumentDataModel::activePart() const
+ObjectPtr XGUI_DocumentDataModel::activePart() const
 {
   if (myActivePart) 
     return myActivePart->part();
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 void XGUI_DocumentDataModel::deactivatePart() 
@@ -493,21 +494,19 @@ void XGUI_DocumentDataModel::deactivatePart()
 Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const
 {
   Qt::ItemFlags aFlags = QAbstractItemModel::flags(theIndex);
-  if (feature(theIndex)) {
+  if (object(theIndex)) {
     aFlags |= Qt::ItemIsEditable;
   }
   return aFlags;
 }
 
-QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) const 
+QModelIndex XGUI_DocumentDataModel::partIndex(const ObjectPtr& theObject) const 
 {
-  FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
-
   int aRow = -1;
   XGUI_PartModel* aModel = 0;
   foreach (XGUI_PartModel* aPartModel, myPartModels) {
     aRow++;
-    if (aPartModel->part() == aFeature) {
+    if (aPartModel->part() == theObject) {
       aModel = aPartModel;
       break;
     }
@@ -518,22 +517,22 @@ QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) cons
   return QModelIndex();
 }
 
-QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) const
+QModelIndex XGUI_DocumentDataModel::featureIndex(const ObjectPtr theObject) const
 {
   // Check that this feature belongs to root document
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  DocumentPtr aDoc = theFeature->document();
+  DocumentPtr aDoc = theObject->document();
   if (aDoc == aRootDoc) {
     // This feature belongs to histrory or top model
-    if (theFeature->isInHistory()) {
+    if (theObject->isInHistory()) {
       int aId;
-      for (aId = 0; aId < aRootDoc->size(FEATURES_GROUP); aId++) {
-        if (theFeature == aRootDoc->feature(FEATURES_GROUP, aId))
+      for (aId = 0; aId < aRootDoc->size(ModelAPI_Feature::group()); aId++) {
+        if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
           break;
       }
       return index(aId + historyOffset(), 0, QModelIndex());
     } else {
-      QModelIndex aIndex = myModel->featureIndex(theFeature);
+      QModelIndex aIndex = myModel->featureIndex(theObject);
       return aIndex.isValid()? 
         createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
         QModelIndex();
@@ -547,7 +546,7 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co
       }
     }
     if (aPartModel) {
-      QModelIndex aIndex = aPartModel->featureIndex(theFeature);
+      QModelIndex aIndex = aPartModel->featureIndex(theObject);
       return aIndex.isValid()? 
         createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
         QModelIndex();
index c6b924bb438889be075bd0dee34ba7ea40a445fc..225a7108febd26062e4f329d6750769ae7b0ea6d 100644 (file)
@@ -54,20 +54,20 @@ public:
 
   //! Returns Feature object by the given Model index.
   //! Returns 0 if the given index is not index of a feature
-  FeaturePtr feature(const QModelIndex& theIndex) const;
+  ObjectPtr object(const QModelIndex& theIndex) const;
 
-  QModelIndex featureIndex(const FeaturePtr theFeature) const;
+  QModelIndex featureIndex(const ObjectPtr theFeature) const;
 
   //! Returns QModelIndex which corresponds to the given feature if this is a part
   //! If the feature is not found then index is not valid
-  QModelIndex partIndex(const FeaturePtr& theFeature) const;
+  QModelIndex partIndex(const ObjectPtr& theFeature) const;
 
   //! Activates a part data model if the index is a Part node index. 
   //! Returns true if active part changed.
   bool activatedIndex(const QModelIndex& theIndex);
 
   //! Retrurns Feature which corresponds to active part
-  FeaturePtr activePart() const;
+  ObjectPtr activePart() const;
 
   //! Retrurns QModelIndex of active part
   QModelIndex activePartIndex() const { return myActivePartIndex; }
index 0bd28f9d7352183a8e060242540ef11b7cb2869e..c9e98b5d45d075c641fde056769a85e3692b026a 100644 (file)
@@ -10,6 +10,7 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultParameters.h>
 
 #include <QIcon>
 #include <QBrush>
@@ -45,18 +46,18 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ParamObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        ObjectPtr aFeature = aRootDoc->object(PARAMETERS_GROUP, theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->data()->name().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       } 
     case ConstructFolder:
         return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
     case ConstructObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->data()->name().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     }
     break;
@@ -71,9 +72,9 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ConstructObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
-        if (aFeature)
-          return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
       }
     }
     break;
@@ -100,10 +101,10 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
 
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
   if (theParent.internalId() == ParamsFolder)
-    return aRootDoc->size(PARAMETERS_GROUP);
+    return aRootDoc->size(ModelAPI_ResultParameters::group());
 
   if (theParent.internalId() == ConstructFolder)
-    return aRootDoc->size(CONSTRUCTIONS_GROUP);
+    return aRootDoc->size(ModelAPI_ResultConstruction::group());
 
   return 0;
 }
@@ -152,7 +153,7 @@ bool XGUI_TopDataModel::hasChildren(const QModelIndex& theParent) const
   return rowCount(theParent) > 0;
 }
 
-ObjectPtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const
 {
   switch (theIndex.internalId()) {
   case ParamsFolder:
@@ -161,50 +162,50 @@ ObjectPtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
   case ParamObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(PARAMETERS_GROUP, theIndex.row());
+      return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
     }
   case ConstructObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+      return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
     }
   }
   return ObjectPtr();
 }
 
 
-QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const
 {
-  return findGroup(theFeature->getGroup().c_str());
+  return findGroup(theObject->groupName().c_str());
 }
 
 QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(PARAMETERS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
 
-QModelIndex XGUI_TopDataModel::featureIndex(const ObjectPtr& theFeature) const
+QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const
 {
   QModelIndex aIndex;
-  if (theFeature) {
+  if (theObject) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-    std::string aGroup = theFeature->getGroup();
+    std::string aGroup = theObject->groupName();
     int aNb = aRootDoc->size(aGroup);
     int aRow = -1;
     for (int i = 0; i < aNb; i++) {
-      if (aRootDoc->feature(aGroup, i) == theFeature) {
+      if (aRootDoc->object(aGroup, i) == theObject) {
         aRow = i;
         break;
       }
     }
     if (aRow != -1) {
-      if (aGroup.compare(PARAMETERS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
         return createIndex(aRow, 0, (qint32) ParamObject);
-      if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
         return createIndex(aRow, 0, (qint32) ConstructObject);
     }
   }
@@ -235,9 +236,9 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     case MyRoot:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId);
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->getName().c_str();
       }
     case ParamsFolder:
       return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
@@ -247,21 +248,21 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
     case ParamObject:
       {
-        ObjectPtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     case ConstructObject:
       {
-        ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
-        if (aFeature)
-          return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
       }
     case HistoryObject:
       {
-        ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
-        if (aFeature)
-          return aFeature->data()->getName().c_str();
+        ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+        if (aObject)
+          return aObject->data()->name().c_str();
       }
     }
     break;
@@ -277,15 +278,15 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return QIcon(":pictures/constr_folder.png");
     case ConstructObject:
       {
-        ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
-        if (aFeature)
-          return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+        ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
+        if (aObject)
+          return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
       }
     case HistoryObject:
       {
-        ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
-        if (aFeature)
-          return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+        ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3);
+        if (aObject)
+          return QIcon(XGUI_Workshop::featureIcon(aObject->getKind()));
       }
     }
    break;
@@ -308,18 +309,18 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
 {
   if (!parent.isValid()) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-    if (aRootDoc->feature(PARTS_GROUP, myId))
+    if (aRootDoc->object(ModelAPI_ResultPart::group(), myId))
       return 1;
     else 
       return 0;
   }
   switch (parent.internalId()) {
   case MyRoot:
-    return 3 + featureDocument()->size(FEATURES_GROUP);
+    return 3 + partDocument()->size(ModelAPI_Feature::group());
   case ParamsFolder:
-    return featureDocument()->size(PARAMETERS_GROUP);
+    return partDocument()->size(ModelAPI_ResultParameters::group());
   case ConstructFolder:
-    return featureDocument()->size(CONSTRUCTIONS_GROUP);
+    return partDocument()->size(ModelAPI_ResultConstruction::group());
   case BodiesFolder:
     return 0;
   }
@@ -383,53 +384,53 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const
 }
 
 
-DocumentPtr XGUI_PartDataModel::featureDocument() const
+DocumentPtr XGUI_PartDataModel::partDocument() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId, true);
-  return aFeature->data()->docRef("PartDocument")->value();
+  ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+  return aObject->data()->docRef("PartDocument")->value();
 }
  
-ObjectPtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
+ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
 {
   switch (theIndex.internalId()) {
   case MyRoot:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(PARTS_GROUP, myId);
+      return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
     }
   case ParamsFolder:
   case ConstructFolder:
   case BodiesFolder:
     return ObjectPtr();
   case ParamObject:
-    return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+    return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row());
   case ConstructObject:
-    return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+    return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
   //case BodiesObject:
-  //  return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+  //  return partDocument()->feature(ModelAPI_ResultConstruction::group(), theIndex.row());
   case HistoryObject:
-    return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); 
+    return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); 
   }
   return ObjectPtr();
 }
 
 bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
 {
-  return (featureDocument() == theDoc);
+  return (partDocument() == theDoc);
 }
 
 
-QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
 {
-  return findGroup(theFeature->getGroup().c_str());
+  return findGroup(theObject->groupName().c_str());
 }
 
 QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(PARAMETERS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
@@ -440,7 +441,7 @@ ObjectPtr XGUI_PartDataModel::part() const
   return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
 }
 
-QModelIndex XGUI_PartDataModel::featureIndex(const ObjectPtr& theObject) const
+QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
 {
   QModelIndex aIndex;
   if (theObject) {
@@ -459,9 +460,9 @@ QModelIndex XGUI_PartDataModel::featureIndex(const ObjectPtr& theObject) const
     }
     if (aRow != -1) {
       return createIndex(aRow + 3, 0, (qint32) HistoryObject);
-/*      if (aGroup.compare(PARAMETERS_GROUP) == 0)
+/*      if (aGroup.compare(ModelAPI_ResultParameters::group()) == 0)
         return createIndex(aRow, 0, (qint32) ParamObject);
-      if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
         return createIndex(aRow, 0, (qint32) ConstructObject);*/
     }
   }
index 9ebf7669ff794593f02355dc31ef3274d9906f4f..b1f808995a545a200dd94796eb67be3853dca6e1 100644 (file)
@@ -32,16 +32,16 @@ public:
 
   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
-  virtual ObjectPtr feature(const QModelIndex& theIndex) const;
+  //! Returns object by the given Model index.
+  //! Returns 0 if the given index is not index of a object
+  virtual ObjectPtr object(const QModelIndex& theIndex) const;
 
-  //! Returns QModelIndex which corresponds to the given feature
-  //! If the feature is not found then index is not valid
-  virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given object
+  //! If the object is not found then index is not valid
+  virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
 
-  //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const ObjectPtr& theFeature) const;
+  //! Returns parent index of the given object
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
@@ -85,19 +85,19 @@ public:
 
   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
-  virtual ObjectPtr feature(const QModelIndex& theIndex) const;
+  //! Returns object by the given Model index.
+  //! Returns 0 if the given index is not index of a object
+  virtual ObjectPtr object(const QModelIndex& theIndex) const;
 
-  //! Returns QModelIndex which corresponds to the given feature
-  //! If the feature is not found then index is not valid
-  virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given object
+  //! If the object is not found then index is not valid
+  virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
 
   //! Returns true if the given document is a sub-document of this tree
   virtual bool hasDocument(const DocumentPtr& theDoc) const;
 
-  //! Returns parent index of the given feature
-  virtual QModelIndex findParent(const ObjectPtr& theFeature) const;
+  //! Returns parent index of the given object
+  virtual QModelIndex findParent(const ObjectPtr& theObject) const;
 
   //! Returns index corresponded to the group
   virtual QModelIndex findGroup(const std::string& theGroup) const;
@@ -108,7 +108,7 @@ public:
 private: 
 
   //! Returns document of the current part
-  DocumentPtr featureDocument() const;
+  DocumentPtr partDocument() const;
 
   //! Types of QModelIndexes
   enum DataIds {