--- a/src/ldObject.h Thu Jan 04 19:40:52 2018 +0200 +++ b/src/ldObject.h Thu Jan 04 19:44:26 2018 +0200 @@ -26,7 +26,7 @@ #define LDOBJ(T) \ public: \ static constexpr LDObjectType SubclassType = OBJ_##T; \ - LD##T (LDDocument* document = nullptr); \ + LD##T(LDDocument* document = nullptr); \ \ virtual LDObjectType type() const override \ { \ @@ -39,8 +39,8 @@ #define LDOBJ_NAME(N) public: virtual QString typeName() const override { return #N; } #define LDOBJ_VERTICES(V) public: virtual int numVertices() const override { return V; } #define LDOBJ_SETCOLORED(V) public: virtual bool isColored() const override { return V; } -#define LDOBJ_COLORED LDOBJ_SETCOLORED (true) -#define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) LDOBJ_DEFAULTCOLOR (MainColor) +#define LDOBJ_COLORED LDOBJ_SETCOLORED(true) +#define LDOBJ_UNCOLORED LDOBJ_SETCOLORED(false) LDOBJ_DEFAULTCOLOR(MainColor) #define LDOBJ_DEFAULTCOLOR(V) public: virtual LDColor defaultColor() const override { return (V); } #define LDOBJ_CUSTOM_SCEMANTIC public: virtual bool isScemantic() const override @@ -48,8 +48,8 @@ #define LDOBJ_NON_SCEMANTIC LDOBJ_CUSTOM_SCEMANTIC { return false; } #define LDOBJ_SETMATRIX(V) public: virtual bool hasMatrix() const override { return V; } -#define LDOBJ_HAS_MATRIX LDOBJ_SETMATRIX (true) -#define LDOBJ_NO_MATRIX LDOBJ_SETMATRIX (false) +#define LDOBJ_HAS_MATRIX LDOBJ_SETMATRIX(true) +#define LDOBJ_NO_MATRIX LDOBJ_SETMATRIX(false) class QListWidgetItem; class LDSubfileReference; @@ -78,7 +78,7 @@ OBJ_FirstType = OBJ_SubfileReference }; -MAKE_ITERABLE_ENUM (LDObjectType) +MAKE_ITERABLE_ENUM(LDObjectType) // // LDObject @@ -91,7 +91,7 @@ class LDObject { public: - LDObject (LDDocument* document = nullptr); + LDObject(LDDocument* document = nullptr); virtual QString asText() const = 0; // This object as LDraw code LDColor color() const; @@ -101,40 +101,40 @@ void destroy(); LDDocument* document() const; LDPolygon* getPolygon(); - virtual void getVertices (QVector<Vertex>& verts) const; - virtual bool hasMatrix() const = 0; // Does this object have a matrix and position? (see LDMatrixObject) + virtual void getVertices(QVector<Vertex>& verts) const; + virtual bool hasMatrix() const = 0; // Does this object have a matrix and position?(see LDMatrixObject) qint32 id() const; - virtual void invert() = 0; // Inverts this object (winding is reversed) + virtual void invert() = 0; // Inverts this object(winding is reversed) virtual bool isColored() const = 0; bool isDestroyed() const; bool isHidden() const; virtual bool isScemantic() const = 0; // Does this object have meaning in the part model? bool isSelected() const; int lineNumber() const; - void move (Vertex vect); + void move(Vertex vect); LDObject* next() const; virtual int numVertices() const = 0; LDObject* previous() const; - bool previousIsInvertnext (LDBfc*& ptr); + bool previousIsInvertnext(LDBfc*& ptr); QColor randomColor() const; - void replace (LDObject* other); - void replace (const LDObjectList& others); + void replace(LDObject* other); + void replace(const LDObjectList& others); void select(); - void setColor (LDColor color); - void setDocument (LDDocument* document); - void setHidden (bool value); - void setVertex (int i, const Vertex& vert); - void swap (LDObject* other); + void setColor(LDColor color); + void setDocument(LDDocument* document); + void setHidden(bool value); + void setVertex(int i, const Vertex& vert); + void swap(LDObject* other); LDObject* topLevelParent(); virtual LDObjectType type() const = 0; virtual QString typeName() const = 0; - const Vertex& vertex (int i) const; + const Vertex& vertex(int i) const; - static QString describeObjects (const LDObjectList& objs); - static LDObject* fromID (int id); - static LDObject* getDefault (const LDObjectType type); - static void moveObjects (LDObjectList objs, const bool up); // TODO: move this to LDDocument? - static QString typeName (LDObjectType type); + static QString describeObjects(const LDObjectList& objs); + static LDObject* fromID(int id); + static LDObject* getDefault(const LDObjectType type); + static void moveObjects(LDObjectList objs, const bool up); // TODO: move this to LDDocument? + static QString typeName(LDObjectType type); protected: virtual ~LDObject(); @@ -152,16 +152,16 @@ }; template<typename T, typename... Args> -T* LDSpawn (Args... args) +T* LDSpawn(Args... args) { - static_assert (std::is_base_of<LDObject, T>::value, + static_assert(std::is_base_of<LDObject, T>::value, "spawn may only be used with LDObject-derivatives"); - T* result = new T (args..., nullptr); + T* result = new T(args..., nullptr); // Set default color. Relying on virtual functions, this cannot be done in the c-tor. // TODO: store -1 as the default color if (result->isColored()) - result->setColor (result->defaultColor()); + result->setColor(result->defaultColor()); return result; } @@ -181,14 +181,14 @@ Vertex m_position; public: - LDMatrixObject (LDDocument* document = nullptr); - LDMatrixObject (const Matrix& transform, const Vertex& pos, LDDocument* document = nullptr); + LDMatrixObject(LDDocument* document = nullptr); + LDMatrixObject(const Matrix& transform, const Vertex& pos, LDDocument* document = nullptr); const Vertex& position() const; - void setCoordinate (const Axis ax, double value); - void setPosition (const Vertex& a); + void setCoordinate(const Axis ax, double value); + void setPosition(const Vertex& a); const Matrix& transform() const; - void setTransform (const Matrix& value); + void setTransform(const Matrix& value); private: Matrix m_transform; @@ -197,24 +197,24 @@ // // // 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 +// represented by a(!) ERROR in the code view. It exists for the purpose of // allowing garbage lines be debugged and corrected within LDForge. // class LDError : public LDObject { - LDOBJ (Error) - LDOBJ_NAME (error) - LDOBJ_VERTICES (0) + LDOBJ(Error) + LDOBJ_NAME(error) + LDOBJ_VERTICES(0) LDOBJ_UNCOLORED LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDError (QString contents, QString reason, LDDocument* document = nullptr); + LDError(QString contents, QString reason, LDDocument* document = nullptr); QString reason() const; QString contents() const; QString fileReferenced() const; - void setFileReferenced (QString value); + void setFileReferenced(QString value); private: QString m_fileReferenced; // If this error was caused by inability to open a file, what file was that? @@ -228,9 +228,9 @@ // class LDEmpty : public LDObject { - LDOBJ (Empty) - LDOBJ_NAME (empty) - LDOBJ_VERTICES (0) + LDOBJ(Empty) + LDOBJ_NAME(empty) + LDOBJ_VERTICES(0) LDOBJ_UNCOLORED LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX @@ -242,17 +242,17 @@ // class LDComment : public LDObject { - LDOBJ (Comment) - LDOBJ_NAME (comment) - LDOBJ_VERTICES (0) + LDOBJ(Comment) + LDOBJ_NAME(comment) + LDOBJ_VERTICES(0) LDOBJ_UNCOLORED LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX public: - LDComment (QString text, LDDocument* document = nullptr); + LDComment(QString text, LDDocument* document = nullptr); QString text() const; - void setText (QString value); + void setText(QString value); private: QString m_text; @@ -282,21 +282,21 @@ class LDBfc : public LDObject { public: - LDOBJ (Bfc) - LDOBJ_NAME (bfc) - LDOBJ_VERTICES (0) + LDOBJ(Bfc) + LDOBJ_NAME(bfc) + LDOBJ_VERTICES(0) LDOBJ_UNCOLORED LDOBJ_CUSTOM_SCEMANTIC { return (statement() == BfcStatement::InvertNext); } LDOBJ_NO_MATRIX public: - LDBfc (const BfcStatement type, LDDocument* document = nullptr); + LDBfc(const BfcStatement type, LDDocument* document = nullptr); BfcStatement statement() const; - void setStatement (BfcStatement value); + void setStatement(BfcStatement value); QString statementToString() const; - static QString statementToString (BfcStatement statement); + static QString statementToString(BfcStatement statement); private: BfcStatement m_statement; @@ -309,21 +309,21 @@ // class LDSubfileReference : public LDMatrixObject { - LDOBJ (SubfileReference) - LDOBJ_NAME (subfilereference) - LDOBJ_VERTICES (0) + LDOBJ(SubfileReference) + LDOBJ_NAME(subfilereference) + LDOBJ_VERTICES(0) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (MainColor) + LDOBJ_DEFAULTCOLOR(MainColor) LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX public: // Inlines this subfile. LDDocument* fileInfo() const; - virtual void getVertices (QVector<Vertex>& verts) const override; - LDObjectList inlineContents (bool deep, bool render); + virtual void getVertices(QVector<Vertex>& verts) const override; + LDObjectList inlineContents(bool deep, bool render); QList<LDPolygon> inlinePolygons(); - void setFileInfo (LDDocument* fileInfo); + void setFileInfo(LDDocument* fileInfo); private: LDDocument* m_fileInfo; @@ -336,16 +336,16 @@ // class LDLine : public LDObject { - LDOBJ (Line) - LDOBJ_NAME (line) - LDOBJ_VERTICES (2) + LDOBJ(Line) + LDOBJ_NAME(line) + LDOBJ_VERTICES(2) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (EdgeColor) + LDOBJ_DEFAULTCOLOR(EdgeColor) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDLine (Vertex v1, Vertex v2, LDDocument* document = nullptr); + LDLine(Vertex v1, Vertex v2, LDDocument* document = nullptr); }; // @@ -355,16 +355,16 @@ // class LDCondLine : public LDLine { - LDOBJ (CondLine) - LDOBJ_NAME (condline) - LDOBJ_VERTICES (4) + LDOBJ(CondLine) + LDOBJ_NAME(condline) + LDOBJ_VERTICES(4) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (EdgeColor) + LDOBJ_DEFAULTCOLOR(EdgeColor) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); + LDCondLine(const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); LDLine* toEdgeLine(); }; @@ -377,16 +377,16 @@ // class LDTriangle : public LDObject { - LDOBJ (Triangle) - LDOBJ_NAME (triangle) - LDOBJ_VERTICES (3) + LDOBJ(Triangle) + LDOBJ_NAME(triangle) + LDOBJ_VERTICES(3) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (MainColor) + LDOBJ_DEFAULTCOLOR(MainColor) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDTriangle (Vertex const& v1, Vertex const& v2, Vertex const& v3, LDDocument* document = nullptr); + LDTriangle(Vertex const& v1, Vertex const& v2, Vertex const& v3, LDDocument* document = nullptr); }; // @@ -397,16 +397,16 @@ // class LDQuad : public LDObject { - LDOBJ (Quad) - LDOBJ_NAME (quad) - LDOBJ_VERTICES (4) + LDOBJ(Quad) + LDOBJ_NAME(quad) + LDOBJ_VERTICES(4) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (MainColor) + LDOBJ_DEFAULTCOLOR(MainColor) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDQuad (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, LDDocument* document = nullptr); + LDQuad(const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, LDDocument* document = nullptr); // Split this quad into two triangles QList<LDTriangle*> splitToTriangles(); @@ -419,9 +419,9 @@ // class LDOverlay : public LDObject { - LDOBJ (Overlay) - LDOBJ_NAME (overlay) - LDOBJ_VERTICES (0) + LDOBJ(Overlay) + LDOBJ_NAME(overlay) + LDOBJ_VERTICES(0) LDOBJ_UNCOLORED LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX @@ -430,12 +430,12 @@ int camera() const; QString fileName() const; int height() const; - void setCamera (int value); - void setFileName (QString value); - void setHeight (int value); - void setWidth (int value); - void setX (int value); - void setY (int value); + void setCamera(int value); + void setFileName(QString value); + void setHeight(int value); + void setWidth(int value); + void setX(int value); + void setY(int value); int width() const; int x() const; int y() const; @@ -451,24 +451,24 @@ class LDBezierCurve : public LDObject { - LDOBJ (BezierCurve) - LDOBJ_NAME (beziercurve) - LDOBJ_VERTICES (4) + LDOBJ(BezierCurve) + LDOBJ_NAME(beziercurve) + LDOBJ_VERTICES(4) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (EdgeColor) + LDOBJ_DEFAULTCOLOR(EdgeColor) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX public: - LDBezierCurve (const Vertex& v0, const Vertex& v1, + LDBezierCurve(const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); - Vertex pointAt (qreal t) const; - LDObjectList rasterize (int segments = 0); - QVector<LDPolygon> rasterizePolygons (int segments = 0); + Vertex pointAt(qreal t) const; + LDObjectList rasterize(int segments = 0); + QVector<LDPolygon> rasterizePolygons(int segments = 0); }; // Other common LDraw stuff -static const QString CALicenseText ("!LICENSE Redistributable under CCAL version 2.0 : " +static const QString CALicenseText("!LICENSE Redistributable under CCAL version 2.0 : " "see CAreadme.txt"); enum