Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / src / PartSet / PartSet_SketcherMgr.cpp
index 292c13596791564f3114ef9858f6b072ddc251a6..113f254a352bd2f823e7ed8cdf8a0abdae65af71 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -368,7 +368,7 @@ bool PartSet_SketcherMgr::isDragModeCreation() const
   // Acceptable features;
   QStringList aList;
   aList << "SketchLine" << "SketchMacroCircle" << "SketchMacroArc" <<
-    "SketchMacroEllipse" << "SketchMacroEllipticArc" << "SketchRectangle";
+    "SketchMacroEllipse" << "SketchMacroEllipticArc" << "SketchMacroRectangle";
   return aList.contains(aId);
 }
 
@@ -504,6 +504,10 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);
       if (isRelaunchEditing)
         launchEditing();
+      else {
+        if (myCurrentSelection.size() > 1)
+          aFOperation->propertyPanel()->cleanContent();
+      }
       myIsEditLaunching = aPrevLaunchingState;
       if (aFeature.get() != NULL) {
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
@@ -1092,6 +1096,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFOperation->feature());
   double aSizeOfView = 0;
   std::shared_ptr<GeomAPI_Pnt> aCentralPoint;
+  // Reset size of view from previous launches
+  mySketchPlane->setSizeOfView(aSizeOfView, false, aCentralPoint);
   if (aFOperation->isEditOperation() &&
       mySketchPlane->getDefaultSizeOfView(myCurrentSketch, aSizeOfView, aCentralPoint)) {
     mySketchPlane->setSizeOfView(aSizeOfView, true, aCentralPoint);
@@ -1130,7 +1136,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
     for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = *anIt;
       if (aFeature.get())
-        anInvalidFeatureNames.append(aFeature->name().c_str());
+        anInvalidFeatureNames.append(QString::fromStdWString(aFeature->name()));
     }
     std::string aPrefixInfo = QString("Invalid features of the sketch will be deleted: %1.\n\n").
                                   arg(anInvalidFeatureNames.join(", ")).toStdString().c_str();
@@ -2249,7 +2255,7 @@ bool isIncludeToResult(const ObjectPtr& theObject)
   for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
     if ((*aIt)->id() == SketchPlugin_Projection::PROJECTED_FEATURE_ID()) {
       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
-      if (aFeature.get()) {
+      if (aFeature.get() && !aFeature->isMacro()) {
         anAttr = aFeature->data()->boolean(SketchPlugin_Projection::INCLUDE_INTO_RESULT());
         if (anAttr.get())
           return anAttr->value();
@@ -2269,17 +2275,18 @@ std::vector<int> PartSet_SketcherMgr::colorOfObject(const ObjectPtr& theObject,
   if (aOCListener->isConflictingObject(theObject)) {
     return Config_PropManager::color("Visualization", "sketch_overconstraint_color");
   }
-  if (aOCListener->isFullyConstrained()) {
-    return Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
-  }
   if (isDistanceKind(aKind)) {
     return Config_PropManager::color("Visualization", "sketch_dimension_color");
   }
+  if (isExternal(theFeature))
+    return Config_PropManager::color("Visualization", "sketch_external_color");
+
+  if (aOCListener->isFullyConstrained()) {
+    return Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
+  }
   if (aKind == SketchPlugin_ConstraintCoincidence::ID())
     return std::vector<int>(3, 0);
 
-  if (isExternal(theFeature))
-    return Config_PropManager::color("Visualization", "sketch_external_color");
   if (isConstruction)
     return Config_PropManager::color("Visualization", "sketch_auxiliary_color");
 
@@ -2344,7 +2351,7 @@ void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject
     thePrs->setWidth(17);
     //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
   }
-  if (isCopy(aFeature) && !isIncludeToResult(aFeature)) {
+  if (isCopy(aFeature) || !isIncludeToResult(aFeature)) {
     double aPrsWidth = thePrs->width();
     thePrs->setWidth(aPrsWidth / 2.5);
   }