Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index 1d87b4ae22475427772f15b6eefe99eb075f9f67..5fa98fc5db0d58d8552e91a059219f65cfe97a00 100644 (file)
@@ -5,11 +5,13 @@
 // Author:      Vitaly Smetannikov
 
 #include "ModuleBase_Tools.h"
+#include <ModuleBase_ParamSpinBox.h>
 
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_ResultParameter.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <Events_Error.h>
@@ -107,6 +109,13 @@ QPixmap lighter(const QString& theIcon, const int theLighterValue)
   return QPixmap::fromImage(aResult);
 }
 
+void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText)
+{
+  bool isBlocked = theSpin->blockSignals(true);
+  theSpin->setText(theText);
+  theSpin->blockSignals(isBlocked);
+}
+
 void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
 {
   bool isBlocked = theSpin->blockSignals(true);
@@ -179,6 +188,24 @@ TopAbs_ShapeEnum shapeType(const QString& theType)
   return TopAbs_SHAPE;
 }
 
+void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter)
+{
+  hasResult = false;
+  hasFeature = false;
+  hasParameter = false;
+  foreach(ObjectPtr aObj, theObjects) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
+
+    hasResult = (aResult.get() != NULL);
+    hasFeature = (aFeature.get() != NULL);
+    hasParameter = (aConstruction.get() != NULL);
+    if (hasFeature && hasResult  && hasParameter)
+      break;
+  }
+}
+
 
 }