]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
1. Projection Sketch feature: regression correction that objects are not selected...
authornds <nds@opencascade.com>
Tue, 6 Sep 2016 10:24:14 +0000 (13:24 +0300)
committernds <nds@opencascade.com>
Tue, 6 Sep 2016 10:48:41 +0000 (13:48 +0300)
2. Reenter of Arc operation for arc by 3 point mode led to crash.

src/PartSet/PartSet_ExternalObjectsMgr.cpp
src/PartSet/PartSet_ExternalObjectsMgr.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/plugin-Sketch.xml

index c636f5b3bfd019bd861be5616dff6ed49de9d399..3128285f1b8b23202dabca00d18ac7d84a26bffc 100755 (executable)
 
 #include <QString>
 
-PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue)
-: myUseExternal(theDefaultValue)
+PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExternal,
+                                                       const std::string& theCanCreateExternal,
+                                                       const bool theDefaultValue)
+: myUseExternal(theDefaultValue), myCanCreateExternal(true)
 {
   QString aIsExternal(theExternal.c_str());
   if (!aIsExternal.isEmpty()) {
     QString aStr = aIsExternal.toUpper();
     myUseExternal = (aStr == "TRUE") || (aStr == "YES"); 
   }
+
+  QString aCanCreateExternal(theCanCreateExternal.c_str());
+  if (!aCanCreateExternal.isEmpty()) {
+    QString aStr = aCanCreateExternal.toUpper();
+    myCanCreateExternal = (aStr == "TRUE") || (aStr == "YES"); 
+  }
 }
 
 bool PartSet_ExternalObjectsMgr::isValidObject(const ObjectPtr& theObject)
index 05d7f5b61c6157da11c4c89623520b5b3cabc3f5..4cc3696da8008aa11a2dc74ba36ef840544d4ccb 100755 (executable)
@@ -31,14 +31,21 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr
  public:
   /// Constructor
   /// \param theExternal the external state
+  /// \param theCanCreateExternal the state if it can and should create external features
   /// \param theDefaultValue the default value for the external object using
-  PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue);
+  PartSet_ExternalObjectsMgr(const std::string& theExternal,
+                             const std::string& theCanCreateExternal,
+                             const bool theDefaultValue);
 
   virtual ~PartSet_ExternalObjectsMgr() {}
 
   /// Returns the state whether the external object is used
   bool useExternal() const { return myUseExternal; }
 
+  /// Returns if new external objects can be created
+  /// \return boolean value
+  bool canCreateExternal() { return myCanCreateExternal;}
+
   /// Checks validity of the given object
   /// \param theObject an object to check
   /// \return valid or not valid
@@ -84,6 +91,8 @@ protected:
 
   /// Boolean value about the neccessity of the external object use
   bool myUseExternal;
+  /// Boolean value about the necessity of a new external object creation
+  bool myCanCreateExternal;
 };
 
 #endif
\ No newline at end of file
index 4674f43b1a4b5fca8c21570ffc36c730a64b7c8e..8fdf8380ffef3552453f1d7adc95595f49552179 100755 (executable)
@@ -86,7 +86,6 @@ void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState()
       if (!anError.isEmpty()) {
         aFOperation->setEditOperation(false);
         //workshop()->operationMgr()->updateApplyOfOperations();
-        beforeStopInternalEdit();
         myIsInternalEditOperation = false;
         updateAcceptAllAction();
       }
index f5e368bc983b66b40c62d6a2e4d913264c21dfb7..1cdac35fa5988ddb145a48cf715c7f876836a3e8 100755 (executable)
@@ -35,7 +35,8 @@ PartSet_WidgetMultiSelector::PartSet_WidgetMultiSelector(QWidget* theParent,
                                                          const Config_WidgetAPI* theData)
 : ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData)
 {
-  myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), false);
+  myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"),
+                                        theData->getProperty("can_create_external"), false);
 }
 
 PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector()
@@ -76,18 +77,26 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr
   // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
   if (aSPFeature.get() == NULL) {
     ObjectPtr anExternalObject = ObjectPtr();
+    GeomShapePtr anExternalShape = GeomShapePtr();
     if (myExternalObjectMgr->useExternal()) {
-      GeomShapePtr aShape = theShape;
-      if (!aShape.get()) {
-        ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-        if (aResult.get())
-          aShape = aResult->shape();
+      if (myExternalObjectMgr->canCreateExternal()) {
+        GeomShapePtr aShape = theShape;
+        if (!aShape.get()) {
+          ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+          if (aResult.get())
+            aShape = aResult->shape();
+        }
+        if (aShape.get() != NULL && !aShape->isNull())
+          anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
+      }
+      else {
+        anExternalObject = theObject;
+        anExternalShape = theShape;
       }
-      if (aShape.get() != NULL && !aShape->isNull())
-        anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
     }
     /// the object is null if the selected feature is "external"(not sketch entity feature of the
     /// current sketch) and it is not created by object manager
     theObject = anExternalObject;
+    theShape = anExternalShape;
   }
 }
index e815b7dc945d8c0c1a2fa69a9b0a156aaa430fb5..22dc4225d5da348333c6dc7a9340a14ad2412240 100755 (executable)
@@ -34,7 +34,8 @@ PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent,
 : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData)
 {
   myUseSketchPlane = theData->getBooleanAttribute("use_sketch_plane", true);
-  myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), true);
+  myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"),
+                                         theData->getProperty("can_create_external"), true);
 }
 
 PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector()
@@ -80,19 +81,27 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr
   // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
   if (aSPFeature.get() == NULL) {
     ObjectPtr anExternalObject = ObjectPtr();
+    GeomShapePtr anExternalShape = GeomShapePtr();
     if (myExternalObjectMgr->useExternal()) {
-      GeomShapePtr aShape = theShape;
-      if (!aShape.get()) {
-        ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-        if (aResult.get())
-          aShape = aResult->shape();
+      if (myExternalObjectMgr->canCreateExternal()) {
+        GeomShapePtr aShape = theShape;
+        if (!aShape.get()) {
+          ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+          if (aResult.get())
+            aShape = aResult->shape();
+        }
+        if (aShape.get() != NULL && !aShape->isNull())
+          anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
+      }
+      else { /// use objects of found selection
+        anExternalObject = theObject;
+        anExternalShape = theShape;
       }
-      if (aShape.get() != NULL && !aShape->isNull())
-        anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
     }
     /// the object is null if the selected feature is "external"(not sketch entity feature of the
     /// current sketch) and it is not created by object manager
     theObject = anExternalObject;
+    theShape = anExternalShape;
   }
 }
 
index 73321550bff7b40a0f034d5f058ca717320961f6..5cb16e6b0b6bd737b5dc2a4b2bd82917e2f02d82 100755 (executable)
@@ -931,8 +931,11 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
     std::shared_ptr<GeomAPI_Pnt> aLineLoc = aLine->location();
     double aDot = aNormal->dot(aLineDir);
     double aDist = aLineLoc->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz());
-    return (fabs(aDot) >= tolerance && fabs(aDot) < 1.0 - tolerance) ||
+    bool aValid = (fabs(aDot) >= tolerance && fabs(aDot) < 1.0 - tolerance) ||
            (fabs(aDot) < tolerance && fabs(aDist) > tolerance);
+    if (!aValid)
+      theError = "Error: Edge is already in the sketch plane.";
+    return aValid;
   }
   else if (anEdge->isCircle() || anEdge->isArc()) {
     std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
@@ -940,8 +943,13 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
     std::shared_ptr<GeomAPI_Pnt> aCircCenter = aCircle->center();
     double aDot = fabs(aNormal->dot(aCircNormal));
     double aDist = aCircCenter->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz());
-    return fabs(aDot - 1.0) < tolerance * tolerance && fabs(aDist) > tolerance;
+    bool aValid = fabs(aDot - 1.0) < tolerance * tolerance && fabs(aDist) > tolerance;
+    if (!aValid)
+      theError.arg(anEdge->isCircle() ? "Error: Cirlce is already in the sketch plane."
+                                      : "Error: Arc is already in the sketch plane.");
+    return aValid;
   }
 
+  theError = "Error: Selected object is not line, circle or arc.";
   return false;
 }
index d6d7d909c5ed4b781616e190a5706fed688dee26..bc8d02f5b6216cf49b5ff24a49f212bd4c88414f 100644 (file)
               label="Edge"
               tooltip="Select external edge."
               shape_types="edge"
-              use_external="false"
+              use_external="true"
+              can_create_external="false"
               use_sketch_plane="false">
           <validator id="SketchPlugin_ProjectionValidator"/>
         </sketch_shape_selector>