Salome HOME
Issue 1299 Angle constraint: support of additional and complementary angles. Test...
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index 6cbbe1c80c3361ba65c7009a2b57c7ac62f63f77..02e774313557d097188d93aa4c4db0c24571cc50 100755 (executable)
@@ -8,6 +8,9 @@
 
 #include <ModuleBase_ParamIntSpinBox.h>
 #include <ModuleBase_ParamSpinBox.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
 
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
@@ -18,6 +21,7 @@
 #include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_Session.h>
 
 #include <TopoDS_Iterator.hxx>
 
@@ -382,6 +386,44 @@ TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape)
   return aShapeType;
 }
 
+void getParameters(QStringList& theParameters)
+{
+  theParameters.clear();
+
+  SessionPtr aSession = ModelAPI_Session::get();
+  std::list<DocumentPtr> aDocList;
+  DocumentPtr anActiveDocument = aSession->activeDocument();
+  DocumentPtr aRootDocument = aSession->moduleDocument();
+  aDocList.push_back(anActiveDocument);
+  if (anActiveDocument != aRootDocument) {
+    aDocList.push_back(aRootDocument);
+  }
+  std::string aGroupId = ModelAPI_ResultParameter::group();
+  for(std::list<DocumentPtr>::const_iterator it = aDocList.begin(); it != aDocList.end(); ++it) {
+    DocumentPtr aDocument = *it;
+    int aSize = aDocument->size(aGroupId);
+    for (int i = 0; i < aSize; i++) {
+      ObjectPtr anObject = aDocument->object(aGroupId, i);
+      std::string aParameterName = anObject->data()->name();
+      theParameters.append(aParameterName.c_str());
+    }
+  }
+}
+
+std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop, const FeaturePtr& theFeature)
+{
+  std::string anAttributeId;
+
+  std::string aXmlCfg, aDescription;
+  theWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
+
+  ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
+  std::string anAttributeTitle;
+  aFactory.getGreedAttribute(anAttributeId);
+
+  return anAttributeId;
+}
+
 } // namespace ModuleBase_Tools