Salome HOME
#2205 Ability to customize the arrows and texts of dimensions: Default arrow/text...
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index bd88803878d9e0690addcc0f7c83764a1388ce5e..4cdd4e928e10fbb67da0e9a8745a30f1dd7a236c 100755 (executable)
@@ -37,7 +37,6 @@
 #include "PartSet_MenuMgr.h"
 #include "PartSet_CustomPrs.h"
 #include "PartSet_IconFactory.h"
-#include "PartSet_WidgetChoice.h"
 #include "PartSet_OverconstraintListener.h"
 
 #include "PartSet_Filters.h"
@@ -52,6 +51,7 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IViewWindow.h>
 #include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetChoice.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_WidgetValidated.h>
 #include <ModuleBase_Tools.h>
@@ -185,6 +185,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   Config_PropManager::registerProp("Visualization", "operation_remove_feature_color",
                           "Color of removed feature in operation", Config_Prop::Color,
                           PartSet_CustomPrs::OPERATION_REMOVE_FEATURE_COLOR());
+  Config_PropManager::registerProp("Visualization", "sketch_preview_plane",
+                          "Color of sketch plane", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_SKETCH_PLANE());
 }
 
 PartSet_Module::~PartSet_Module()
@@ -255,6 +258,7 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_CollinearSelection", new PartSet_CollinearSelection);
   aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
+  aFactory->registerValidator("PartSet_DifferentPoints", new PartSet_DifferentPointsValidator);
   aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
   aFactory->registerValidator("PartSet_MultyTranslationSelection",
     new PartSet_MultyTranslationSelection);
@@ -788,7 +792,7 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
   } else if (theType == "sketch_launcher") {
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
   } else if (theType == "module_choice") {
-    aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi);
+    aWgt = new ModuleBase_WidgetChoice(theParent, theWidgetApi);
     connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
             this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
   }
@@ -982,14 +986,14 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
   }
   if (aView.IsNull())
     return;
-  double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize());
+  double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
 
   double aPrevLen = SketcherPrs_Tools::getArrowSize();
   SketcherPrs_Tools::setArrowSize(aLen);
-  const double aPrevScale = aViewer->Scale(aViewer->activeView());
   const double aCurScale = aViewer->activeView()->Camera()->Scale();
   aViewer->SetScale(aViewer->activeView(), aCurScale);
-  SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight());
+  double aTextHeight = SketcherPrs_Tools::getConfigTextHeight();
+  SketcherPrs_Tools::setTextHeight (aTextHeight);
   bool isModified = false;
   QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
   foreach (AISObjectPtr aAIS, aPrsList) {
@@ -998,6 +1002,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
     if (!aDim.IsNull()) {
       aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
+      aDim->DimensionAspect()->TextAspect()->SetHeight(aTextHeight);
       aContext->Redisplay(aDim, false);
       isModified = true;
     }
@@ -1263,7 +1268,7 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
       aTreeView->setExpanded(myActivePartIndex, false);
 
     XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
-    myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
+    myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
     bool needUpdate = false;
     if (myActivePartIndex.isValid()) {
       needUpdate = aTreeView->isExpanded(myActivePartIndex);
@@ -1335,7 +1340,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
     //aMgr->setActiveDocument(aMgr->moduleDocument());
     return;
   }
-  if (theIndex.column() != 0) // Use only first column
+  if (theIndex.column() != 1) // Use only first column
     return;
 
   XGUI_Workshop* aWorkshop = getWorkshop();
@@ -1471,7 +1476,7 @@ void PartSet_Module::setReentrantPreSelection(const std::shared_ptr<Events_Messa
 void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
                                      int theIndex)
 {
-  PartSet_WidgetChoice* aChoiceWidget = dynamic_cast<PartSet_WidgetChoice*>(theWidget);
+  ModuleBase_WidgetChoice* aChoiceWidget = dynamic_cast<ModuleBase_WidgetChoice*>(theWidget);
   if (!aChoiceWidget)
     return;