From: vsv Date: Wed, 30 Jul 2014 07:31:38 +0000 (+0400) Subject: Provide distance between points of lines X-Git-Tag: V_0.4.4~129 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66d6a0e9ffd402b9252c0c367b6e9d8dd8d9c636;p=modules%2Fshaper.git Provide distance between points of lines --- diff --git a/src/ModuleBase/ModuleBase_ResultValidators.cpp b/src/ModuleBase/ModuleBase_ResultValidators.cpp index 548fc549c..67a9ca5a9 100644 --- a/src/ModuleBase/ModuleBase_ResultValidators.cpp +++ b/src/ModuleBase/ModuleBase_ResultValidators.cpp @@ -29,7 +29,7 @@ TopoDS_Shape shape(ResultPtr theResult) } -bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const +bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); if (!aResult) @@ -42,7 +42,7 @@ bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const } -bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const +bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); if (!aResult) @@ -62,7 +62,7 @@ bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const } -bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const +bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); if (!aResult) diff --git a/src/ModuleBase/ModuleBase_ResultValidators.h b/src/ModuleBase/ModuleBase_ResultValidators.h index 50cc2e7b1..1b55460e0 100644 --- a/src/ModuleBase/ModuleBase_ResultValidators.h +++ b/src/ModuleBase/ModuleBase_ResultValidators.h @@ -15,19 +15,19 @@ public: virtual bool isValid(const ObjectPtr theObject) const = 0; }; -class ModuleBase_ResulPointValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultPointValidator: public ModuleBase_ResultValidator { public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class ModuleBase_ResulLineValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultLineValidator: public ModuleBase_ResultValidator { public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class ModuleBase_ResulArcValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultArcValidator: public ModuleBase_ResultValidator { public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 4b456e859..10f8ba4f3 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -48,33 +49,39 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aValuePoint = aFeatureValue->point(); - ObjectPtr aValueFeature = aFeatureValue->object(); - if (aValueFeature) { - isDone = setObject(aValueFeature); + ObjectPtr aObject = aFeatureValue->object(); + if (aObject) { + isDone = setObject(aObject); } if (!isDone && aValuePoint) { - // find the given point in the feature attributes - std::list > anAttiributes = - aValueFeature->data()->attributes(GeomDataAPI_Point2D::type()); - std::list >::const_iterator anIt = anAttiributes.begin(), - aLast = anAttiributes.end(); - boost::shared_ptr aFPoint; - for (;anIt!=aLast && !aFPoint; anIt++) { - boost::shared_ptr aCurPoint = - boost::dynamic_pointer_cast(*anIt); - if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion()) - aFPoint = aCurPoint; + FeaturePtr aFeature = ModuleBase_Tools::feature(aObject); + if (aFeature) { + // find the given point in the feature attributes + std::list > anAttiributes = + aFeature->data()->attributes(GeomDataAPI_Point2D::type()); + std::list >::const_iterator anIt = anAttiributes.begin(), + aLast = anAttiributes.end(); + boost::shared_ptr aFPoint; + for (;anIt!=aLast && !aFPoint; anIt++) { + boost::shared_ptr aCurPoint = + boost::dynamic_pointer_cast(*anIt); + if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion()) + aFPoint = aCurPoint; + } + if (aFPoint) + isDone = setAttribute(aFPoint); } - if (aFPoint) - isDone = setAttribute(aFPoint); } } } return isDone; } -bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) const +bool ModuleBase_WidgetFeatureOrAttribute::storeValue(ObjectPtr theFeature) const { + FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); + if (!aFeature) + return false; boost::shared_ptr aData = theFeature->data(); boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(attributeID())); @@ -85,19 +92,19 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons else if (myAttribute) aRef->setAttr(myAttribute); - theFeature->execute(); + aFeature->execute(); updateObject(theFeature); return true; } -bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature) +bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(ObjectPtr theFeature) { boost::shared_ptr aData = theFeature->data(); boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(attributeID())); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); + FeaturePtr aFeature = ModuleBase_Tools::feature(aRef->object()); if (aFeature) { setObject(aFeature); myAttribute = aRef->attr(); @@ -116,7 +123,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature) bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr& theAttribute) { - if (!theAttribute || !featureKinds().contains(theAttribute->attributeType().c_str())) + if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str())) return false; myAttribute = theAttribute; diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h index dc9bad6d8..54e2e08eb 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h @@ -36,9 +36,9 @@ public: /// Saves the internal parameters to the given feature /// \param theFeature a model feature to be changed - virtual bool storeValue(FeaturePtr theFeature) const; + virtual bool storeValue(ObjectPtr theFeature) const; - virtual bool restoreValue(FeaturePtr theFeature); + virtual bool restoreValue(ObjectPtr theFeature); protected: /// Set the attribute diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index e6d71aa23..ec1425964 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -29,10 +29,10 @@