Salome HOME
New architecture debugging
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 16 Jul 2014 12:49:11 +0000 (16:49 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 16 Jul 2014 12:49:11 +0000 (16:49 +0400)
src/Model/Model_Document.cpp
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index 7718721fc8f5a9a76bb1c00d5540223d74e50ca0..88a0914ff9c1dc539f233f719f6c43c1db1d7711 100644 (file)
@@ -350,16 +350,18 @@ FeaturePtr Model_Document::addFeature(std::string theID)
   TDF_Label anEmptyLab;
   FeaturePtr anEmptyFeature;
   FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+  boost::shared_ptr<Model_Document> aDocToAdd = 
+    boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd());
   if (aFeature) {
     TDF_Label aFeatureLab;
     if (!aFeature->isAction()) {// do not add action to the data model
-      TDF_Label aFeaturesLab = groupLabel(ModelAPI_Feature::group());
+      TDF_Label aFeaturesLab = aDocToAdd->groupLabel(ModelAPI_Feature::group());
       aFeatureLab = aFeaturesLab.NewChild();
-      initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
+      aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS);
       // keep the feature ID to restore document later correctly
       TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str());
-      setUniqueName(aFeature);
-      myObjs[ModelAPI_Feature::group()].push_back(aFeature);
+      aDocToAdd->setUniqueName(aFeature);
+      aDocToAdd->myObjs[ModelAPI_Feature::group()].push_back(aFeature);
       // store feature in the history of features array
       if (aFeature->isInHistory()) {
         AddToRefArray(aFeaturesLab, aFeatureLab);
@@ -434,6 +436,7 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
     boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
     aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
     ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+    ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName());
   }
 }
 
@@ -681,7 +684,6 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
         if (anObj->isInHistory()) {
           ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
         }
-        ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
         // results of this feature must be redisplayed (hided)
         static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
         const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = boost::dynamic_pointer_cast<ModelAPI_Feature>(anObj)->results();
@@ -690,6 +692,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
           boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
           aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
           ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+          ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName());
         }
       } else if (aDSTag < aFeatureTag) { // a new feature is inserted
         // create a feature
index db10764ad1cea8a67ed8e7978d38efb3fa7c7295..84db77027aeee3f9e5f164e1289cabdfff897275 100644 (file)
@@ -50,7 +50,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
       if (aFeature) {
         if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
             aType == EVENT_OBJECT_CREATED) {
-          myModule->visualizePreview(aFeature->firstResult(), true, false);
+          myModule->visualizePreview(aFeature, true, false);
           //if (aType == EVENT_OBJECT_CREATED)
           myModule->activateFeature(aFeature, true);
         }
index b52edee63b7be64f4a160c94421bf1e053c3daa0..84a9ec96f1c121ca210bd74a0fa487fc529a99dc 100644 (file)
@@ -349,7 +349,7 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
       std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
                                             aLast = aList.end();
       for (; anIt != aLast; anIt++)
-        visualizePreview((*anIt)->firstResult(), false, false);
+        visualizePreview((*anIt), false, false);
       aDisplayer->updateViewer();
     }
   }
@@ -444,7 +444,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
-void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay,
+void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
                                       const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -455,19 +455,19 @@ void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay,
   if (!aPreviewOp)
     return;
 
+  ResultPtr aResult = theFeature->firstResult();
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (isDisplay) {
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
-    if (aSPFeature)
-    {
+    if (aSPFeature) {
       boost::shared_ptr<GeomAPI_AISObject> anAIS = 
-        aSPFeature->getAISObject(aDisplayer->getAISObject(theFeature));
-      aDisplayer->redisplay(theFeature, anAIS, false);
+        aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
+      aDisplayer->redisplay(aResult, anAIS, false);
     }
   }
   else
-    aDisplayer->erase(theFeature, false);
+    aDisplayer->erase(aResult, false);
 
   if (isUpdateViewer)
     aDisplayer->updateViewer();
@@ -509,7 +509,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
     if (!aSPFeature)
       continue;
-    visualizePreview((*anIt)->firstResult(), true, false);
+    visualizePreview((*anIt), true, false);
     aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false);
   }
   aDisplayer->updateViewer();
index eaec86601bf7f913335699a9f04cdee09c0e8b06..4133472f1f6f059276b9e66a3bfb56c1d234bb6f 100644 (file)
@@ -55,7 +55,7 @@ public:
   /// \param theFeature the feature instance to be displayed
   /// \param isDisplay the state whether the presentation should be displayed or erased
   /// \param isUpdateViewer the flag whether the viewer should be updated
-  void visualizePreview(ResultPtr theResult, bool isDisplay,
+  void visualizePreview(FeaturePtr theFeature, bool isDisplay,
                         const bool isUpdateViewer = true);
 
   /// Activates the feature in the displayer
index ac6b3af89c6029d0d1712861addda58985ca1b57..649e7f6bd5d80b7799e7c9af967a4ba8cd91a7dc 100644 (file)
@@ -87,7 +87,7 @@ void XGUI_Displayer::erase(ResultPtr theResult,
 }
 
 
-bool XGUI_Displayer::redisplay(ResultPtr theFeature,
+bool XGUI_Displayer::redisplay(ResultPtr theResult,
                                boost::shared_ptr<GeomAPI_AISObject> theAIS,
                                const bool isUpdateViewer)
 {
@@ -104,12 +104,12 @@ bool XGUI_Displayer::redisplay(ResultPtr theFeature,
     //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
   }
   // display or redisplay presentation
-  boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theFeature];
-  if (isVisible(theFeature) && anObj && !anObj->empty()) {
+  boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theResult];
+  if (isVisible(theResult) && anObj && !anObj->empty()) {
       aContext->RecomputeSelectionOnly(anAIS);
   }
   else {
-    myResult2AISObjectMap[theFeature] = theAIS;
+    myResult2AISObjectMap[theResult] = theAIS;
     aContext->Display(anAIS, false);
     isCreated = true;
   }
index 778cec850659368c6ed7dc3c8d417628cb39d2fe..a9c3f7a48ca1b56f983cca7c27deb58330146a8e 100644 (file)
@@ -85,7 +85,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
         }
         if (aPartModel) {
           QModelIndex aIndex = aPartModel->findParent(aObject);
-          int aStart = aPartModel->rowCount(aIndex) - 1;
+          int aStart = aPartModel->rowCount(aIndex); // check this index
           aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
           insertRow(aStart, aIndex);
         }
@@ -101,7 +101,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(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group
+        if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group
           int aStart = myPartModels.size() - 1;
           removeSubModel(aStart);
           removeRow(aStart, partFolderNode());
@@ -246,6 +246,7 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
     return aVal;
   }
   if (theParent.internalId() == PartsFolder) {
+    int aSize = myPartModels.size();
     return myPartModels.size();
   }
   if (theParent.internalId() == HistoryNode) {
index 084a800c935ab24b055d55fe0143140adcf7707a..9f2d068a229830fdc8a78e37ec355f385a43a13b 100644 (file)
@@ -885,8 +885,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
   QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
   if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
-    if (aPart)
-      activatePart(aPart);
+    activatePart(aPart);
   } else if (theId == "DEACTIVATE_PART_CMD") 
     activatePart(ResultPartPtr());
   else if (theId == "DELETE_CMD")