]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1186 misprint “Origin/PointCoordindates”. The correction: using 'title' or 'label...
authornds <nds@opencascade.com>
Wed, 3 Feb 2016 06:16:27 +0000 (09:16 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:04:33 +0000 (17:04 +0300)
It is checked on: distance(attribute filled by a point), fillet

src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp

index 76c8991611bef98ce8e4bf8536633a60d32cb140..4d89489a42166c11a8b513d186ba93a888db56c1 100644 (file)
@@ -105,12 +105,8 @@ ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& the
     }
   }
 
-  std::string aPluginFileName = myFeaturesInFiles[theFeatureId];
-  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
-  aWdgReader.readAll();
-  std::string aXmlCfg = aWdgReader.featureWidgetCfg(theFeatureId);
-  std::string aDescription = aWdgReader.featureDescription(theFeatureId);
-
+  std::string aXmlCfg, aDescription;
+  getXMLRepresentation(theFeatureId, aXmlCfg, aDescription);
   aFOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
   aFOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
 
@@ -200,3 +196,14 @@ void ModuleBase_IModule::operationResumed(ModuleBase_Operation* theOperation)
 {
   emit resumed(theOperation);
 }
+
+void ModuleBase_IModule::getXMLRepresentation(const std::string& theFeatureId,
+                                              std::string& theXmlCfg, std::string& theDescription)
+{
+  std::string aPluginFileName = myFeaturesInFiles[theFeatureId];
+  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
+  aWdgReader.readAll();
+
+  theXmlCfg = aWdgReader.featureWidgetCfg(theFeatureId);
+  theDescription = aWdgReader.featureDescription(theFeatureId);
+}
index 5995810242be23a5e2b12a20631e0f5cb39a4444..6c034a798bc7674e4bb1597734d78cb24358b31c 100755 (executable)
@@ -256,6 +256,13 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   virtual AttributePtr findAttribute(const ObjectPtr& theObject,\r
                                      const GeomShapePtr& theGeomShape) = 0;\r
 \r
+  /// Returns XML information by the feature index\r
+  /// \param theFeatureId a feature id\r
+  /// \param theXmlCfg XML configuration\r
+  /// \param theDescription feature description\r
+  void getXMLRepresentation(const std::string& theFeatureId, std::string& theXmlCfg,\r
+                            std::string& theDescription);\r
+\r
 signals:\r
   /// Signal which is emitted when operation is launched\r
   void operationLaunched();\r
@@ -296,7 +303,6 @@ protected slots:
   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
 \r
 protected:\r
-\r
   /// Reference to workshop\r
   ModuleBase_IWorkshop* myWorkshop;\r
 \r
index f32f0aca8dc7ce29cba19c7777daedfb0be209b5..0bca512683ca6942182cf33af26e20ed38080ea2 100644 (file)
@@ -121,6 +121,45 @@ void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage)
   thePage->alignToTop();
 }
 
+void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theFeatureKind,
+                                                 const std::string& theAttributeId,
+                                                 std::string& theTitle)
+{
+  if (!theTitle.empty())
+    return;
+
+  myParentId = myWidgetApi->widgetId();
+  if (!myWidgetApi->toChildWidget())
+    return;
+
+  do {  //Iterate over each node
+    std::string aWdgType = myWidgetApi->widgetType();
+    // Find title under PageGroup
+    if (myWidgetApi->isGroupBoxWidget() ||
+        ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
+
+      getAttributeTitle(theFeatureKind, theAttributeId, theTitle);
+    } else {
+      // Find title here
+      std::string anAttributeId = myWidgetApi->widgetId();
+      if (anAttributeId == theAttributeId) {
+        theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();
+        if (theTitle.empty())
+          theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();
+
+      }
+      if (myWidgetApi->isPagedWidget()) {
+        //If current widget is toolbox or switch-casebox then fetch all
+        //it's pages recursively and setup into the widget.
+        myWidgetApi->toChildWidget();
+        do {
+          getAttributeTitle(theFeatureKind, theAttributeId, theTitle);
+        } while (myWidgetApi->toNextWidget() && theTitle.empty());
+      }
+    }
+  } while (myWidgetApi->toNextWidget() && theTitle.empty());
+}
+
 ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType,
                                                                 QWidget* theParent)
 {
index 05f3b7b8a2bba7c6fc1c8750ac3e109523047785..f51f541fac81f8c9091281bc1d9c7a776fbdad27 100644 (file)
@@ -48,7 +48,15 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
     return myModelWidgets;
   }
 
- protected:
+  /// Returns the value of the title key from XML definition of the attribute in the feature
+  /// \param theFeatureKind a value of a kind of a feature
+  /// \param theAttributeId a value of a kind of the attribute under the feature
+  /// \param theTitle the result title
+  void getAttributeTitle(const std::string& theFeatureKind,
+                         const std::string& theAttributeId,
+                         std::string& theTitle);
+
+protected:
   /// check if ModuleBase_Widget has expandable widgets in getControls
   bool hasExpandingControls(QWidget* theParent);
 
index af47d9d7c734ed4acd0497114c107ed2e0cb3422..8f083325092901a9055f7f5552f0b0d14d9605c8 100755 (executable)
@@ -539,7 +539,7 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList()
       AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
       QString aName;
       if (anAttribute.get()) {
-        std::string anAttrName = generateName(anAttribute);
+        std::string anAttrName = generateName(anAttribute, myWorkshop);
         aName = QString::fromStdString(anAttrName);
       }
       else {
index 0f0b2c15a8eda3efe5a491fa3fa50df0ec93a98b..131911c1ac63610d701806d4c99e745e0623aa09 100755 (executable)
@@ -9,6 +9,10 @@
 #include <ModuleBase_ISelection.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_IModule.h>
 
 #include <ModelAPI_ResultConstruction.h>
 
@@ -171,13 +175,26 @@ void ModuleBase_WidgetSelector::deactivate()
 }
 
 //********************************************************************
-std::string ModuleBase_WidgetSelector::generateName(const AttributePtr& theAttribute)
+std::string ModuleBase_WidgetSelector::generateName(const AttributePtr& theAttribute,
+                                                    ModuleBase_IWorkshop* theWorkshop)
 {
   std::string aName;
   if (theAttribute.get() != NULL) {
-    std::stringstream aStreamName;
-    aStreamName << theAttribute->owner()->data()->name() << "/"<< theAttribute->id();
-    aName = aStreamName.str();
+    ModuleBase_Operation* anOperation = theWorkshop->currentOperation();
+
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+    if (aFeature.get()) {
+      std::string aXmlCfg, aDescription;
+      theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription);
+
+      ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
+      std::string anAttributeTitle;
+      aFactory.getAttributeTitle(aFeature->getKind(), theAttribute->id(), anAttributeTitle);
+
+      std::stringstream aStreamName;
+      aStreamName << theAttribute->owner()->data()->name() << "/"<< anAttributeTitle.c_str();
+      aName = aStreamName.str();
+    }
   }
   return aName;
 }
index 150a0ce349d07410f8403d447a8fb27c9372e547..a73a677c2632b5771f49e66ce1ce7b4fa30ba225 100755 (executable)
@@ -111,7 +111,8 @@ Q_OBJECT
   /// Returns a name in the next form: attribute_feature_name/attribute_id
   /// \param theAttribute a model attribute
   /// \return string value
-  static std::string generateName(const AttributePtr& theAttribite);
+  static std::string generateName(const AttributePtr& theAttribite,
+                                  ModuleBase_IWorkshop* theWorkshop);
 };
 
 #endif
index 27b99ab853e266076c6125929484eff434e75157..27487c72a0c00eddbf73f7565bc328ea2d698e72 100644 (file)
@@ -243,7 +243,7 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName()
       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 {