X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetFeature.cpp;h=faf664fe53e9d48180ac7323988e5be4e256808f;hb=dcd54507eb794c21a02c95ad26c1779c36481274;hp=983329b53ddf61b42dae50d72e1ad5bc23e0e2a2;hpb=3ce4e2cad0e6802282a5a1d10c49c041e8a9f287;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 983329b53..faf664fe5 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -19,7 +20,8 @@ #include #include #include -#include +#include +#include #include #include @@ -27,13 +29,13 @@ #include ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, - const Config_WidgetAPI* theData, + const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myContainer = new QWidget(theParent); QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); - aControlLay->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::adjustMargins(aControlLay); QString aLabelText = QString::fromStdString(theData->widgetLabel()); myLabel = new QLabel(aLabelText, myContainer); @@ -47,7 +49,6 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, QString aTTip = QString::fromStdString(theData->widgetTooltip()); myEditor->setToolTip(aTTip); - aControlLay->addWidget(myEditor); aControlLay->setStretch(1, 1); } @@ -61,8 +62,8 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) isDone = setObject(aFeatureValue->object()); } @@ -71,7 +72,7 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); std::list aValidators; std::list > anArguments; @@ -80,9 +81,9 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSen // Check the type of selected object std::list::iterator aValidator = aValidators.begin(); bool isValid = true; - for(; aValidator != aValidators.end(); aValidator++) { - const ModelAPI_ResultValidator* aResValidator = - dynamic_cast(*aValidator); + for (; aValidator != aValidators.end(); aValidator++) { + const ModelAPI_ResultValidator* aResValidator = + dynamic_cast(*aValidator); if (aResValidator) { isValid = false; if (aResValidator->isValid(theObject)) { @@ -97,9 +98,9 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSen // Check the acceptability of the object as attribute aValidator = aValidators.begin(); std::list >::iterator aArgs = anArguments.begin(); - for(; aValidator != aValidators.end(); aValidator++, aArgs++) { - const ModelAPI_AttributeValidator* aAttrValidator = - dynamic_cast(*aValidator); + for (; aValidator != aValidators.end(); aValidator++, aArgs++) { + const ModelAPI_RefAttrValidator* aAttrValidator = + dynamic_cast(*aValidator); if (aAttrValidator) { if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) { return false; @@ -117,11 +118,12 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSen bool ModuleBase_WidgetFeature::storeValue() const { //FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); - //if (!aFeature) - // return false; + if (!myObject) + return false; + boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; aRef->setObject(myObject); @@ -133,13 +135,12 @@ bool ModuleBase_WidgetFeature::storeValue() const bool ModuleBase_WidgetFeature::restoreValue() { boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); - ObjectPtr aObj = aRef->object(); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); - if (aFeature) { - myObject = aFeature; + ObjectPtr anObjPtr = aRef->object(); + if (anObjPtr) { + myObject = anObjPtr; myEditor->setText(myObject ? myObject->data()->name().c_str() : ""); return true; }