}
}
- 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));
{
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);
+}
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
virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
\r
protected:\r
-\r
/// Reference to workshop\r
ModuleBase_IWorkshop* myWorkshop;\r
\r
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)
{
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);
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 {
#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>
}
//********************************************************************
-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;
}
/// 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
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 {