Salome HOME
Merge branch 'Dev_1.3.0' of newgeom:newgeom into Dev_1.3.0
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index 6bbc85002567f16a820ddcc8205aae44eba53b1d..cd842eedc73b8e1bb1cf974103ca9655b7af123f 100644 (file)
@@ -33,6 +33,7 @@
 #include <GeomValidators_Face.h>
 #include <GeomValidators_ConstructionComposite.h>
 #include <GeomValidators_ZeroOffset.h>
+#include <GeomValidators_BooleanArguments.h>
 
 
 #include <ModelAPI_Object.h>
@@ -135,7 +136,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
 
   mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop));
-  mySelectionFilters.Append(new PartSet_FilterInfinite());
+  mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop));
 }
 
 PartSet_Module::~PartSet_Module()
@@ -196,6 +197,9 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("GeomValidators_ZeroOffset",
                               new GeomValidators_ZeroOffset);
 
+  aFactory->registerValidator("GeomValidators_BooleanArguments",
+                              new GeomValidators_BooleanArguments);
+
   aFactory->registerValidator("PartSet_SketchEntityValidator",
                               new PartSet_SketchEntityValidator);
 
@@ -315,6 +319,11 @@ bool PartSet_Module::canRedo() const
   return aCanRedo;
 }
 
+bool PartSet_Module::canCommitOperation() const
+{
+  return mySketchMgr->canCommitOperation();
+}
+
 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 {
   // the sketch manager put the restriction to the objects display
@@ -380,24 +389,6 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
         }
       }
     }
-  } else {
-    // Start editing constraint
-    if (theOperation->isEditOperation()) {
-      // TODO: #391 - to be removed
-      std::string aId = theOperation->id().toStdString();
-      if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
-          PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
-        // Find and activate widget for management of point for dimension line position
-        QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
-        foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
-          PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
-          if (aPntWgt) {
-            aPanel->activateWidget(aPntWgt);
-            return;
-          }
-        }
-      }
-    }
   }
 }
 
@@ -495,48 +486,49 @@ void PartSet_Module::onVertexSelected()
 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
                                             Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  ModuleBase_IWorkshop* aWorkshop = workshop();
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+  XGUI_Workshop* aXUIWorkshop = aConnector->workshop();
   ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
     PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, 
       theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
-    aLabelWgt->setWorkshop(aWorkshop);
+    aLabelWgt->setWorkshop(aXUIWorkshop);
     connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
     connect(aLabelWgt, SIGNAL(showConstraintToggled(bool)),
       mySketchMgr, SLOT(onShowConstraintsToggle(bool)));
     aWgt = aLabelWgt;
   } else if (theType == "sketch-2dpoint_selector") {
-    PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
-    aPointWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
+                                                                 theWidgetApi, theParentId);
     aPointWgt->setSketch(mySketchMgr->activeSketch());
     connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
     aWgt = aPointWgt;
   } else if (theType == "point2ddistance") {
-    PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
-    aDistanceWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent,
+                                                        aWorkshop, theWidgetApi, theParentId);
     aDistanceWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = aDistanceWgt;
   } else if(theType == "point2dangle") {
-    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent, theWidgetApi, theParentId);
-    anAngleWgt->setWorkshop(aWorkshop);
+    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent,
+                                                           aWorkshop, theWidgetApi, theParentId);
     anAngleWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = anAngleWgt;
   } else if (theType == "sketch_shape_selector") {
     PartSet_WidgetShapeSelector* aShapeSelectorWgt =
-      new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
+      new PartSet_WidgetShapeSelector(theParent, aWorkshop, theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
   } else if (theType == "sketch_multi_selector") {
     PartSet_WidgetMultiSelector* aShapeSelectorWgt =
-      new PartSet_WidgetMultiSelector(theParent, workshop(), theWidgetApi, theParentId);
+      new PartSet_WidgetMultiSelector(theParent, aWorkshop, theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
-    aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt = new PartSet_WidgetEditor(theParent, aWorkshop, theWidgetApi, theParentId);
   } else if (theType == "export_file_selector") {
-    aWgt = new PartSet_WidgetFileSelector(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi, theParentId);
   } else if (theType == "sketch_launcher") {
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi, theParentId);
   }