From: vsv Date: Tue, 5 Aug 2014 11:39:53 +0000 (+0400) Subject: Distance constraint optimization X-Git-Tag: V_0.4.4~117 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e4e9446cd26b23a5b5d58a1a6de2f7bd4fa0c865;p=modules%2Fshaper.git Distance constraint optimization --- diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index e699a72de..47e9960be 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) return isDone; } -bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject) +bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); @@ -95,9 +96,10 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject) if (!isValid) return false; - myObject = theObject; + myObject = ModuleBase_Tools::feature(theObject); myEditor->setText(theObject ? theObject->data()->name().c_str() : ""); - emit valuesChanged(); + if (theSendEvent) + emit valuesChanged(); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h index fbfc7e2e9..81720edab 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetFeature.h @@ -56,7 +56,7 @@ protected: /// Fill the widget values by given point /// \param thePoint the point /// \return the boolean result of the feature set - bool setObject(const ObjectPtr& theObject); + bool setObject(const ObjectPtr& theObject, bool theSendEvent = true); /// Returns current widget feature /// \return the feature @@ -70,7 +70,6 @@ protected: /// \return the list of kinds const QStringList& featureKinds() const { return myObjectKinds; } -private: ObjectPtr myObject; ///< the current widget feature QStringList myObjectKinds; ///< the kinds of possible features diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index daa23d531..525d24356 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -51,7 +51,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa boost::shared_ptr aValuePoint = aFeatureValue->point(); ObjectPtr aObject = aFeatureValue->object(); if (aObject) { - isDone = setObject(aObject); + isDone = setObject(aObject, false); } if (aValuePoint) { FeaturePtr aFeature = ModuleBase_Tools::feature(aObject); @@ -69,9 +69,11 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa aFPoint = aCurPoint; } if (aFPoint) - isDone = setAttribute(aFPoint); + isDone = setAttribute(aFPoint, false); } } + if (isDone) + emit valuesChanged(); } } return isDone; @@ -82,13 +84,13 @@ 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())); - ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this; - if (object()) - aRef->setObject(object()); + if (myObject) + aRef->setObject(myObject); if (myAttribute) aRef->setAttr(myAttribute); @@ -106,7 +108,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(ObjectPtr theFeature) FeaturePtr aFeature = ModuleBase_Tools::feature(aRef->object()); if (aFeature) { - setObject(aFeature); + myObject = aFeature; myAttribute = aRef->attr(); std::string aText = ""; @@ -121,14 +123,17 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(ObjectPtr theFeature) return false; } -bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr& theAttribute) +bool ModuleBase_WidgetFeatureOrAttribute::setAttribute( + const boost::shared_ptr& theAttribute, + bool theSendEvent) { if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str())) return false; myAttribute = theAttribute; editor()->setText(theAttribute ? theAttribute->attributeType().c_str() : ""); - emit valuesChanged(); + if (theSendEvent) + emit valuesChanged(); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h index 54e2e08eb..9de6c149a 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h @@ -44,7 +44,8 @@ protected: /// Set the attribute /// \param theAttribute value /// \return the boolean result of the attribute set - bool setAttribute(const boost::shared_ptr& theAttribute); + bool setAttribute(const boost::shared_ptr& theAttribute, + bool theSendEvent = true); protected: boost::shared_ptr myAttribute; /// < the attribute