#include <ModuleBase_Tools.h>
#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_Filter.h>
+#include <ModuleBase_IModule.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
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<ModelAPI_Result>(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<ModelAPI_Result>(theSelectedObject);
+ if (aSelectAttr.get() != NULL) {
+ aSelectAttr->setValue(aResult, theShape);
}
}
}
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<GeomAPI_Shape>(new GeomAPI_Shape()));
-}
-
//********************************************************************
bool ModuleBase_WidgetShapeSelector::restoreValueCustom()
{
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;
}
AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
if (aRefAttr && aRefAttr->attr().get() != NULL) {
//myIsObject = aRefAttr->isObject();
- std::string anAttrName = generateName(aRefAttr->attr());
+ std::string anAttrName = generateName(aRefAttr->attr(), myWorkshop);
myTextLine->setText(QString::fromStdString(anAttrName));
}
else {