Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.cpp
index ea613603b9d3a3417b05e78da8bdeb6841ad5db6..231e54fb2cddaa70bbcfbeb0b7d9f0adfe269791 100644 (file)
@@ -1,12 +1,19 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ConstructionPlugin_Point.cxx
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
 
 #include "ConstructionPlugin_Point.h"
-#include "ModelAPI_PluginManager.h"
+#include "ModelAPI_Session.h"
 #include "ModelAPI_Document.h"
 #include "ModelAPI_Data.h"
 #include "ModelAPI_AttributeDouble.h"
+#include <ModelAPI_ResultConstruction.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
+
+#include <Config_PropManager.h>
 
 using namespace std;
 
@@ -14,18 +21,35 @@ ConstructionPlugin_Point::ConstructionPlugin_Point()
 {
 }
 
+const std::string& ConstructionPlugin_Point::getKind()
+{
+  static std::string MY_KIND = ConstructionPlugin_Point::ID();
+  return MY_KIND;
+}
+
 void ConstructionPlugin_Point::initAttributes()
 {
-  data()->addAttribute(POINT_ATTR_X, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(POINT_ATTR_Y, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::type());
+}
+
+void ConstructionPlugin_Point::execute()
+{
+  std::shared_ptr<GeomAPI_Pnt> aPnt(
+      new GeomAPI_Pnt(data()->real(ConstructionPlugin_Point::X())->value(),
+                      data()->real(ConstructionPlugin_Point::Y())->value(),
+                      data()->real(ConstructionPlugin_Point::Z())->value()));
+
+  std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
+  aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
+  setResult(aConstr);
 }
 
-// this is for debug only
-#include <iostream>
-void ConstructionPlugin_Point::execute() 
+void ConstructionPlugin_Point::customisePresentation(AISObjectPtr thePrs)
 {
-  // TODO: create a real shape for the point using OCC layer
-  cout<<"X="<<data()->real(POINT_ATTR_X)->value()<<" Y="<<data()->real(POINT_ATTR_Y)->value()
-      <<" Z="<<data()->real(POINT_ATTR_Z)->value()<<endl;
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "construction_point_color",
+                                                    ConstructionPlugin_Point::DEFAULT_COLOR());
+  thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  thePrs->redisplay();
 }