Salome HOME
Update unit tests for the PlaneGCS solver. Bug fixes.
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
index 35613280488db8da7792cba3637c4eb3dbc95e6e..47fa2a04f5d5d5f71da9630ad4c7816bfcef7306 100755 (executable)
@@ -367,6 +367,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);
@@ -492,7 +497,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()
@@ -818,15 +823,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;
 }
@@ -1030,6 +1037,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)
 {