From: nds Date: Wed, 3 Feb 2016 06:16:27 +0000 (+0300) Subject: #1186 misprint “Origin/PointCoordindates”. The correction: using 'title' or 'label... X-Git-Tag: V_2.2.0~166 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=186984f0f222b39b57d31ba267c7bea97686b491;p=modules%2Fshaper.git #1186 misprint “Origin/PointCoordindates”. The correction: using 'title' or 'label' value instead of attribute id. It is checked on: distance(attribute filled by a point), fillet --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 76c899161..4d89489a4 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -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); +} diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 599581024..6c034a798 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -256,6 +256,13 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape) = 0; + /// Returns XML information by the feature index + /// \param theFeatureId a feature id + /// \param theXmlCfg XML configuration + /// \param theDescription feature description + void getXMLRepresentation(const std::string& theFeatureId, std::string& theXmlCfg, + std::string& theDescription); + signals: /// Signal which is emitted when operation is launched void operationLaunched(); @@ -296,7 +303,6 @@ protected slots: virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId); protected: - /// Reference to workshop ModuleBase_IWorkshop* myWorkshop; diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index f32f0aca8..0bca51268 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -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) { diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 05f3b7b8a..f51f541fa 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -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); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index af47d9d7c..8f0833250 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -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 { diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 0f0b2c15a..131911c1a 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -9,6 +9,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 150a0ce34..a73a677c2 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -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 diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 27b99ab85..27487c72a 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -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 {