Salome HOME
"2.11 Constraint with a point from the intersection between an outer edge and plane...
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index fb633f631f74732dd83902a51aa880447962a1cf..641d17ac239f668baa3bd2e5efc6d8d9817dd933 100755 (executable)
@@ -18,6 +18,7 @@
 #include "PartSet_CustomPrs.h"
 #include "PartSet_IconFactory.h"
 #include "PartSet_WidgetChoice.h"
+#include "PartSet_OverconstraintListener.h"
 
 #include "PartSet_Filters.h"
 #include "PartSet_FilterInfinite.h"
@@ -36,6 +37,8 @@
 #include <ModuleBase_FilterFactory.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_OperationFeature.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_OperationDescription.h>
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
@@ -60,6 +63,7 @@
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_DataModel.h>
 #include <XGUI_ErrorMgr.h>
+#include <XGUI_CustomPrs.h>
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
@@ -92,6 +96,7 @@
 #include <QMessageBox>
 #include <QMainWindow>
 #include <QLineEdit>
+#include <QString>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomDataAPI_Dir.h>
@@ -110,7 +115,7 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop*
 
 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 : ModuleBase_IModule(theWshop),
-  myVisualLayerId(0), myHasConstraintShown(true)
+  myVisualLayerId(0)
 {
   new PartSet_IconFactory();
 
@@ -131,15 +136,29 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
           SLOT(onViewTransformed(int)));
   connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)),
           SLOT(onViewCreated(ModuleBase_IViewWindow*)));
-
   myMenuMgr = new PartSet_MenuMgr(this);
   myCustomPrs = new PartSet_CustomPrs(theWshop);
 
+  myOverconstraintListener = new PartSet_OverconstraintListener(theWshop);
+
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
 
   mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop));
   mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop));
+
+  myHasConstraintShown[PartSet_Tools::Geometrical] = true;
+  myHasConstraintShown[PartSet_Tools::Dimensional] = true;
+
+  Config_PropManager::registerProp("Visualization", "operation_parameter_color",
+                          "Reference shape wireframe color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_PARAMETER_COLOR());
+  Config_PropManager::registerProp("Visualization", "operation_result_color",
+                          "Result shape wireframe color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_RESULT_COLOR());
+  Config_PropManager::registerProp("Visualization", "operation_highlight_color",
+                          "Multi selector item color in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR());
 }
 
 PartSet_Module::~PartSet_Module()
@@ -151,6 +170,7 @@ PartSet_Module::~PartSet_Module()
       aFilter.Nullify();
   }
   delete myCustomPrs;
+  delete myOverconstraintListener;
 }
 
 void PartSet_Module::activateSelectionFilters()
@@ -190,6 +210,8 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_FilletSelection", new PartSet_FilletSelection);
   aFactory->registerValidator("PartSet_AngleSelection", new PartSet_AngleSelection);
   aFactory->registerValidator("PartSet_EqualSelection", new PartSet_EqualSelection);
+  aFactory->registerValidator("PartSet_CollinearSelection", new PartSet_CollinearSelection);
+  aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
   aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
   aFactory->registerValidator("PartSet_SketchEntityValidator", new PartSet_SketchEntityValidator);
@@ -231,9 +253,7 @@ void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
       // the selection is cleared after commit the create operation
       // in order to do not use the same selected objects in the restarted operation
       // for common behaviour, the selection is cleared even if the operation is not restarted
-      XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-      XGUI_Workshop* aWorkshop = aConnector->workshop();
-      aWorkshop->selector()->clearSelection();
+      getWorkshop()->selector()->clearSelection();
     }
   }
 }
@@ -257,8 +277,10 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
   }
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
-  if (aFOperation)
-    myCustomPrs->activate(aFOperation->feature(), true);
+  if (aFOperation) {
+    myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, true);
+    myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, true);
+  }
 }
 
 void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
@@ -266,13 +288,16 @@ void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
   ModuleBase_IModule::operationResumed(theOperation);
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
-  if (aFOperation)
-    myCustomPrs->activate(aFOperation->feature(), true);
+  if (aFOperation) {
+    myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, true);
+    myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, true);
+  }
 }
 
 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
 {
-  bool isModified = myCustomPrs->deactivate(false);
+  bool isModified = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeArguments, false) ||
+                    myCustomPrs->deactivate(ModuleBase_IModule::CustomizeResults, false);
 
   if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
     mySketchMgr->stopNestedSketch(theOperation);
@@ -284,7 +309,13 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
     aDisplayer->updateViewer();
   }
-  mySketchMgr->onShowConstraintsToggle(myHasConstraintShown);
+
+  QMap<PartSet_Tools::ConstraintVisibleState, bool>::const_iterator anIt = myHasConstraintShown.begin(),
+                                                                    aLast = myHasConstraintShown.end();
+  for (; anIt != aLast; anIt++) {
+    myHasConstraintShown[anIt.key()];
+    mySketchMgr->onShowConstraintsToggle(anIt.value(), myHasConstraintShown[anIt.key()]);
+  }
 }
 
 ModuleBase_Operation* PartSet_Module::currentOperation() const
@@ -344,6 +375,11 @@ bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
   return mySketchMgr->canDisplayObject(theObject);
 }
 
+void PartSet_Module::processHiddenObject(const std::list<ObjectPtr>& theObjects)
+{
+  mySketchMgr->processHiddenObject(theObjects);
+}
+
 bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
 {
   bool aCanActivate = ModuleBase_IModule::canActivateSelection(theObject);
@@ -385,9 +421,7 @@ void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation,
   myMenuMgr->grantedOperationIds(theOperation, theIds);
 
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
-    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-    XGUI_Workshop* aWorkshop = aConnector->workshop();
-
+    XGUI_Workshop* aWorkshop = getWorkshop();
     theIds.append(aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text());
   }
 }
@@ -413,8 +447,7 @@ void PartSet_Module::clearViewer()
 {
   myCustomPrs->clearPrs();
 
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = getWorkshop();
   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
   aDisplayer->deactivateSelectionFilters();
 }
@@ -431,6 +464,47 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
     aPanel->activateWidget(aPanel->modelWidgets().first());
 }
 
+bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
+                                   QList<ModuleBase_ModelWidget*>& theWidgets) const
+{
+  bool aProcessed = false;
+
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
+  XGUI_Workshop* aWorkshop = getWorkshop();
+  XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+  if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) {
+    ModuleBase_ISelection* aSelection = workshop()->selection();
+    // click on a point in sketch leads here with the point is highlighted, not yet selected
+    QList<ModuleBase_ViewerPrs> aPreselection = aSelection->getHighlighted();
+    if (aPreselection.size() == 1) {
+      ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0];
+      ObjectPtr anObject = aSelectedPrs.object();
+
+      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+      FeaturePtr anOpFeature = aFOperation->feature();
+      TopoDS_Shape aShape = aSelectedPrs.shape();
+      // click on the digit of dimension constrain comes here with an empty shape, so we need the check
+      if (aFeature == anOpFeature && !aShape.IsNull()) {
+        AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape,
+                                                                         mySketchMgr->activeSketch());
+        if (anAttribute.get()) {
+          QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+          ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), workshop());
+
+          const std::string anAttributeId = anAttribute->id();
+          aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId);
+
+          theWidgets = aFactory.getModelWidgets();
+          // it is possible that the point does not present in XML definition,
+          // in this case, we assume that it is not processed by this module
+          // e.g. "Intersection point" feature
+          aProcessed = !theWidgets.isEmpty();
+        }
+      }
+    }
+  }
+  return aProcessed;
+}
 
 void PartSet_Module::onSelectionChanged()
 {
@@ -469,7 +543,7 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
   XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
-  anOpMgr->onKeyReleased(theEvent);
+  anOpMgr->onKeyReleased(theWnd->viewPort(), theEvent);
 }
 
 void PartSet_Module::onOperationActivatedByPreselection()
@@ -483,16 +557,15 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
                                             Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
   ModuleBase_IWorkshop* aWorkshop = workshop();
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
-  XGUI_Workshop* aXUIWorkshop = aConnector->workshop();
+  XGUI_Workshop* aXUIWorkshop = getWorkshop();
   ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
     PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop,
-      theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
+      theWidgetApi, theParentId, mySketchMgr->showConstraintStates());
     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)));
+    connect(aLabelWgt, SIGNAL(showConstraintToggled(bool, int)),
+      mySketchMgr, SLOT(onShowConstraintsToggle(bool, int)));
     aWgt = aLabelWgt;
   } else if (theType == "sketch-2dpoint_selector") {
     PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
@@ -553,8 +626,7 @@ bool PartSet_Module::deleteObjects()
 {
   bool isProcessed = false;
 
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = getWorkshop();
   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
 
   //SessionPtr aMgr = ModelAPI_Session::get();
@@ -638,10 +710,15 @@ void PartSet_Module::onFeatureTriggered()
 
 void PartSet_Module::launchOperation(const QString& theCmdId)
 {
+  if (myWorkshop->currentOperation() && 
+      myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) {
+      const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates = mySketchMgr->showConstraintStates();
+      myHasConstraintShown = aShownStates;
+  }
   if (PartSet_SketcherMgr::constraintsIdList().contains(theCmdId)) {
     // Show constraints if a constraint was anOperation
-    myHasConstraintShown = mySketchMgr->isConstraintsShown();
-    mySketchMgr->onShowConstraintsToggle(true);
+    mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Geometrical);
+    mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Dimensional);
   }
   ModuleBase_IModule::launchOperation(theCmdId);
 }
@@ -685,8 +762,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
 
   //Handle(V3d_View) aView = aViewer->activeView();
 
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = getWorkshop();
   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
   Handle(V3d_Viewer) aV3dViewer = aContext->CurrentViewer();
   Handle(V3d_View) aView;
@@ -703,7 +779,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
   }
   if (aView.IsNull())
     return;
-  double aLen = aView->Convert(20);
+  double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize());
 
   double aPrevLen = SketcherPrs_Tools::getArrowSize();
   SketcherPrs_Tools::setArrowSize(aLen);
@@ -727,11 +803,70 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     aDisplayer->updateViewer();
 }
 
-bool PartSet_Module::customizeObject(ObjectPtr theObject, const bool theUpdateViewer)
+void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature, const ModuleBase_CustomizeFlag& theFlag,
+                                       const bool theUpdateViewer)
+{
+  myCustomPrs->activate(theFeature, theFlag, theUpdateViewer);
+}
+
+void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
+                                         const bool theUpdateViewer)
+{
+  myCustomPrs->deactivate(theFlag, theUpdateViewer);
+}
+
+bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+                                           std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
+{
+  bool aCustomized = false;
+
+  if (theResult.get())
+    return aCustomized;
+
+  XGUI_Workshop* aWorkshop = getWorkshop();
+  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+  ObjectPtr anObject = aDisplayer->getObject(thePrs);
+  if (anObject.get()) {
+    bool isConflicting = myOverconstraintListener->isConflictingObject(anObject);
+    // customize sketcy symbol presentation
+    if (thePrs.get()) {
+      Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
+      if (!anAISIO.IsNull()) {
+        if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
+          Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
+          if (!aPrs.IsNull()) {
+            std::vector<int> aColor;
+            myOverconstraintListener->getConflictingColor(aColor);
+            aPrs->SetConflictingConstraint(isConflicting, aColor);
+            aCustomized = true;
+          }
+        }
+      }
+    }
+    // customize sketch dimension constraint presentation
+    if (!aCustomized) {
+      std::vector<int> aColor;
+      if (isConflicting) {
+        myOverconstraintListener->getConflictingColor(aColor);
+      }
+      if (aColor.empty())
+        XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
+      if (!aColor.empty()) {
+        thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+        aCustomized = true;
+      }
+    }
+  }
+
+  return aCustomized;
+}
+
+bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+                                     const bool theUpdateViewer)
 {
   bool isRedisplayed = false;
-  if (myCustomPrs->isActive())
-    isRedisplayed = myCustomPrs->redisplay(theObject, theUpdateViewer);
+  if (myCustomPrs->isActive(theFlag))
+    isRedisplayed = myCustomPrs->redisplay(theObject, theFlag, theUpdateViewer);
 
   return isRedisplayed;
 }
@@ -758,8 +893,7 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
   SessionPtr aMgr = ModelAPI_Session::get();
   QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD");
 
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = getWorkshop();
   QLabel* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
 
   aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
@@ -777,15 +911,17 @@ ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
   if (aOperation) {
     /// If last line finished on vertex the lines creation sequence has to be break
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
-    ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
-    // if there is an active widget, find the presented object in it
-    if (!anActiveWidget)
-      anActiveWidget = aPanel->preselectionWidget();
+    if (aPanel) {
+      ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
+      // if there is an active widget, find the presented object in it
+      if (!anActiveWidget)
+        anActiveWidget = aPanel->preselectionWidget();
     
-    ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
-                                                                           (anActiveWidget);
-    if (aWidgetValidated)
-      anObject = aWidgetValidated->findPresentedObject(theAIS);
+      ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
+                                                                             (anActiveWidget);
+      if (aWidgetValidated)
+        anObject = aWidgetValidated->findPresentedObject(theAIS);
+    }
   }
   return anObject;
 }
@@ -857,8 +993,7 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
     if (myWorkshop->currentOperation() && 
       (!aAllowActivationList.contains(myWorkshop->currentOperation()->id())))
       return;
-    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-    XGUI_Workshop* aWorkshop = aConnector->workshop();
+    XGUI_Workshop* aWorkshop = getWorkshop();
     XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
     QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
     QPalette aPalet = aLabel->palette();
@@ -902,8 +1037,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
   if (theIndex.column() != 0) // Use only first column
     return;
 
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = getWorkshop();
   XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
   // De not use non editable Indexes
   if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0)
@@ -989,6 +1123,41 @@ void PartSet_Module::beforeOperationStopped(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
+GeomShapePtr PartSet_Module::findShape(const AttributePtr& theAttribute)
+{
+  GeomShapePtr aGeomShape;
+
+  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+  if (anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
+    aGeomShape = PartSet_Tools::findShapeBy2DPoint(theAttribute, myWorkshop);
+  }
+  return aGeomShape;
+}
+
+//******************************************************
+AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject,
+                                           const GeomShapePtr& theGeomShape)
+{
+  AttributePtr anAttribute;
+  GeomShapePtr aGeomShape = theGeomShape;
+  if (!aGeomShape.get()) {
+    // processing shape of result, e.g. sketch circle center is selected, this is a result
+    // the geom shape is empty, the shape of result should be used
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult.get()) {
+      aGeomShape = aResult->shape();
+    }
+  }
+
+  if (aGeomShape.get()) {
+    TopoDS_Shape aTDSShape = aGeomShape->impl<TopoDS_Shape>();
+    return PartSet_Tools::findAttributeBy2dPoint(theObject, aTDSShape, 
+                                                 mySketchMgr->activeSketch());
+  }
+  return anAttribute;
+}
+
 //******************************************************
 void PartSet_Module::onBooleanOperationChange(int theOperation)
 {
@@ -1008,3 +1177,10 @@ void PartSet_Module::onBooleanOperationChange(int theOperation)
     break;
   }
 }
+
+//******************************************************
+XGUI_Workshop* PartSet_Module::getWorkshop() const
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+  return aConnector->workshop();
+}