Tue, 07 Jan 2014 11:56:26 +0200
- some cleanup
--- a/src/addObjectDialog.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/addObjectDialog.cc Tue Jan 07 11:56:26 2014 +0200 @@ -64,7 +64,7 @@ switch (type) { - case LDObject::Comment: + case LDObject::EComment: { le_comment = new QLineEdit; @@ -74,28 +74,28 @@ le_comment->setMinimumWidth (384); } break; - case LDObject::Line: + case LDObject::ELine: { coordCount = 6; } break; - case LDObject::Triangle: + case LDObject::ETriangle: { coordCount = 9; } break; - case LDObject::Quad: - case LDObject::CondLine: + case LDObject::EQuad: + case LDObject::ECondLine: { coordCount = 12; } break; - case LDObject::Vertex: + case LDObject::EVertex: { coordCount = 3; } break; - case LDObject::BFC: + case LDObject::EBFC: { rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); @@ -112,7 +112,7 @@ rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->type); } break; - case LDObject::Subfile: + case LDObject::ESubfile: { coordCount = 3; tw_subfileList = new QTreeWidget(); @@ -169,7 +169,7 @@ if (obj != null) colnum = obj->getColor(); else - colnum = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor; + colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; pb_color = new QPushButton; setButtonBackground (pb_color, colnum); @@ -189,10 +189,10 @@ switch (type) { - case LDObject::Line: - case LDObject::CondLine: - case LDObject::Triangle: - case LDObject::Quad: + case LDObject::ELine: + case LDObject::ECondLine: + case LDObject::ETriangle: + case LDObject::EQuad: // Apply coordinates if (obj) @@ -204,15 +204,15 @@ break; - case LDObject::Comment: + case LDObject::EComment: layout->addWidget (le_comment, 0, 1); break; - case LDObject::BFC: + case LDObject::EBFC: layout->addWidget (rb_bfcType, 0, 1); break; - case LDObject::Subfile: + case LDObject::ESubfile: layout->addWidget (tw_subfileList, 1, 1, 1, 2); layout->addWidget (lb_subfileName, 2, 1); layout->addWidget (le_subfileName, 2, 2); @@ -229,7 +229,7 @@ QLabel* lb_matrix = new QLabel ("Matrix:"); le_matrix = new QLineEdit; // le_matrix->setValidator (new QDoubleValidator); - matrix defaultMatrix = g_identity; + Matrix defaultMatrix = g_identity; if (mo) { @@ -328,14 +328,14 @@ setlocale (LC_ALL, "C"); // FIXME: Redirect to Edit Raw - if (obj && obj->getType() == LDObject::Error) + if (obj && obj->getType() == LDObject::EError) return; - if (type == LDObject::Empty) + if (type == LDObject::EEmpty) return; // Nothing to edit with empties const bool newObject = (obj == null); - matrix transform = g_identity; + Matrix transform = g_identity; AddObjectDialog dlg (type, obj); assert (!obj || obj->getType() == type); @@ -343,7 +343,7 @@ if (dlg.exec() == false) return; - if (type == LDObject::Subfile) + if (type == LDObject::ESubfile) { QStringList matrixstrvals = dlg.le_matrix->text().split (" ", QString::SkipEmptyParts); @@ -355,30 +355,30 @@ for (str val : matrixstrvals) matrixvals[i++] = val.toFloat(); - transform = matrix (matrixvals); + transform = Matrix (matrixvals); } } switch (type) { - case LDObject::Comment: + case LDObject::EComment: { LDComment* comm = initObj<LDComment> (obj); comm->text = dlg.le_comment->text(); } break; - case LDObject::Line: - case LDObject::Triangle: - case LDObject::Quad: - case LDObject::CondLine: + case LDObject::ELine: + case LDObject::ETriangle: + case LDObject::EQuad: + case LDObject::ECondLine: { if (!obj) obj = LDObject::getDefault (type); for (int i = 0; i < obj->vertices(); ++i) { - vertex v; + Vertex v; for_axes (ax) v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); @@ -387,13 +387,13 @@ } } break; - case LDObject::BFC: + case LDObject::EBFC: { LDBFC* bfc = initObj<LDBFC> (obj); bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); } break; - case LDObject::Vertex: + case LDObject::EVertex: { LDVertex* vert = initObj<LDVertex> (obj); @@ -402,7 +402,7 @@ } break; - case LDObject::Subfile: + case LDObject::ESubfile: { str name = dlg.le_subfileName->text();
--- a/src/document.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/document.cc Tue Jan 07 11:56:26 2014 +0200 @@ -360,7 +360,7 @@ LDObject* obj = parseLine (line); // Check for parse errors and warn about tthem - if (obj->getType() == LDObject::Error) + if (obj->getType() == LDObject::EError) { log ("Couldn't parse line #%1: %2", getProgress() + 1, static_cast<LDError*> (obj)->reason); @@ -677,7 +677,7 @@ LDComment* fpathComment = null; LDObject* first = getObject (1); - if (!isImplicit() && first != null && first->getType() == LDObject::Comment) + if (!isImplicit() && first != null && first->getType() == LDObject::EComment) { fpathComment = static_cast<LDComment*> (first); @@ -751,9 +751,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static vertex parseVertex (QStringList& s, const int n) +static Vertex parseVertex (QStringList& s, const int n) { - vertex v; + Vertex v; for_axes (ax) v[ax] = s[n + ax].toDouble(); @@ -880,7 +880,7 @@ obj->setColor (tokens[1].toLong()); obj->setPosition (parseVertex (tokens, 2)); // 2 - 4 - matrix transform; + Matrix transform; for (int i = 0; i < 9; ++i) transform[i] = tokens[i + 5].toDouble(); // 5 - 13 @@ -979,7 +979,7 @@ // Go through all objects in the current file and reload the subfiles for (LDObject* obj : getCurrentDocument()->getObjects()) { - if (obj->getType() == LDObject::Subfile) + if (obj->getType() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); LDDocument* fileInfo = getDocument (ref->getFileInfo()->getName()); @@ -992,7 +992,7 @@ // Reparse gibberish files. It could be that they are invalid because // of loading errors. Circumstances may be different now. - if (obj->getType() == LDObject::Error) + if (obj->getType() == LDObject::EError) obj->replace (parseLine (static_cast<LDError*> (obj)->contents)); } } @@ -1004,7 +1004,7 @@ getHistory()->add (new AddHistory (getObjects().size(), obj)); m_Objects << obj; - if (obj->getType() == LDObject::Vertex) + if (obj->getType() == LDObject::EVertex) m_Vertices << obj; #ifdef DEBUG @@ -1175,7 +1175,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::Subfile) + if (deep && obj->getType() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj);
--- a/src/extprogs.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/extprogs.cc Tue Jan 07 11:56:26 2014 +0200 @@ -170,7 +170,7 @@ { for (LDObject* obj : objects) { - if (obj->getType() == LDObject::Subfile) + if (obj->getType() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepInline);
--- a/src/gldraw.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gldraw.cc Tue Jan 07 11:56:26 2014 +0200 @@ -52,7 +52,7 @@ // Matrix templates for circle drawing. 2 is substituted with // the scale value, 1 is inverted to -1 if needed. -static const matrix g_circleDrawTransforms[3] = +static const Matrix g_circleDrawTransforms[3] = { { 2, 0, 0, 0, 1, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 2, 0, 1, 0 }, @@ -101,12 +101,12 @@ const struct LDGLAxis { const QColor col; - const vertex vert; + const Vertex vert; } g_GLAxes[3] = { - { QColor (255, 0, 0), vertex (10000, 0, 0) }, // X - { QColor (80, 192, 0), vertex (0, 10000, 0) }, // Y - { QColor (0, 160, 192), vertex (0, 0, 10000) }, // Z + { QColor (255, 0, 0), Vertex (10000, 0, 0) }, // X + { QColor (80, 192, 0), Vertex (0, 10000, 0) }, // Y + { QColor (0, 160, 192), Vertex (0, 0, 10000) }, // Z }; static bool g_glInvert = false; @@ -319,8 +319,8 @@ } if ((list == BFCFrontList || list == BFCBackList) && - obj->getType() != LDObject::Line && - obj->getType() != LDObject::CondLine) + obj->getType() != LDObject::ELine && + obj->getType() != LDObject::ECondLine) { if (list == GL::BFCFrontList) qcol = QColor (40, 192, 0); @@ -514,11 +514,11 @@ // This converts a 2D point on the screen to a 3D point in the model. If 'snap' // is true, the 3D point will snap to the current grid. // ----------------------------------------------------------------------------- -vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const +Vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const { assert (camera() != EFreeCamera); - vertex pos3d; + Vertex pos3d; const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; const Axis axisX = cam->axisX; const Axis axisY = cam->axisY; @@ -553,7 +553,7 @@ // Inverse operation for the above - convert a 3D position to a 2D screen // position. Don't ask me how this code manages to work, I don't even know. // ----------------------------------------------------------------------------- -QPoint GLRenderer::coordconv3_2 (const vertex& pos3d) const +QPoint GLRenderer::coordconv3_2 (const Vertex& pos3d) const { GLfloat m[16]; const LDFixedCameraInfo* cam = &g_FixedCameras[m_camera]; @@ -568,7 +568,7 @@ const double y = pos3d.y(); const double z = pos3d.z(); - vertex transformed; + Vertex transformed; transformed[X] = (m[0] * x) + (m[1] * y) + (m[2] * z) + m[3]; transformed[Y] = (m[4] * x) + (m[5] * y) + (m[6] * z) + m[7]; transformed[Z] = (m[8] * x) + (m[9] * y) + (m[10] * z) + m[11]; @@ -635,7 +635,7 @@ if (getEditMode() == EDrawMode) { QPoint poly[4]; - vertex poly3d[4]; + Vertex poly3d[4]; int numverts = 4; // Calculate polygon data @@ -644,7 +644,7 @@ numverts = m_drawedVerts.size() + 1; int i = 0; - for (vertex& vert : m_drawedVerts) + for (Vertex& vert : m_drawedVerts) poly3d[i++] = vert; // Draw the cursor vertex as the last one in the list. @@ -729,7 +729,7 @@ drawBlip (paint, coordconv3_2 (m_hoverpos)); else { - QVector<vertex> verts, verts2; + QVector<Vertex> verts, verts2; const double dist0 = getCircleDrawDist (0), dist1 = (m_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; const int segs = lores; @@ -742,7 +742,7 @@ // Calculate the preview positions of vertices for (int i = 0; i < segs; ++i) { - vertex v = g_origin; + Vertex v = g_origin; v[relX] = m_drawedVerts[0][relX] + (cos (i * angleUnit) * dist0); v[relY] = m_drawedVerts[0][relY] + (sin (i * angleUnit) * dist0); verts << v; @@ -756,7 +756,7 @@ } int i = 0; - for (const vertex& v : verts + verts2) + for (const Vertex& v : verts + verts2) { // Calculate the 2D point of the vertex QPoint point = coordconv3_2 (v); @@ -942,7 +942,7 @@ { glBegin (gltype); - const int numverts = (obj->getType() != LDObject::CondLine) ? obj->vertices() : 2; + const int numverts = (obj->getType() != LDObject::ECondLine) ? obj->vertices() : 2; if (g_glInvert == false) for (int i = 0; i < numverts; ++i) @@ -962,12 +962,12 @@ switch (obj->getType()) { - case LDObject::Line: + case LDObject::ELine: { compileSubObject (obj, GL_LINES); } break; - case LDObject::CondLine: + case LDObject::ECondLine: { // Draw conditional lines with a dash pattern - however, use a full // line when drawing a pick list to make selecting them easier. @@ -982,17 +982,17 @@ glDisable (GL_LINE_STIPPLE); } break; - case LDObject::Triangle: + case LDObject::ETriangle: { compileSubObject (obj, GL_TRIANGLES); } break; - case LDObject::Quad: + case LDObject::EQuad: { compileSubObject (obj, GL_QUADS); } break; - case LDObject::Subfile: + case LDObject::ESubfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); QList<LDObject*> objs; @@ -1008,7 +1008,7 @@ LDObject* prev = ref->prev(); - if (prev && prev->getType() == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) + if (prev && prev->getType() == LDObject::EBFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext) g_glInvert = !g_glInvert; for (LDObject* obj : objs) @@ -1027,7 +1027,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void GLRenderer::compileVertex (const vertex& vrt) +void GLRenderer::compileVertex (const Vertex& vrt) { glVertex3d (vrt[X], -vrt[Y], -vrt[Z]); } @@ -1045,12 +1045,12 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void GLRenderer::addDrawnVertex (vertex pos) +void GLRenderer::addDrawnVertex (Vertex pos) { // If we picked an already-existing vertex, stop drawing if (getEditMode() == EDrawMode) { - for (vertex& vert : m_drawedVerts) + for (Vertex& vert : m_drawedVerts) { if (vert == pos) { @@ -1153,12 +1153,12 @@ { // Find the closest vertex to our cursor double mindist = 1024.0f; - vertex closest; + Vertex closest; bool valid = false; QPoint curspos = coordconv3_2 (m_hoverpos); - for (const vertex& pos3d: m_knownVerts) + for (const Vertex& pos3d: m_knownVerts) { QPoint pos2d = coordconv3_2 (pos3d); @@ -1489,9 +1489,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -matrix GLRenderer::getCircleDrawMatrix (double scale) +Matrix GLRenderer::getCircleDrawMatrix (double scale) { - matrix transform = g_circleDrawTransforms[camera() % 3]; + Matrix transform = g_circleDrawTransforms[camera() % 3]; for (int i = 0; i < 9; ++i) { @@ -1511,7 +1511,7 @@ (void) accept; // Clean the selection and create the object - QList<vertex>& verts = m_drawedVerts; + QList<Vertex>& verts = m_drawedVerts; QList<LDObject*> objs; switch (getEditMode()) @@ -1576,7 +1576,7 @@ double dist0 = getCircleDrawDist (0), dist1 = getCircleDrawDist (1); LDDocument* refFile = null; - matrix transform; + Matrix transform; bool circleOrDisc = false; if (dist1 < dist0) @@ -1627,7 +1627,7 @@ double x0 = m_drawedVerts[0][relX], y0 = m_drawedVerts[0][relY]; - vertex templ; + Vertex templ; templ[relX] = x0; templ[relY] = y0; templ[relZ] = getDepthValue(); @@ -1638,7 +1638,7 @@ for (int i = 0; i < segs; ++i) { - vertex v0, v1, v2, v3; + Vertex v0, v1, v2, v3; v0 = v1 = v2 = v3 = templ; v0[relX] += c0[i].x1(); v0[relY] += c0[i].y1(); @@ -1700,7 +1700,7 @@ double GLRenderer::getCircleDrawDist (int pos) const { assert (m_drawedVerts.size() >= pos + 1); - const vertex& v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : m_hoverpos; + const Vertex& v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : m_hoverpos; Axis relX, relY; getRelativeAxes (relX, relY); @@ -1720,15 +1720,15 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static QList<vertex> getVertices (LDObject* obj) +static QList<Vertex> getVertices (LDObject* obj) { - QList<vertex> verts; + QList<Vertex> verts; if (obj->vertices() >= 2) { for (int i = 0; i < obj->vertices(); ++i) verts << obj->getVertex (i); - } elif (obj->getType() == LDObject::Subfile) + } elif (obj->getType() == LDObject::ESubfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline); @@ -1764,7 +1764,7 @@ } // Mark in known vertices of this object - QList<vertex> verts = getVertices (obj); + QList<Vertex> verts = getVertices (obj); m_knownVerts << verts; removeDuplicates (m_knownVerts); @@ -2058,7 +2058,7 @@ return; } - vertex v0 = m_drawedVerts[0], + Vertex v0 = m_drawedVerts[0], v1 = (m_drawedVerts.size() >= 2) ? m_drawedVerts[1] : m_hoverpos; const Axis ax = getCameraAxis (false), @@ -2104,7 +2104,7 @@ for (LDObject* obj : getFile()->getObjects()) { - if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) + if (obj->getType() == LDObject::EOverlay && static_cast<LDOverlay*> (obj)->getCamera() == cam) { ovlobj = static_cast<LDOverlay*> (obj); break; @@ -2155,7 +2155,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::Empty) + if (nextobj && nextobj->getType() == LDObject::EEmpty) nextobj->deleteSelf(); // If the overlay object was there and the overlay itself is @@ -2186,7 +2186,7 @@ break; } - if (obj->getType() == LDObject::Overlay) + if (obj->getType() == LDObject::EOverlay) lastOverlay = i; }
--- a/src/gldraw.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gldraw.h Tue Jan 07 11:56:26 2014 +0200 @@ -42,7 +42,7 @@ // Meta for overlays struct LDGLOverlay { - vertex v0, + Vertex v0, v1; int ox, oy; @@ -164,7 +164,7 @@ QTimer* m_toolTipTimer; Qt::MouseButtons m_lastButtons; Qt::KeyboardModifiers m_keymods; - vertex m_hoverpos; + Vertex m_hoverpos; double m_virtWidth, m_virtHeight, m_rotX[7], @@ -190,19 +190,19 @@ int m_width, m_height, m_totalmove; - QList<vertex> m_drawedVerts; + QList<Vertex> m_drawedVerts; bool m_rectdraw; - vertex m_rectverts[4]; + Vertex m_rectverts[4]; QColor m_bgcolor; double m_depthValues[6]; LDGLOverlay m_overlays[6]; - QList<vertex> m_knownVerts; + QList<Vertex> m_knownVerts; - void addDrawnVertex (vertex m_hoverpos); + void addDrawnVertex (Vertex m_hoverpos); LDOverlay* findOverlayObject (EFixedCamera cam); void updateRectVerts(); void getRelativeAxes (Axis& relX, Axis& relY) const; - matrix getCircleDrawMatrix (double scale); + Matrix getCircleDrawMatrix (double scale); void drawBlip (QPainter& paint, QPoint pos) const; // Compute geometry for camera icons @@ -221,13 +221,13 @@ void compileSubObject (LDObject* obj, const GLenum gltype); // Compile a single vertex to a list - void compileVertex (const vertex& vrt); + void compileVertex (const Vertex& vrt); // Convert a 2D point to a 3D point - vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; + Vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; // Convert a 3D point to a 2D point - QPoint coordconv3_2 (const vertex& pos3d) const; + QPoint coordconv3_2 (const Vertex& pos3d) const; // Perform object selection void pick (int mouseX, int mouseY);
--- a/src/gui.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gui.cc Tue Jan 07 11:56:26 2014 +0200 @@ -277,7 +277,7 @@ title += fmt (": <anonymous>"); if (getCurrentDocument()->getObjectCount() > 0 && - getCurrentDocument()->getObject (0)->getType() == LDObject::Comment) + getCurrentDocument()->getObject (0)->getType() == LDObject::EComment) { // Append title LDComment* comm = static_cast<LDComment*> (getCurrentDocument()->getObject (0)); @@ -337,7 +337,7 @@ switch (obj->getType()) { - case LDObject::Comment: + case LDObject::EComment: { descr = static_cast<LDComment*> (obj)->text; @@ -346,13 +346,13 @@ descr.remove (0, 1); } break; - case LDObject::Empty: + case LDObject::EEmpty: break; // leave it empty - case LDObject::Line: - case LDObject::Triangle: - case LDObject::Quad: - case LDObject::CondLine: + case LDObject::ELine: + case LDObject::ETriangle: + case LDObject::EQuad: + case LDObject::ECondLine: { for (int i = 0; i < obj->vertices(); ++i) { @@ -363,17 +363,17 @@ } } break; - case LDObject::Error: + case LDObject::EError: { descr = fmt ("ERROR: %1", obj->raw()); } break; - case LDObject::Vertex: + case LDObject::EVertex: { descr = static_cast<LDVertex*> (obj)->pos.stringRep (true); } break; - case LDObject::Subfile: + case LDObject::ESubfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); @@ -385,12 +385,12 @@ descr += ')'; } break; - case LDObject::BFC: + case LDObject::EBFC: { descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type]; } break; - case LDObject::Overlay: + case LDObject::EOverlay: { LDOverlay* ovl = static_cast<LDOverlay*> (obj); descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->getCamera()], @@ -417,7 +417,7 @@ } // Color gibberish orange on red so it stands out. - if (obj->getType() == LDObject::Error) + if (obj->getType() == LDObject::EError) { item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); @@ -612,14 +612,14 @@ // ----------------------------------------------------------------------------- LDObject::Type ForgeWindow::getUniformSelectedType() { - LDObject::Type result = LDObject::Unidentified; + LDObject::Type result = LDObject::EUnidentified; for (LDObject* obj : selection()) { - if (result != LDObject::Unidentified && obj->getColor() != result) - return LDObject::Unidentified; + if (result != LDObject::EUnidentified && obj->getColor() != result) + return LDObject::EUnidentified; - if (result == LDObject::Unidentified) + if (result == LDObject::EUnidentified) result = obj->getType(); } @@ -653,7 +653,7 @@ QMenu* contextMenu = new QMenu; - if (single && singleObj->getType() != LDObject::Empty) + if (single && singleObj->getType() != LDObject::EEmpty) { contextMenu->addAction (ui->actionEdit); contextMenu->addSeparator(); @@ -928,16 +928,6 @@ } } -void ForgeWindow::setStatusBarText (str text) -{ - statusBar()->showMessage (text); -} - -Ui_LDForgeUI* ForgeWindow::getInterface() const -{ - return ui; -} - void ForgeWindow::updateDocumentList() { ui->fileList->clear();
--- a/src/gui.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gui.h Tue Jan 07 11:56:26 2014 +0200 @@ -93,9 +93,6 @@ { Q_OBJECT - typedefs: - using ActionMethodType = void (ForgeWindow::*)(); - public: ForgeWindow(); void buildObjList(); @@ -130,9 +127,7 @@ m_quickColors = colors; } - void setStatusBarText (str text); void addMessage (str msg); - Ui_LDForgeUI* getInterface() const; void refreshObjectList(); void updateActionShortcuts(); KeySequenceConfig* shortcutForAction (QAction* act);
--- a/src/gui_actions.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gui_actions.cc Tue Jan 07 11:56:26 2014 +0200 @@ -198,56 +198,56 @@ // ----------------------------------------------------------------------------- DEFINE_ACTION (NewSubfile, 0) { - AddObjectDialog::staticDialog (LDObject::Subfile, null); + AddObjectDialog::staticDialog (LDObject::ESubfile, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewLine, 0) { - AddObjectDialog::staticDialog (LDObject::Line, null); + AddObjectDialog::staticDialog (LDObject::ELine, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewTriangle, 0) { - AddObjectDialog::staticDialog (LDObject::Triangle, null); + AddObjectDialog::staticDialog (LDObject::ETriangle, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewQuad, 0) { - AddObjectDialog::staticDialog (LDObject::Quad, null); + AddObjectDialog::staticDialog (LDObject::EQuad, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewCLine, 0) { - AddObjectDialog::staticDialog (LDObject::CondLine, null); + AddObjectDialog::staticDialog (LDObject::ECondLine, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewComment, 0) { - AddObjectDialog::staticDialog (LDObject::Comment, null); + AddObjectDialog::staticDialog (LDObject::EComment, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewBFC, 0) { - AddObjectDialog::staticDialog (LDObject::BFC, null); + AddObjectDialog::staticDialog (LDObject::EBFC, null); } // ============================================================================= // ----------------------------------------------------------------------------- DEFINE_ACTION (NewVertex, 0) { - AddObjectDialog::staticDialog (LDObject::Vertex, null); + AddObjectDialog::staticDialog (LDObject::EVertex, null); } // ============================================================================= @@ -318,14 +318,14 @@ LDObject::Type type = getUniformSelectedType(); - if (type == LDObject::Unidentified) + if (type == LDObject::EUnidentified) return; // If we're selecting subfile references, the reference filename must also // be uniform. str refName; - if (type == LDObject::Subfile) + if (type == LDObject::ESubfile) { refName = static_cast<LDSubfile*> (selection()[0])->getFileInfo()->getName(); @@ -341,7 +341,7 @@ if (obj->getType() != type) continue; - if (type == LDObject::Subfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) + if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) continue; obj->select();
--- a/src/gui_editactions.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/gui_editactions.cc Tue Jan 07 11:56:26 2014 +0200 @@ -129,7 +129,7 @@ QList<LDObject*> objs; - if (obj->getType() == LDObject::Subfile) + if (obj->getType() == LDObject::ESubfile) objs = static_cast<LDSubfile*> (obj)->inlineContents ( (LDSubfile::InlineFlags) ( (deep) ? LDSubfile::DeepInline : 0) | @@ -175,7 +175,7 @@ for (LDObject* obj : objs) { - if (obj->getType() != LDObject::Quad) + if (obj->getType() != LDObject::EQuad) continue; // Find the index of this quad @@ -218,7 +218,7 @@ ui.setupUi (dlg); ui.code->setText (obj->raw()); - if (obj->getType() == LDObject::Error) + if (obj->getType() == LDObject::EError) ui.errorDescription->setText (static_cast<LDError*> (obj)->reason); else { @@ -282,13 +282,13 @@ for (LDObject* obj : objs) { const LDObject::Type type = obj->getType(); - if (type != LDObject::Quad && type != LDObject::Triangle) + if (type != LDObject::EQuad && type != LDObject::ETriangle) continue; int numLines; LDLine* lines[4]; - if (type == LDObject::Quad) + if (type == LDObject::EQuad) { numLines = 4; @@ -388,7 +388,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void doMoveObjects (vertex vect) +void doMoveObjects (Vertex vect) { // Apply the grid values vect[X] *= *currentGrid().confs[Grid::X]; @@ -453,7 +453,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -static void rotateVertex (vertex& v, const vertex& rotpoint, const matrix& transform) +static void rotateVertex (Vertex& v, const Vertex& rotpoint, const Matrix& transform) { v.move (-rotpoint); v.transform (transform, g_origin); @@ -465,14 +465,14 @@ static void doRotate (const int l, const int m, const int n) { QList<LDObject*> sel = selection(); - QList<vertex*> queue; - const vertex rotpoint = rotPoint (sel); + QList<Vertex*> queue; + const Vertex rotpoint = rotPoint (sel); const double angle = (pi * *currentGrid().confs[Grid::Angle]) / 180, cosangle = cos (angle), sinangle = sin (angle); // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 - matrix transform ( + Matrix transform ( { (l* l * (1 - cosangle)) + cosangle, (m* l * (1 - cosangle)) - (n* sinangle), @@ -494,7 +494,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - vertex v = obj->getVertex (i); + Vertex v = obj->getVertex (i); rotateVertex (v, rotpoint, transform); obj->setVertex (i, v); } @@ -511,10 +511,10 @@ // Transform the matrix mo->setTransform (transform * mo->getTransform()); - } elif (obj->getType() == LDObject::Vertex) + } elif (obj->getType() == LDObject::EVertex) { LDVertex* vert = static_cast<LDVertex*> (obj); - vertex v = vert->pos; + Vertex v = vert->pos; rotateVertex (v, rotpoint, transform); vert->pos = v; } @@ -570,8 +570,8 @@ if (mo != null) { - vertex v = mo->getPosition(); - matrix t = mo->getTransform(); + Vertex v = mo->getPosition(); + Matrix t = mo->getTransform(); for_axes (ax) roundToDecimals (v[ax], 3); @@ -589,7 +589,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - vertex v = obj->getVertex (i); + Vertex v = obj->getVertex (i); for_axes (ax) roundToDecimals (v[ax], 3); @@ -619,7 +619,7 @@ int col = maincolor; - if (obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine) + if (obj->getType() == LDObject::ELine || obj->getType() == LDObject::ECondLine) col = edgecolor; obj->setColor (col); @@ -658,7 +658,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - vertex v = obj->getVertex (i); + Vertex v = obj->getVertex (i); for (Axis ax : sel) { @@ -704,7 +704,7 @@ { for (int i = 0; i < obj->vertices(); ++i) { - vertex v = obj->getVertex (i); + Vertex v = obj->getVertex (i); for (Axis ax : sel) v[ax] *= -1; @@ -726,7 +726,7 @@ for (LDObject* obj : sel) { - if (obj->getType() != LDObject::CondLine) + if (obj->getType() != LDObject::ECondLine) continue; LDLine* repl = static_cast<LDCondLine*> (obj)->demote();
--- a/src/history.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/history.h Tue Jan 07 11:56:26 2014 +0200 @@ -158,9 +158,9 @@ IMPLEMENT_HISTORY_TYPE (Move) QList<int> indices; - vertex dest; + Vertex dest; - MoveHistory (QList<int> indices, vertex dest) : + MoveHistory (QList<int> indices, Vertex dest) : indices (indices), dest (dest) {} };
--- a/src/ldtypes.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/ldtypes.cc Tue Jan 07 11:56:26 2014 +0200 @@ -1,11 +1,11 @@ /* * LDForge: LDraw parts authoring CAD - * Copyright( C) 2013, 2014 Santeri Piippo + * Copyright (C) 2013, 2014 Santeri Piippo * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or - * ( at your option) any later version. + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,9 +25,9 @@ #include "gldraw.h" #include "colors.h" -cfg( String, ld_defaultname, ""); -cfg( String, ld_defaultuser, ""); -cfg( Int, ld_defaultlicense, 0); +cfg (String, ld_defaultname, ""); +cfg (String, ld_defaultuser, ""); +cfg (Int, ld_defaultlicense, 0); // List of all LDObjects static QList<LDObject*> g_LDObjects; @@ -36,14 +36,14 @@ // LDObject constructors // ----------------------------------------------------------------------------- LDObject::LDObject() : - m_Hidden( false), - m_Selected( false), - m_Parent( null), - m_File( null), - m_GLInit( false), - qObjListEntry( null) + m_Hidden (false), + m_Selected (false), + m_Parent (null), + m_File (null), + m_GLInit (false), + qObjListEntry (null) { - memset( m_coords, 0, sizeof m_coords); + memset (m_coords, 0, sizeof m_coords); chooseID(); g_LDObjects << this; } @@ -54,15 +54,15 @@ { int32 id = 1; // 0 shalt be null - for( LDObject* obj : g_LDObjects) + for (LDObject* obj : g_LDObjects) { - assert( obj != this); + assert (obj != this); - if( obj->getID() >= id) + if (obj->getID() >= id) id = obj->getID() + 1; } - setID( id); + setID (id); } // ============================================================================= @@ -72,7 +72,7 @@ // ----------------------------------------------------------------------------- LDObject::Type LDObject::getType() const { - return LDObject::Unidentified; + return LDObject::EUnidentified; } bool LDObject::hasMatrix() const @@ -102,11 +102,11 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::setVertexCoord( int i, Axis ax, double value) +void LDObject::setVertexCoord (int i, Axis ax, double value) { - vertex v = getVertex( i); + Vertex v = getVertex (i); v[ax] = value; - setVertex( i, v); + setVertex (i, v); } LDError::LDError() {} @@ -115,14 +115,14 @@ // ----------------------------------------------------------------------------- str LDComment::raw() const { - return fmt( "0 %1", text); + return fmt ("0 %1", text); } // ============================================================================= // ----------------------------------------------------------------------------- str LDSubfile::raw() const { - str val = fmt( "1 %1 %2 ", getColor(), getPosition()); + str val = fmt ("1 %1 %2 ", getColor(), getPosition()); val += getTransform().stringRep(); val += ' '; val += getFileInfo()->getName(); @@ -133,10 +133,10 @@ // ----------------------------------------------------------------------------- str LDLine::raw() const { - str val = fmt( "2 %1", getColor()); + str val = fmt ("2 %1", getColor()); - for( int i = 0; i < 2; ++i) - val += fmt( " %1", getVertex( i)); + for (int i = 0; i < 2; ++i) + val += fmt (" %1", getVertex (i)); return val; } @@ -145,10 +145,10 @@ // ----------------------------------------------------------------------------- str LDTriangle::raw() const { - str val = fmt( "3 %1", getColor()); + str val = fmt ("3 %1", getColor()); - for( int i = 0; i < 3; ++i) - val += fmt( " %1", getVertex( i)); + for (int i = 0; i < 3; ++i) + val += fmt (" %1", getVertex (i)); return val; } @@ -157,10 +157,10 @@ // ----------------------------------------------------------------------------- str LDQuad::raw() const { - str val = fmt( "4 %1", getColor()); + str val = fmt ("4 %1", getColor()); - for( int i = 0; i < 4; ++i) - val += fmt( " %1", getVertex( i)); + for (int i = 0; i < 4; ++i) + val += fmt (" %1", getVertex (i)); return val; } @@ -169,11 +169,11 @@ // ----------------------------------------------------------------------------- str LDCondLine::raw() const { - str val = fmt( "5 %1", getColor()); + str val = fmt ("5 %1", getColor()); // Add the coordinates - for( int i = 0; i < 4; ++i) - val += fmt( " %1", getVertex( i)); + for (int i = 0; i < 4; ++i) + val += fmt (" %1", getVertex (i)); return val; } @@ -189,7 +189,7 @@ // ----------------------------------------------------------------------------- str LDVertex::raw() const { - return fmt( "0 !LDFORGE VERTEX %1 %2", getColor(), pos); + return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos); } // ============================================================================= @@ -217,7 +217,7 @@ str LDBFC::raw() const { - return fmt( "0 BFC %1", LDBFC::statements[type]); + return fmt ("0 BFC %1", LDBFC::statements[type]); } // ============================================================================= @@ -230,12 +230,12 @@ // | | ==> | / / | // | | |/ / | // 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 (getVertex (0), getVertex (1), getVertex (3)); + LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3)); // The triangles also inherit the quad's color - tri1->setColor( getColor()); - tri2->setColor( getColor()); + tri1->setColor (getColor()); + tri2->setColor (getColor()); QList<LDTriangle*> triangles; triangles << tri1; @@ -245,13 +245,13 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::replace( LDObject* other) +void LDObject::replace (LDObject* other) { long idx = getIndex(); - assert( idx != -1); + assert (idx != -1); // Replace the instance of the old object with the new object - getFile()->setObject( idx, other); + getFile()->setObject (idx, other); // Remove the old object deleteSelf(); @@ -259,28 +259,28 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::swap( LDObject* other) +void LDObject::swap (LDObject* other) { - assert( getFile() == other->getFile()); - getFile()->swapObjects( this, other); + assert (getFile() == other->getFile()); + getFile()->swapObjects (this, other); } // ============================================================================= // ----------------------------------------------------------------------------- -LDLine::LDLine( vertex v1, vertex v2) +LDLine::LDLine (Vertex v1, Vertex v2) { - setVertex( 0, v1); - setVertex( 1, v2); + setVertex (0, v1); + setVertex (1, v2); } // ============================================================================= // ----------------------------------------------------------------------------- -LDQuad::LDQuad( const vertex& v0, const vertex& v1, const vertex& v2, const vertex& v3) +LDQuad::LDQuad (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3) { - setVertex( 0, v0); - setVertex( 1, v1); - setVertex( 2, v2); - setVertex( 3, v3); + setVertex (0, v0); + setVertex (1, v1); + setVertex (2, v2); + setVertex (3, v3); } // ============================================================================= @@ -296,51 +296,51 @@ void LDObject::deleteSelf() { // If this object was selected, unselect it now - if( isSelected()) + if (isSelected()) unselect(); // If this object was associated to a file, remove it off it now - if( getFile()) - getFile()->forgetObject( this); + if (getFile()) + getFile()->forgetObject (this); // Delete the GL lists - GL::deleteLists( this); + GL::deleteLists (this); // Remove this object from the list of LDObjects - g_LDObjects.removeOne( this); + g_LDObjects.removeOne (this); delete this; } // ============================================================================= // ----------------------------------------------------------------------------- -static void transformObject( LDObject* obj, matrix transform, vertex pos, int parentcolor) +static void transformObject (LDObject* obj, Matrix transform, Vertex pos, int parentcolor) { - switch( obj->getType()) + switch (obj->getType()) { - case LDObject::Line: - case LDObject::CondLine: - case LDObject::Triangle: - case LDObject::Quad: + case LDObject::ELine: + case LDObject::ECondLine: + case LDObject::ETriangle: + case LDObject::EQuad: - for( int i = 0; i < obj->vertices(); ++i) + for (int i = 0; i < obj->vertices(); ++i) { - vertex v = obj->getVertex( i); - v.transform( transform, pos); - obj->setVertex( i, v); + Vertex v = obj->getVertex (i); + v.transform (transform, pos); + obj->setVertex (i, v); } break; - case LDObject::Subfile: + case LDObject::ESubfile: { - LDSubfile* ref = static_cast<LDSubfile*>( obj); - matrix newMatrix = transform * ref->getTransform(); - vertex newpos = ref->getPosition(); + LDSubfile* ref = static_cast<LDSubfile*> (obj); + Matrix newMatrix = transform * ref->getTransform(); + Vertex newpos = ref->getPosition(); - newpos.transform( transform, pos); - ref->setPosition( newpos); - ref->setTransform( newMatrix); + newpos.transform (transform, pos); + ref->setPosition (newpos); + ref->setTransform (newMatrix); } break; @@ -348,22 +348,22 @@ break; } - if( obj->getColor() == maincolor) - obj->setColor( parentcolor); + if (obj->getColor() == maincolor) + obj->setColor (parentcolor); } // ============================================================================= // ----------------------------------------------------------------------------- -QList<LDObject*> LDSubfile::inlineContents( InlineFlags flags) +QList<LDObject*> LDSubfile::inlineContents (InlineFlags flags) { - QList<LDObject*> objs = getFileInfo()->inlineContents( flags); + QList<LDObject*> objs = getFileInfo()->inlineContents (flags); // Transform the objects - for( LDObject* obj : objs) + for (LDObject* obj : objs) { // Set the parent now so we know what inlined the object. - obj->setParent( this); - transformObject( obj, getTransform(), getPosition(), getColor()); + obj->setParent (this); + transformObject (obj, getTransform(), getPosition(), getColor()); } return objs; @@ -373,10 +373,10 @@ // ----------------------------------------------------------------------------- long LDObject::getIndex() const { - assert( getFile() != null); + assert (getFile() != null); - for( int i = 0; i < getFile()->getObjectCount(); ++i) - if( getFile()->getObject( i) == this) + for (int i = 0; i < getFile()->getObjectCount(); ++i) + if (getFile()->getObject (i) == this) return i; return -1; @@ -384,53 +384,53 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::moveObjects( QList<LDObject*> objs, const bool up) +void LDObject::moveObjects (QList<LDObject*> objs, const bool up) { - if( objs.isEmpty()) + if (objs.isEmpty()) return; // If we move down, we need to iterate the array in reverse order. - const long start = up ? 0 :( objs.size() - 1); + const long start = up ? 0 : (objs.size() - 1); const long end = up ? objs.size() : -1; const long incr = up ? 1 : -1; QList<LDObject*> objsToCompile; LDDocument* file = objs[0]->getFile(); - for( long i = start; i != end; i += incr) + for (long i = start; i != end; i += incr) { LDObject* obj = objs[i]; const long idx = obj->getIndex(), - target = idx +( up ? -1 : 1); + target = idx + (up ? -1 : 1); - if( ( up && idx == 0) ||( !up && idx ==( long)( file->getObjects().size() - 1))) + if ( (up && idx == 0) || (!up && idx == (long) (file->getObjects().size() - 1))) { // One of the objects hit the extrema. If this happens, this should be the first // object to be iterated on. Thus, nothing has changed yet and it's safe to just // abort the entire operation. - assert( i == start); + assert (i == start); return; } objsToCompile << obj; - objsToCompile << file->getObject( target); + objsToCompile << file->getObject (target); - obj->swap( file->getObject( target)); + obj->swap (file->getObject (target)); } - removeDuplicates( objsToCompile); + removeDuplicates (objsToCompile); // The objects need to be recompiled, otherwise their pick lists are left with // the wrong index colors which messes up selection. - for( LDObject* obj : objsToCompile) - g_win->R()->compileObject( obj); + for (LDObject* obj : objsToCompile) + g_win->R()->compileObject (obj); } // ============================================================================= // ----------------------------------------------------------------------------- -str LDObject::typeName( LDObject::Type type) +str LDObject::typeName (LDObject::Type type) { - LDObject* obj = LDObject::getDefault( type); + LDObject* obj = LDObject::getDefault (type); str name = obj->getTypeName(); obj->deleteSelf(); return name; @@ -438,36 +438,36 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str LDObject::describeObjects( const QList<LDObject*>& objs) +str LDObject::describeObjects (const QList<LDObject*>& objs) { bool firstDetails = true; str text = ""; - if( objs.isEmpty()) + if (objs.isEmpty()) return "nothing"; // :) - for( long i = 0; i < LDObject::NumTypes; ++i) + for (long i = 0; i < ENumTypes; ++i) { - LDObject::Type objType =( LDObject::Type) i; + Type objType = (Type) i; int count = 0; - for( LDObject * obj : objs) - if( obj->getType() == objType) + for (LDObject * obj : objs) + if (obj->getType() == objType) count++; - if( count == 0) + if (count == 0) continue; - if( !firstDetails) + if (!firstDetails) text += ", "; - str noun = fmt( "%1%2", typeName( objType), plural( count)); + str noun = fmt ("%1%2", typeName (objType), plural (count)); // Plural of "vertex" is "vertices", correct that - if( objType == LDObject::Vertex && count != 1) + if (objType == EVertex && count != 1) noun = "vertices"; - text += fmt( "%1 %2", count, noun); + text += fmt ("%1 %2", count, noun); firstDetails = false; } @@ -478,12 +478,12 @@ // ----------------------------------------------------------------------------- LDObject* LDObject::topLevelParent() { - if( !getParent()) + if (!getParent()) return this; LDObject* it = this; - while( it->getParent()) + while (it->getParent()) it = it->getParent(); return it; @@ -494,12 +494,12 @@ LDObject* LDObject::next() const { long idx = getIndex(); - assert( idx != -1); + assert (idx != -1); - if( idx ==( long) getFile()->getObjectCount() - 1) + if (idx == (long) getFile()->getObjectCount() - 1) return null; - return getFile()->getObject( idx + 1); + return getFile()->getObject (idx + 1); } // ============================================================================= @@ -507,55 +507,55 @@ LDObject* LDObject::prev() const { long idx = getIndex(); - assert( idx != -1); + assert (idx != -1); - if( idx == 0) + if (idx == 0) return null; - return getFile()->getObject( idx - 1); + return getFile()->getObject (idx - 1); } // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::move( vertex vect) +void LDObject::move (Vertex vect) { - if( hasMatrix()) + if (hasMatrix()) { - LDMatrixObject* mo = dynamic_cast<LDMatrixObject*>( this); - mo->setPosition( mo->getPosition() + vect); + LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); + mo->setPosition (mo->getPosition() + vect); } - elif( getType() == LDObject::Vertex) + elif (getType() == LDObject::EVertex) { // ugh - static_cast<LDVertex*>( this)->pos += vect; + static_cast<LDVertex*> (this)->pos += vect; } else { - for( int i = 0; i < vertices(); ++i) - setVertex( i, getVertex( i) + vect); + for (int i = 0; i < vertices(); ++i) + setVertex (i, getVertex (i) + vect); } } // ============================================================================= // ----------------------------------------------------------------------------- #define CHECK_FOR_OBJ(N) \ - if( type == LDObject::N) \ + if (type == LDObject::E##N) \ return new LD##N; -LDObject* LDObject::getDefault( const LDObject::Type type) +LDObject* LDObject::getDefault (const LDObject::Type type) { - CHECK_FOR_OBJ( Comment) - CHECK_FOR_OBJ( BFC) - CHECK_FOR_OBJ( Line) - CHECK_FOR_OBJ( CondLine) - CHECK_FOR_OBJ( Subfile) - CHECK_FOR_OBJ( Triangle) - CHECK_FOR_OBJ( Quad) - CHECK_FOR_OBJ( Empty) - CHECK_FOR_OBJ( BFC) - CHECK_FOR_OBJ( Error) - CHECK_FOR_OBJ( Vertex) - CHECK_FOR_OBJ( Overlay) + CHECK_FOR_OBJ (Comment) + CHECK_FOR_OBJ (BFC) + CHECK_FOR_OBJ (Line) + CHECK_FOR_OBJ (CondLine) + CHECK_FOR_OBJ (Subfile) + CHECK_FOR_OBJ (Triangle) + CHECK_FOR_OBJ (Quad) + CHECK_FOR_OBJ (Empty) + CHECK_FOR_OBJ (BFC) + CHECK_FOR_OBJ (Error) + CHECK_FOR_OBJ (Vertex) + CHECK_FOR_OBJ (Overlay) return null; } @@ -573,9 +573,9 @@ { // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. // Thus, we swap 1 and 2. - vertex tmp = getVertex( 1); - setVertex( 1, getVertex( 2)); - setVertex( 2, tmp); + Vertex tmp = getVertex (1); + setVertex (1, getVertex (2)); + setVertex (2, tmp); return; } @@ -587,9 +587,9 @@ // Quad: 0 -> 1 -> 2 -> 3 // rev: 0 -> 3 -> 2 -> 1 // Thus, we swap 1 and 3. - vertex tmp = getVertex( 1); - setVertex( 1, getVertex( 3)); - setVertex( 3, tmp); + Vertex tmp = getVertex (1); + setVertex (1, getVertex (3)); + setVertex (3, tmp); } // ============================================================================= @@ -604,11 +604,11 @@ int idx = getIndex(); - if( idx > 0) + if (idx > 0) { - LDBFC* bfc = dynamic_cast<LDBFC*>( prev()); + LDBFC* bfc = dynamic_cast<LDBFC*> (prev()); - if( bfc && bfc->type == LDBFC::InvertNext) + if (bfc && bfc->type == LDBFC::InvertNext) { // This is prefixed with an invertnext, thus remove it. bfc->deleteSelf(); @@ -617,29 +617,29 @@ } // Not inverted, thus prefix it with a new invertnext. - LDBFC* bfc = new LDBFC( LDBFC::InvertNext); - getFile()->insertObj( idx, bfc); + LDBFC* bfc = new LDBFC (LDBFC::InvertNext); + getFile()->insertObj (idx, bfc); } // ============================================================================= // ----------------------------------------------------------------------------- -static void invertLine( LDObject* line) +static void invertLine (LDObject* line) { // 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)); - line->setVertex( 1, tmp); + Vertex tmp = line->getVertex (0); + line->setVertex (0, line->getVertex (1)); + line->setVertex (1, tmp); } void LDLine::invert() { - invertLine( this); + invertLine (this); } void LDCondLine::invert() { - invertLine( this); + invertLine (this); } void LDVertex::invert() {} @@ -650,21 +650,21 @@ { LDLine* repl = new LDLine; - for( int i = 0; i < repl->vertices(); ++i) - repl->setVertex( i, getVertex( i)); + for (int i = 0; i < repl->vertices(); ++i) + repl->setVertex (i, getVertex (i)); - repl->setColor( getColor()); + repl->setColor (getColor()); - replace( repl); + replace (repl); return repl; } // ============================================================================= // ----------------------------------------------------------------------------- -LDObject* LDObject::fromID( int id) +LDObject* LDObject::fromID (int id) { - for( LDObject* obj : g_LDObjects) - if( obj->getID() == id) + for (LDObject* obj : g_LDObjects) + if (obj->getID() == id) return obj; return null; @@ -674,7 +674,7 @@ // ----------------------------------------------------------------------------- str LDOverlay::raw() const { - return fmt( "0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", + return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight()); } @@ -685,21 +685,21 @@ // It takes care of history management so we can capture low-level changes, this // makes history stuff work out of the box. // ----------------------------------------------------------------------------- -template<class T> static void changeProperty( LDObject* obj, T* ptr, const T& val) +template<class T> static void changeProperty (LDObject* obj, T* ptr, const T& val) { long idx; - if( *ptr == val) + if (*ptr == val) return; - if( obj->getFile() &&( idx = obj->getIndex()) != -1) + if (obj->getFile() && (idx = obj->getIndex()) != -1) { str before = obj->raw(); *ptr = val; str after = obj->raw(); - if( before != after) - obj->getFile()->addToHistory( new EditHistory( idx, before, after)); + if (before != after) + obj->getFile()->addToHistory (new EditHistory (idx, before, after)); } else *ptr = val; @@ -707,50 +707,50 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::setColor( const int& val) +void LDObject::setColor (const int& val) { - changeProperty( this, &m_Color, val); + changeProperty (this, &m_Color, val); } // ============================================================================= // ----------------------------------------------------------------------------- -const vertex& LDObject::getVertex( int i) const +const Vertex& LDObject::getVertex (int i) const { return m_coords[i]->data(); } // ============================================================================= // ----------------------------------------------------------------------------- -void LDObject::setVertex( int i, const vertex& vert) +void LDObject::setVertex (int i, const Vertex& vert) { - changeProperty( this, &m_coords[i], LDSharedVertex::getSharedVertex( vert)); + changeProperty (this, &m_coords[i], LDSharedVertex::getSharedVertex (vert)); } // ============================================================================= // ----------------------------------------------------------------------------- -void LDMatrixObject::setPosition( const vertex& a) +void LDMatrixObject::setPosition (const Vertex& a) { - changeProperty( getLinkPointer(), &m_Position, LDSharedVertex::getSharedVertex( a)); + changeProperty (getLinkPointer(), &m_Position, LDSharedVertex::getSharedVertex (a)); } // ============================================================================= // ----------------------------------------------------------------------------- -void LDMatrixObject::setTransform( const matrix& val) +void LDMatrixObject::setTransform (const Matrix& val) { - changeProperty( getLinkPointer(), &m_Transform, val); + changeProperty (getLinkPointer(), &m_Transform, val); } // ============================================================================= // ----------------------------------------------------------------------------- -static QMap<vertex, LDSharedVertex*> g_sharedVerts; +static QMap<Vertex, LDSharedVertex*> g_sharedVerts; -LDSharedVertex* LDSharedVertex::getSharedVertex( const vertex& a) +LDSharedVertex* LDSharedVertex::getSharedVertex (const Vertex& a) { - auto it = g_sharedVerts.find( a); + auto it = g_sharedVerts.find (a); - if( it == g_sharedVerts.end()) + if (it == g_sharedVerts.end()) { - LDSharedVertex* v = new LDSharedVertex( a); + LDSharedVertex* v = new LDSharedVertex (a); g_sharedVerts[a] = v; return v; } @@ -760,20 +760,20 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDSharedVertex::addRef( LDObject* a) +void LDSharedVertex::addRef (LDObject* a) { m_refs << a; } // ============================================================================= // ----------------------------------------------------------------------------- -void LDSharedVertex::delRef( LDObject* a) +void LDSharedVertex::delRef (LDObject* a) { - m_refs.removeOne( a); + m_refs.removeOne (a); - if( m_refs.empty()) + if (m_refs.empty()) { - g_sharedVerts.remove( m_data); + g_sharedVerts.remove (m_data); delete this; } } @@ -782,33 +782,33 @@ // ----------------------------------------------------------------------------- void LDObject::select() { - if( !getFile()) + if (!getFile()) { - log( "Warning: Object #%1 cannot be selected as it is not assigned a file!\n", getID()); + log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", getID()); return; } - getFile()->addToSelection( this); + getFile()->addToSelection (this); } // ============================================================================= // ----------------------------------------------------------------------------- void LDObject::unselect() { - if( !getFile()) + if (!getFile()) { - log( "Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", getID()); + log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", getID()); return; } - getFile()->removeFromSelection( this); + getFile()->removeFromSelection (this); } // ============================================================================= // ----------------------------------------------------------------------------- -str getLicenseText( int id) +str getLicenseText (int id) { - switch( id) + switch (id) { case 0: return CALicense; @@ -820,7 +820,7 @@ return ""; } - assert( false); + assert (false); return ""; } @@ -830,41 +830,41 @@ { /* LDObject* copy = clone(); - copy->setFile( null); - copy->setGLInit( false); + copy->setFile (null); + copy->setGLInit (false); copy->chooseID(); - copy->setSelected( false); + copy->setSelected (false); */ /* - LDObject* copy = getDefault( getType()); - copy->setColor( getColor()); + LDObject* copy = getDefault (getType()); + copy->setColor (getColor()); - if( hasMatrix()) + if (hasMatrix()) { - LDMatrixObject* copyMo = static_cast<LDMatrixObject*>( copy); - const LDMatrixObject* mo = static_cast<const LDMatrixObject*>( this); - copyMo->setPosition( mo->getPosition()); - copyMo->setTransform( mo->getTransform()); + LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy); + const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this); + copyMo->setPosition (mo->getPosition()); + copyMo->setTransform (mo->getTransform()); } else { - for( int i = 0; i < vertices(); ++i) - copy->setVertex( getVertex( i)); + for (int i = 0; i < vertices(); ++i) + copy->setVertex (getVertex (i)); } - switch( getType()) + switch (getType()) { case Subfile: { - LDSubfile* copyRef = static_cast<LDSubfile*>( copy); - const LDSubfile* ref = static_cast<const LDSubfile*>( this); + LDSubfile* copyRef = static_cast<LDSubfile*> (copy); + const LDSubfile* ref = static_cast<const LDSubfile*> (this); - copyRef->setFileInfo( ref->getFileInfo()); + copyRef->setFileInfo (ref->getFileInfo()); } } */ - LDObject* copy = parseLine( raw()); + LDObject* copy = parseLine (raw()); return copy; } \ No newline at end of file
--- a/src/ldtypes.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/ldtypes.h Tue Jan 07 11:56:26 2014 +0200 @@ -33,7 +33,7 @@ public: \ virtual LDObject::Type getType() const override \ { \ - return LDObject::T; \ + return LDObject::E##T; \ } \ virtual str raw() const override; \ virtual void invert() override; @@ -79,19 +79,19 @@ // Object type codes. Codes are sorted in order of significance. enum Type { - Subfile, // Object represents a sub-file reference - Quad, // Object represents a quadrilateral - Triangle, // Object represents a triangle - Line, // Object represents a line - CondLine, // Object represents a conditional line - Vertex, // Object is a vertex, LDForge extension object - BFC, // Object represents a BFC statement - Overlay, // Object contains meta-info about an overlay image. - Comment, // Object represents a comment - Error, // Object is the result of failed parsing - Empty, // Object represents an empty line - Unidentified, // Object is an uninitialized (SHOULD NEVER HAPPEN) - NumTypes // Amount of object types + 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, // Object is an uninitialized (SHOULD NEVER HAPPEN) + ENumTypes // Amount of object types }; LDObject(); @@ -109,7 +109,7 @@ virtual LDObject::Type getType() const; // Get a vertex by index - const vertex& getVertex (int i) const; + const Vertex& getVertex (int i) const; // Type name of this object virtual str getTypeName() const; @@ -127,7 +127,7 @@ virtual bool isScemantic() const; // Moves this object using the given vertex as a movement List - void move (vertex vect); + void move (Vertex vect); // Object after this in the current file LDObject* next() const; @@ -145,7 +145,7 @@ void select(); // Set a vertex to the given value - void setVertex (int i, const vertex& vert); + void setVertex (int i, const Vertex& vert); // Set a single coordinate of a vertex void setVertexCoord (int i, Axis ax, double value); @@ -165,8 +165,7 @@ // Get type name by enumerator static str typeName (LDObject::Type type); - // Returns a sample object by the given enumerator - // TODO: Use of this function only really results in hacks, get rid of it! + // Returns a default-constructed LDObject by the given type static LDObject* getDefault (const LDObject::Type type); // TODO: move this to LDDocument? @@ -206,12 +205,12 @@ class LDSharedVertex { public: - inline const vertex& data() const + inline const Vertex& data() const { return m_data; } - inline operator const vertex&() const + inline operator const Vertex&() const { return m_data; } @@ -219,14 +218,14 @@ void addRef (LDObject* a); void delRef (LDObject* a); - static LDSharedVertex* getSharedVertex (const vertex& a); + static LDSharedVertex* getSharedVertex (const Vertex& a); protected: - LDSharedVertex (const vertex& a) : m_data (a) {} + LDSharedVertex (const Vertex& a) : m_data (a) {} private: QList<LDObject*> m_refs; - vertex m_data; + Vertex m_data; }; // ============================================================================= @@ -247,29 +246,29 @@ class LDMatrixObject { PROPERTY (public, LDObject*, LinkPointer, NO_OPS, STOCK_WRITE) - PROPERTY (public, matrix, Transform, NO_OPS, CUSTOM_WRITE) + PROPERTY (public, Matrix, Transform, NO_OPS, CUSTOM_WRITE) public: LDMatrixObject() : m_Position (LDSharedVertex::getSharedVertex (g_origin)) {} - LDMatrixObject (const matrix& transform, const vertex& pos) : + LDMatrixObject (const Matrix& transform, const Vertex& pos) : m_Transform (transform), m_Position (LDSharedVertex::getSharedVertex (pos)) {} - inline const vertex& getPosition() const + inline const Vertex& getPosition() const { return m_Position->data(); } void setCoordinate (const Axis ax, double value) { - vertex v = getPosition(); + Vertex v = getPosition(); v[ax] = value; setPosition (v); } - void setPosition (const vertex& a); + void setPosition (const Vertex& a); private: LDSharedVertex* m_Position; @@ -442,7 +441,7 @@ public: LDLine() {} - LDLine (vertex v1, vertex v2); + LDLine (Vertex v1, Vertex v2); }; // ============================================================================= @@ -483,7 +482,7 @@ public: LDTriangle() {} - LDTriangle (vertex v0, vertex v1, vertex v2) + LDTriangle (Vertex v0, Vertex v1, Vertex v2) { setVertex (0, v0); setVertex (1, v1); @@ -508,7 +507,7 @@ public: LDQuad() {} - LDQuad (const vertex& v0, const vertex& v1, const vertex& v2, const vertex& v3); + LDQuad (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3); // Split this quad into two triangles (note: heap-allocated) QList<LDTriangle*> splitToTriangles(); @@ -534,7 +533,7 @@ public: LDVertex() {} - vertex pos; + Vertex pos; }; // =============================================================================
--- a/src/main.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/main.cc Tue Jan 07 11:56:26 2014 +0200 @@ -40,8 +40,8 @@ File g_file_stderr (stderr, File::Write); static str g_versionString, g_fullVersionString; -const vertex g_origin (0.0f, 0.0f, 0.0f); -const matrix g_identity ( {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); +const Vertex g_origin (0.0f, 0.0f, 0.0f); +const Matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); cfg (Bool, firststart, true);
--- a/src/main.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/main.h Tue Jan 07 11:56:26 2014 +0200 @@ -51,11 +51,11 @@ #include "config.h" #define APPNAME "LDForge" -#define UNIXNAME "ldforge" +#define UNIXNAME "ldforge" #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 999 -#define BUILD_ID BUILD_INTERNAL +#define BUILD_ID BUILD_INTERNAL #define BUILD_INTERNAL 0 #define BUILD_RELEASE 1
--- a/src/misc.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/misc.cc Tue Jan 07 11:56:26 2014 +0200 @@ -209,7 +209,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex rotPoint (const QList<LDObject*>& objs) +Vertex rotPoint (const QList<LDObject*>& objs) { LDBoundingBox box; @@ -234,11 +234,11 @@ case CustomPoint: { - return vertex (edit_rotpoint_x, edit_rotpoint_y, edit_rotpoint_z); + return Vertex (edit_rotpoint_x, edit_rotpoint_y, edit_rotpoint_z); } } - return vertex(); + return Vertex(); } // =============================================================================
--- a/src/misc.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/misc.h Tue Jan 07 11:56:26 2014 +0200 @@ -46,8 +46,8 @@ // Grid stuff struct gridinfo { - const char* const name; - float* const confs[4]; + const char* const name; + float* const confs[4]; }; extern_cfg (Int, grid); @@ -67,7 +67,7 @@ CustomPoint }; -vertex rotPoint (const QList<LDObject*>& objs); +Vertex rotPoint (const QList<LDObject*>& objs); void configRotationPoint(); // =============================================================================
--- a/src/misc/ringFinder.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/misc/ringFinder.cc Tue Jan 07 11:56:26 2014 +0200 @@ -133,7 +133,7 @@ { const Solution& sol = *solp; - if (m_bestSolution == null || sol > *m_bestSolution) + if (m_bestSolution == null || sol.isBetterThan (m_bestSolution)) m_bestSolution = / } @@ -142,15 +142,15 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool RingFinder::Solution::operator> (const RingFinder::Solution& other) const +bool RingFinder::Solution::isBetterThan (const Solution* other) const { // If this solution has less components than the other one, this one // is definitely better. - if (getComponents().size() < other.getComponents().size()) + if (getComponents().size() < other->getComponents().size()) return true; // vice versa - if (other.getComponents().size() < getComponents().size()) + if (other->getComponents().size() < getComponents().size()) return false; // Calculate the maximum ring number. Since the solutions have equal @@ -162,7 +162,7 @@ for (int i = 0; i < getComponents().size(); ++i) { maxA = max (getComponents()[i].num, maxA); - maxB = max (other.getComponents()[i].num, maxB); + maxB = max (other->getComponents()[i].num, maxB); } if (maxA < maxB)
--- a/src/misc/ringFinder.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/misc/ringFinder.h Tue Jan 07 11:56:26 2014 +0200 @@ -51,7 +51,7 @@ } // Compare solutions - bool operator> (const Solution& other) const; + bool isBetterThan (const Solution* other) const; private: QVector<Component> m_components;
--- a/src/primitives.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/primitives.cc Tue Jan 07 11:56:26 2014 +0200 @@ -392,7 +392,7 @@ { case Circle: { - vertex v0 (x0, 0.0f, z0), + Vertex v0 (x0, 0.0f, z0), v1 (x1, 0.0f, z1); LDLine* line = new LDLine; @@ -440,7 +440,7 @@ } } - vertex v0 (x0, y0, z0), + Vertex v0 (x0, y0, z0), v1 (x1, y1, z1), v2 (x2, y2, z2), v3 (x3, y3, z3); @@ -474,7 +474,7 @@ z2 = (z0 >= 0.0f) ? 1.0f : -1.0f; } - vertex v0 (x0, 0.0f, z0), + Vertex v0 (x0, 0.0f, z0), v1 (x1, 0.0f, z1), v2 (x2, 0.0f, z2); @@ -497,16 +497,16 @@ for (int i : condLineSegs) { - vertex v0 (radialPoint (i, divs, cos), 0.0f, radialPoint (i, divs, sin)), + Vertex v0 (radialPoint (i, divs, cos), 0.0f, radialPoint (i, divs, sin)), v1, v2 (radialPoint (i + 1, divs, cos), 0.0f, radialPoint (i + 1, divs, sin)), v3 (radialPoint (i - 1, divs, cos), 0.0f, radialPoint (i - 1, divs, sin)); if (type == Cylinder) - v1 = vertex (v0[X], 1.0f, v0[Z]); + v1 = Vertex (v0[X], 1.0f, v0[Z]); elif (type == Cone) { - v1 = vertex (v0[X] * (num + 1), 0.0f, v0[Z] * (num + 1)); + v1 = Vertex (v0[X] * (num + 1), 0.0f, v0[Z] * (num + 1)); v0[X] *= num; v0[Y] = 1.0f; v0[Z] *= num;
--- a/src/primitives.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/primitives.h Tue Jan 07 11:56:26 2014 +0200 @@ -74,17 +74,17 @@ Q_OBJECT public: - explicit PrimitiveLister (QObject* parent = 0); - virtual ~PrimitiveLister(); - static void start(); + explicit PrimitiveLister (QObject* parent = 0); + virtual ~PrimitiveLister(); + static void start(); public slots: - void work(); + void work(); signals: - void starting (int num); - void workDone(); - void update (int i); + void starting (int num); + void workDone(); + void update (int i); private: QList<Primitive> m_prims;
--- a/src/property.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/property.h Tue Jan 07 11:56:26 2014 +0200 @@ -57,14 +57,14 @@ #define DEFINE_PROPERTY_NO_OPS( TYPE, NAME ) #define DEFINE_PROPERTY_STR_OPS( TYPE, NAME ) \ - void append##NAME( TYPE a ) \ + void appendTo##NAME( TYPE a ) \ { \ TYPE tmp( m_##NAME ); \ - tmp.append( a ); \ + tmp.append( a ); \ set##NAME( tmp ); \ } \ \ - void prepend##NAME( TYPE a ) \ + void prependTo##NAME( TYPE a ) \ { \ TYPE tmp( m_##NAME ); \ tmp.prepend( a ); \
--- a/src/types.cc Tue Jan 07 08:53:27 2014 +0200 +++ b/src/types.cc Tue Jan 07 11:56:26 2014 +0200 @@ -42,7 +42,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex::vertex (double x, double y, double z) +Vertex::Vertex (double x, double y, double z) { m_coords[X] = x; m_coords[Y] = y; @@ -51,7 +51,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void vertex::move (const vertex& other) +void Vertex::move (const Vertex& other) { for_axes (ax) m_coords[ax] += other[ax]; @@ -59,7 +59,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -double vertex::distanceTo (const vertex& other) const +double Vertex::distanceTo (const Vertex& other) const { double dx = abs (x() - other.x()); double dy = abs (y() - other.y()); @@ -69,9 +69,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex vertex::midpoint (const vertex& other) +Vertex Vertex::midpoint (const Vertex& other) { - vertex mid; + Vertex mid; for_axes (ax) mid[ax] = (m_coords[ax] + other[ax]) / 2; @@ -81,7 +81,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str vertex::stringRep (bool mangled) const +str Vertex::stringRep (bool mangled) const { str fmtstr = "%1 %2 %3"; @@ -93,7 +93,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void vertex::transform (matrix matr, vertex pos) +void Vertex::transform (Matrix matr, Vertex pos) { double x2 = (matr[0] * x()) + (matr[1] * y()) + (matr[2] * z()) + pos[X]; double y2 = (matr[3] * x()) + (matr[4] * y()) + (matr[5] * z()) + pos[Y]; @@ -106,43 +106,43 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex vertex::operator-() const +Vertex Vertex::operator-() const { - return vertex (-m_coords[X], -m_coords[Y], -m_coords[Z]); + return Vertex (-m_coords[X], -m_coords[Y], -m_coords[Z]); } // ============================================================================= // ----------------------------------------------------------------------------- -bool vertex::operator!= (const vertex& other) const +bool Vertex::operator!= (const Vertex& other) const { return !operator== (other); } // ============================================================================= // ----------------------------------------------------------------------------- -double& vertex::operator[] (const Axis ax) +double& Vertex::operator[] (const Axis ax) { return coord ( (int) ax); } -const double& vertex::operator[] (const Axis ax) const +const double& Vertex::operator[] (const Axis ax) const { return coord ( (int) ax); } -double& vertex::operator[] (const int ax) +double& Vertex::operator[] (const int ax) { return coord (ax); } -const double& vertex::operator[] (const int ax) const +const double& Vertex::operator[] (const int ax) const { return coord (ax); } // ============================================================================= // ----------------------------------------------------------------------------- -bool vertex::operator== (const vertex& other) const +bool Vertex::operator== (const Vertex& other) const { return coord (X) == other[X] && coord (Y) == other[Y] && @@ -151,7 +151,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex& vertex::operator/= (const double d) +Vertex& Vertex::operator/= (const double d) { for_axes (ax) m_coords[ax] /= d; @@ -161,15 +161,15 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex vertex::operator/ (const double d) const +Vertex Vertex::operator/ (const double d) const { - vertex other (*this); + Vertex other (*this); return other /= d; } // ============================================================================= // ----------------------------------------------------------------------------- -vertex& vertex::operator+= (const vertex& other) +Vertex& Vertex::operator+= (const Vertex& other) { move (other); return *this; @@ -177,16 +177,16 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex vertex::operator+ (const vertex& other) const +Vertex Vertex::operator+ (const Vertex& other) const { - vertex newvert (*this); + Vertex newvert (*this); newvert.move (other); return newvert; } // ============================================================================= // ----------------------------------------------------------------------------- -int vertex::operator< (const vertex& other) const +int Vertex::operator< (const Vertex& other) const { if (operator== (other)) return false; @@ -208,7 +208,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -matrix::matrix (double vals[]) +Matrix::Matrix (double vals[]) { for (int i = 0; i < 9; ++i) m_vals[i] = vals[i]; @@ -216,7 +216,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -matrix::matrix (double fillval) +Matrix::Matrix (double fillval) { for (int i = 0; i < 9; ++i) m_vals[i] = fillval; @@ -224,7 +224,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -matrix::matrix (initlist<double> vals) +Matrix::Matrix (initlist<double> vals) { assert (vals.size() == 9); memcpy (&m_vals[0], & (*vals.begin()), sizeof m_vals); @@ -232,7 +232,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void matrix::puts() const +void Matrix::puts() const { for (int i = 0; i < 3; ++i) { @@ -245,7 +245,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -str matrix::stringRep() const +str Matrix::stringRep() const { str val; @@ -262,16 +262,16 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void matrix::zero() +void Matrix::zero() { memset (&m_vals[0], 0, sizeof m_vals); } // ============================================================================= // ----------------------------------------------------------------------------- -matrix matrix::mult (matrix other) const +Matrix Matrix::mult (Matrix other) const { - matrix val; + Matrix val; val.zero(); for (int i = 0; i < 3; ++i) @@ -284,7 +284,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -matrix& matrix::operator= (matrix other) +Matrix& Matrix::operator= (Matrix other) { memcpy (&m_vals[0], &other.m_vals[0], sizeof m_vals); return *this; @@ -292,7 +292,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -double matrix::getDeterminant() const +double Matrix::getDeterminant() const { return (val (0) * val (4) * val (8)) + (val (1) * val (5) * val (6)) + @@ -304,7 +304,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool matrix::operator== (const matrix& other) const +bool Matrix::operator== (const Matrix& other) const { for (int i = 0; i < 9; ++i) if (val (i) != other[i]) @@ -345,12 +345,12 @@ m_val = str::number (v); } -StringFormatArg::StringFormatArg (const vertex& v) +StringFormatArg::StringFormatArg (const Vertex& v) { m_val = v.stringRep (false); } -StringFormatArg::StringFormatArg (const matrix& v) +StringFormatArg::StringFormatArg (const Matrix& v) { m_val = v.stringRep(); } @@ -590,16 +590,16 @@ { switch (obj->getType()) { - case LDObject::Line: - case LDObject::Triangle: - case LDObject::Quad: - case LDObject::CondLine: + case LDObject::ELine: + case LDObject::ETriangle: + case LDObject::EQuad: + case LDObject::ECondLine: { for (int i = 0; i < obj->vertices(); ++i) calcVertex (obj->getVertex (i)); } break; - case LDObject::Subfile: + case LDObject::ESubfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline); @@ -619,7 +619,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -LDBoundingBox& LDBoundingBox::operator<< (const vertex& v) +LDBoundingBox& LDBoundingBox::operator<< (const Vertex& v) { calcVertex (v); return *this; @@ -635,7 +635,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void LDBoundingBox::calcVertex (const vertex& v) +void LDBoundingBox::calcVertex (const Vertex& v) { for_axes (ax) { @@ -684,9 +684,9 @@ // ============================================================================= // ----------------------------------------------------------------------------- -vertex LDBoundingBox::center() const +Vertex LDBoundingBox::center() const { - return vertex ( + return Vertex ( (m_Vertex0[X] + m_Vertex1[X]) / 2, (m_Vertex0[Y] + m_Vertex1[Y]) / 2, (m_Vertex0[Z] + m_Vertex1[Z]) / 2);
--- a/src/types.h Tue Jan 07 08:53:27 2014 +0200 +++ b/src/types.h Tue Jan 07 11:56:26 2014 +0200 @@ -59,20 +59,20 @@ // // A mathematical 3 x 3 matrix // ============================================================================= -class matrix +class Matrix { public: - matrix() {} - matrix (initlist<double> vals); - matrix (double fillval); - matrix (double vals[]); + Matrix() {} + Matrix (initlist<double> vals); + Matrix (double fillval); + Matrix (double vals[]); double getDeterminant() const; - matrix mult (matrix other) const; + Matrix mult (Matrix other) const; void puts() const; str stringRep() const; void zero(); - matrix& operator= (matrix other); + Matrix& operator= (Matrix other); inline double& val (int idx) { @@ -84,7 +84,7 @@ return m_vals[idx]; } - inline matrix operator* (matrix other) const + inline Matrix operator* (Matrix other) const { return mult (other); } @@ -99,7 +99,7 @@ return val (idx); } - bool operator== (const matrix& other) const; + bool operator== (const Matrix& other) const; private: double m_vals[9]; @@ -108,31 +108,31 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -// vertex +// Vertex // // Vertex class, contains a single point in 3D space. Not to be confused with // LDVertex, which is a vertex used in an LDraw part file. // ============================================================================= -class vertex +class Vertex { public: - vertex() {} - vertex (double x, double y, double z); + Vertex() {} + Vertex (double x, double y, double z); - double distanceTo (const vertex& other) const; - vertex midpoint (const vertex& other); - void move (const vertex& other); + double distanceTo (const Vertex& other) const; + Vertex midpoint (const Vertex& other); + void move (const Vertex& other); str stringRep (bool mangled) const; - void transform (matrix matr, vertex pos); + void transform (Matrix matr, Vertex pos); - vertex& operator+= (const vertex& other); - vertex operator+ (const vertex& other) const; - vertex operator/ (const double d) const; - vertex& operator/= (const double d); - bool operator== (const vertex& other) const; - bool operator!= (const vertex& other) const; - vertex operator-() const; - int operator< (const vertex& other) const; + Vertex& operator+= (const Vertex& other); + Vertex operator+ (const Vertex& other) const; + Vertex operator/ (const double d) const; + Vertex& operator/= (const double d); + bool operator== (const Vertex& other) const; + bool operator!= (const Vertex& other) const; + Vertex operator-() const; + int operator< (const Vertex& other) const; double& operator[] (const Axis ax); const double& operator[] (const Axis ax) const; double& operator[] (const int ax); @@ -214,8 +214,8 @@ StringFormatArg (const float& v); StringFormatArg (const double& v); - StringFormatArg (const vertex& v); - StringFormatArg (const matrix& v); + StringFormatArg (const Vertex& v); + StringFormatArg (const Matrix& v); StringFormatArg (const char* v); StringFormatArg (const void* v); @@ -321,8 +321,8 @@ class LDBoundingBox { PROPERTY (private, bool, Empty, BOOL_OPS, STOCK_WRITE) - PROPERTY (private, vertex, Vertex0, NO_OPS, STOCK_WRITE) - PROPERTY (private, vertex, Vertex1, NO_OPS, STOCK_WRITE) + PROPERTY (private, Vertex, Vertex0, NO_OPS, STOCK_WRITE) + PROPERTY (private, Vertex, Vertex1, NO_OPS, STOCK_WRITE) public: LDBoundingBox(); @@ -330,11 +330,11 @@ void calculate(); double size() const; void calcObject (LDObject* obj); - void calcVertex (const vertex& v); - vertex center() const; + void calcVertex (const Vertex& v); + Vertex center() const; LDBoundingBox& operator<< (LDObject* obj); - LDBoundingBox& operator<< (const vertex& v); + LDBoundingBox& operator<< (const Vertex& v); }; // Formatter function @@ -361,8 +361,8 @@ extern File g_file_stdout; extern File g_file_stderr; -extern const vertex g_origin; // Vertex at (0, 0, 0) -extern const matrix g_identity; // Identity matrix +extern const Vertex g_origin; // Vertex at (0, 0, 0) +extern const Matrix g_identity; // Identity matrix static const double pi = 3.14159265358979323846;