Salome HOME
Bug fixing in sketcher
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 08:47:22 +0000 (12:47 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 08:47:22 +0000 (12:47 +0400)
src/ModelAPI/ModelAPI_Feature.cpp
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Displayer.cpp

index de34edd0a6f6c4b64bf0c51accf09ea75ff031a0..fa4651408dd513c906e83528f53b41141ee8c085 100644 (file)
@@ -33,7 +33,8 @@ void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theRe
   myResults.push_back(theResult);
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
   ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
-  //TODO VSV:Create event for first Feature Events_Loop::loop()->flush(anEvent);
+  // Create event for first Feature 
+  Events_Loop::loop()->flush(anEvent);
 }
 
 boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
index 7cef128b199ef70e7039f81d652b1a25b0cd7f6b..0f60b0c80bd0077e0216ba291ebd458a0da48cdb 100644 (file)
@@ -5,9 +5,13 @@
 #include <PartSet_Listener.h>
 
 #include <PartSet_Module.h>
+#include <PartSet_OperationSketchBase.h>
 
 #include <XGUI_Displayer.h>
 #include <XGUI_Workshop.h>
+#include <XGUI_OperationMgr.h>
+
+#include <ModuleBase_Operation.h>
 
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
@@ -24,7 +28,7 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
 : myModule(theModule)
 {
   Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED));
+  //aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
@@ -36,28 +40,26 @@ PartSet_Listener::~PartSet_Listener()
 //******************************************************
 void PartSet_Listener::processEvent(const Events_Message* theMessage)
 {
+  ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation();
+  PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (!aSketchOp) 
+    return;
+
+  XGUI_Displayer* aDisplayer = myModule->workshop()->displayer();
   QString aType = QString(theMessage->eventID().eventText());
-  if (aType == EVENT_OBJECT_UPDATED ||
-      aType == EVENT_OBJECT_CREATED)
-  {
+  if (aType == EVENT_OBJECT_CREATED) {
     const ModelAPI_ObjectUpdatedMessage* aUpdMsg = 
       dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
     std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      ObjectPtr aObject = *anIt;
-      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
-      if (aFeature) {
-        if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) ||
-            aType == EVENT_OBJECT_CREATED) {
-          myModule->activateFeature(aFeature, true);
-          // TODO myModule->visualizePreview(aFeature, true, false);
-        }
-      }
+      aDisplayer->deactivate(*anIt, false);
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
+      if (aFeature)
+        myModule->activateFeature(aFeature, false);
     }
-    myModule->workshop()->displayer()->updateViewer();
-  }
-  if (aType == EVENT_OBJECT_DELETED) {
+
+  } else if (aType == EVENT_OBJECT_DELETED) {
     const ModelAPI_ObjectDeletedMessage* aDelMsg = 
       dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
index 91cb98096808d85a4a41d63ab060eb851be7874b..99d36b0ad8f3400c492f6a56e866447672ea5c6b 100644 (file)
@@ -360,7 +360,8 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
           aDisplayer->activateInLocalContext((*aIt), aModes, false);
         }
       }
-      FeaturePtr aFeature = aPrevOp->feature();
+    }
+/*      FeaturePtr aFeature = aPrevOp->feature();
       if (aFeature) {
         std::list<ResultPtr> aResList = aFeature->results();
         std::list<ResultPtr>::iterator aIt;
@@ -368,7 +369,7 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
           aDisplayer->deactivate((*aIt), false);
         }
       }
-    }
+    }*/
     ModelAPI_EventCreator::get()->sendUpdated(theFeature, 
         Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 //  }
@@ -519,8 +520,8 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
-                                        isUpdateViewer);
+    std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
+    aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
   }
 }
 
index 704d5b2decf2f24ca6c50e2f68c37995719ce547..38f6181fcac558aa00e560b29eba1de62d749493 100644 (file)
@@ -183,6 +183,7 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
   // Activate selection of objects from prs
   if (!anAIS.IsNull()) {
     aContext->ClearSelected(false); // ToCheck
+    //aContext->upClearSelected(false); // ToCheck
     aContext->Load(anAIS, -1, true/*allow decomposition*/);
     aContext->Deactivate(anAIS);