Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Axis.cpp
index 570a3a3b8edb2b58a4a19ff02b5c39e0f59dacd7..e3d7eb34c4f58e7f2edf07b540e17386bf62c61a 100644 (file)
@@ -6,13 +6,20 @@
 
 #include "ConstructionPlugin_Axis.h"
 
+#include <Config_PropManager.h>
+
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeString.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
 using namespace std;
 
 ConstructionPlugin_Axis::ConstructionPlugin_Axis()
@@ -21,13 +28,17 @@ ConstructionPlugin_Axis::ConstructionPlugin_Axis()
 
 void ConstructionPlugin_Axis::initAttributes()
 {
+  data()->addAttribute(ConstructionPlugin_Axis::METHOD(),
+                       ModelAPI_AttributeString::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(),
-                       ModelAPI_AttributeSelection::type());
+                       ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(),
-                       ModelAPI_AttributeSelection::type());
+                       ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(),
+                       ModelAPI_AttributeSelection::typeId());
 }
 
-void ConstructionPlugin_Axis::execute()
+void ConstructionPlugin_Axis::createAxisByTwoPoints()
 {
   AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST());
   AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND());
@@ -48,9 +59,26 @@ void ConstructionPlugin_Axis::execute()
   }
 }
 
-void ConstructionPlugin_Axis::customisePresentation(AISObjectPtr thePrs)
+void ConstructionPlugin_Axis::execute()
+{
+  AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
+  std::string aMethodType = aMethodTypeAttr->value();
+  if (aMethodType == "AxisByPointsCase") {
+    createAxisByTwoPoints();
+  } else if (aMethodType == "AxisByCylindricalFaceCase") {
+    #ifdef _DEBUG
+    std::cout << "ConstructionPlugin_Axis::execute: " << "AxisByCylindricalFaceCase is not supported yet." << std::endl;
+    #endif
+  }
+}
+
+bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+                                                    std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
 {
-  thePrs->setColor(0, 0, 0);
-  thePrs->setLineStyle(3);
-  thePrs->redisplay();
+  bool isCustomized = theDefaultPrs.get() != NULL &&
+                      theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
+
+  isCustomized = thePrs->setLineStyle(3);
+
+  return isCustomized;
 }