OpenLexocad  27.0
Globals.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <memory>
6 #include <sstream>
7 #include <string>
8 
9 #ifndef M_PI
10 #define M_PI 3.1415926535897932384626433832795029
11 #endif
12 
13 #ifndef END_OF_LOOP
14 #define END_OF_LOOP -2
15 #endif
16 
17 #ifndef END_OF_FACE
18 #define END_OF_FACE -1
19 #endif
20 
21 namespace OpenLxApp
22 {
23 enum class OPENLXAPP_EXPORT SDK_Language
24 {
26  CSHARP,
27  // CPLUSPLUS -> conflict with cadwork3d
28 };
29 
30 enum class OPENLXAPP_EXPORT View_Direction
31 {
32  X,
33  Y,
34  Z,
35  NX,
36  NY,
37  NZ,
38  AXO_LEFT,
40 };
41 
42 enum class OPENLXAPP_EXPORT Event
43 {
48  FileOpened,
49  NewFile,
50  BeforeSave,
57  // PickedPoint
58 };
59 
61 {
62  int major = 0;
63  int minor = 0;
64  int micro = 0;
65  int revision = 0;
66  std::string name;
67 
77  std::string toString() const
78  {
79  std::stringstream ss;
80  ss << name << " Version: " << major << "." << minor << " Build " << revision;
81  return ss.str();
82  }
83 };
84 
85 enum class ErrorCode
86 {
87  NoError = 0,
88  UnknownError = 1,
89  InvalidArguments = 2,
92 
93 };
94 } // namespace OpenLxApp
95 
96 #define FORWARD_DECL(x, y) \
97  namespace x \
98  { \
99  class y; \
100  }
101 
102 #define PLUGIN_HEADER(_class_) \
103 public: \
104  std::string getName() override { return #_class_; }
105 
106 #define PLUGIN_SOURCE(_class_) \
107  PLUGINDECL App::Plugin* createPlugin(App::PluginManager& mgr) { return (App::Plugin*)new _class_(); }
108 
109 
110 
122 #define OBJECT_HEADER(_class_, _type_) \
123 public: \
124  static LxIfc4::LxIfc4EntityEnum getEntityType_Static() { return LxIfc4::_type_; } \
125 \
126  explicit _class_(std::shared_ptr<_class_> other) { _coreObj = other->_coreObj; } \
127  _class_& operator=(std::shared_ptr<_class_> other) \
128  { \
129  _coreObj = other->_coreObj; \
130  return *this; \
131  } \
132  friend bool operator==(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return x->_coreObj == y->_coreObj; } \
133  friend bool operator!=(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return !(x == y); } \
134  friend bool operator<(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return x->_coreObj < y->_coreObj; } \
135  friend bool operator>(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return y < x; } \
136  friend bool operator<=(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return !(x > y); } \
137  friend bool operator>=(std::shared_ptr<_class_> x, std::shared_ptr<_class_> y) { return !(x < y); } \
138  bool isEqual(std::shared_ptr<_class_> other) const /*For Python*/ { return (_coreObj == other->_coreObj); }
139 
140 #define PROXY_HEADER_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
141  OBJECT_HEADER(_openlexocadclass_, _type_) \
142 public: \
143  _openlexocadclass_(_corelexocadclass_* aObj); \
144 \
145 public: \
146  _corelexocadclass_* __getCasted__() const;
147 
148 
149 #define PROXY_HEADER(_openlexocadclass_, _corelexocadclass_, _type_) \
150  PROXY_HEADER_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
151 public: \
152  _openlexocadclass_(std::shared_ptr<OpenLxApp::Document> aDoc); \
153 \
154 public: \
155  static std::shared_ptr<_openlexocadclass_> createIn(std::shared_ptr<OpenLxApp::Document> aDoc); \
156 \
157 public: \
158  static std::shared_ptr<_openlexocadclass_> createFrom(_corelexocadclass_* aObj);
159 
160 
161 #ifdef _DEBUG
162 #define PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
163  _corelexocadclass_* _openlexocadclass_::__getCasted__() const \
164  { \
165  auto casted = dynamic_cast<_corelexocadclass_*>(_coreObj); \
166  assert(casted); \
167  return casted; \
168  }
169 #define PROXY_SOURCE(_openlexocadclass_, _corelexocadclass_, _type_) \
170  PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
171  _openlexocadclass_::_openlexocadclass_(std::shared_ptr<OpenLxApp::Document> aDoc) \
172  /* TODO: ADD CALL TO SUPER CLASS */ { _coreObj = aDoc->__getInternalDoc__()->createObject<_corelexocadclass_>(); } \
173  std::shared_ptr<_openlexocadclass_> _openlexocadclass_::createIn(std::shared_ptr<OpenLxApp::Document> aDoc) \
174  { \
175  auto obj = aDoc->__getInternalDoc__()->createObject<_corelexocadclass_>(); \
176  assert(obj); \
177  if(obj) return std::make_shared<_openlexocadclass_>(obj); \
178  else return nullptr;
179  } \
180  std::shared_ptr<_openlexocadclass_> _openlexocadclass_::createFrom(_corelexocadclass_* aObj) \
181  { \
182  if(aObj) return std::make_shared<_openlexocadclass_>(aObj); \
183  else return nullptr; \
184  }
185 #define PROXY_SOURCE_CUSTOM_CREATE(_openlexocadclass_, _corelexocadclass_, _type_) \
186  PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_)
187 #else
188 #define PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
189  _corelexocadclass_* _openlexocadclass_::__getCasted__() const \
190  { \
191  auto casted = dynamic_cast<_corelexocadclass_*>(_coreObj); \
192  return casted; \
193  }
194 #define PROXY_SOURCE(_openlexocadclass_, _corelexocadclass_, _type_) \
195  PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_) \
196  _openlexocadclass_::_openlexocadclass_(std::shared_ptr<OpenLxApp::Document> aDoc) \
197  /* TODO: ADD CALL TO SUPER CLASS */ { _coreObj = aDoc->__getInternalDoc__()->createObject<_corelexocadclass_>(); } \
198  std::shared_ptr<_openlexocadclass_> _openlexocadclass_::createIn(std::shared_ptr<OpenLxApp::Document> aDoc) \
199  { \
200  auto obj = aDoc->__getInternalDoc__()->createObject<_corelexocadclass_>(); \
201  if(obj) return std::make_shared<_openlexocadclass_>(obj); \
202  else return nullptr; \
203  } \
204  std::shared_ptr<_openlexocadclass_> _openlexocadclass_::createFrom(_corelexocadclass_* aObj) \
205  { \
206  if(aObj) return std::make_shared<_openlexocadclass_>(aObj); \
207  else return nullptr; \
208  }
209 #define PROXY_SOURCE_CUSTOM_CREATE(_openlexocadclass_, _corelexocadclass_, _type_) \
210  PROXY_SOURCE_ABSTRACT(_openlexocadclass_, _corelexocadclass_, _type_)
211 #endif
212 
213 
214 #define EXT_FORWARD_DECL(_class_) class _class_##_Proxy;
215 
216 #define EXT_DECLARE_PROXYOBJECT(_class_, _parentclass_) \
217  class _class_##_Proxy : public _parentclass_ \
218  { \
219  OBJECT_HEADER(_class_##_Proxy, IFC_ENTITY_UNDEFINED) \
220  public: \
221  _class_##_Proxy(_class_* aObject) : _parentclass_(aObject) { assert(aObject); } \
222  virtual ~_class_##_Proxy(void) {} \
223 \
224  protected: \
225  _class_##_Proxy() {} \
226  }; \
227  DECLARE_OBJECT_FACTORY(_class_##_Factory, _class_, IFC_ENTITY_UNDEFINED);
228 
229 
230 #define EXT_OBJECT_SOURCE(_class_, _parent_) \
231  TYPESYSTEM_SOURCE(_class_, _parent_) \
232  LX_NODE_SOURCE(_class_, _parent_)
233 
234 #define EXT_FORWARD_DECL(_class_) class _class_##_Proxy;
235 
245 #define DECL_PROPERTY(_class_, _name_, _type_) \
246 public: \
247  _type_ get##_name_() const; \
248 \
249 public: \
250  void set##_name_(const _type_& aValue);
251 
252 #define DEFINE_PROPERTY(_class_, _name_, _propname_, _type_) \
253  _type_ _class_::get##_name_() const { return __getCasted__()->_propname_.getValue(); } \
254  void _class_::set##_name_(const _type_& aValue) { __getCasted__()->_propname_.setValue(aValue); }
CloseDocument
Definition: Globals.h:44
X
Definition: Globals.h:32
NX
Definition: Globals.h:32
UpdateSelection
Definition: Globals.h:44
PYTHON
Definition: Globals.h:25
Core::PropertyText name
Definition: CoreDocument.h:143
AXO_LEFT
Definition: Globals.h:32
RemoveSelection
Definition: Globals.h:44
CSHARP
Definition: Globals.h:25
ErrorCode
Definition: Globals.h:85
#define OPENLXAPP_EXPORT
Definition: OpenLxApp_defines.h:12
Definition: ActiveScript.h:9
RemoveActivePoint
Definition: Globals.h:44
Definition: Globals.h:60
Y
Definition: Globals.h:32
RecomputeFinished
Definition: Globals.h:44
NZ
Definition: Globals.h:32
SetActivePoint
Definition: Globals.h:44
NewFile
Definition: Globals.h:44
Z
Definition: Globals.h:32
std::string toString() const
Definition: Globals.h:77
AXO_BACK_LEFT
Definition: Globals.h:32
FileOpened
Definition: Globals.h:44
NY
Definition: Globals.h:32
SetActiveDocument
Definition: Globals.h:44
BeforeSave
Definition: Globals.h:44
ClearSelection
Definition: Globals.h:44
AddSelection
Definition: Globals.h:44
std::string name
Definition: Globals.h:66
NewDocument
Definition: Globals.h:44