Salome HOME
Shape plane filter should process shapes of objects selected in object browser.
authornds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 15:21:49 +0000 (18:21 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 3 Jul 2015 15:23:45 +0000 (18:23 +0300)
Provides the vidget validated by IWorkshop to use the filters of AIS context
The goal is to ask context filters by preselection an in onSelectionChanged for presentations from OB only.

15 files changed:
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetMultiSelector.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h

index a237e6e294911c07c9e353c06e2d89c0de7a21d7..4926a1e8118fbd6a0fff57f6cc40f2286dad0b27 100644 (file)
@@ -17,6 +17,7 @@
 #include <memory>
 
 class Config_WidgetAPI;
+class ModuleBase_IWorkshop;
 class QKeyEvent;
 
 /**\class ModuleBase_ModelWidget
@@ -82,7 +83,9 @@ Q_OBJECT
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped selection values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+  /// \param toValidate the boolean value whether the value should be checked by filters
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate)
   {
     return false;
   }
index 58891e564d2bb1c9bec7a299fcdf7b7c3b2c1c52..0cfb9863045d943ccd2d2a8f268dae8597ab66be 100644 (file)
@@ -288,7 +288,7 @@ void ModuleBase_Operation::activateByPreselection()
         if (!aWgt->canSetValue())
           continue;
 
-        if (!aWgt->setSelection(myPreSelection)) {
+        if (!aWgt->setSelection(myPreSelection, true)) {
           isSet = false;
           break;
         } else {
index 946bfa116925e8d3a895e9fc047cdffafb7fa52d..9b0222ca57ae21b818d7ed2f049b0ba00e6753ce 100644 (file)
@@ -201,7 +201,8 @@ void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/)
 }
 
 //********************************************************************
-bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                                                  const bool theToValidate)
 {
   QList<ModuleBase_ViewerPrs> aSkippedValues;
 
@@ -210,7 +211,7 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& t
   for (; anIt != aLast; anIt++) {
     ModuleBase_ViewerPrs aValue = *anIt;
     bool aProcessed = false;
-    if (isValidSelection(aValue)) {
+    if (!theToValidate || isValidInFilters(aValue)) {
       aProcessed = setSelectionCustom(aValue);
     }
     else
@@ -272,7 +273,7 @@ QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   activateSelection(true);
-  activateFilters(myWorkshop, true);
+  activateFilters(true);
   QList<ModuleBase_ViewerPrs> anEmptyList;
   // This method will call Selection changed event which will call onSelectionChanged
   // To clear mySelection, myListControl and storeValue()
@@ -319,13 +320,13 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum
     TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
     if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
       activateSelection(false);
-      activateFilters(myWorkshop, false);
+      activateFilters(false);
       bool isBlocked = myTypeCombo->blockSignals(true);
       myTypeCombo->setCurrentIndex(idx);
       myTypeCombo->blockSignals(isBlocked);
 
       activateSelection(true);
-      activateFilters(myWorkshop, true);
+      activateFilters(true);
       break;
     }
   }
index 92114088774dc9bb2184a8be7900d51821d70596..2fed320e4e18ea56403ba3b4689d2f4b31bf4b29 100644 (file)
@@ -72,7 +72,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped selection values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate);
 
   /// Checks the widget validity. By default, it returns true.
   /// \param theValue a selected presentation in the view
index dcfb86bec31f814fce42413e07561fbfa6a4fd5b..1b9df3d5791662a726fa62917a0e56e6838723f2 100755 (executable)
@@ -15,8 +15,7 @@ ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
                                                      ModuleBase_IWorkshop* theWorkshop,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
- : ModuleBase_WidgetValidated(theParent, theData, theParentId),
-   myWorkshop(theWorkshop)
+ : ModuleBase_WidgetValidated(theParent, theWorkshop, theData, theParentId)
 {
 }
 
@@ -48,7 +47,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 
   QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(
                                                               ModuleBase_ISelection::AllControls);
-  bool isDone = setSelection(aSelected);
+  bool isDone = setSelection(aSelected, true);
 
   emit valuesChanged();
   // the updateObject method should be called to flush the updated sigal. The workshop listens it,
@@ -138,13 +137,10 @@ void ModuleBase_WidgetSelector::activateCustom()
   // Restore selection in the viewer by the attribute selection list
   myWorkshop->setSelected(getAttributeSelection());
 
-  activateFilters(myWorkshop, true);
+  activateFilters(true);
 }
 
 //********************************************************************
-#include <ModuleBase_IViewer.h>
-#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
-#include <StdSelect_BRepOwner.hxx>
 bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
 {
   GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
@@ -157,30 +153,6 @@ bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPr
     FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aResult);
     aValid = aSelectedFeature != myFeature;
   }
-  
-  // selection happens in the Object browser.
-  // it creates a selection owner and check whether the viewer filters process it
-  if (thePrs.owner().IsNull() && thePrs.object().get()) {
-    ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-    if (aResult.get())
-      aShape = aResult->shape();
-
-    const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
-
-    Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
-    Handle(StdSelect_BRepOwner) aShapeOwner = new StdSelect_BRepOwner(aTDShape, anIO);
-
-    const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
-    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
-    for (; anIt.More() && aValid; anIt.Next()) {
-      Handle(SelectMgr_Filter) aFilter = anIt.Value();
-      if (aFilter == myWorkshop->validatorFilter())
-        continue;
-
-      aValid = aFilter->IsOk(aShapeOwner);
-    }
-    aShapeOwner.Nullify();
-  }
   return aValid;
 }
 
@@ -200,5 +172,5 @@ void ModuleBase_WidgetSelector::deactivate()
 {
   disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
   activateSelection(false);
-  activateFilters(myWorkshop, false);
+  activateFilters(false);
 }
index dd853530efea79353512265e326ac25b3c47c3b6..2d3796f67361806f73d5a5efb88083f59f89db7c 100755 (executable)
@@ -111,9 +111,6 @@ protected:
                                 GeomShapePtr& theShape);
 
   //----------- Class members -------------
-protected:
-  /// Reference to workshop
-  ModuleBase_IWorkshop* myWorkshop;
 };
 
 #endif
index 889817706c8c12849cd3d0a88231d4e414f81756..94f837e924f515748ea8ca98923f6acdf26af75d 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <SelectMgr_EntityOwner.hxx>
+#include <StdSelect_BRepOwner.hxx>
 
 #include <Events_Loop.h>
 
 //#define DEBUG_VALID_STATE
 
 ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
+                                                       ModuleBase_IWorkshop* theWorkshop,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
- : ModuleBase_ModelWidget(theParent, theData, theParentId), isValidateBlocked(false)
+: ModuleBase_ModelWidget(theParent, theData, theParentId), isValidateBlocked(false),
+  myWorkshop(theWorkshop)
 {
 }
 
@@ -31,7 +34,8 @@ ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetValidated::setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+bool ModuleBase_WidgetValidated::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                                              const bool theToValidate)
 {
   if (theValues.empty())
     return false;
@@ -39,7 +43,7 @@ bool ModuleBase_WidgetValidated::setSelection(QList<ModuleBase_ViewerPrs>& theVa
   ModuleBase_ViewerPrs aValue = theValues.takeFirst();
   bool isDone = false;
 
-  if (isValidSelection(aValue)) {
+  if (!theToValidate || isValidInFilters(aValue)) {
     isDone = setSelectionCustom(aValue);
     // updateObject - to update/redisplay feature
     // it is commented in order to perfom it outside the method
@@ -50,6 +54,41 @@ bool ModuleBase_WidgetValidated::setSelection(QList<ModuleBase_ViewerPrs>& theVa
   return isDone;
 }
 
+//********************************************************************
+bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs)
+{
+  bool aValid = true;
+  Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner();
+
+  // if an owern is null, the selection happens in the Object browser.
+  // creates a selection owner on the base of object shape and the object AIS object
+  if (anOwner.IsNull() && thePrs.owner().IsNull() && thePrs.object().get()) {
+    ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+    if (aResult.get()) {
+      GeomShapePtr aShape = aResult->shape();
+
+      const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
+      Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
+      anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+    }
+  }
+  // finds 
+  if (!anOwner.IsNull()) {
+    const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
+    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
+    for (; anIt.More() && aValid; anIt.Next()) {
+      Handle(SelectMgr_Filter) aFilter = anIt.Value();
+      //if (aFilter == myWorkshop->validatorFilter())
+      //  continue;
+      aValid = aFilter->IsOk(anOwner);
+    }
+  }
+  // removes created owner
+  if (!anOwner.IsNull() && anOwner != thePrs.owner())
+    anOwner.Nullify();
+  return aValid;
+}
+
 //********************************************************************
 bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue)
 {
@@ -139,12 +178,11 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const
   return aValid;
 }
 
-void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorkshop,
-                                                 const bool toActivate)
+void ModuleBase_WidgetValidated::activateFilters(const bool toActivate)
 {
-  ModuleBase_IViewer* aViewer = theWorkshop->viewer();
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
 
-  Handle(SelectMgr_Filter) aSelFilter = theWorkshop->validatorFilter();
+  Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter();
   if (toActivate)
     aViewer->addSelectionFilter(aSelFilter);
   else {
index f1caa0905984d5d2a265b52dd60a11af5a6d8f0b..9861d424806144ca7b4d24412156cee5ce9460c2 100644 (file)
@@ -38,10 +38,17 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg
   /// \param theData the widget configuation. The attribute of the model widget is obtained from
   /// \param theParentId is Id of a parent of the current attribute
   ModuleBase_WidgetValidated(QWidget* theParent,
+                             ModuleBase_IWorkshop* theWorkshop,
                              const Config_WidgetAPI* theData,
                              const std::string& theParentId);
   virtual ~ModuleBase_WidgetValidated();
 
+  /// Checks whether all active viewer filters validate the presentation
+  /// \param theWorkshop an active workshop
+  /// \param theValue a selected presentation in the view
+  /// \return a boolean value
+  bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
+
   /// Checks all widget validator if the owner is valid
   /// \param theValue a selected presentation in the view
   /// \return a boolean value
@@ -52,8 +59,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg
   /// The method is called by the current operation to process the operation preselection.
   /// It is redefined to check the value validity and if it is, fill the attribute with by value
   /// \param theValues the wrapped selection values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
-
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate);
 protected:
   /// Creates a backup of the current values of the attribute
   /// It should be realized in the specific widget because of different
@@ -82,7 +89,7 @@ protected:
   /// It obtains selection filters from the workshop and activates them in the active viewer
   /// \param theWorkshop an active workshop
   /// \param toActivate a flag about activation or deactivation the filters
-  virtual void activateFilters(ModuleBase_IWorkshop* theWorkshop, const bool toActivate);
+  virtual void activateFilters(const bool toActivate);
 
   /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored
   /// \param theValue a viewer presentation
@@ -97,6 +104,9 @@ protected:
   // Removes all presentations from internal maps.
   void clearValidState();
 
+protected:
+  ModuleBase_IWorkshop* myWorkshop;  /// Reference to workshop
+
 private:
   QList<ModuleBase_ViewerPrs> myValidPrs;
   QList<ModuleBase_ViewerPrs> myInvalidPrs;
index e997f05cf97a1c967fb30473753308a9ae390008..8ad7937e4460cfd94357c929b6216d7adb2b84f4 100644 (file)
@@ -503,9 +503,8 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
   XGUI_Workshop* aXUIWorkshop = aConnector->workshop();
   ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
-    PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, 
+    PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop,
       theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
-    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)),
index fbce745f6b8e1311db77e51f305a8da73b03ddae..00b126e9ccf434124f1c455b7bead941a65a7e28 100644 (file)
@@ -41,9 +41,10 @@ PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector()
   delete myExternalObjectMgr;
 }
 
-bool PartSet_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+bool PartSet_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                                               const bool theToValidate)
 {
-  bool aSucceed = ModuleBase_WidgetMultiSelector::setSelection(theValues);
+  bool aSucceed = ModuleBase_WidgetMultiSelector::setSelection(theValues, theToValidate);
   if (aSucceed) {
     // TODO(nds): unite with externalObject(), remove parameters
     //myFeature->execute();
index 20fead7d50d567792a8215b20c5e76ffc7a69b5f..e0479547ed5b09fda35eb3d9ca34c9b03d73dc5c 100644 (file)
@@ -49,7 +49,8 @@ Q_OBJECT
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped selection values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate);
 
 protected:
   /// Checks the widget validity. By default, it returns true.
index ab596837dd6952a8012824845aca10a05ab1b304..e48dc8b0ebc7cc52418008e1ef723fed84b17ecd 100644 (file)
@@ -122,7 +122,8 @@ PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
 {
 }
 
-bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                                         const bool theToValidate)
 {
   if (theValues.empty())
     return false;
index 6e9ba600394b85dec9abac749e0b735da2a62ba9..d42bd44fb4e1f1229cea95edf3b9a83c4519e507 100644 (file)
@@ -56,7 +56,8 @@ Q_OBJECT
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped widget values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate);
 
   virtual bool restoreValue();
 
index d0de6fb9453c12268cd49596c302830d4481ecce..e9e43ba5ac243a79ab060b8edfd131e2367fd42b 100644 (file)
 
 
 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
+                                                     ModuleBase_IWorkshop* theWorkshop,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId,
                                                      bool toShowConstraints)
-    : ModuleBase_WidgetValidated(theParent, theData, theParentId),
-      myPreviewDisplayed(false),
-      myWorkshop(NULL)
+: ModuleBase_WidgetValidated(theParent, theWorkshop, theData, theParentId),
+  myPreviewDisplayed(false)
 {
   myText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel("", theParent);
@@ -83,7 +83,8 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
   erasePreviewPlanes();
 }
 
-bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrs>& theValues)
+bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                                             const bool theToValidate)
 {
   // do not use the given selection if the plane of the sketch has been already set.
   // If this check is absent, a selected plane in the viewer can be set in the sketch
@@ -91,7 +92,7 @@ bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrs>& theVal
   if (plane().get())
     return true;
 
-  return ModuleBase_WidgetValidated::setSelection(theValues);
+  return ModuleBase_WidgetValidated::setSelection(theValues, theToValidate);
 }
 
 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
@@ -103,13 +104,13 @@ QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
 
 void PartSet_WidgetSketchLabel::onSelectionChanged()
 {
-  QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selector()->selection()->getSelected(
+  QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(
                                                            ModuleBase_ISelection::AllControls);
   if (aSelected.empty())
     return;
   ModuleBase_ViewerPrs aPrs = aSelected.first();
 
-  bool isDone = ModuleBase_WidgetValidated::setSelection(aSelected);
+  bool isDone = ModuleBase_WidgetValidated::setSelection(aSelected, true);
   if (!isDone)
     return;
 
@@ -164,13 +165,13 @@ void PartSet_WidgetSketchLabel::onSelectionChanged()
   // 5. Clear text in the label
   myLabel->setText("");
   myLabel->setToolTip("");
-  disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), 
+  disconnect(workshop()->selector(), SIGNAL(selectionChanged()), 
               this, SLOT(onSelectionChanged()));
   // 6. deactivate face selection filter
-  activateFilters(myWorkshop->module()->workshop(), false);
+  activateFilters(false);
 
   // 7. Clear selection mode and define sketching mode
-  //XGUI_Displayer* aDisp = myWorkshop->displayer();
+  //XGUI_Displayer* aDisp = workshop()->displayer();
   //aDisp->closeLocalContexts();
   emit planeSelected(plane());
   // after the plane is selected in the sketch, the sketch selection should be activated
@@ -179,7 +180,7 @@ void PartSet_WidgetSketchLabel::onSelectionChanged()
   activateSelection(true);
 
   // 8. Update sketcher actions
-  XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
+  XGUI_ActionsMgr* anActMgr = workshop()->actionsMgr();
   anActMgr->update();
   myWorkshop->viewer()->update();
 }
@@ -264,7 +265,7 @@ void PartSet_WidgetSketchLabel::activateCustom()
   }
 
   bool aBodyIsVisualized = false;
-  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  XGUI_Displayer* aDisp = workshop()->displayer();
   QObjectPtrList aDisplayed = aDisp->displayedObjects();
   foreach (ObjectPtr anObj, aDisplayed) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
@@ -284,8 +285,8 @@ void PartSet_WidgetSketchLabel::activateCustom()
   myLabel->setText(myText);
   myLabel->setToolTip(myTooltip);
 
-  connect(myWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  activateFilters(myWorkshop->module()->workshop(), true);
+  connect(workshop()->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+  activateFilters(true);
 
   aDisp->updateViewer();
 }
@@ -295,7 +296,7 @@ void PartSet_WidgetSketchLabel::deactivate()
   erasePreviewPlanes();
   activateSelection(false);
 
-  activateFilters(myWorkshop->module()->workshop(), false);
+  activateFilters(false);
 }
 
 void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
@@ -304,21 +305,21 @@ void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
     QIntList aModes;
     std::shared_ptr<GeomAPI_Pln> aPlane = plane();
     if (aPlane.get()) {
-      myWorkshop->moduleConnector()->module()->activeSelectionModes(aModes);
+      myWorkshop->module()->activeSelectionModes(aModes);
     }
     else {
       aModes << TopAbs_FACE;
     }
-    myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
+    myWorkshop->activateSubShapesSelection(aModes);
   } else {
-    myWorkshop->moduleConnector()->deactivateSubShapesSelection();
+    myWorkshop->deactivateSubShapesSelection();
   }
 }
 
 void PartSet_WidgetSketchLabel::erasePreviewPlanes()
 {
   if (myPreviewDisplayed) {
-    XGUI_Displayer* aDisp = myWorkshop->displayer();
+    XGUI_Displayer* aDisp = workshop()->displayer();
     aDisp->eraseAIS(myYZPlane, false);
     aDisp->eraseAIS(myXZPlane, false);
     aDisp->eraseAIS(myXYPlane, false);
@@ -353,7 +354,7 @@ void PartSet_WidgetSketchLabel::showPreviewPlanes()
     myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG);
     myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB);
   }
-  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  XGUI_Displayer* aDisp = workshop()->displayer();
   aDisp->displayAIS(myYZPlane, false);
   aDisp->displayAIS(myXZPlane, false);
   aDisp->displayAIS(myXYPlane, false);
@@ -426,3 +427,9 @@ void PartSet_WidgetSketchLabel::showConstraints(bool theOn)
   myShowConstraints->setChecked(theOn);
   emit showConstraintToggled(theOn);
 }
+
+XGUI_Workshop* PartSet_WidgetSketchLabel::workshop() const
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+  return aConnector->workshop();
+}
index 4074ad53d8587cad2b045d2471adb6f0d2469a31..3eddeb2d2c52a910b48e6e03a3e716586bbc0dbf 100644 (file)
@@ -42,7 +42,8 @@ Q_OBJECT
   /// \param theParent the parent object
   /// \param theData the widget configuation. The attribute of the model widget is obtained from
   /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
+  PartSet_WidgetSketchLabel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                            const Config_WidgetAPI* theData,
                             const std::string& theParentId, bool toShowConstraints);
 
   virtual ~PartSet_WidgetSketchLabel();
@@ -52,7 +53,8 @@ Q_OBJECT
   /// The method is called by the current operation to process the operation preselection.
   /// It is redefined to do nothing if the plane of the sketch has been already set.
   /// \param theValues the wrapped selection values
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues);
+  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+                            const bool theToValidate);
 
   virtual bool restoreValue()
   {
@@ -66,13 +68,6 @@ Q_OBJECT
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
-  /// Returns pointer to workshop
-  XGUI_Workshop* workshop() const { return myWorkshop; }
-
-  /// Set pointer to workshop
-  /// \param theWork a pointer to workshop
-  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
-
   /// Returns sketcher plane
   std::shared_ptr<GeomAPI_Pln> plane() const;
 
@@ -132,6 +127,9 @@ protected:
                                   std::shared_ptr<GeomAPI_Dir> theNorm, 
                                   const int theRGB[3]);
 
+  //! Returns workshop
+  XGUI_Workshop* workshop() const;
+
   /// Set sketch plane by shape
   /// \param theShape a planar face
   std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
@@ -147,8 +145,6 @@ protected:
   QString myText;
   QString myTooltip;
 
-  XGUI_Workshop* myWorkshop;
-
   AISObjectPtr myYZPlane;
   AISObjectPtr myXZPlane;
   AISObjectPtr myXYPlane;