]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_Module.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/EDF_2020_Lot2'
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index 446b253b31c064f3380bb860c37458d7bbafe409..108db7563a6e55d89ff1affa57834a6112d3deb3 100644 (file)
@@ -233,6 +233,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
                                    "Hidden faces transparency",
                                    Config_Prop::DblSpin,
                                    "0.8");
+
   std::ostringstream aStream;
   aStream << SketcherPrs_Tools::getDefaultArrowSize();
   Config_PropManager::registerProp("Visualization", "dimension_arrow_size",
@@ -255,6 +256,12 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
     "Feature items in Object Browser",
     Config_Prop::Color, FEATURE_ITEM_COLOR);
 
+  Config_PropManager::registerProp("Visualization", "zoom_trihedron_arrows",
+    "Keep trihedron arrows view size constant", Config_Prop::Boolean, "false");
+
+  Config_PropManager::registerProp("Visualization", "axis_arrow_size",
+    "Trihedron arrows constant size", Config_Prop::IntSpin, "10");
+
   Config_PropManager::registerProp("Shortcuts", "add_parameter_shortcut",
     "Add parameter in parameters manager dialog",
     Config_Prop::Shortcut, "Ctrl+A");
@@ -1146,13 +1153,13 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     return;
 
   bool isModified = false;
+  double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
   ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
   if (aCurrentOperation &&
     (PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
      sketchMgr()->isNestedSketchOperation(aCurrentOperation) ||
      (aCurrentOperation->id() == "Measurement")))
   {
-    double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
     SketcherPrs_Tools::setArrowSize(aLen);
     const double aCurScale = aViewer->activeView()->Camera()->Scale();
     aViewer->SetScale(aViewer->activeView(), aCurScale);
@@ -1171,10 +1178,24 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
         isModified = true;
       }
     }
-    if (isModified)
-      aDisplayer->updateViewer();
   }
 
+  // Manage trihedron arrows
+  if (Config_PropManager::boolean("Visualization", "zoom_trihedron_arrows")) {
+    Handle(AIS_Trihedron) aTrihedron = aViewer->trihedron();
+    if (!aTrihedron.IsNull()) {
+      double aAxLen =
+        aView->Convert(Config_PropManager::integer("Visualization", "axis_arrow_size"));
+      Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+      double aAxisLen = aDatumAspect->AxisLength(Prs3d_DP_XAxis);
+      aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, aAxLen / aAxisLen);
+      aTrihedron->Attributes()->SetDatumAspect(aDatumAspect);
+      aContext->Redisplay(aTrihedron, false);
+      isModified = true;
+    }
+  }
+  if (isModified)
+    aDisplayer->updateViewer();
 }
 
 //******************************************************
@@ -1826,3 +1847,30 @@ void PartSet_Module::disableCustomMode(ModuleBase_CustomizeFlag theMode) {
 void PartSet_Module::enableCustomModes() {
   myCustomPrs->enableCustomModes();
 }
+
+//******************************************************
+void PartSet_Module::onConflictingConstraints()
+{
+  const std::set<ObjectPtr>& aConstraints = myOverconstraintListener->conflictingObjects();
+  QObjectPtrList aObjectsList;
+  std::set<ObjectPtr>::const_iterator aIt;
+  for (aIt = aConstraints.cbegin(); aIt != aConstraints.cend(); aIt++) {
+    if (mySketchReentrantMgr->isLastAutoConstraint(*aIt))
+      aObjectsList.append(*aIt);
+  }
+  if (aObjectsList.size() > 0) {
+    XGUI_Workshop* aWorkshop = getWorkshop();
+    QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
+    ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription);
+    XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
+
+    ModuleBase_Operation* anOp = anOpMgr->currentOperation();
+    if (sketchMgr()->isNestedSketchOperation(anOp))
+      anOp->abort();
+
+    anOpMgr->startOperation(anOpAction);
+    aWorkshop->deleteFeatures(aObjectsList);
+    anOpMgr->commitOperation();
+    ModuleBase_Tools::flushUpdated(sketchMgr()->activeSketch());
+  }
+}