Salome HOME
1. Correction for perfomance problem by Apply button state update: do not listen...
[modules/shaper.git] / src / PartSet / PartSet_Tools.cpp
index 48a5c6a1cdc3cc0d2ba7014d0d52b385d4190315..a08190d7b5c7caef2afd22b425a72c5ba6f2c0b3 100755 (executable)
@@ -53,6 +53,7 @@
 
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <V3d_View.hxx>
 #include <gp_Pln.hxx>
@@ -304,7 +305,7 @@ std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findFirstEqualPointInArgumen
 
   // may be feature is not updated yet, execute is not performed and references features
   // are not created. Case: rectangle macro feature
-  ModuleBase_ModelWidget::updateObject(theFeature);
+  ModuleBase_Tools::flushUpdated(theFeature);
 
   std::list<AttributePtr> anAttributes = theFeature->data()->attributes(
                                           ModelAPI_AttributeRefList::typeId());
@@ -521,6 +522,15 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
         (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      // selection shape has no result owner => the trihedron axis
+      // TODO: make reference to the real axes when they are implemented in the initialization plugin
+      if (!aRes.get()) {
+        ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()->objectByName(
+          ModelAPI_ResultConstruction::group(), "Origin");
+        if (aPointObj.get()) { // if initialization plugin performed well
+          aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+        }     
+      }
       if (!aRes.get()) {
         aRes = aMyFeature->firstResult();
       }
@@ -551,6 +561,15 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
         (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      // if there is no object, it means that this is the origin point: search it in the module document
+      if (!aRes.get()) {
+        ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()->objectByName(
+          ModelAPI_ResultConstruction::group(), "Origin");
+        if (aPointObj.get()) { // if initialization plugin performed well
+          aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+        }     
+      }
+      // reference to itself with name "Origin" (but this may cause the infinitive cycling)
       if (!aRes.get()) {
         // If the point is selected not from Result object
         std::shared_ptr<GeomAPI_Shape> aShape =