Salome HOME
Issue #3092: Do not relaunch editing on multi-selection if editing feature is still...
[modules/shaper.git] / src / PartSet / PartSet_SketcherMgr.cpp
index f0e4b1d43290943724342ae998bcd58cbf74b32e..bd4c35fae988df2c1cceee69b11d42889015f27b 100644 (file)
@@ -414,7 +414,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
     }
     // Init flyout point for radius rotation
     FeaturePtr aFeature = myCurrentSelection.begin().key();
-
     get2dPoint(theWnd, theEvent, myCurrentPoint);
     if (isSketcher) {
       if (aCanDrag) {
@@ -444,14 +443,33 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       /// Internal edit should not be stored as editing operation as the result will be a
       /// creation operation, where previous selection should not be used(and will be cleared)
       myIsEditLaunching = !myModule->sketchReentranceMgr()->isInternalEditActive();
-      aFOperation->commit();
+
+      std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+        std::dynamic_pointer_cast<SketchPlugin_Feature>(aFOperation->feature());
+      bool isRelaunchEditing = true;
+      if (aSPFeature->isExternal()) {
+        foreach(FeaturePtr aF, myCurrentSelection.keys()) {
+          FeaturePtr aProducerFeature = PartSet_Tools::findRefsToMeFeature(aF,
+            aSPFeature->getKind());
+          if (aProducerFeature == aSPFeature) {
+            isRelaunchEditing = false;
+            break;
+          }
+        }
+      }
+      else
+        isRelaunchEditing = !myCurrentSelection.contains(aSPFeature);
+
+      if (isRelaunchEditing)
+        aFOperation->commit();
 
       if (aCanDrag) {
         myIsDragging = true;
         myDragDone = false;
       }
       myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);
-      launchEditing();
+      if (isRelaunchEditing)
+        launchEditing();
       myIsEditLaunching = aPrevLaunchingState;
       if (aFeature.get() != NULL) {
         std::shared_ptr<SketchPlugin_Feature> aSPFeature =
@@ -970,6 +988,8 @@ bool PartSet_SketcherMgr::isEntity(const std::string& theId)
          (theId == SketchPlugin_Arc::ID()) ||
          (theId == SketchPlugin_Circle::ID()) ||
          (theId == SketchPlugin_Ellipse::ID()) ||
+         (theId == SketchPlugin_Projection::ID()) ||
+         (theId == SketchPlugin_IntersectionPoint::ID()) ||
          (theId == SketchPlugin_EllipticArc::ID());
 }
 
@@ -2001,6 +2021,8 @@ void PartSet_SketcherMgr::updateBySketchParameters(
       if (aPrevState != theState) {
         /// call all sketch features redisplay, the expression state will be corrected in customize
         /// of distance presentation
+        SketcherPrs_Tools::
+          sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
         Events_ID anEventId = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
         PartSet_Tools::sendSubFeaturesEvent(myCurrentSketch, anEventId);
       }
@@ -2190,51 +2212,45 @@ bool isIncludeToResult(const ObjectPtr& theObject)
   return true;
 }
 
-
-void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject,
-  const AISObjectPtr& thePrs) const
+//**************************************************************************************
+std::vector<int> PartSet_SketcherMgr::colorOfObject(const ObjectPtr& theObject,
+  const FeaturePtr& theFeature, bool isConstruction) const
 {
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+  static const QStringList& aConstrIds = constraintsIdList();
   PartSet_OverconstraintListener* aOCListener = myModule->overconstraintListener();
+  std::string aKind = theFeature->getKind();
 
-  // Check constraints objects
-  const QStringList& aConstrIds = constraintsIdList();
-  std::string aKind = aFeature->getKind();
-  if (aConstrIds.contains(QString(aKind.c_str()))) {
-    std::vector<int> aColor;
+  if (isDistanceKind(aKind)) {
     if (aOCListener->isConflictingObject(theObject))
-      aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
-    else if (isDistanceKind(aKind))
-      aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+      return Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+    return Config_PropManager::color("Visualization", "sketch_dimension_color");
+  }
+  if (isExternal(theFeature))
+    return Config_PropManager::color("Visualization", "sketch_external_color");
+  if (isConstruction)
+    return Config_PropManager::color("Visualization", "sketch_auxiliary_color");
 
-    if (!aColor.empty())
-      thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-    return;
+  if (aOCListener->isFullyConstrained()) {
+    return Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
   }
-  int aShapeType = thePrs->getShapeType();
-  // a compound is processed like the edge because the
-  // arc feature uses the compound for presentable AIS
-  if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
-    return;
+  else if (aOCListener->isConflictingObject(theObject)) {
+    return Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+  }
+  return Config_PropManager::color("Visualization", "sketch_entity_color");
+}
+
+//**************************************************************************************
+void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject,
+  const AISObjectPtr& thePrs) const
+{
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
 
   // set color from preferences
   std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
     aFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
   bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
 
-  std::vector<int> aColor;
-  if (aOCListener->isFullyConstrained())
-    aColor = Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
-  else if (aOCListener->isConflictingObject(theObject))
-    aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
-  else {
-    if (isConstruction)
-      aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
-    else if (isExternal(aFeature))
-      aColor = Config_PropManager::color("Visualization", "sketch_external_color");
-    else
-      aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
-  }
+  std::vector<int> aColor = colorOfObject(theObject, aFeature, isConstruction);
   if (!aColor.empty()) {
     // The code below causes redisplay again
     if (ModelAPI_Session::get()->isOperation()) {
@@ -2249,6 +2265,20 @@ void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject
     thePrs->setColor(aColor[0], aColor[1], aColor[2]);
   }
 
+  int aShapeType = thePrs->getShapeType();
+  // a compound is processed like the edge because the
+  // arc feature uses the compound for presentable AIS
+  if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
+    return;
+
+  if (isExternal(aFeature)) {
+    thePrs->setWidth(1);
+    return;
+  }
+  std::string aKind = aFeature->getKind();
+  if (isDistanceKind(aKind))
+    return;
+
   if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
     if (isConstruction) {
       // Set axilliary line