Salome HOME
Display point object as '+' symbol
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ConstructionPlugin_Point.cxx
4 // Created:     27 Mar 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "ConstructionPlugin_Point.h"
8 #include "ModelAPI_Session.h"
9 #include "ModelAPI_Document.h"
10 #include "ModelAPI_Data.h"
11 #include "ModelAPI_AttributeDouble.h"
12 #include <ModelAPI_ResultConstruction.h>
13 #include <GeomAlgoAPI_PointBuilder.h>
14 #include <GeomAPI_Pnt.h>
15
16 #include <Config_PropManager.h>
17
18 using namespace std;
19
20 ConstructionPlugin_Point::ConstructionPlugin_Point()
21 {
22 }
23
24 const std::string& ConstructionPlugin_Point::getKind()
25 {
26   static std::string MY_KIND = ConstructionPlugin_Point::ID();
27   return MY_KIND;
28 }
29
30 void ConstructionPlugin_Point::initAttributes()
31 {
32   data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::typeId());
33   data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::typeId());
34   data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::typeId());
35 }
36
37 void ConstructionPlugin_Point::execute()
38 {
39   std::shared_ptr<GeomAPI_Pnt> aPnt(
40       new GeomAPI_Pnt(data()->real(ConstructionPlugin_Point::X())->value(),
41                       data()->real(ConstructionPlugin_Point::Y())->value(),
42                       data()->real(ConstructionPlugin_Point::Z())->value()));
43
44   std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
45   aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
46   setResult(aConstr);
47 }
48
49 bool ConstructionPlugin_Point::customisePresentation(ResultPtr theResult, 
50                                                      AISObjectPtr thePrs,
51                                std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
52 {
53   bool isCustomized = theDefaultPrs.get() != NULL &&
54                       theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
55   thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
56   return true;
57 }