Mon, 02 Jun 2014 13:16:14 +0300
- LDObject::Type moved back to global namespace
src/actions.cc | file | annotate | diff | comparison | revisions | |
src/actionsEdit.cc | file | annotate | diff | comparison | revisions | |
src/addObjectDialog.cc | file | annotate | diff | comparison | revisions | |
src/addObjectDialog.h | file | annotate | diff | comparison | revisions | |
src/basics.cc | file | annotate | diff | comparison | revisions | |
src/extPrograms.cc | file | annotate | diff | comparison | revisions | |
src/glCompiler.cc | file | annotate | diff | comparison | revisions | |
src/glRenderer.cc | file | annotate | diff | comparison | revisions | |
src/ldDocument.cc | file | annotate | diff | comparison | revisions | |
src/ldObject.cc | file | annotate | diff | comparison | revisions | |
src/ldObject.h | file | annotate | diff | comparison | revisions | |
src/mainWindow.cc | file | annotate | diff | comparison | revisions | |
src/mainWindow.h | file | annotate | diff | comparison | revisions |
--- a/src/actions.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/actions.cc Mon Jun 02 13:16:14 2014 +0300 @@ -198,56 +198,56 @@ // DEFINE_ACTION (NewSubfile, 0) { - AddObjectDialog::staticDialog (LDObject::ESubfile, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Subfile, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewLine, 0) { - AddObjectDialog::staticDialog (LDObject::ELine, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Line, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewTriangle, 0) { - AddObjectDialog::staticDialog (LDObject::ETriangle, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Triangle, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewQuad, 0) { - AddObjectDialog::staticDialog (LDObject::EQuad, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Quad, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewCLine, 0) { - AddObjectDialog::staticDialog (LDObject::ECondLine, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_CondLine, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewComment, 0) { - AddObjectDialog::staticDialog (LDObject::EComment, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Comment, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewBFC, 0) { - AddObjectDialog::staticDialog (LDObject::EBFC, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_BFC, LDObjectPtr()); } // ============================================================================= // DEFINE_ACTION (NewVertex, 0) { - AddObjectDialog::staticDialog (LDObject::EVertex, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Vertex, LDObjectPtr()); } // ============================================================================= @@ -316,16 +316,16 @@ if (selection().isEmpty()) return; - LDObject::Type type = getUniformSelectedType(); + LDObjectType type = getUniformSelectedType(); - if (type == LDObject::EUnidentified) + if (type == OBJ_Unknown) return; // If we're selecting subfile references, the reference filename must also // be uniform. String refName; - if (type == LDObject::ESubfile) + if (type == OBJ_Subfile) { refName = selection()[0].staticCast<LDSubfile>()->fileInfo()->name(); @@ -341,7 +341,7 @@ if (obj->type() != type) continue; - if (type == LDObject::ESubfile && obj.staticCast<LDSubfile>()->fileInfo()->name() != refName) + if (type == OBJ_Subfile && obj.staticCast<LDSubfile>()->fileInfo()->name() != refName) continue; obj->select(); @@ -805,7 +805,7 @@ // be carried over to the subfile. for (LDObjectPtr obj : getCurrentDocument()->objects()) { - if (obj->type() != LDObject::EBFC) + if (obj->type() != OBJ_BFC) continue; LDBFC::Statement a = obj.staticCast<LDBFC>()->statement();
--- a/src/actionsEdit.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/actionsEdit.cc Mon Jun 02 13:16:14 2014 +0300 @@ -124,7 +124,7 @@ // inlined contents. long idx = obj->lineNumber(); - if (idx == -1 || obj->type() != LDObject::ESubfile) + if (idx == -1 || obj->type() != OBJ_Subfile) continue; LDObjectList objs = obj.staticCast<LDSubfile>()->inlineContents (deep, false); @@ -165,7 +165,7 @@ for (LDObjectPtr obj : objs) { - if (obj->type() != LDObject::EQuad) + if (obj->type() != OBJ_Quad) continue; // Find the index of this quad @@ -201,7 +201,7 @@ ui.setupUi (dlg); ui.code->setText (obj->asText()); - if (obj->type() == LDObject::EError) + if (obj->type() == OBJ_Error) ui.errorDescription->setText (obj.staticCast<LDError>()->reason()); else { @@ -258,13 +258,14 @@ for (LDObjectPtr obj : objs) { - const LDObject::Type type = obj->type(); - if (type != LDObject::EQuad && type != LDObject::ETriangle) + const LDObjectType type = obj->type(); + + if (type != OBJ_Quad && type != OBJ_Triangle) continue; LDLinePtr lines[4]; - if (type == LDObject::EQuad) + if (type == OBJ_Quad) { LDQuadPtr quad = obj.staticCast<LDQuad>(); lines[0] = spawn<LDLine> (quad->vertex (0), quad->vertex (1)); @@ -474,7 +475,7 @@ // Transform the matrix mo->setTransform (transform * mo->transform()); } - elif (obj->type() == LDObject::EVertex) + elif (obj->type() == OBJ_Vertex) { LDVertexPtr vert = obj.staticCast<LDVertex>(); Vertex v = vert->pos; @@ -572,7 +573,7 @@ int col = maincolor; - if (obj->type() == LDObject::ELine || obj->type() == LDObject::ECondLine) + if (obj->type() == OBJ_Line || obj->type() == OBJ_CondLine) col = edgecolor; obj->setColor (col); @@ -680,7 +681,7 @@ for (LDObjectPtr obj : sel) { - if (obj->type() != LDObject::ECondLine) + if (obj->type() != OBJ_CondLine) continue; obj.staticCast<LDCondLine>()->demote();
--- a/src/addObjectDialog.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/addObjectDialog.cc Mon Jun 02 13:16:14 2014 +0300 @@ -53,7 +53,7 @@ // ============================================================================= // -AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObjectPtr obj, QWidget* parent) : +AddObjectDialog::AddObjectDialog (const LDObjectType type, LDObjectPtr obj, QWidget* parent) : QDialog (parent) { setlocale (LC_ALL, "C"); @@ -63,7 +63,7 @@ switch (type) { - case LDObject::EComment: + case OBJ_Comment: { le_comment = new QLineEdit; @@ -73,28 +73,28 @@ le_comment->setMinimumWidth (384); } break; - case LDObject::ELine: + case OBJ_Line: { coordCount = 6; } break; - case LDObject::ETriangle: + case OBJ_Triangle: { coordCount = 9; } break; - case LDObject::EQuad: - case LDObject::ECondLine: + case OBJ_Quad: + case OBJ_CondLine: { coordCount = 12; } break; - case LDObject::EVertex: + case OBJ_Vertex: { coordCount = 3; } break; - case LDObject::EBFC: + case OBJ_BFC: { rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); @@ -111,7 +111,7 @@ rb_bfcType->setValue ((int) obj.staticCast<LDBFC>()->statement()); } break; - case LDObject::ESubfile: + case OBJ_Subfile: { coordCount = 3; tw_subfileList = new QTreeWidget(); @@ -168,7 +168,7 @@ if (obj != null) colnum = obj->color(); else - colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; + colnum = (type == OBJ_CondLine || type == OBJ_Line) ? edgecolor : maincolor; pb_color = new QPushButton; setButtonBackground (pb_color, colnum); @@ -188,10 +188,10 @@ switch (type) { - case LDObject::ELine: - case LDObject::ECondLine: - case LDObject::ETriangle: - case LDObject::EQuad: + case OBJ_Line: + case OBJ_CondLine: + case OBJ_Triangle: + case OBJ_Quad: // Apply coordinates if (obj != null) { @@ -205,15 +205,15 @@ } break; - case LDObject::EComment: + case OBJ_Comment: layout->addWidget (le_comment, 0, 1); break; - case LDObject::EBFC: + case OBJ_BFC: layout->addWidget (rb_bfcType, 0, 1); break; - case LDObject::ESubfile: + case OBJ_Subfile: layout->addWidget (tw_subfileList, 1, 1, 1, 2); layout->addWidget (lb_subfileName, 2, 1); layout->addWidget (le_subfileName, 2, 2); @@ -324,15 +324,15 @@ // ============================================================================= // ============================================================================= -void AddObjectDialog::staticDialog (const LDObject::Type type, LDObjectPtr obj) +void AddObjectDialog::staticDialog (const LDObjectType type, LDObjectPtr obj) { setlocale (LC_ALL, "C"); // FIXME: Redirect to Edit Raw - if (obj && obj->type() == LDObject::EError) + if (obj && obj->type() == OBJ_Error) return; - if (type == LDObject::EEmpty) + if (type == OBJ_Empty) return; // Nothing to edit with empties const bool newObject = (obj == null); @@ -344,7 +344,7 @@ if (dlg.exec() == QDialog::Rejected) return; - if (type == LDObject::ESubfile) + if (type == OBJ_Subfile) { QStringList matrixstrvals = dlg.le_matrix->text().split (" ", String::SkipEmptyParts); @@ -362,17 +362,17 @@ switch (type) { - case LDObject::EComment: + case OBJ_Comment: { LDCommentPtr comm = initObj<LDComment> (obj); comm->setText (dlg.le_comment->text()); } break; - case LDObject::ELine: - case LDObject::ETriangle: - case LDObject::EQuad: - case LDObject::ECondLine: + case OBJ_Line: + case OBJ_Triangle: + case OBJ_Quad: + case OBJ_CondLine: { if (not obj) obj = LDObject::getDefault (type); @@ -390,20 +390,20 @@ } } break; - case LDObject::EBFC: + case OBJ_BFC: { LDBFCPtr bfc = initObj<LDBFC> (obj); bfc->setStatement ((LDBFC::Statement) dlg.rb_bfcType->value()); } break; - case LDObject::EVertex: + case OBJ_Vertex: { LDVertexPtr vert = initObj<LDVertex> (obj); vert->pos.apply ([&](Axis ax, double& value) { value = dlg.dsb_coords[ax]->value(); }); } break; - case LDObject::ESubfile: + case OBJ_Subfile: { String name = dlg.le_subfileName->text();
--- a/src/addObjectDialog.h Mon Jun 02 13:00:58 2014 +0300 +++ b/src/addObjectDialog.h Mon Jun 02 13:16:14 2014 +0300 @@ -34,8 +34,8 @@ Q_OBJECT public: - AddObjectDialog (const LDObject::Type type, LDObjectPtr obj, QWidget* parent = null); - static void staticDialog (const LDObject::Type type, LDObjectPtr obj); + AddObjectDialog (const LDObjectType type, LDObjectPtr obj, QWidget* parent = null); + static void staticDialog (const LDObjectType type, LDObjectPtr obj); QLabel* lb_typeIcon;
--- a/src/basics.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/basics.cc Mon Jun 02 13:16:14 2014 +0300 @@ -235,16 +235,16 @@ { switch (obj->type()) { - case LDObject::ELine: - case LDObject::ETriangle: - case LDObject::EQuad: - case LDObject::ECondLine: + case OBJ_Line: + case OBJ_Triangle: + case OBJ_Quad: + case OBJ_CondLine: { for (int i = 0; i < obj->numVertices(); ++i) calcVertex (obj->vertex (i)); } break; - case LDObject::ESubfile: + case OBJ_Subfile: { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); LDObjectList objs = ref->inlineContents (true, false);
--- a/src/extPrograms.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/extPrograms.cc Mon Jun 02 13:16:14 2014 +0300 @@ -170,7 +170,7 @@ { for (LDObjectPtr obj : objects) { - if (obj->type() == LDObject::ESubfile) + if (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); LDObjectList objs = ref->inlineContents (true, false);
--- a/src/glCompiler.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/glCompiler.cc Mon Jun 02 13:16:14 2014 +0300 @@ -324,10 +324,10 @@ { // Note: We cannot split quads into triangles here, it would mess up the // wireframe view. Quads must go into separate vbos. - case LDObject::ETriangle: - case LDObject::EQuad: - case LDObject::ELine: - case LDObject::ECondLine: + case OBJ_Triangle: + case OBJ_Quad: + case OBJ_Line: + case OBJ_CondLine: { LDPolygon* poly = obj->getPolygon(); poly->id = obj->id(); @@ -336,7 +336,7 @@ break; } - case LDObject::ESubfile: + case OBJ_Subfile: { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); auto data = ref->inlinePolygons();
--- a/src/glRenderer.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/glRenderer.cc Mon Jun 02 13:16:14 2014 +0300 @@ -1660,7 +1660,7 @@ for (int i = 0; i < obj->numVertices(); ++i) verts << obj->vertex (i); } - elif (obj->type() == LDObject::ESubfile) + elif (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); LDObjectList objs = ref->inlineContents (true, false); @@ -2072,7 +2072,7 @@ // If this is the last overlay image, we need to remove the empty space after it as well. LDObjectPtr nextobj = ovlobj->next(); - if (nextobj && nextobj->type() == LDObject::EEmpty) + if (nextobj && nextobj->type() == OBJ_Empty) nextobj->destroy(); // If the overlay object was there and the overlay itself is @@ -2104,7 +2104,7 @@ break; } - if (obj->type() == LDObject::EOverlay) + if (obj->type() == OBJ_Overlay) lastOverlay = i; }
--- a/src/ldDocument.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/ldDocument.cc Mon Jun 02 13:16:14 2014 +0300 @@ -406,7 +406,7 @@ LDObjectPtr obj = parseLine (line); // Check for parse errors and warn about tthem - if (obj->type() == LDObject::EError) + if (obj->type() == OBJ_Error) { print ("Couldn't parse line #%1: %2", progress() + 1, obj.staticCast<LDError>()->reason()); @@ -741,7 +741,7 @@ // If the second object in the list holds the file name, update that now. LDObjectPtr nameObject = getObject (1); - if (nameObject != null && nameObject->type() == LDObject::EComment) + if (nameObject != null && nameObject->type() == OBJ_Comment) { LDCommentPtr nameComment = nameObject.staticCast<LDComment>(); @@ -1031,7 +1031,7 @@ // Go through all objects in the current file and reload the subfiles for (LDObjectPtr obj : getCurrentDocument()->objects()) { - if (obj->type() == LDObject::ESubfile) + if (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); LDDocumentPtr fileInfo = getDocument (ref->fileInfo()->name()); @@ -1044,7 +1044,7 @@ // Reparse gibberish files. It could be that they are invalid because // of loading errors. Circumstances may be different now. - if (obj->type() == LDObject::EError) + if (obj->type() == OBJ_Error) obj->replace (parseLine (obj.staticCast<LDError>()->contents())); } } @@ -1099,7 +1099,7 @@ if (isImplicit()) return; - if (obj->type() == LDObject::ESubfile) + if (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); @@ -1123,7 +1123,7 @@ if (isImplicit()) return; - if (obj->type() == LDObject::ESubfile) + if (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); @@ -1286,7 +1286,7 @@ for (LDObjectPtr obj : inlineContents (true, true)) { - assert (obj->type() != LDObject::ESubfile); + assert (obj->type() != OBJ_Subfile); LDPolygon* data = obj->getPolygon(); if (data != null) @@ -1339,7 +1339,7 @@ // Got another sub-file reference, inline it if we're deep-inlining. If not, // just add it into the objects normally. Yay, recursion! - if (deep == true && obj->type() == LDObject::ESubfile) + if (deep == true && obj->type() == OBJ_Subfile) { for (LDObjectPtr otherobj : obj.staticCast<LDSubfile>()->inlineContents (deep, renderinline)) objs << otherobj;
--- a/src/ldObject.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/ldObject.cc Mon Jun 02 13:16:14 2014 +0300 @@ -329,10 +329,10 @@ { switch (obj->type()) { - case LDObject::ELine: - case LDObject::ECondLine: - case LDObject::ETriangle: - case LDObject::EQuad: + case OBJ_Line: + case OBJ_CondLine: + case OBJ_Triangle: + case OBJ_Quad: for (int i = 0; i < obj->numVertices(); ++i) { @@ -343,7 +343,7 @@ break; - case LDObject::ESubfile: + case OBJ_Subfile: { LDSubfilePtr ref = qSharedPointerCast<LDSubfile> (obj); Matrix newMatrix = transform * ref->transform(); @@ -383,12 +383,12 @@ // LDPolygon* LDObject::getPolygon() { - Type ot = type(); + LDObjectType ot = type(); int num = - (ot == LDObject::ELine) ? 2 : - (ot == LDObject::ETriangle) ? 3 : - (ot == LDObject::EQuad) ? 4 : - (ot == LDObject::ECondLine) ? 5 : + (ot == OBJ_Line) ? 2 : + (ot == OBJ_Triangle) ? 3 : + (ot == OBJ_Quad) ? 4 : + (ot == OBJ_CondLine) ? 5 : 0; if (num == 0) return null; @@ -476,7 +476,7 @@ // ============================================================================= // -String LDObject::typeName (LDObject::Type type) +String LDObject::typeName (LDObjectType type) { return LDObject::getDefault (type)->typeName(); } @@ -490,7 +490,7 @@ if (objs.isEmpty()) return "nothing"; // :) - for (Type objType = EFirstType; objType < ENumTypes; ++objType) + for (LDObjectType objType = OBJ_FirstType; objType < OBJ_NumTypes; ++objType) { int count = 0; @@ -507,7 +507,7 @@ String noun = format ("%1%2", typeName (objType), plural (count)); // Plural of "vertex" is "vertices", correct that - if (objType == EVertex && count != 1) + if (objType == OBJ_Vertex && count != 1) noun = "vertices"; text += format ("%1 %2", count, noun); @@ -563,7 +563,7 @@ { LDObjectPtr prev (previous()); - if (prev != null && prev->type() == EBFC && prev.staticCast<LDBFC>()->statement() == LDBFC::InvertNext) + if (prev != null && prev->type() == OBJ_BFC && prev.staticCast<LDBFC>()->statement() == LDBFC::InvertNext) { ptr = prev.staticCast<LDBFC>(); return true; @@ -581,7 +581,7 @@ LDMatrixObjectPtr mo = self().toStrongRef().dynamicCast<LDMatrixObject>(); mo->setPosition (mo->position() + vect); } - elif (type() == LDObject::EVertex) + elif (type() == OBJ_Vertex) { // ugh self().toStrongRef().staticCast<LDVertex>()->pos += vect; @@ -595,23 +595,23 @@ // ============================================================================= // -LDObjectPtr LDObject::getDefault (const LDObject::Type type) +LDObjectPtr LDObject::getDefault (const LDObjectType type) { switch (type) { - case EComment: return spawn<LDComment>(); - case EBFC: return spawn<LDBFC>(); - case ELine: return spawn<LDLine>(); - case ECondLine: return spawn<LDCondLine>(); - case ESubfile: return spawn<LDSubfile>(); - case ETriangle: return spawn<LDTriangle>(); - case EQuad: return spawn<LDQuad>(); - case EEmpty: return spawn<LDEmpty>(); - case EError: return spawn<LDError>(); - case EVertex: return spawn<LDVertex>(); - case EOverlay: return spawn<LDOverlay>(); - case EUnidentified: assert (false); - case ENumTypes: assert (false); + case OBJ_Comment: return spawn<LDComment>(); + case OBJ_BFC: return spawn<LDBFC>(); + case OBJ_Line: return spawn<LDLine>(); + case OBJ_CondLine: return spawn<LDCondLine>(); + case OBJ_Subfile: return spawn<LDSubfile>(); + case OBJ_Triangle: return spawn<LDTriangle>(); + case OBJ_Quad: return spawn<LDQuad>(); + case OBJ_Empty: return spawn<LDEmpty>(); + case OBJ_Error: return spawn<LDError>(); + case OBJ_Vertex: return spawn<LDVertex>(); + case OBJ_Overlay: return spawn<LDOverlay>(); + case OBJ_Unknown: assert (false); + case OBJ_NumTypes: assert (false); } return LDObjectPtr(); }
--- a/src/ldObject.h Mon Jun 02 13:00:58 2014 +0300 +++ b/src/ldObject.h Mon Jun 02 13:16:14 2014 +0300 @@ -24,9 +24,9 @@ #define LDOBJ(T) \ public: \ - virtual LDObject::Type type() const override \ + virtual LDObjectType type() const override \ { \ - return LDObject::E##T; \ + return OBJ_##T; \ } \ virtual String asText() const override; \ virtual void invert() override; \ @@ -58,6 +58,26 @@ class LDBFC; using LDBFCPtr = QSharedPointer<LDBFC>; +// Object type codes. +enum LDObjectType +{ + OBJ_Subfile, // Object represents a sub-file reference + OBJ_Quad, // Object represents a quadrilateral + OBJ_Triangle, // Object represents a triangle + OBJ_Line, // Object represents a line + OBJ_CondLine, // Object represents a conditional line + OBJ_Vertex, // Object is a vertex, LDForge extension object + OBJ_BFC, // Object represents a BFC statement + OBJ_Overlay, // Object contains meta-info about an overlay image. + OBJ_Comment, // Object represents a comment + OBJ_Error, // Object is the result of failed parsing + OBJ_Empty, // Object represents an empty line + OBJ_Unknown, // Unknown object type (some functions return this; TODO: they probably should not) + + OBJ_NumTypes, // Amount of object types + OBJ_FirstType = OBJ_Subfile +}; + // ============================================================================= // LDObject // @@ -78,138 +98,118 @@ PROPERTY (private, QColor, randomColor, setRandomColor, STOCK_WRITE) PROPERTY (private, LDObjectWeakPtr, self, setSelf, STOCK_WRITE) - public: - // Object type codes. - enum Type - { - ESubfile, // Object represents a sub-file reference - EQuad, // Object represents a quadrilateral - ETriangle, // Object represents a triangle - ELine, // Object represents a line - ECondLine, // Object represents a conditional line - EVertex, // Object is a vertex, LDForge extension object - EBFC, // Object represents a BFC statement - EOverlay, // Object contains meta-info about an overlay image. - EComment, // Object represents a comment - EError, // Object is the result of failed parsing - EEmpty, // Object represents an empty line - EUnidentified, // Unknown object type (some functions return this; TODO: they probably should not) +public: + LDObject (LDObjectPtr* selfptr); + + // This object as LDraw code + virtual String asText() const = 0; + + // Makes a copy of this object + LDObjectPtr createCopy() const; + + // Deletes this object + void destroy(); - ENumTypes, // Amount of object types - EFirstType = ESubfile - }; + // Removes this object from selection + void deselect(); - LDObject (LDObjectPtr* selfptr); + // Does this object have a matrix and position? (see LDMatrixObject) + virtual bool hasMatrix() const = 0; - // This object as LDraw code - virtual String asText() const = 0; + // Inverts this object (winding is reversed) + virtual void invert() = 0; - // Makes a copy of this object - LDObjectPtr createCopy() const; + // Is this object colored? + virtual bool isColored() const = 0; - // Deletes this object - void destroy(); + // Does this object have meaning in the part model? + virtual bool isScemantic() const = 0; - // Removes this object from selection - void deselect(); + // Index (i.e. line number) of this object + long lineNumber() const; - // Does this object have a matrix and position? (see LDMatrixObject) - virtual bool hasMatrix() const = 0; + // Moves this object using the given vertex as a movement List + void move (Vertex vect); - // Inverts this object (winding is reversed) - virtual void invert() = 0; + // Object after this in the current file + LDObjectPtr next() const; - // Is this object colored? - virtual bool isColored() const = 0; - - // Does this object have meaning in the part model? - virtual bool isScemantic() const = 0; + // Number of vertices this object has + virtual int numVertices() const = 0; - // Index (i.e. line number) of this object - long lineNumber() const; + // Object prior to this in the current file + LDObjectPtr previous() const; - // Moves this object using the given vertex as a movement List - void move (Vertex vect); - - // Object after this in the current file - LDObjectPtr next() const; + // Is the previous object INVERTNEXT? + bool previousIsInvertnext (LDBFCPtr& ptr); - // Number of vertices this object has - virtual int numVertices() const = 0; + // Replace this LDObject with another LDObject. Object is deleted in the process. + void replace (LDObjectPtr other); - // Object prior to this in the current file - LDObjectPtr previous() const; + // Selects this object. + void select(); - // Is the previous object INVERTNEXT? - bool previousIsInvertnext (LDBFCPtr& ptr); + // Set a vertex to the given value + void setVertex (int i, const Vertex& vert); - // Replace this LDObject with another LDObject. Object is deleted in the process. - void replace (LDObjectPtr other); + // Set a single coordinate of a vertex + void setVertexCoord (int i, Axis ax, double value); - // Selects this object. - void select(); + // Swap this object with another. + void swap (LDObjectPtr other); - // Set a vertex to the given value - void setVertex (int i, const Vertex& vert); + // What object in the current file ultimately references this? + LDObjectPtr topLevelParent(); - // Set a single coordinate of a vertex - void setVertexCoord (int i, Axis ax, double value); - - // Swap this object with another. - void swap (LDObjectPtr other); + // Type enumerator of this object + virtual LDObjectType type() const = 0; - // What object in the current file ultimately references this? - LDObjectPtr topLevelParent(); + // Type name of this object + virtual String typeName() const = 0; - // Type enumerator of this object - virtual Type type() const = 0; - - // Type name of this object - virtual String typeName() const = 0; + // Get a vertex by index + const Vertex& vertex (int i) const; - // Get a vertex by index - const Vertex& vertex (int i) const; + // Get type name by enumerator + static String typeName (LDObjectType type); - // Get type name by enumerator - static String typeName (LDObject::Type type); + // Returns a default-constructed LDObject by the given type + static LDObjectPtr getDefault (const LDObjectType type); - // Returns a default-constructed LDObject by the given type - static LDObjectPtr getDefault (const LDObject::Type type); + // TODO: move this to LDDocument? + static void moveObjects (LDObjectList objs, const bool up); - // TODO: move this to LDDocument? - static void moveObjects (LDObjectList objs, const bool up); + // Get a description of a list of LDObjects + static String describeObjects (const LDObjectList& objs); + static LDObjectPtr fromID (int id); + LDPolygon* getPolygon(); - // Get a description of a list of LDObjects - static String describeObjects (const LDObjectList& objs); - static LDObjectPtr fromID (int id); - LDPolygon* getPolygon(); + // TODO: make this private! + QListWidgetItem* qObjListEntry; - // TODO: make this private! - QListWidgetItem* qObjListEntry; - - // This is public because I cannot protect it as the lambda deletor would - // have to be the friend. Do not call this! Ever! - void finalDelete(); + // This is public because I cannot protect it as the lambda deletor would + // have to be the friend. Do not call this! Ever! + void finalDelete(); - protected: - // LDObjects are to be deleted with the finalDelete() method, not with - // operator delete. This is because it seems virtual functions cannot - // be properly called from the destructor, thus a normal method must - // be used instead. The destructor also doesn't seem to be able to - // be private without causing a truckload of problems so it's protected - // instead. - virtual ~LDObject(); - void chooseID(); +protected: + // LDObjects are to be deleted with the finalDelete() method, not with + // operator delete. This is because it seems virtual functions cannot + // be properly called from the destructor, thus a normal method must + // be used instead. The destructor also doesn't seem to be able to + // be private without causing a truckload of problems so it's protected + // instead. + virtual ~LDObject(); + void chooseID(); - // Even though we supply a custom deleter to QSharedPointer, the shared - // pointer's base class still calls operator delete directly in one of - // its methods. The method should never be called but we need to declare - // the class making this delete call a friend anyway. - friend class QSharedPointer<LDObject>; - friend class QSharedPointer<LDObject>::ExternalRefCount; + // Even though we supply a custom deleter to QSharedPointer, the shared + // pointer's base class still calls operator delete directly in one of + // its methods. The method should never be called but we need to declare + // the class making this delete call a friend anyway. + friend class QSharedPointer<LDObject>; + friend class QSharedPointer<LDObject>::ExternalRefCount; - private: - LDSharedVertex* m_coords[4]; +private: + LDSharedVertex* m_coords[4]; }; // @@ -225,7 +225,7 @@ return ptr.staticCast<T>(); } -NUMERIC_ENUM_OPERATORS (LDObject::Type) +NUMERIC_ENUM_OPERATORS (LDObjectType) // // Apparently QWeakPointer doesn't implement operator<. This is a problem when
--- a/src/mainWindow.cc Mon Jun 02 13:00:58 2014 +0300 +++ b/src/mainWindow.cc Mon Jun 02 13:16:14 2014 +0300 @@ -261,7 +261,7 @@ title += getCurrentDocument()->getDisplayName(); if (getCurrentDocument()->getObjectCount() > 0 && - getCurrentDocument()->getObject (0)->type() == LDObject::EComment) + getCurrentDocument()->getObject (0)->type() == OBJ_Comment) { // Append title LDCommentPtr comm = getCurrentDocument()->getObject (0).staticCast<LDComment>(); @@ -324,7 +324,7 @@ switch (obj->type()) { - case LDObject::EComment: + case OBJ_Comment: { descr = obj.staticCast<LDComment>()->text(); @@ -335,13 +335,13 @@ break; } - case LDObject::EEmpty: + case OBJ_Empty: break; // leave it empty - case LDObject::ELine: - case LDObject::ETriangle: - case LDObject::EQuad: - case LDObject::ECondLine: + case OBJ_Line: + case OBJ_Triangle: + case OBJ_Quad: + case OBJ_CondLine: { for (int i = 0; i < obj->numVertices(); ++i) { @@ -353,19 +353,19 @@ break; } - case LDObject::EError: + case OBJ_Error: { descr = format ("ERROR: %1", obj->asText()); break; } - case LDObject::EVertex: + case OBJ_Vertex: { descr = obj.staticCast<LDVertex>()->pos.toString (true); break; } - case LDObject::ESubfile: + case OBJ_Subfile: { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); @@ -378,13 +378,13 @@ break; } - case LDObject::EBFC: + case OBJ_BFC: { descr = LDBFC::k_statementStrings[obj.staticCast<LDBFC>()->statement()]; break; } - case LDObject::EOverlay: + case OBJ_Overlay: { LDOverlayPtr ovl = obj.staticCast<LDOverlay>(); descr = format ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->camera()], @@ -412,7 +412,7 @@ } // Color gibberish orange on red so it stands out. - if (obj->type() == LDObject::EError) + if (obj->type() == OBJ_Error) { item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); @@ -599,16 +599,16 @@ // ============================================================================= // -LDObject::Type MainWindow::getUniformSelectedType() +LDObjectType MainWindow::getUniformSelectedType() { - LDObject::Type result = LDObject::EUnidentified; + LDObjectType result = OBJ_Unknown; for (LDObjectPtr obj : selection()) { - if (result != LDObject::EUnidentified && obj->color() != result) - return LDObject::EUnidentified; + if (result != OBJ_Unknown && obj->color() != result) + return OBJ_Unknown; - if (result == LDObject::EUnidentified) + if (result == OBJ_Unknown) result = obj->type(); } @@ -642,7 +642,7 @@ QMenu* contextMenu = new QMenu; - if (single && singleObj->type() != LDObject::EEmpty) + if (single && singleObj->type() != OBJ_Empty) { contextMenu->addAction (ui->actionEdit); contextMenu->addSeparator();
--- a/src/mainWindow.h Mon Jun 02 13:00:58 2014 +0300 +++ b/src/mainWindow.h Mon Jun 02 13:16:14 2014 +0300 @@ -135,10 +135,10 @@ //! red), -1 if there is no such consensus. int getSelectedColor(); - //! \returns the uniform selected type (i.e. \c LDObject::ELine if everything - //! selected is a line), \c LDObject::EUnidentified if there is no such + //! \returns the uniform selected type (i.e. \c OBJ_Line if everything + //! selected is a line), \c OBJ_Unknown if there is no such //! consensus. - LDObject::Type getUniformSelectedType(); + LDObjectType getUniformSelectedType(); //! Automatically scrolls the object list so that it points to the first //! selected object.