From: nds Date: Thu, 21 May 2015 12:42:13 +0000 (+0300) Subject: default value for Extrusion X-Git-Tag: V_1.2.0~123^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=98c00aa05819f40e846688897eabf5237fbb723b;p=modules%2Fshaper.git default value for Extrusion --- diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index d68dbe414..5783d542c 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -13,7 +13,8 @@ icon=":icons/plane.png" label="Plane face" tooltip="Select a planar face" - shape_types="face"> + shape_types="face" + default="<sketch>"> + shape_types="face" + default="<sketch>"> 1) return false; return true; } -std::string Model_AttributeSelection::namingName() +std::string Model_AttributeSelection::namingName(const std::string& theDefaultName) { std::string aName(""); - if(!this->isInitialized()) return aName; + if(!this->isInitialized()) + return !theDefaultName.empty() ? theDefaultName : aName; Handle(TDataStd_Name) anAtt; if(selectionLabel().FindAttribute(TDataStd_Name::GetID(), anAtt)) { aName = TCollection_AsciiString(anAtt->Get()).ToCString(); @@ -663,7 +664,7 @@ std::string Model_AttributeSelection::namingName() ResultPtr aCont = context(); aName = "Undefined name"; if(!aCont.get() || aCont->shape()->isNull()) - return aName; + return !theDefaultName.empty() ? theDefaultName : aName; if (!aSubSh.get() || aSubSh->isNull()) { // no subshape, so just the whole feature name return aCont->data()->name(); } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index b900299de..19c1a1514 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -40,7 +40,8 @@ public: MODEL_EXPORT virtual bool update(); /// Returns a textual string of the selection - MODEL_EXPORT virtual std::string namingName(); + /// \param theDefaultValue a name, which is returned if the naming name can not be obtained + MODEL_EXPORT virtual std::string namingName(const std::string& theDefaultValue = ""); /// Returns an Id of the selection /// NOTE: This method has been added for temporary export of groups towards old GEOM diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 495da4180..71c850e59 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -42,7 +42,8 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute MODELAPI_EXPORT virtual std::string attributeType(); /// Returns a textual string of the selection - virtual std::string namingName() = 0; + /// \param theDefaultValue a value, which is used if the naming name can not be obtained + virtual std::string namingName(const std::string& theDefaultValue = "") = 0; /// Returns an id of the selection virtual int Id() = 0; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index cea370ba2..785e98b41 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -263,7 +263,7 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() bool isNameUpdated = false; AttributeSelectionPtr aSelect = aData->selection(attributeID()); if (aSelect) { - myTextLine->setText(QString::fromStdString(aSelect->namingName())); + myTextLine->setText(QString::fromStdString(aSelect->namingName(getDefaultValue()))); isNameUpdated = true; } if (!isNameUpdated) { @@ -283,7 +283,7 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() } } else { - myTextLine->setText(""); + myTextLine->setText(getDefaultValue().c_str()); } } }