]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix of activation/deactivation of documents
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 12:47:23 +0000 (16:47 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 12:47:23 +0000 (16:47 +0400)
src/Model/Model_Document.cpp
src/Model/Model_Object.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index 6343d8b7b7d837fd35d5348701a136bcc9429089..f1f67b7b6e04ce8d1df976b6dca5c0a38f424849 100644 (file)
@@ -585,11 +585,14 @@ void Model_Document::synchronizeFeatures()
       aDSTag = aFLabIter.Value()->Label().Tag();
     }
     if (aDSTag > aFeatureTag) { // feature is removed
-      Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP);
-      Model_FeatureDeletedMessage aMsg2(aThis, (*aFIter)->getGroup());
+      FeaturePtr aFeature = *aFIter;
       aFIter = myFeatures.erase(aFIter);
       // event: model is updated
-      Events_Loop::loop()->send(aMsg1);
+      if (aFeature->isInHistory()) {
+        Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP);
+        Events_Loop::loop()->send(aMsg1);
+      }
+      Model_FeatureDeletedMessage aMsg2(aThis, aFeature->getGroup());
       Events_Loop::loop()->send(aMsg2);
     } else if (aDSTag < aFeatureTag) { // a new feature is inserted
       // create a feature
index 8179d701d6d70c7032fdad2deba769ae3d72db08..811edf709171f691d7f0340747d471d1011bea10 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <Model.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Document.h>
 
 #include <TDataStd_Name.hxx>
 
@@ -34,7 +35,7 @@ public:
   MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();}
 
   /// Returns to which group in the document must be added feature
-  MODEL_EXPORT virtual const std::string& getGroup() {return myRef->getGroup();}
+  MODEL_EXPORT virtual const std::string& getGroup() {return FEATURES_GROUP;}
 
   /// Returns document this feature belongs to
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
index d1ca2c2ed4b895c46237f14eeb63322c674fe33b..37c78f82a4aec5b3f23d24765e9a8a83bd4b6756 100644 (file)
@@ -7,6 +7,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <Model_Events.h>
+#include <ModelAPI_Object.h>
 
 #include <Events_Loop.h>
 
@@ -58,7 +59,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       if (aDoc == myDocument) {  // If root objects
         if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Update only Parts group
           // Add a new part
-          int aStart = myPartModels.size() + 1;
+          int aStart = myPartModels.size();
           XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this);
           aModel->setPartId(myPartModels.count());
           myPartModels.append(aModel);
@@ -100,6 +101,11 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
           int aStart = myPartModels.size() - 1;
           removeSubModel(aStart);
           removeRow(aStart, partFolderNode());
+          if (myActivePart && (!isPartSubModel(myActivePart))) {
+            myActivePart = 0;
+            myActivePartIndex = QModelIndex();
+            myModel->setItemsColor(ACTIVE_COLOR);
+          }
         } else { // Update top groups (other except parts
           QModelIndex aIndex = myModel->findGroup(aGroup);
           int aStart = myModel->rowCount(aIndex);
@@ -470,6 +476,7 @@ void XGUI_DocumentDataModel::deactivatePart()
   if (myActivePart) 
     myActivePart->setItemsColor(PASSIVE_COLOR);
   myActivePart = 0;
+  myActivePartIndex = QModelIndex();
   myModel->setItemsColor(ACTIVE_COLOR);
 }
  
@@ -484,11 +491,16 @@ Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const
 
 QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) const 
 {
+  FeaturePtr aFeature = theFeature;
+  if (!aFeature->data()) {
+    ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+    aFeature = aObject->featureRef();
+  }
   int aRow = -1;
   XGUI_PartModel* aModel = 0;
   foreach (XGUI_PartModel* aPartModel, myPartModels) {
     aRow++;
-    if (aPartModel->part() == theFeature) {
+    if (aPartModel->part() == aFeature) {
       aModel = aPartModel;
       break;
     }
index 389f81420925586f6724787be794a2a9e1a964bb..c18868292a01269773b40d41eb0068442528b7bb 100644 (file)
@@ -121,7 +121,6 @@ void XGUI_Workshop::startApplication()
   Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
   aLoop->registerListener(this, aFeatureUpdatedId);
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
 
   activateModule();
   if (myMainWindow) {
@@ -238,13 +237,6 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     }
   }
 
-  // Process deletion of a part
-  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
-    PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-    if (aMgr->currentDocument() == aMgr->rootDocument())
-      activatePart(FeaturePtr()); // Activate PartSet
-  }
-
   //Update property panel on corresponding message. If there is no current operation (no
   //property panel), or received message has different feature to the current - do nothing.
   static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);