38 |
38 |
39 #define LDOBJ_NAME(N) public: virtual QString typeName() const override { return #N; } |
39 #define LDOBJ_NAME(N) public: virtual QString typeName() const override { return #N; } |
40 #define LDOBJ_VERTICES(V) public: virtual int numVertices() const override { return V; } |
40 #define LDOBJ_VERTICES(V) public: virtual int numVertices() const override { return V; } |
41 #define LDOBJ_SETCOLORED(V) public: virtual bool isColored() const override { return V; } |
41 #define LDOBJ_SETCOLORED(V) public: virtual bool isColored() const override { return V; } |
42 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) |
42 #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) |
43 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) LDOBJ_DEFAULTCOLOR (MainColor()) |
43 #define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) LDOBJ_DEFAULTCOLOR (MainColor) |
44 #define LDOBJ_DEFAULTCOLOR(V) public: virtual LDColor defaultColor() const override { return (V); } |
44 #define LDOBJ_DEFAULTCOLOR(V) public: virtual LDColor defaultColor() const override { return (V); } |
45 |
45 |
46 #define LDOBJ_CUSTOM_SCEMANTIC public: virtual bool isScemantic() const override |
46 #define LDOBJ_CUSTOM_SCEMANTIC public: virtual bool isScemantic() const override |
47 #define LDOBJ_SCEMANTIC LDOBJ_CUSTOM_SCEMANTIC { return true; } |
47 #define LDOBJ_SCEMANTIC LDOBJ_CUSTOM_SCEMANTIC { return true; } |
48 #define LDOBJ_NON_SCEMANTIC LDOBJ_CUSTOM_SCEMANTIC { return false; } |
48 #define LDOBJ_NON_SCEMANTIC LDOBJ_CUSTOM_SCEMANTIC { return false; } |
95 PROPERTY (public, LDObject*, parent, setParent, STOCK_WRITE) |
95 PROPERTY (public, LDObject*, parent, setParent, STOCK_WRITE) |
96 PROPERTY (public, LDDocument*, document, setDocument, CUSTOM_WRITE) |
96 PROPERTY (public, LDDocument*, document, setDocument, CUSTOM_WRITE) |
97 PROPERTY (private, int32, id, setID, STOCK_WRITE) |
97 PROPERTY (private, int32, id, setID, STOCK_WRITE) |
98 PROPERTY (public, LDColor, color, setColor, CUSTOM_WRITE) |
98 PROPERTY (public, LDColor, color, setColor, CUSTOM_WRITE) |
99 PROPERTY (private, QColor, randomColor, setRandomColor, STOCK_WRITE) |
99 PROPERTY (private, QColor, randomColor, setRandomColor, STOCK_WRITE) |
100 PROPERTY (private, LDObject*, self, setSelf, STOCK_WRITE) |
|
101 |
100 |
102 public: |
101 public: |
103 LDObject (LDDocument* document = nullptr); |
102 LDObject (LDDocument* document = nullptr); |
104 virtual ~LDObject(); |
103 virtual ~LDObject(); |
105 |
104 |
212 T* result = new T (args..., nullptr); |
211 T* result = new T (args..., nullptr); |
213 |
212 |
214 // Set default color. Relying on virtual functions, this cannot be done in the c-tor. |
213 // Set default color. Relying on virtual functions, this cannot be done in the c-tor. |
215 // TODO: store -1 as the default color |
214 // TODO: store -1 as the default color |
216 if (result->isColored()) |
215 if (result->isColored()) |
217 result->setColor (ptr->defaultColor()); |
216 result->setColor (result->defaultColor()); |
218 |
217 |
219 return result; |
218 return result; |
220 } |
|
221 |
|
222 // |
|
223 // Apparently QPointer doesn't implement operator<. This is a problem when |
|
224 // some of the code needs to sort and remove duplicates from LDObject lists. |
|
225 // Adding a specialized version here: |
|
226 // |
|
227 inline bool operator< (LDObject* a, LDObject* b) |
|
228 { |
|
229 return a.data() < b.data(); |
|
230 } |
219 } |
231 |
220 |
232 // |
221 // |
233 // |
222 // |
234 // Common code for objects with matrices. This class is multiple-derived in |
223 // Common code for objects with matrices. This class is multiple-derived in |
439 { |
428 { |
440 LDOBJ (CondLine) |
429 LDOBJ (CondLine) |
441 LDOBJ_NAME (condline) |
430 LDOBJ_NAME (condline) |
442 LDOBJ_VERTICES (4) |
431 LDOBJ_VERTICES (4) |
443 LDOBJ_COLORED |
432 LDOBJ_COLORED |
444 LDOBJ_DEFAULTCOLOR (EdgeColor()) |
433 LDOBJ_DEFAULTCOLOR (EdgeColor) |
445 LDOBJ_SCEMANTIC |
434 LDOBJ_SCEMANTIC |
446 LDOBJ_NO_MATRIX |
435 LDOBJ_NO_MATRIX |
447 |
436 |
448 public: |
437 public: |
449 LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); |
438 LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); |