OpenLexocad  28.0
ExecObject.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Core/DocObject.h>
4 namespace Core
5 {
6 class CoreDocument;
7 }
8 
9 class QMutex;
10 
11 namespace App
12 {
13 class ElementTool;
14 }
15 
16 
17 namespace Core
18 {
19 
21 {
23  EXECUTE_FAILED = 1
24 };
25 
26 class LX_CORE_EXPORT ExecuteError
27 {
28 public:
29  ExecuteError(Core::DocObject* obj, const std::string& m = "");
31  std::string msg;
32 };
33 
34 class LX_CORE_EXPORT ExecuteContext
35 {
36 public:
37  ExecuteContext(QMutex& aMutex) : mutex(aMutex) {}
38  std::vector<Core::ExecuteError> objects_with_errors;
39  // Holds an array of error message that are recorded when executing the object
40  std::map<Core::DocObject*, std::vector<std::string> > errorMsgPerObject;
41 
42  bool throwException_On_Error = true;
43  bool checkShape = true;
44  bool checkFacetedBrep = false;
45  bool checkSliverFaces = false;
46  bool printErrorMessage = true;
47  bool checkResultFromPolyToAcisConverter = false; // PolyToAcisConverter has sometimes problems, removing loops etc
48  int checkLevel = 20;
49  double _tolerance;
50 
51 #ifdef SWIG
52  private:
53 #endif
54  QMutex& mutex;
55  void addErrorMsg(Core::DocObject* o, const std::string& msg);
56 };
57 
58 class LX_CORE_EXPORT ExecObject : public Core::DocObject
59 {
62  // PROPERTYCONTAINER_HEADER( Core::ExecObject );
63 
64 public:
66  // //
67  // --------------------- BEGIN API --------------------- //
68  // //
69  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
70  // //
72 
73  friend class ::App::ElementTool;
74 
75 
79  bool isExecutable() const override { return true; }
81  void skipExecution(bool yesno);
83  bool skipExecution() const;
84 
86  static void getOrderedLinks(const Core::ExecObject* obj, std::vector<Core::ExecObject*>& ordered_links);
88  static void getLinks(const Core::ExecObject* obj, std::vector<Core::ExecObject*>& links);
89 
90 
91 
92 protected:
94  virtual ~ExecObject();
95 
97  // //
98  // ---------------------- END API ---------------------- //
99  // //
101 
102 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
103 
104 private:
105  bool _skipExecution;
106  bool mOnlyVisibleHasChanged = false;
107 
108 
109 #endif
110 };
111 
112 
113 } // namespace Core
Core::ExecObject::execute
virtual Core::ExecuteStatus execute(Core::ExecuteContext *context)=0
Is called when the document is recomputed.
Core::ExecuteError::obj
Core::DocObject * obj
Definition: ExecObject.h:30
Core::ExecuteContext::addErrorMsg
void addErrorMsg(Core::DocObject *o, const std::string &msg)
Core::ExecObject::ExecObject
ExecObject()
Core::ExecuteContext::ExecuteContext
ExecuteContext(QMutex &aMutex)
Definition: ExecObject.h:37
Core::ExecuteContext::errorMsgPerObject
std::map< Core::DocObject *, std::vector< std::string > > errorMsgPerObject
Definition: ExecObject.h:40
Core::ExecuteError::ExecuteError
ExecuteError(Core::DocObject *obj, const std::string &m="")
Core::ExecObject
Definition: ExecObject.h:59
Core::ExecuteContext
Definition: ExecObject.h:35
DocObject.h
Core::EXECUTE_FAILED
@ EXECUTE_FAILED
Definition: ExecObject.h:23
Core::EXECUTE_OK
@ EXECUTE_OK
Definition: ExecObject.h:22
Core::ExecuteContext::_tolerance
double _tolerance
Definition: ExecObject.h:49
Core::DocObject
Definition: DocObject.h:54
Core
Definition: Base.h:5
LX_NODE_HEADER
#define LX_NODE_HEADER()
Definition: PropertyMacros.h:7
Core::ExecuteContext::mutex
QMutex & mutex
Definition: ExecObject.h:54
Core::ExecObject::~ExecObject
virtual ~ExecObject()
Core::ExecuteError::msg
std::string msg
Definition: ExecObject.h:31
Core::ExecObject::getLinks
static void getLinks(const Core::ExecObject *obj, std::vector< Core::ExecObject * > &links)
Returns all ExecObjects that 'obj' directly links to.
Core::ExecuteContext::objects_with_errors
std::vector< Core::ExecuteError > objects_with_errors
Definition: ExecObject.h:38
Core::ExecuteStatus
ExecuteStatus
Definition: ExecObject.h:21
Core::ExecObject::isExecutable
bool isExecutable() const override
Checks if the ExecObject is executable.
Definition: ExecObject.h:79
Core::ExecObject::skipExecution
bool skipExecution() const
Checks if the execution of the object is skipped.
Core::ExecuteError
Definition: ExecObject.h:27
TYPESYSTEM_HEADER
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
Core::ExecObject::getOrderedLinks
static void getOrderedLinks(const Core::ExecObject *obj, std::vector< Core::ExecObject * > &ordered_links)
Returns all ExecObjects that 'obj' directly or indirectly links to. Returns them ordered from bottom ...
Core::ExecObject::skipExecution
void skipExecution(bool yesno)
Skips the execution of an ExecObject.