]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2027 Sketcher Trim Feature: preselection in reentrant operation
authornds <nds@opencascade.com>
Thu, 30 Mar 2017 10:21:07 +0000 (13:21 +0300)
committernds <nds@opencascade.com>
Thu, 30 Mar 2017 10:21:28 +0000 (13:21 +0300)
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/PartSet/PartSet_SketcherReentrantMgr.h
src/PartSet/PartSet_WidgetFeaturePointSelector.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp

index 18125ad34cfb25b8bf623c5957f79eb4469ec84a..41ee6b2a22905cea2c9cb0e237de0c2f5dc87dab 100755 (executable)
@@ -46,11 +46,7 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
                                                     std::vector<int>& theColor)
 {
   if (myConflictingObjects.find(theObject) != myConflictingObjects.end()) {
-    Quantity_Color aColor = ModuleBase_Tools::color("Visualization",
-                                                    "sketch_overconstraint_color");
-    theColor.push_back(aColor.Red()*255.);
-    theColor.push_back(aColor.Green()*255.);
-    theColor.push_back(aColor.Blue()*255.);
+    theColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
   }
   if (myIsFullyConstrained) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
@@ -59,13 +55,8 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       CompositeFeaturePtr aCompositeFeature = aModule->sketchMgr()->activeSketch();
       // the given object is sub feature of the current sketch(created or edited)
-      if (ModelAPI_Tools::compositeOwner(aFeature) == aCompositeFeature) {
-        Quantity_Color aColor = ModuleBase_Tools::color("Visualization",
-                                                        "sketch_fully_constrained_color");
-        theColor.push_back(aColor.Red()*0.);
-        theColor.push_back(aColor.Green()*255.);
-        theColor.push_back(aColor.Blue()*0.);
-      }
+      if (ModelAPI_Tools::compositeOwner(aFeature) == aCompositeFeature)
+        theColor = Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
     }
   }
 }
index 488f5660a99f9361880f0c25d393bf3b9159bf90..00b8f3f257cbada2d17a201fcea1cc2cc08ab2e0 100644 (file)
@@ -246,6 +246,12 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow*
         std::shared_ptr<ModuleBase_ViewerPrs> aSelectedPrs;
         if (!aPreSelected.empty())
           aSelectedPrs = aPreSelected.front();
+        if (!aSelectedPrs.get() && aSelectedPrs->object().get()
+            && !aSelectedPrs->object()->data()->isValid()) {
+          // the selected object was removed diring restart, e.g. presentable macro feature
+          // there are created objects to replace the object depending on created feature kind
+          aSelectedPrs = generatePreSelection();
+        }
         aMouseProcessor->setPreSelection(aSelectedPrs, theWnd, theEvent);
         //aPoint2DWdg->mouseReleased(theWnd, theEvent);
         //if (!aPreSelected.empty())
@@ -255,7 +261,6 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow*
       ModuleBase_Tools::blockUpdateViewer(false);
     }
   }
-
   return aProcessed;
 }
 
@@ -394,10 +399,19 @@ void PartSet_SketcherReentrantMgr::appendCreatedObjects(const std::set<ObjectPtr
   if (!myIsFlagsBlocked) // we need to collect objects only when launch operation is called
     return;
 
+  FeaturePtr aCurrentFeature;
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                       (myWorkshop->currentOperation());
+  if (aFOperation)
+    aCurrentFeature = aFOperation->feature();
+
+
   for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin();
        anIt != theObjects.end(); ++anIt) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
-    if (myCreatedFeatures.find(aFeature) != myCreatedFeatures.end())
+    if (aFeature == aCurrentFeature)
+      continue;
+    if (myCreatedFeatures.find(aFeature) == myCreatedFeatures.end())
       myCreatedFeatures.insert(aFeature);
   }
 }
@@ -714,6 +728,13 @@ bool PartSet_SketcherReentrantMgr::isTangentArc(ModuleBase_Operation* theOperati
   return aTangentArc;
 }
 
+std::shared_ptr<ModuleBase_ViewerPrs> PartSet_SketcherReentrantMgr::generatePreSelection()
+{
+  std::shared_ptr<ModuleBase_ViewerPrs> aPrs;
+
+  return aPrs;
+}
+
 void PartSet_SketcherReentrantMgr::updateAcceptAllAction()
 {
   CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
index 17006c1e482cf8115a09624e0a4b1422e43f9c53..96ff877538642fcf6c77b8c30da2969b8a20412f 100644 (file)
@@ -22,6 +22,7 @@ class QMouseEvent;
 
 class XGUI_Workshop;
 class PartSet_Module;
+class ModuleBase_ViewerPrs;
 
 /// \ingroup PartSet_SketcherReentrantMgr
 /// It provides reentrant create operations in sketch, that is when all inputs are valid,
@@ -174,6 +175,10 @@ private:
   bool isTangentArc(ModuleBase_Operation* theOperation,
                     const std::shared_ptr<ModelAPI_CompositeFeature>& /*theSketch*/) const;
 
+  /// Creates selection instance by the current feature and created by restart objects
+  /// \returns viewer selection presentation
+  std::shared_ptr<ModuleBase_ViewerPrs> generatePreSelection();
+
   /// Accept All action is enabled if an internal edit is started.
   /// It updates the state of the button
   void updateAcceptAllAction();
index f2808b3ad2f929397e103f76106c99bd8ee8cc1a..e8c4abf8c71a1f949d7d5bca8e6ace9640e30e1a 100644 (file)
@@ -167,6 +167,9 @@ bool PartSet_WidgetFeaturePointSelector::fillFeature(
   if (theSelectedPrs.get() && theSelectedPrs->object().get())
     anObject = theSelectedPrs->object();
 
+  if (!anObject.get())
+    return aFilled;
+
   gp_Pnt aPnt = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
   double aX, anY;
   Handle(V3d_View) aView = theWindow->v3dView();
index 774a961b949d681d67a3d8bebae251e35f6a53b2..3b12526d65f173073c1bca9a414f0feb96dc4a64 100644 (file)
@@ -53,7 +53,7 @@
 #define SKETCH_EXTERNAL_COLOR "170,0,225"
 #define SKETCH_AUXILIARY_COLOR "0,85,0"
 #define SKETCH_OVERCONSTRAINT_COLOR "0,0,0"
-#define SKETCH_FULLY_CONSTRAINED_COLOR "150,150,150"
+#define SKETCH_FULLY_CONSTRAINED_COLOR "0,150,0"
 
 //#define SET_PLANES_COLOR_IN_PREFERENCES