X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetShapeSelector.cpp;h=8b07d585103bc4bfa081025d1275d10307b767f8;hb=423f6b0a08a86d5e47115b87603cddeae4468b49;hp=b4b7083670b122fd6a5fda36f3c7eddce80b4cf8;hpb=22b9a67e18cbd5d8eabba1ab85f26f5bad963c30;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index b4b708367..8b07d5851 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -37,7 +39,6 @@ #include #include -#include #include @@ -76,7 +77,7 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); myLabel = new QLabel(aLabelText, this); if (!aLabelIcon.isEmpty()) - myLabel->setPixmap(QPixmap(aLabelIcon)); + myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon)); QString aToolTip = QString::fromStdString(theData->widgetTooltip()); @@ -100,23 +101,24 @@ ModuleBase_WidgetShapeSelector::~ModuleBase_WidgetShapeSelector() } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::storeValueCustom() const +bool ModuleBase_WidgetShapeSelector::storeValueCustom() { - // the value is stored on the selection changed signal processing + // the value is stored on the selection changed signal processing return true; } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::setSelection(QList& theValues, +bool ModuleBase_WidgetShapeSelector::setSelection(QList& theValues, const bool theToValidate) { if (theValues.empty()) { // In order to make reselection possible, set empty object and shape should be done - setSelectionCustom(ModuleBase_ViewerPrs()); + setSelectionCustom(std::shared_ptr(new ModuleBase_ViewerPrs( + ObjectPtr(), GeomShapePtr(), NULL))); return false; } // it removes the processed value from the parameters list - ModuleBase_ViewerPrs aValue = theValues.takeFirst(); + ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst(); bool isDone = false; if (!theToValidate || isValidInFilters(aValue)) { @@ -131,16 +133,16 @@ bool ModuleBase_WidgetShapeSelector::setSelection(QList& t } //******************************************************************** -QList ModuleBase_WidgetShapeSelector::getAttributeSelection() const +QList ModuleBase_WidgetShapeSelector::getAttributeSelection() const { - QList aSelected; + QList aSelected; if(myFeature) { DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute); std::shared_ptr aShapePtr = getShape(); - ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL); + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs(anObject, aShapePtr, NULL)); aSelected.append(aPrs); } return aSelected; @@ -170,7 +172,7 @@ void ModuleBase_WidgetShapeSelector::updateFocus() } //******************************************************************** -QIntList ModuleBase_WidgetShapeSelector::getShapeTypes() const +QIntList ModuleBase_WidgetShapeSelector::shapeTypes() const { QIntList aShapeTypes; foreach(QString aType, myShapeTypes) { @@ -184,22 +186,10 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const { GeomShapePtr aShape; DataPtr aData = myFeature->data(); - if (!aData->isValid()) - return aShape; - - 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(); + if (aData->isValid()) { + AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); + aShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop); } - return aShape; } @@ -234,38 +224,3 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() } } } - -//******************************************************************** -void ModuleBase_WidgetShapeSelector::storeAttributeValue() -{ - ModuleBase_WidgetValidated::storeAttributeValue(); - - DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); - - myObject = ModuleBase_Tools::getObject(anAttribute); - myShape = getShape(); - myRefAttribute = AttributePtr(); - myIsObject = false; - AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); - if (aRefAttr) { - myIsObject = aRefAttr->isObject(); - myRefAttribute = aRefAttr->attr(); - } -} - -//******************************************************************** -void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid) -{ - ModuleBase_WidgetValidated::restoreAttributeValue(theValid); - - DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); - - setObject(myObject, myShape); - AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); - if (aRefAttr) { - if (!myIsObject) - aRefAttr->setAttr(myRefAttribute); - } -}