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