X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetShapeSelector.cpp;h=b68e282b69630d35b31d42bb8790a3f5064adf2e;hb=eef14b29d313b9dd16453d12f20aa02383ee139c;hp=47fc4b44c12474b84c49673fab4988121f6ac93b;hpb=2eaafb182129c24c711adcc75ecacd74ce917141;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 47fc4b44c..b68e282b6 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,8 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen QString aToolTip = QString::fromStdString(theData->widgetTooltip()); myTextLine = new QLineEdit(this); + QString anObjName = QString::fromStdString(attributeID()); + myTextLine->setObjectName(anObjName); myTextLine->setReadOnly(true); myTextLine->setToolTip(aToolTip); myTextLine->installEventFilter(this); @@ -109,25 +112,30 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) { DataPtr aData = myFeature->data(); - AttributeReferencePtr aRef = aData->reference(attributeID()); - if (aRef) { + std::string aType = aData->attribute(attributeID())->attributeType(); + if (aType == ModelAPI_AttributeReference::typeId()) { + AttributeReferencePtr aRef = aData->reference(attributeID()); ObjectPtr aObject = aRef->value(); if (!(aObject && aObject->isSame(theSelectedObject))) { aRef->setValue(theSelectedObject); } - } else { + } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); - if (aRefAttr) { + + AttributePtr anAttribute = myWorkshop->module()->findAttribute(theSelectedObject, theShape); + if (anAttribute.get()) + aRefAttr->setAttr(anAttribute); + else { ObjectPtr aObject = aRefAttr->object(); if (!(aObject && aObject->isSame(theSelectedObject))) { aRefAttr->setObject(theSelectedObject); } - } else { - AttributeSelectionPtr aSelectAttr = aData->selection(attributeID()); - ResultPtr aResult = std::dynamic_pointer_cast(theSelectedObject); - if (aSelectAttr.get() != NULL) { - aSelectAttr->setValue(aResult, theShape); - } + } + } else if (aType == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr aSelectAttr = aData->selection(attributeID()); + ResultPtr aResult = std::dynamic_pointer_cast(theSelectedObject); + if (aSelectAttr.get() != NULL) { + aSelectAttr->setValue(aResult, theShape); } } } @@ -152,13 +160,6 @@ QList ModuleBase_WidgetShapeSelector::getAttributeSelectio return aSelected; } -//******************************************************************** -void ModuleBase_WidgetShapeSelector::clearAttribute() -{ - // In order to make reselection possible, set empty object and shape should be done - setObject(ObjectPtr(), std::shared_ptr(new GeomAPI_Shape())); -} - //******************************************************************** bool ModuleBase_WidgetShapeSelector::restoreValueCustom() { @@ -200,9 +201,18 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const if (!aData->isValid()) return aShape; - AttributeSelectionPtr aSelect = aData->selection(attributeID()); - if (aSelect) - aShape = aSelect->value(); + std::string aType = aData->attribute(attributeID())->attributeType(); + if (aType == ModelAPI_AttributeReference::typeId()) { + } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { + AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); + if (aRefAttr.get() && !aRefAttr->isObject()) { + AttributePtr anAttribute = aRefAttr->attr(); + aShape = myWorkshop->module()->findShape(anAttribute); + } + } else if (aType == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr aSelectAttr = aData->selection(attributeID()); + aShape = aSelectAttr->value(); + } return aShape; } @@ -229,12 +239,8 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); if (aRefAttr && aRefAttr->attr().get() != NULL) { //myIsObject = aRefAttr->isObject(); - AttributePtr anAttr = aRefAttr->attr(); - if (anAttr.get() != NULL) { - std::stringstream aName; - aName <owner()->data()->name()<<"/"<id(); - myTextLine->setText(QString::fromStdString(aName.str())); - } + std::string anAttrName = generateName(aRefAttr->attr(), myWorkshop); + myTextLine->setText(QString::fromStdString(anAttrName)); } else { myTextLine->setText(getDefaultValue().c_str());