diff -r 397870c6ed38 -r 9e9c52ca955e src/LDObject.h --- a/src/LDObject.h Sun Mar 09 14:04:06 2014 +0200 +++ b/src/LDObject.h Sun Mar 09 14:59:46 2014 +0200 @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -#ifndef LDFORGE_LDTYPES_H -#define LDFORGE_LDTYPES_H - +#pragma once #include "Main.h" #include "Types.h" #include "misc/DocumentPointer.h" @@ -32,14 +30,14 @@ } \ \ public: \ - virtual LDObject::Type getType() const override \ + virtual LDObject::Type type() const override \ { \ return LDObject::E##T; \ } \ - virtual QString raw() const override; \ + virtual QString asText() const override; \ virtual void invert() override; -#define LDOBJ_NAME(N) virtual QString getTypeName() const override { return #N; } +#define LDOBJ_NAME(N) virtual QString typeName() const override { return #N; } #define LDOBJ_VERTICES(V) virtual int vertices() const override { return V; } #define LDOBJ_SETCOLORED(V) virtual bool isColored() const override { return V; } #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) @@ -68,14 +66,14 @@ // ============================================================================= class LDObject { - PROPERTY (public, bool, Hidden, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, bool, Selected, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, LDObject*, Parent, NO_OPS, STOCK_WRITE) - PROPERTY (public, LDDocument*, File, NO_OPS, STOCK_WRITE) // TODO: rename~ - PROPERTY (private, int, ID, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, Color, NUM_OPS, CUSTOM_WRITE) - PROPERTY (public, bool, GLInit, BOOL_OPS, STOCK_WRITE) - PROPERTY (public, QString, Origin, NO_OPS, STOCK_WRITE) + PROPERTY (public, bool, isHidden, setHidden, STOCK_WRITE) + PROPERTY (public, bool, isSelected, setSelected, STOCK_WRITE) + PROPERTY (public, LDObject*, parent, setParent, STOCK_WRITE) + PROPERTY (public, LDDocument*, document, setDocument, STOCK_WRITE) + PROPERTY (private, int, id, setID, STOCK_WRITE) + PROPERTY (public, int, color, setColor, CUSTOM_WRITE) + PROPERTY (public, bool, isGLInit, setGLInit, STOCK_WRITE) + PROPERTY (public, QString, origin, setOrigin, STOCK_WRITE) public: // Object type codes. @@ -102,19 +100,19 @@ LDObject* createCopy() const; // Deletes this object - void deleteSelf(); + void destroy(); // Index (i.e. line number) of this object - long getIndex() const; + long lineNumber() const; // Type enumerator of this object - virtual Type getType() const = 0; + virtual Type type() const = 0; // Get a vertex by index - const Vertex& getVertex (int i) const; + const Vertex& vertex (int i) const; // Type name of this object - virtual QString getTypeName() const = 0; + virtual QString typeName() const = 0; // Does this object have a matrix and position? (see LDMatrixObject) virtual bool hasMatrix() const = 0; @@ -135,10 +133,10 @@ LDObject* next() const; // Object prior to this in the current file - LDObject* prev() const; + LDObject* previous() const; // This object as LDraw code - virtual QString raw() const = 0; + virtual QString asText() const = 0; // Replace this LDObject with another LDObject. Object is deleted in the process. void replace (LDObject* other); @@ -204,7 +202,7 @@ // LDSharedVertex // // For use as coordinates of LDObjects. Keeps count of references. -// ----------------------------------------------------------------------------- +// ============================================================================= class LDSharedVertex { public: @@ -232,8 +230,6 @@ }; // ============================================================================= -// LDMatrixObject -// ============================================================================= // // Common code for objects with matrices. This class is multiple-derived in // and thus not used directly other than as a common storage point for matrices @@ -245,28 +241,28 @@ // In 0.1-alpha, there was a separate 'radial' type which had a position and // matrix as well. Even though right now only LDSubfile uses this, I'm keeping // this class distinct in case I get new extension ideas. :) -// ============================================================================= +// class LDMatrixObject { - PROPERTY (public, LDObject*, LinkPointer, NO_OPS, STOCK_WRITE) - PROPERTY (public, Matrix, Transform, NO_OPS, CUSTOM_WRITE) + PROPERTY (public, LDObject*, linkPointer, setLinkPointer, STOCK_WRITE) + PROPERTY (public, Matrix, transform, setTransform, CUSTOM_WRITE) public: LDMatrixObject() : - m_Position (LDSharedVertex::getSharedVertex (g_origin)) {} + m_position (LDSharedVertex::getSharedVertex (g_origin)) {} LDMatrixObject (const Matrix& transform, const Vertex& pos) : - m_Transform (transform), - m_Position (LDSharedVertex::getSharedVertex (pos)) {} + m_transform (transform), + m_position (LDSharedVertex::getSharedVertex (pos)) {} - inline const Vertex& getPosition() const + inline const Vertex& position() const { - return m_Position->data(); + return m_position->data(); } void setCoordinate (const Axis ax, double value) { - Vertex v = getPosition(); + Vertex v = position(); v[ax] = value; setPosition (v); } @@ -274,17 +270,15 @@ void setPosition (const Vertex& a); private: - LDSharedVertex* m_Position; + LDSharedVertex* m_position; }; // ============================================================================= -// LDError // // Represents a line in the LDraw file that could not be properly parsed. It is // represented by a (!) ERROR in the code view. It exists for the purpose of -// allowing garbage lines be debugged and corrected within LDForge. The member -// zContent contains the contents of the unparsable line. -// ============================================================================= +// allowing garbage lines be debugged and corrected within LDForge. +// class LDError : public LDObject { LDOBJ (Error) @@ -293,24 +287,21 @@ LDOBJ_UNCOLORED LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX - PROPERTY (public, QString, FileReferenced, STR_OPS, STOCK_WRITE) + PROPERTY (public, QString, fileReferenced, setFileReferenced, STOCK_WRITE) + PROPERTY (private, QString, contents, setContents, STOCK_WRITE) + PROPERTY (private, QString, reason, setReason, STOCK_WRITE) public: LDError(); - LDError (QString contents, QString reason) : contents (contents), reason (reason) {} - - // Content of this unknown line - QString contents; - - // Why is this gibberish? - QString reason; + LDError (QString contents, QString reason) : + m_contents (contents), + m_reason (reason) {} }; // ============================================================================= -// LDEmpty // // Represents an empty line in the LDraw code file. -// ============================================================================= +// class LDEmpty : public LDObject { LDOBJ (Empty) @@ -322,13 +313,12 @@ }; // ============================================================================= -// LDComment // -// Represents a code-0 comment in the LDraw code file. Member text contains -// the text of the comment. -// ============================================================================= +// Represents a code-0 comment in the LDraw code file. +// class LDComment : public LDObject { + PROPERTY (public, QString, text, setText, STOCK_WRITE) LDOBJ (Comment) LDOBJ_NAME (comment) LDOBJ_VERTICES (0) @@ -338,21 +328,18 @@ public: LDComment() {} - LDComment (QString text) : text (text) {} - - QString text; // The text of this comment + LDComment (QString text) : m_text (text) {} }; // ============================================================================= -// LDBFC // // Represents a 0 BFC statement in the LDraw code. eStatement contains the type // of this statement. -// ============================================================================= +// class LDBFC : public LDObject { public: - enum Type + enum Statement { CertifyCCW, CCW, @@ -371,18 +358,17 @@ LDOBJ_NAME (bfc) LDOBJ_VERTICES (0) LDOBJ_UNCOLORED - LDOBJ_CUSTOM_SCEMANTIC { return (type == InvertNext); } + LDOBJ_CUSTOM_SCEMANTIC { return (statement() == InvertNext); } LDOBJ_NO_MATRIX + PROPERTY (public, Statement, statement, setStatement, STOCK_WRITE) public: LDBFC() {} - LDBFC (const LDBFC::Type type) : - type (type) {} + LDBFC (const LDBFC::Statement type) : + m_statement (type) {} // Statement strings - static const char* statements[]; - - Type type; + static const char* k_statementStrings[]; }; // ============================================================================= @@ -398,7 +384,7 @@ LDOBJ_COLORED LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX - PROPERTY (public, LDDocumentPointer, FileInfo, NO_OPS, CUSTOM_WRITE) + PROPERTY (public, LDDocumentPointer, fileInfo, setFileInfo, CUSTOM_WRITE) public: enum InlineFlag @@ -406,8 +392,7 @@ DeepInline = (1 << 0), CacheInline = (1 << 1), RendererInline = (1 << 2), - - DeepCacheInline = DeepInline | CacheInline, + DeepCacheInline = (DeepInline | CacheInline), }; Q_DECLARE_FLAGS (InlineFlags, InlineFlag) @@ -555,20 +540,18 @@ LDOBJ_UNCOLORED LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX - PROPERTY (public, int, Camera, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, X, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, Y, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, Width, NUM_OPS, STOCK_WRITE) - PROPERTY (public, int, Height, NUM_OPS, STOCK_WRITE) - PROPERTY (public, QString, FileName, STR_OPS, STOCK_WRITE) + PROPERTY (public, int, camera, setCamera, STOCK_WRITE) + PROPERTY (public, int, x, setX, STOCK_WRITE) + PROPERTY (public, int, y, setY, STOCK_WRITE) + PROPERTY (public, int, width, setWidth, STOCK_WRITE) + PROPERTY (public, int, height, setHeight, STOCK_WRITE) + PROPERTY (public, QString, fileName, setFileName, STOCK_WRITE) }; // Other common LDraw stuff -static const QString CALicense = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt", - NonCALicense = "!LICENSE Not redistributable : see NonCAreadme.txt"; -static const int lores = 16; -static const int hires = 48; +static const QString g_CALicense ("!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt"); +static const QString g_nonCALicense ("!LICENSE Not redistributable : see NonCAreadme.txt"); +static const int g_lores = 16; +static const int g_hires = 48; QString getLicenseText (int id); - -#endif // LDFORGE_LDTYPES_H