Wed, 05 Mar 2014 02:24:05 +0200
- renamed several LDObject methods
src/AddObjectDialog.cc | file | annotate | diff | comparison | revisions | |
src/Document.cc | file | annotate | diff | comparison | revisions | |
src/EditHistory.cc | file | annotate | diff | comparison | revisions | |
src/EditHistory.h | file | annotate | diff | comparison | revisions | |
src/ExternalPrograms.cc | file | annotate | diff | comparison | revisions | |
src/GLRenderer.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/Types.cc | file | annotate | diff | comparison | revisions | |
src/actions/EditActions.cc | file | annotate | diff | comparison | revisions | |
src/actions/MainActions.cc | file | annotate | diff | comparison | revisions |
--- a/src/AddObjectDialog.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/AddObjectDialog.cc Wed Mar 05 02:24:05 2014 +0200 @@ -104,11 +104,11 @@ if (i == LDBFC::NumStatements / 2) rb_bfcType->rowBreak(); - rb_bfcType->addButton (LDBFC::statements[i]); + rb_bfcType->addButton (LDBFC::k_statementStrings[i]); } if (obj) - rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->type); + rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->m_statement); } break; case LDObject::ESubfile: @@ -198,7 +198,7 @@ { for (int i = 0; i < coordCount / 3; ++i) for (int j = 0; j < 3; ++j) - dsb_coords[ (i * 3) + j]->setValue (obj->getVertex (i).getCoordinate (j)); + dsb_coords[ (i * 3) + j]->setValue (obj->vertex (i).getCoordinate (j)); } break; @@ -327,7 +327,7 @@ setlocale (LC_ALL, "C"); // FIXME: Redirect to Edit Raw - if (obj && obj->getType() == LDObject::EError) + if (obj && obj->type() == LDObject::EError) return; if (type == LDObject::EEmpty) @@ -337,7 +337,7 @@ Matrix transform = g_identity; AddObjectDialog dlg (type, obj); - assert (!obj || obj->getType() == type); + assert (obj == null || obj->type() == type); if (dlg.exec() == false) return; @@ -389,7 +389,7 @@ case LDObject::EBFC: { LDBFC* bfc = initObj<LDBFC> (obj); - bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); + bfc->m_statement = (LDBFC::Statement) dlg.rb_bfcType->value(); } break; case LDObject::EVertex:
--- a/src/Document.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/Document.cc Wed Mar 05 02:24:05 2014 +0200 @@ -380,7 +380,7 @@ LDObject* obj = parseLine (line); // Check for parse errors and warn about tthem - if (obj->getType() == LDObject::EError) + if (obj->type() == LDObject::EError) { log ("Couldn't parse line #%1: %2", getProgress() + 1, static_cast<LDError*> (obj)->reason); @@ -735,7 +735,7 @@ // Only do this if the file is explicitly open. LDObject* nameObject = getObject (1); - if (!isImplicit() && nameObject != null && nameObject->getType() == LDObject::EComment) + if (!isImplicit() && nameObject != null && nameObject->type() == LDObject::EComment) { LDComment* nameComment = static_cast<LDComment*> (nameObject); @@ -750,7 +750,7 @@ // File is open, now save the model to it. Note that LDraw requires files to // have DOS line endings, so we terminate the lines with \r\n. for (LDObject* obj : getObjects()) - f.write ((obj->raw() + "\r\n").toUtf8()); + f.write ((obj->asText() + "\r\n").toUtf8()); // File is saved, now clean up. f.close(); @@ -852,8 +852,8 @@ if (tokens.size() > 2 && tokens[1] == "BFC") { for (int i = 0; i < LDBFC::NumStatements; ++i) - if (comm == fmt ("BFC %1", LDBFC::statements [i])) - return new LDBFC ( (LDBFC::Type) i); + if (comm == fmt ("BFC %1", LDBFC::k_statementStrings [i])) + return new LDBFC ( (LDBFC::Statement) i); // MLCAD is notorious for stuffing these statements in parts it // creates. The above block only handles valid statements, so we @@ -861,7 +861,7 @@ struct { QString a; - LDBFC::Type b; + LDBFC::Statement b; } BFCData[] = { { "INVERTNEXT", LDBFC::InvertNext }, @@ -1037,7 +1037,7 @@ // Go through all objects in the current file and reload the subfiles for (LDObject* obj : getCurrentDocument()->getObjects()) { - if (obj->getType() == LDObject::ESubfile) + if (obj->type() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); LDDocument* fileInfo = getDocument (ref->getFileInfo()->getName()); @@ -1045,12 +1045,12 @@ if (fileInfo) ref->setFileInfo (fileInfo); else - ref->replace (new LDError (ref->raw(), fmt ("Could not open %1", ref->getFileInfo()->getName()))); + ref->replace (new LDError (ref->asText(), fmt ("Could not open %1", ref->getFileInfo()->getName()))); } // Reparse gibberish files. It could be that they are invalid because // of loading errors. Circumstances may be different now. - if (obj->getType() == LDObject::EError) + if (obj->type() == LDObject::EError) obj->replace (parseLine (static_cast<LDError*> (obj)->contents)); } } @@ -1062,12 +1062,12 @@ getHistory()->add (new AddHistory (getObjects().size(), obj)); m_Objects << obj; - if (obj->getType() == LDObject::EVertex) + if (obj->type() == LDObject::EVertex) m_Vertices << obj; #ifdef DEBUG if (!isImplicit()) - dlog ("Added object #%1 (%2)\n", obj->getID(), obj->getTypeName()); + dlog ("Added object #%1 (%2)\n", obj->getID(), obj->typeName()); #endif obj->setFile (this); @@ -1093,7 +1093,7 @@ #ifdef DEBUG if (!isImplicit()) - dlog ("Inserted object #%1 (%2) at %3\n", obj->getID(), obj->getTypeName(), pos); + dlog ("Inserted object #%1 (%2) at %3\n", obj->getID(), obj->typeName(), pos); #endif } @@ -1101,7 +1101,7 @@ // ----------------------------------------------------------------------------- void LDDocument::forgetObject (LDObject* obj) { - int idx = obj->getIndex(); + int idx = obj->lineNumber(); obj->unselect(); assert (m_Objects[idx] == obj); @@ -1132,8 +1132,8 @@ // Mark this change to history if (!m_History->isIgnoring()) { - QString oldcode = getObject (idx)->raw(); - QString newcode = obj->raw(); + QString oldcode = getObject (idx)->asText(); + QString newcode = obj->asText(); *m_History << new EditHistory (idx, oldcode, newcode); } @@ -1239,7 +1239,7 @@ // Got another sub-file reference, inline it if we're deep-inlining. If not, // just add it into the objects normally. Also, we only cache immediate // subfiles and this is not one. Yay, recursion! - if (deep && obj->getType() == LDObject::ESubfile) + if (deep && obj->type() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj);
--- a/src/EditHistory.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/EditHistory.cc Wed Mar 05 02:24:05 2014 +0200 @@ -147,7 +147,7 @@ // DelHistory::DelHistory (int idx, LDObject* obj) : m_Index (idx), - m_Code (obj->raw()) {} + m_Code (obj->asText()) {} // ============================================================================= // heh
--- a/src/EditHistory.h Mon Feb 24 00:25:18 2014 +0200 +++ b/src/EditHistory.h Wed Mar 05 02:24:05 2014 +0200 @@ -146,7 +146,7 @@ AddHistory (int idx, LDObject* obj) : m_Index (idx), - m_Code (obj->raw()) {} + m_Code (obj->asText()) {} }; // =============================================================================
--- a/src/ExternalPrograms.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/ExternalPrograms.cc Wed Mar 05 02:24:05 2014 +0200 @@ -170,7 +170,7 @@ { for (LDObject* obj : objects) { - if (obj->getType() == LDObject::ESubfile) + if (obj->type() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); LDObjectList objs = ref->inlineContents (LDSubfile::DeepInline); @@ -181,7 +181,7 @@ obj->deleteSelf(); } else - f.write ((obj->raw() + "\r\n").toUtf8()); + f.write ((obj->asText() + "\r\n").toUtf8()); } }
--- a/src/GLRenderer.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/GLRenderer.cc Wed Mar 05 02:24:05 2014 +0200 @@ -309,8 +309,8 @@ } if ((list == BFCFrontList || list == BFCBackList) && - obj->getType() != LDObject::ELine && - obj->getType() != LDObject::ECondLine) + obj->type() != LDObject::ELine && + obj->type() != LDObject::ECondLine) { if (list == GL::BFCFrontList) qcol = QColor (40, 192, 0); @@ -932,14 +932,14 @@ { glBegin (gltype); - const int numverts = (obj->getType() != LDObject::ECondLine) ? obj->vertices() : 2; + const int numverts = (obj->type() != LDObject::ECondLine) ? obj->vertices() : 2; if (g_glInvert == false) for (int i = 0; i < numverts; ++i) - compileVertex (obj->getVertex (i)); + compileVertex (obj->vertex (i)); else for (int i = numverts - 1; i >= 0; --i) - compileVertex (obj->getVertex (i)); + compileVertex (obj->vertex (i)); glEnd(); } @@ -950,7 +950,7 @@ { setObjectColor (obj, list); - switch (obj->getType()) + switch (obj->type()) { case LDObject::ELine: { @@ -993,9 +993,9 @@ if (ref->getTransform().getDeterminant() < 0) g_glInvert = !g_glInvert; - LDObject* prev = ref->prev(); + LDObject* prev = ref->previous(); - if (prev && prev->getType() == LDObject::EBFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) + if (prev && prev->type() == LDObject::EBFC && static_cast<LDBFC*> (prev)->m_statement == LDBFC::InvertNext) g_glInvert = !g_glInvert; for (LDObject* obj : objs) @@ -1725,8 +1725,8 @@ if (obj->vertices() >= 2) { for (int i = 0; i < obj->vertices(); ++i) - verts << obj->getVertex (i); - } elif (obj->getType() == LDObject::ESubfile) + verts << obj->vertex (i); + } elif (obj->type() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); LDObjectList objs = ref->inlineContents (LDSubfile::DeepCacheInline); @@ -2098,7 +2098,7 @@ return; LDObject* obj = selection().first(); - AddObjectDialog::staticDialog (obj->getType(), obj); + AddObjectDialog::staticDialog (obj->type(), obj); g_win->endAction(); ev->accept(); } @@ -2111,7 +2111,7 @@ for (LDObject* obj : getFile()->getObjects()) { - if (obj->getType() == LDObject::EOverlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) + if (obj->type() == LDObject::EOverlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) { ovlobj = static_cast<LDOverlay*> (obj); break; @@ -2162,7 +2162,7 @@ // If this is the last overlay image, we need to remove the empty space after it as well. LDObject* nextobj = ovlobj->next(); - if (nextobj && nextobj->getType() == LDObject::EEmpty) + if (nextobj && nextobj->type() == LDObject::EEmpty) nextobj->deleteSelf(); // If the overlay object was there and the overlay itself is @@ -2193,7 +2193,7 @@ break; } - if (obj->getType() == LDObject::EOverlay) + if (obj->type() == LDObject::EOverlay) lastOverlay = i; }
--- a/src/LDObject.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/LDObject.cc Wed Mar 05 02:24:05 2014 +0200 @@ -69,7 +69,7 @@ // ----------------------------------------------------------------------------- void LDObject::setVertexCoord (int i, Axis ax, double value) { - Vertex v = getVertex (i); + Vertex v = vertex (i); v[ax] = value; setVertex (i, v); } @@ -78,14 +78,14 @@ // ============================================================================= // ----------------------------------------------------------------------------- -QString LDComment::raw() const +QString LDComment::asText() const { return fmt ("0 %1", text); } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDSubfile::raw() const +QString LDSubfile::asText() const { QString val = fmt ("1 %1 %2 ", getColor(), getPosition()); val += getTransform().toString(); @@ -96,77 +96,77 @@ // ============================================================================= // ----------------------------------------------------------------------------- -QString LDLine::raw() const +QString LDLine::asText() const { QString val = fmt ("2 %1", getColor()); for (int i = 0; i < 2; ++i) - val += fmt (" %1", getVertex (i)); + val += fmt (" %1", vertex (i)); return val; } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDTriangle::raw() const +QString LDTriangle::asText() const { QString val = fmt ("3 %1", getColor()); for (int i = 0; i < 3; ++i) - val += fmt (" %1", getVertex (i)); + val += fmt (" %1", vertex (i)); return val; } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDQuad::raw() const +QString LDQuad::asText() const { QString val = fmt ("4 %1", getColor()); for (int i = 0; i < 4; ++i) - val += fmt (" %1", getVertex (i)); + val += fmt (" %1", vertex (i)); return val; } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDCondLine::raw() const +QString LDCondLine::asText() const { QString val = fmt ("5 %1", getColor()); // Add the coordinates for (int i = 0; i < 4; ++i) - val += fmt (" %1", getVertex (i)); + val += fmt (" %1", vertex (i)); return val; } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDError::raw() const +QString LDError::asText() const { return contents; } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDVertex::raw() const +QString LDVertex::asText() const { return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos); } // ============================================================================= // ----------------------------------------------------------------------------- -QString LDEmpty::raw() const +QString LDEmpty::asText() const { return ""; } // ============================================================================= // ----------------------------------------------------------------------------- -const char* LDBFC::statements[] = +const char* LDBFC::k_statementStrings[] = { "CERTIFY CCW", "CCW", @@ -180,9 +180,9 @@ "NOCLIP", }; -QString LDBFC::raw() const +QString LDBFC::asText() const { - return fmt ("0 BFC %1", LDBFC::statements[type]); + return fmt ("0 BFC %1", LDBFC::k_statementStrings[m_statement]); } // ============================================================================= @@ -195,8 +195,8 @@ // | | ==> | / / | // | | |/ / | // 1---2 1 1---2 - LDTriangle* tri1 = new LDTriangle (getVertex (0), getVertex (1), getVertex (3)); - LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3)); + LDTriangle* tri1 = new LDTriangle (vertex (0), vertex (1), vertex (3)); + LDTriangle* tri2 = new LDTriangle (vertex (1), vertex (2), vertex (3)); // The triangles also inherit the quad's color tri1->setColor (getColor()); @@ -212,7 +212,7 @@ // ----------------------------------------------------------------------------- void LDObject::replace (LDObject* other) { - long idx = getIndex(); + long idx = lineNumber(); assert (idx != -1); // Replace the instance of the old object with the new object @@ -281,7 +281,7 @@ // ----------------------------------------------------------------------------- static void transformObject (LDObject* obj, Matrix transform, Vertex pos, int parentcolor) { - switch (obj->getType()) + switch (obj->type()) { case LDObject::ELine: case LDObject::ECondLine: @@ -290,7 +290,7 @@ for (int i = 0; i < obj->vertices(); ++i) { - Vertex v = obj->getVertex (i); + Vertex v = obj->vertex (i); v.transform (transform, pos); obj->setVertex (i, v); } @@ -336,7 +336,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -long LDObject::getIndex() const +long LDObject::lineNumber() const { assert (getFile() != null); @@ -365,7 +365,7 @@ { LDObject* obj = objs[i]; - const long idx = obj->getIndex(), + const long idx = obj->lineNumber(), target = idx + (up ? -1 : 1); if ( (up && idx == 0) || (!up && idx == (long) (file->getObjects().size() - 1))) @@ -396,7 +396,7 @@ QString LDObject::typeName (LDObject::Type type) { LDObject* obj = LDObject::getDefault (type); - QString name = obj->getTypeName(); + QString name = obj->typeName(); obj->deleteSelf(); return name; } @@ -417,7 +417,7 @@ int count = 0; for (LDObject * obj : objs) - if (obj->getType() == objType) + if (obj->type() == objType) count++; if (count == 0) @@ -458,7 +458,7 @@ // ----------------------------------------------------------------------------- LDObject* LDObject::next() const { - long idx = getIndex(); + long idx = lineNumber(); assert (idx != -1); if (idx == (long) getFile()->getObjectCount() - 1) @@ -469,9 +469,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDObject* LDObject::prev() const +LDObject* LDObject::previous() const { - long idx = getIndex(); + long idx = lineNumber(); assert (idx != -1); if (idx == 0) @@ -489,7 +489,7 @@ LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); mo->setPosition (mo->getPosition() + vect); } - elif (getType() == LDObject::EVertex) + elif (type() == LDObject::EVertex) { // ugh static_cast<LDVertex*> (this)->pos += vect; @@ -497,7 +497,7 @@ else { for (int i = 0; i < vertices(); ++i) - setVertex (i, getVertex (i) + vect); + setVertex (i, vertex (i) + vect); } } @@ -538,8 +538,8 @@ { // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. // Thus, we swap 1 and 2. - Vertex tmp = getVertex (1); - setVertex (1, getVertex (2)); + Vertex tmp = vertex (1); + setVertex (1, vertex (2)); setVertex (2, tmp); return; @@ -552,8 +552,8 @@ // Quad: 0 -> 1 -> 2 -> 3 // rev: 0 -> 3 -> 2 -> 1 // Thus, we swap 1 and 3. - Vertex tmp = getVertex (1); - setVertex (1, getVertex (3)); + Vertex tmp = vertex (1); + setVertex (1, vertex (3)); setVertex (3, tmp); } @@ -567,13 +567,13 @@ // flipped but I don't have a method for checking flatness yet. // Food for thought... - int idx = getIndex(); + int idx = lineNumber(); if (idx > 0) { - LDBFC* bfc = dynamic_cast<LDBFC*> (prev()); + LDBFC* bfc = dynamic_cast<LDBFC*> (previous()); - if (bfc && bfc->type == LDBFC::InvertNext) + if (bfc && bfc->m_statement == LDBFC::InvertNext) { // This is prefixed with an invertnext, thus remove it. bfc->deleteSelf(); @@ -592,8 +592,8 @@ { // For lines, we swap the vertices. I don't think that a // cond-line's control points need to be swapped, do they? - Vertex tmp = line->getVertex (0); - line->setVertex (0, line->getVertex (1)); + Vertex tmp = line->vertex (0); + line->setVertex (0, line->vertex (1)); line->setVertex (1, tmp); } @@ -616,7 +616,7 @@ LDLine* repl = new LDLine; for (int i = 0; i < repl->vertices(); ++i) - repl->setVertex (i, getVertex (i)); + repl->setVertex (i, vertex (i)); repl->setColor (getColor()); @@ -637,7 +637,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -QString LDOverlay::raw() const +QString LDOverlay::asText() const { return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight()); @@ -657,11 +657,11 @@ if (*ptr == val) return; - if (obj->getFile() && (idx = obj->getIndex()) != -1) + if (obj->getFile() && (idx = obj->lineNumber()) != -1) { - QString before = obj->raw(); + QString before = obj->asText(); *ptr = val; - QString after = obj->raw(); + QString after = obj->asText(); if (before != after) obj->getFile()->addToHistory (new EditHistory (idx, before, after)); @@ -679,7 +679,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -const Vertex& LDObject::getVertex (int i) const +const Vertex& LDObject::vertex (int i) const { return m_coords[i]->data(); } @@ -830,6 +830,6 @@ } */ - LDObject* copy = parseLine (raw()); + LDObject* copy = parseLine (asText()); return copy; } \ No newline at end of file
--- a/src/LDObject.h Mon Feb 24 00:25:18 2014 +0200 +++ b/src/LDObject.h Wed Mar 05 02:24:05 2014 +0200 @@ -31,14 +31,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) @@ -103,16 +103,16 @@ void deleteSelf(); // 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; @@ -133,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); @@ -349,7 +349,7 @@ class LDBFC : public LDObject { public: - enum Type + enum Statement { CertifyCCW, CCW, @@ -368,18 +368,18 @@ LDOBJ_NAME (bfc) LDOBJ_VERTICES (0) LDOBJ_UNCOLORED - LDOBJ_CUSTOM_SCEMANTIC { return (type == InvertNext); } + LDOBJ_CUSTOM_SCEMANTIC { return (m_statement == InvertNext); } LDOBJ_NO_MATRIX public: LDBFC() {} - LDBFC (const LDBFC::Type type) : - type (type) {} + LDBFC (const LDBFC::Statement type) : + m_statement (type) {} // Statement strings - static const char* statements[]; + static const char* k_statementStrings[]; - Type type; + Statement m_statement; }; // =============================================================================
--- a/src/MainWindow.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/MainWindow.cc Wed Mar 05 02:24:05 2014 +0200 @@ -268,7 +268,7 @@ title += fmt (": <anonymous>"); if (getCurrentDocument()->getObjectCount() > 0 && - getCurrentDocument()->getObject (0)->getType() == LDObject::EComment) + getCurrentDocument()->getObject (0)->type() == LDObject::EComment) { // Append title LDComment* comm = static_cast<LDComment*> (getCurrentDocument()->getObject (0)); @@ -330,7 +330,7 @@ { QString descr; - switch (obj->getType()) + switch (obj->type()) { case LDObject::EComment: { @@ -339,7 +339,9 @@ // Remove leading whitespace while (descr[0] == ' ') descr.remove (0, 1); - } break; + + break; + } case LDObject::EEmpty: break; // leave it empty @@ -354,19 +356,22 @@ if (i != 0) descr += ", "; - descr += obj->getVertex (i).toString (true); + descr += obj->vertex (i).toString (true); } - } break; + break; + } case LDObject::EError: { - descr = fmt ("ERROR: %1", obj->raw()); - } break; + descr = fmt ("ERROR: %1", obj->asText()); + break; + } case LDObject::EVertex: { descr = static_cast<LDVertex*> (obj)->pos.toString (true); - } break; + break; + } case LDObject::ESubfile: { @@ -378,12 +383,14 @@ descr += fmt ("%1%2", ref->getTransform()[i], (i != 8) ? " " : ""); descr += ')'; - } break; + break; + } case LDObject::EBFC: { - descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type]; - } break; + descr = LDBFC::k_statementStrings[static_cast<LDBFC*> (obj)->m_statement]; + break; + } case LDObject::EOverlay: { @@ -391,17 +398,18 @@ descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()], basename (ovl->getFileName()), ovl->getX(), ovl->getY(), ovl->getWidth(), ovl->getHeight()); + break; } - break; default: { - descr = obj->getTypeName(); - } break; + descr = obj->typeName(); + break; + } } QListWidgetItem* item = new QListWidgetItem (descr); - item->setIcon (getIcon (obj->getTypeName())); + item->setIcon (getIcon (obj->typeName())); // Use italic font if hidden if (obj->isHidden()) @@ -412,7 +420,7 @@ } // Color gibberish orange on red so it stands out. - if (obj->getType() == LDObject::EError) + if (obj->type() == LDObject::EError) { item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); @@ -536,7 +544,7 @@ { // If we have a selection, put the item after it. if (!selection().isEmpty()) - return selection().last()->getIndex() + 1; + return selection().last()->lineNumber() + 1; // Otherwise place the object at the end. return getCurrentDocument()->getObjectCount(); @@ -615,7 +623,7 @@ return LDObject::EUnidentified; if (result == LDObject::EUnidentified) - result = obj->getType(); + result = obj->type(); } return result; @@ -648,7 +656,7 @@ QMenu* contextMenu = new QMenu; - if (single && singleObj->getType() != LDObject::EEmpty) + if (single && singleObj->type() != LDObject::EEmpty) { contextMenu->addAction (ui->actionEdit); contextMenu->addSeparator(); @@ -737,7 +745,7 @@ } } - AddObjectDialog::staticDialog (obj->getType(), obj); + AddObjectDialog::staticDialog (obj->type(), obj); } // =============================================================================
--- a/src/Types.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/Types.cc Wed Mar 05 02:24:05 2014 +0200 @@ -315,7 +315,7 @@ // ----------------------------------------------------------------------------- void LDBoundingBox::calcObject (LDObject* obj) { - switch (obj->getType()) + switch (obj->type()) { case LDObject::ELine: case LDObject::ETriangle: @@ -323,7 +323,7 @@ case LDObject::ECondLine: { for (int i = 0; i < obj->vertices(); ++i) - calcVertex (obj->getVertex (i)); + calcVertex (obj->vertex (i)); } break; case LDObject::ESubfile:
--- a/src/actions/EditActions.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/actions/EditActions.cc Wed Mar 05 02:24:05 2014 +0200 @@ -1,5 +1,5 @@ /* - * LDForge: LDraw parts authoring CAD + * LDForge: LDasText parts authoring CAD * Copyright (C) 2013, 2014 Santeri Piippo * * This program is free software: you can redistribute it and/or modify @@ -55,7 +55,7 @@ if (data.length() > 0) data += "\n"; - data += obj->raw(); + data += obj->asText(); ++num; } @@ -121,14 +121,14 @@ { // Get the index of the subfile so we know where to insert the // inlined contents. - long idx = obj->getIndex(); + long idx = obj->lineNumber(); if (idx == -1) continue; LDObjectList objs; - if (obj->getType() == LDObject::ESubfile) + if (obj->type() == LDObject::ESubfile) objs = static_cast<LDSubfile*> (obj)->inlineContents ( (LDSubfile::InlineFlags) ( (deep) ? LDSubfile::DeepInline : 0) | @@ -140,7 +140,7 @@ // Merge in the inlined objects for (LDObject * inlineobj : objs) { - QString line = inlineobj->raw(); + QString line = inlineobj->asText(); inlineobj->deleteSelf(); LDObject* newobj = parseLine (line); getCurrentDocument()->insertObj (idx++, newobj); @@ -174,11 +174,11 @@ for (LDObject* obj : objs) { - if (obj->getType() != LDObject::EQuad) + if (obj->type() != LDObject::EQuad) continue; // Find the index of this quad - long index = obj->getIndex(); + long index = obj->lineNumber(); if (index == -1) return; @@ -215,9 +215,9 @@ Ui::EditRawUI ui; ui.setupUi (dlg); - ui.code->setText (obj->raw()); + ui.code->setText (obj->asText()); - if (obj->getType() == LDObject::EError) + if (obj->type() == LDObject::EError) ui.errorDescription->setText (static_cast<LDError*> (obj)->reason); else { @@ -280,7 +280,7 @@ for (LDObject* obj : objs) { - const LDObject::Type type = obj->getType(); + const LDObject::Type type = obj->type(); if (type != LDObject::EQuad && type != LDObject::ETriangle) continue; @@ -292,24 +292,24 @@ numLines = 4; LDQuad* quad = static_cast<LDQuad*> (obj); - lines[0] = new LDLine (quad->getVertex (0), quad->getVertex (1)); - lines[1] = new LDLine (quad->getVertex (1), quad->getVertex (2)); - lines[2] = new LDLine (quad->getVertex (2), quad->getVertex (3)); - lines[3] = new LDLine (quad->getVertex (3), quad->getVertex (0)); + lines[0] = new LDLine (quad->vertex (0), quad->vertex (1)); + lines[1] = new LDLine (quad->vertex (1), quad->vertex (2)); + lines[2] = new LDLine (quad->vertex (2), quad->vertex (3)); + lines[3] = new LDLine (quad->vertex (3), quad->vertex (0)); } else { numLines = 3; LDTriangle* tri = static_cast<LDTriangle*> (obj); - lines[0] = new LDLine (tri->getVertex (0), tri->getVertex (1)); - lines[1] = new LDLine (tri->getVertex (1), tri->getVertex (2)); - lines[2] = new LDLine (tri->getVertex (2), tri->getVertex (0)); + lines[0] = new LDLine (tri->vertex (0), tri->vertex (1)); + lines[1] = new LDLine (tri->vertex (1), tri->vertex (2)); + lines[2] = new LDLine (tri->vertex (2), tri->vertex (0)); } for (int i = 0; i < numLines; ++i) { - long idx = obj->getIndex() + i + 1; + long idx = obj->lineNumber() + i + 1; lines[i]->setColor (edgecolor); getCurrentDocument()->insertObj (idx, lines[i]); @@ -334,15 +334,15 @@ if (obj->vertices() < 2) continue; - int idx = obj->getIndex(); + int ln = obj->lineNumber(); for (int i = 0; i < obj->vertices(); ++i) { LDVertex* vert = new LDVertex; - vert->pos = obj->getVertex (i); + vert->pos = obj->vertex (i); vert->setColor (obj->getColor()); - getCurrentDocument()->insertObj (++idx, vert); + getCurrentDocument()->insertObj (++ln, vert); R()->compileObject (vert); ++num; } @@ -493,7 +493,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - Vertex v = obj->getVertex (i); + Vertex v = obj->vertex (i); rotateVertex (v, rotpoint, transform); obj->setVertex (i, v); } @@ -510,7 +510,7 @@ // Transform the matrix mo->setTransform (transform * mo->getTransform()); } - elif (obj->getType() == LDObject::EVertex) + elif (obj->type() == LDObject::EVertex) { LDVertex* vert = static_cast<LDVertex*> (obj); Vertex v = vert->pos; @@ -588,7 +588,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - Vertex v = obj->getVertex (i); + Vertex v = obj->vertex (i); for_axes (ax) roundToDecimals (v[ax], 3); @@ -618,7 +618,7 @@ int col = maincolor; - if (obj->getType() == LDObject::ELine || obj->getType() == LDObject::ECondLine) + if (obj->type() == LDObject::ELine || obj->type() == LDObject::ECondLine) col = edgecolor; obj->setColor (col); @@ -657,7 +657,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - Vertex v = obj->getVertex (i); + Vertex v = obj->vertex (i); for (Axis ax : sel) { @@ -703,7 +703,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - Vertex v = obj->getVertex (i); + Vertex v = obj->vertex (i); for (Axis ax : sel) v[ax] *= -1; @@ -725,7 +725,7 @@ for (LDObject* obj : sel) { - if (obj->getType() != LDObject::ECondLine) + if (obj->type() != LDObject::ECondLine) continue; LDLine* repl = static_cast<LDCondLine*> (obj)->demote(); @@ -824,7 +824,7 @@ prevIsHistory = ishistory; } - int idx = obj ? obj->getIndex() : 0; + int idx = obj ? obj->lineNumber() : 0; getCurrentDocument()->insertObj (idx++, comm); // If we're adding a history line right before a scemantic object, pad it
--- a/src/actions/MainActions.cc Mon Feb 24 00:25:18 2014 +0200 +++ b/src/actions/MainActions.cc Wed Mar 05 02:24:05 2014 +0200 @@ -84,7 +84,7 @@ newFile(); - const LDBFC::Type BFCType = + const LDBFC::Statement BFCType = ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; @@ -258,7 +258,7 @@ return; LDObject* obj = selection() [0]; - AddObjectDialog::staticDialog (obj->getType(), obj); + AddObjectDialog::staticDialog (obj->type(), obj); } // ============================================================================= @@ -338,7 +338,7 @@ for (LDObject* obj : getCurrentDocument()->getObjects()) { - if (obj->getType() != type) + if (obj->type() != type) continue; if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) @@ -435,7 +435,7 @@ for (LDObject* obj : selection()) { - QString contents = obj->raw(); + QString contents = obj->asText(); QByteArray data = contents.toUtf8(); file.write (data, data.size()); file.write ("\r\n", 2); @@ -690,7 +690,7 @@ LDObject* obj; if (selection().size() == 1) - defval = selection()[0]->getIndex(); + defval = selection()[0]->lineNumber(); int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, 1, getCurrentDocument()->getObjectCount(), 1, &ok); @@ -713,7 +713,7 @@ QString parentpath = getCurrentDocument()->getFullPath(); // BFC type of the new subfile - it shall inherit the BFC type of the parent document - LDBFC::Type bfctype = LDBFC::NoCertify; + LDBFC::Statement bfctype = LDBFC::NoCertify; // Dirname of the new subfile QString subdirname = dirname (parentpath); @@ -734,7 +734,7 @@ QString fullsubname; // Where to insert the subfile reference? - int refidx = selection()[0]->getIndex(); + int refidx = selection()[0]->lineNumber(); // Determine title of subfile if (titleobj != null) @@ -802,7 +802,7 @@ if (!bfc) continue; - LDBFC::Type a = bfc->type; + LDBFC::Statement a = bfc->m_statement; if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) { @@ -813,7 +813,7 @@ // Get the body of the document in LDraw code for (LDObject* obj : selection()) - code << obj->raw(); + code << obj->asText(); // Create the new subfile document LDDocument* doc = new LDDocument;