From: nds Date: Tue, 6 Sep 2016 10:24:14 +0000 (+0300) Subject: 1. Projection Sketch feature: regression correction that objects are not selected... X-Git-Tag: V_2.5.0~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1993f63b15d942f2360ee0dabc7d01adf71338b9;p=modules%2Fshaper.git 1. Projection Sketch feature: regression correction that objects are not selected for it. 2. Reenter of Arc operation for arc by 3 point mode led to crash. --- diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.cpp b/src/PartSet/PartSet_ExternalObjectsMgr.cpp index c636f5b3b..3128285f1 100755 --- a/src/PartSet/PartSet_ExternalObjectsMgr.cpp +++ b/src/PartSet/PartSet_ExternalObjectsMgr.cpp @@ -14,14 +14,22 @@ #include -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) diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h index 05d7f5b61..4cc3696da 100755 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -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 diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 4674f43b1..8fdf8380f 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -86,7 +86,6 @@ void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState() if (!anError.isEmpty()) { aFOperation->setEditOperation(false); //workshop()->operationMgr()->updateApplyOfOperations(); - beforeStopInternalEdit(); myIsInternalEditOperation = false; updateAcceptAllAction(); } diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index f5e368bc9..1cdac35fa 100755 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -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; } } diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index e815b7dc9..22dc4225d 100755 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -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; } } diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 73321550b..5cb16e6b0 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -931,8 +931,11 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr 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 aCircle = anEdge->circle(); @@ -940,8 +943,13 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr 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; } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index d6d7d909c..bc8d02f5b 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -172,7 +172,8 @@ label="Edge" tooltip="Select external edge." shape_types="edge" - use_external="false" + use_external="true" + can_create_external="false" use_sketch_plane="false">