Salome HOME
09be73726729380ce997b7d211ac4383deba5a6c
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Services.cpp
1 // Name   : ModelHighAPI_Services.cpp
2 // Purpose: 
3 //
4 // History:
5 // 17/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Services.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Ax3.h>
11 #include <GeomAPI_Pnt.h>
12 #include <ModelAPI_Session.h>
13
14 //--------------------------------------------------------------------------------------
15 std::shared_ptr<ModelAPI_Document> moduleDocument()
16 {
17   return ModelAPI_Session::get()->moduleDocument();
18 }
19
20 //--------------------------------------------------------------------------------------
21 std::shared_ptr<ModelAPI_Document> activeDocument()
22 {
23   return ModelAPI_Session::get()->activeDocument();
24 }
25
26 //--------------------------------------------------------------------------------------
27 std::shared_ptr<GeomAPI_Ax3> defaultPlane( const std::string& theName )
28 {
29   std::shared_ptr<GeomAPI_Pnt> o(new GeomAPI_Pnt(0, 0, 0));
30   std::shared_ptr<GeomAPI_Dir> n, x;
31   if (theName == "XOY") {
32       n.reset(new GeomAPI_Dir(0, 0, 1));
33       x.reset(new GeomAPI_Dir(1, 0, 0));
34   } else if (theName == "XOZ") {
35       n.reset(new GeomAPI_Dir(0, -1, 0));
36       x.reset(new GeomAPI_Dir(1, 0, 0));
37   } else if (theName == "YOZ") {
38       n.reset(new GeomAPI_Dir(1, 0, 0));
39       x.reset(new GeomAPI_Dir(0, 1, 0));
40   }
41
42   return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(o, x, n));
43 }
44
45 //--------------------------------------------------------------------------------------
46 void begin()
47 {
48   ModelAPI_Session::get()->startOperation();
49 }
50 void end()
51 {
52   ModelAPI_Session::get()->finishOperation();
53 }
54 void apply()
55 {
56   auto aSession = ModelAPI_Session::get();
57   aSession->finishOperation();
58   aSession->startOperation();
59 }
60
61 //--------------------------------------------------------------------------------------
62 void undo()
63 {
64   ModelAPI_Session::get()->undo();
65 }
66 void redo()
67 {
68   ModelAPI_Session::get()->redo();
69 }
70
71 //--------------------------------------------------------------------------------------
72 void reset()
73 {
74   ModelAPI_Session::get()->closeAll();
75 }
76
77 //--------------------------------------------------------------------------------------