]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #138: Fixed problem with lines
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 23 Sep 2014 08:58:49 +0000 (12:58 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 23 Sep 2014 08:58:49 +0000 (12:58 +0400)
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp

index be392c0097207ca07c38d6ac1f2fa3f302bf005e..43709df50c354fb6150680e67b6f9f8cab3cff5f 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketchBase.h>
+#include <PartSet_OperationSketch.h>
 
 #include <XGUI_Displayer.h>
 #include <XGUI_Workshop.h>
@@ -28,7 +29,7 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
     : myModule(theModule)
 {
   Events_Loop* aLoop = Events_Loop::loop();
-  //aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  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));
 }
@@ -51,12 +52,27 @@ void PartSet_Listener::processEvent(const boost::shared_ptr<Events_Message>& the
     boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
         boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
+
+    PartSet_OperationSketch* aSketchOp = 
+      dynamic_cast<PartSet_OperationSketch*>(myModule->workshop()->operationMgr()->currentOperation());
+
     std::set<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      aDisplayer->deactivate(*anIt);
-      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
-      if (aFeature)
-        myModule->activateFeature(aFeature, false);
+      ObjectPtr aObj = (*anIt);
+      aDisplayer->deactivate(aObj);
+      boost::shared_ptr<SketchPlugin_Sketch> aSketch = 
+        boost::dynamic_pointer_cast<SketchPlugin_Sketch>(aObj);
+      if (aSketch) // Activate sketcher for planes selection
+        myModule->activateFeature(aSketch, false);
+      // If current operation is Sketch then there is no active sketching operation
+      // and possible the object was created by Redo operatgion
+      else if (aSketchOp) {
+          XGUI_Displayer* aDisplayer = myModule->workshop()->displayer();
+          // Very possible it is not displayed
+          aDisplayer->display(aObj, false);
+          std::list<int> aModes = aSketchOp->getSelectionModes(aObj);
+          aDisplayer->activateInLocalContext(aObj, aModes, false);
+      }
     }
 
   } else if (aType == EVENT_OBJECT_DELETED) {
index 398293c615bd774ac907a22389178b921dab1e6d..9dd3141eb50135b8836616dde205871b20884857 100644 (file)
@@ -50,20 +50,16 @@ std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
 
 std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
 {
+  //TODO: Define position of selection modes definition
   std::list<int> aModes;
-  //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-  //if (aFeature) {
-  //  if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
-  //      aModes.clear();
-  //      aModes.push_back(AIS_DSM_Text);
-  //      aModes.push_back(AIS_DSM_Line);
-  //      return aModes;
-  //  }
-  //}
-  aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
-  aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
-  aModes.push_back(AIS_DSM_Text);
-  aModes.push_back(AIS_DSM_Line);
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
+    aModes.push_back(AIS_DSM_Text);
+    aModes.push_back(AIS_DSM_Line);
+  } else {
+    aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+    aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+  }
   return aModes;
 }
 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
index d62098dffc2ae3bb8db47d514bfa2bfb16a92d57..555f0abfeb50e3e2c0b05225e91e83e658fa2b93 100644 (file)
@@ -22,7 +22,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
   // If the object is not a line then it is accepted
   const ModelAPI_ResultValidator* aLineValidator =
       dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultLine"));
-  if (aLineValidator && (!aLineValidator->isValid(theObject)))
+  if (!aLineValidator->isValid(theObject))
     return true;
 
   // If it is a line then we have to check that first attribute id not a line