Salome HOME
<sketch> default value for Extrusion
authornds <natalia.donis@opencascade.com>
Thu, 21 May 2015 12:42:13 +0000 (15:42 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 21 May 2015 12:46:04 +0000 (15:46 +0300)
src/FeaturesPlugin/extrusion_widget.xml
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp

index d68dbe414245c643f29f4360236875664d0105dd..5783d542c91d650034452da3bccba393a648ea67 100644 (file)
@@ -13,7 +13,8 @@
                     icon=":icons/plane.png"
                     label="Plane face"
                     tooltip="Select a planar face"
-                    shape_types="face">
+                    shape_types="face"
+                    default="&lt;sketch&gt;">
       <validator id="GeomValidators_Face" parameters="plane"/>
     </shape_selector>
     <doublevalue
@@ -32,7 +33,8 @@
                     icon=":icons/plane_inverted.png"
                     label="Plane face"
                     tooltip="Select a planar face"
-                    shape_types="face">
+                    shape_types="face"
+                    default="&lt;sketch&gt;">
       <validator id="GeomValidators_Face" parameters="plane"/>
     </shape_selector>
     <doublevalue
index d6f9f869eb5fdf184b293bcd64e754a05bf03006..6ff60d02e363dde45d66a62466e116f72c006518 100644 (file)
@@ -649,10 +649,11 @@ bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfS
   if(aNumber > 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();
   }
index b900299de1b8f16fc8e3b22e3e64c68d89e222e8..19c1a151490126d014cc4931642f3d492bebbe08 100644 (file)
@@ -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
index 495da4180492d8eb36b9d62ba4d6e7978e6bd698..71c850e59830047483ded064f64885f76fd9bcd9 100644 (file)
@@ -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;
index cea370ba22459d542c78437cc3e13f7c637347af..785e98b4141f73de40e9fbe431f8e9ee1d31ca67 100644 (file)
@@ -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());
       }
     }
   }