Salome HOME
Get rid of compilation warnings. Part I.
[modules/shaper.git] / src / PartSet / PartSet_SketcherMgr.cpp
index bcf6db4be9bedf1554dc90a14d4d49f0b548d4ee..aaa1ff6d4d2691785d3bf9c47ed343f419fa7386 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  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
@@ -170,10 +170,17 @@ void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner,
 }
 
 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
-  : QObject(theModule), myModule(theModule), myIsEditLaunching(false), myIsDragging(false),
-    myDragDone(false), myIsMouseOverWindow(false),
-    myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
-    myIsPopupMenuActive(false), myExternalPointsMgr(0), myNoDragMoving(false)
+  : QObject(theModule),
+    myModule(theModule),
+    myIsEditLaunching(false),
+    myIsDragging(false),
+    myDragDone(false),
+    myIsMouseOverWindow(false),
+    myIsMouseOverViewProcessed(true),
+    myIsPopupMenuActive(false),
+    myPreviousUpdateViewerEnabled(true),
+    myExternalPointsMgr(0),
+    myNoDragMoving(false)
 {
   ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
@@ -592,6 +599,7 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
       aProcessor->mouseReleased(theWnd, theEvent);
   }
   if (MyModeByDrag && aOp) {
+    aViewer->enableMultiselection(true);
     QString aOpId = aOp->id();
     if (aOpId == "Sketch")
       return;
@@ -680,7 +688,6 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
 #endif
 
     Handle(V3d_View) aView = theWnd->v3dView();
-    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
     Point aMousePnt;
     get2dPoint(theWnd, theEvent, aMousePnt);
 
@@ -1184,7 +1191,6 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   qDebug(QString("startSketch: %1, %2").arg(anInfo.size()).arg(anInfoStr).toStdString().c_str());
 #endif
 
-  bool aHasPlane = false;
   std::shared_ptr<GeomAPI_Pln> aPln;
   aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
   Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter);
@@ -1194,8 +1200,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   workshop()->selectionActivate()->updateSelectionFilters();
   workshop()->selectionActivate()->updateSelectionModes();
 
-  Events_Loop::loop()->flush(EVENT_DISP);
   Events_Loop::loop()->flush(EVENT_ATTR);
+  Events_Loop::loop()->flush(EVENT_DISP);
 
   myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
 
@@ -1500,8 +1506,6 @@ bool PartSet_SketcherMgr::canDisplayConstraint(const FeaturePtr& theFeature,
 
   std::string aKind = theFeature->getKind();
   if (aConstrIds.contains(QString(aKind.c_str()))) {
-    bool isTypedConstraint = false;
-
     switch (theState) {
       case PartSet_Tools::Dimensional: {
         bool isDistance = isDistanceKind(aKind);
@@ -1751,8 +1755,6 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
   std::map<AttributePtr, int> aSelectedAttributes = anInfo.myAttributes;
   std::set<ResultPtr> aSelectedResults = anInfo.myResults;
 
-  ModuleBase_IViewer* aViewer = theWorkshop->viewer();
-
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
 
@@ -1823,13 +1825,13 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
       // result owners are put in the list of selection only if local selected shapes were not
       // found
       if (aSelectedResults.find(aResult) != aSelectedResults.end()) {
-        for  ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
+        for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
           Handle(StdSelect_BRepOwner) anOwner =
-            Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
-          if ( anOwner.IsNull() || !anOwner->HasShape() || theOwnersToSelect.FindIndex(anOwner))
+              Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
+          if (anOwner.IsNull() || !anOwner->HasShape() || theOwnersToSelect.FindIndex(anOwner))
             continue;
-            // select whole result
-            theOwnersToSelect.Add(anOwner);
+          // select whole result
+          theOwnersToSelect.Add(anOwner);
         }
       }
     }
@@ -1863,8 +1865,8 @@ void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                            (getCurrentOperation());
   if (aFOperation) {
-    if (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
-        isNestedSketchOperation(aFOperation) &&
+    if ((PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
+         isNestedSketchOperation(aFOperation)) &&
         thePreviousState == ModuleBase_ModelWidget::ModifiedInPP) {
       FeaturePtr aFeature = aFOperation->feature();
       visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
@@ -1923,9 +1925,6 @@ void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature,
   if (isEditOperation || !theFeature.get())
     return;
 
-  ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
-
   // 1. change visibility of the object itself, here the presentable object is processed,
   // e.g. constraints features
   //FeaturePtr aFeature = aFOperation->feature();
@@ -2064,8 +2063,6 @@ void PartSet_SketcherMgr::updateBySketchParameters(
     case PartSet_Tools::Geometrical:
     case PartSet_Tools::Dimensional: {
       if (aPrevState != theState) {
-        ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
-        XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
         int aNumberOfSubs = myCurrentSketch->numberOfSubs();
         for (int i = 0; i < aNumberOfSubs; i++) {
           FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
@@ -2090,6 +2087,8 @@ void PartSet_SketcherMgr::updateBySketchParameters(
       }
     }
     break;
+    default: // [to avoid compilation warning]
+      break;
   }
 }
 
@@ -2278,26 +2277,26 @@ bool isIncludeToResult(const ObjectPtr& theObject)
 std::vector<int> PartSet_SketcherMgr::colorOfObject(const ObjectPtr& theObject,
   const FeaturePtr& theFeature, bool isConstruction) const
 {
-  static const QStringList& aConstrIds = constraintsIdList();
   PartSet_OverconstraintListener* aOCListener = myModule->overconstraintListener();
   std::string aKind = theFeature->getKind();
 
+  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)) {
-    if (aOCListener->isConflictingObject(theObject))
-      return Config_PropManager::color("Visualization", "sketch_overconstraint_color");
     return Config_PropManager::color("Visualization", "sketch_dimension_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");
 
-  if (aOCListener->isFullyConstrained()) {
-    return Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
-  }
-  else if (aOCListener->isConflictingObject(theObject)) {
-    return Config_PropManager::color("Visualization", "sketch_overconstraint_color");
-  }
   return Config_PropManager::color("Visualization", "sketch_entity_color");
 }