Thu, 09 May 2013 17:03:44 +0300
Further removal of hungarian notation
--- a/src/addObjectDialog.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/addObjectDialog.cpp Thu May 09 17:03:44 2013 +0300 @@ -30,7 +30,7 @@ #define APPLY_COORDS(OBJ, N) \ for (short i = 0; i < N; ++i) \ for (const Axis ax : g_Axes) \ - OBJ->vaCoords[i][ax] = dlg.dsb_coords[(i * 3) + ax]->value (); + OBJ->coords[i][ax] = dlg.dsb_coords[(i * 3) + ax]->value (); // ============================================================================= class SubfileListItem : public QTreeWidgetItem { @@ -137,7 +137,7 @@ if (obj) { LDSubfile* ref = static_cast<LDSubfile*> (obj); - le_subfileName->setText (ref->zFileName); + le_subfileName->setText (ref->fileName); } break; @@ -171,10 +171,10 @@ if (obj) { LDRadial* rad = static_cast<LDRadial*> (obj); - rb_radType->setValue (rad->eRadialType); - sb_radSegments->setValue (rad->dSegments); - cb_radHiRes->setChecked ((rad->dDivisions == 48) ? Qt::Checked : Qt::Unchecked); - sb_radRingNum->setValue (rad->dRingNum); + rb_radType->setValue (rad->radType); + sb_radSegments->setValue (rad->segs); + cb_radHiRes->setChecked ((rad->divs == 48) ? Qt::Checked : Qt::Unchecked); + sb_radRingNum->setValue (rad->ringNum); } break; @@ -192,7 +192,7 @@ // Show a color edit dialog for the types that actually use the color if (defaults->isColored ()) { if (obj != null) - dColor = obj->dColor; + dColor = obj->color; else dColor = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor; @@ -222,7 +222,7 @@ if (obj) { for (short i = 0; i < coordCount / 3; ++i) for (short j = 0; j < 3; ++j) - dsb_coords[(i * 3) + j]->setValue (obj->vaCoords[i].coord (j)); + dsb_coords[(i * 3) + j]->setValue (obj->coords[i].coord (j)); } break; @@ -244,7 +244,7 @@ if (obj) for (short i = 0; i < 3; ++i) - dsb_coords[i]->setValue (static_cast<LDRadial*> (obj)->vPosition.coord (i)); + dsb_coords[i]->setValue (static_cast<LDRadial*> (obj)->pos.coord (i)); break; case LDObject::Subfile: @@ -254,7 +254,7 @@ if (obj) for (short i = 0; i < 3; ++i) - dsb_coords[i]->setValue (static_cast<LDSubfile*> (obj)->vPosition.coord (i)); + dsb_coords[i]->setValue (static_cast<LDSubfile*> (obj)->pos.coord (i)); break; default: @@ -269,9 +269,9 @@ if (obj) { if (obj->getType () == LDObject::Subfile) - defval = static_cast<LDSubfile*> (obj)->mMatrix; + defval = static_cast<LDSubfile*> (obj)->transform; else - defval = static_cast<LDRadial*> (obj)->mMatrix; + defval = static_cast<LDRadial*> (obj)->transform; } le_matrix->setText (defval.stringRep ()); @@ -411,7 +411,7 @@ case LDObject::Line: { LDLine* line = initObj<LDLine> (obj); - line->dColor = dlg.dColor; + line->color = dlg.dColor; APPLY_COORDS (line, 2) } break; @@ -419,7 +419,7 @@ case LDObject::Triangle: { LDTriangle* tri = initObj<LDTriangle> (obj); - tri->dColor = dlg.dColor; + tri->color = dlg.dColor; APPLY_COORDS (tri, 3) } break; @@ -427,7 +427,7 @@ case LDObject::Quad: { LDQuad* quad = initObj<LDQuad> (obj); - quad->dColor = dlg.dColor; + quad->color = dlg.dColor; APPLY_COORDS (quad, 4) } break; @@ -435,7 +435,7 @@ case LDObject::CondLine: { LDCondLine* line = initObj<LDCondLine> (obj); - line->dColor = dlg.dColor; + line->color = dlg.dColor; APPLY_COORDS (line, 4) } break; @@ -450,26 +450,26 @@ case LDObject::Vertex: { LDVertex* vert = initObj<LDVertex> (obj); - vert->dColor = dlg.dColor; + vert->color = dlg.dColor; for (const Axis ax : g_Axes) - vert->vPosition[ax] = dlg.dsb_coords[ax]->value (); + vert->pos[ax] = dlg.dsb_coords[ax]->value (); } break; case LDObject::Radial: { LDRadial* pRad = initObj<LDRadial> (obj); - pRad->dColor = dlg.dColor; + pRad->color = dlg.dColor; for (const Axis ax : g_Axes) - pRad->vPosition[ax] = dlg.dsb_coords[ax]->value (); + pRad->pos[ax] = dlg.dsb_coords[ax]->value (); - pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48; - pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions); - pRad->eRadialType = (LDRadial::Type) dlg.rb_radType->value (); - pRad->dRingNum = dlg.sb_radRingNum->value (); - pRad->mMatrix = transform; + pRad->divs = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48; + pRad->segs = min<short> (dlg.sb_radSegments->value (), pRad->divs); + pRad->radType = (LDRadial::Type) dlg.rb_radType->value (); + pRad->ringNum = dlg.sb_radRingNum->value (); + pRad->transform = transform; } break; @@ -484,14 +484,14 @@ return; LDSubfile* ref = initObj<LDSubfile> (obj); - ref->dColor = dlg.dColor; + ref->color = dlg.dColor; for (const Axis ax : g_Axes) - ref->vPosition[ax] = dlg.dsb_coords[ax]->value (); + ref->pos[ax] = dlg.dsb_coords[ax]->value (); - ref->zFileName = name; - ref->mMatrix = transform; - ref->pFile = file; + ref->fileName = name; + ref->transform = transform; + ref->fileInfo = file; } break;
--- a/src/bbox.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/bbox.cpp Thu May 09 17:03:44 2013 +0300 @@ -50,7 +50,7 @@ { LDLine* line = static_cast<LDLine*> (obj); for (short i = 0; i < 2; ++i) - calcVertex (line->vaCoords[i]); + calcVertex (line->coords[i]); } break; @@ -58,7 +58,7 @@ { LDTriangle* tri = static_cast<LDTriangle*> (obj); for (short i = 0; i < 3; ++i) - calcVertex (tri->vaCoords[i]); + calcVertex (tri->coords[i]); } break; @@ -66,7 +66,7 @@ { LDQuad* quad = static_cast<LDQuad*> (obj); for (short i = 0; i < 4; ++i) - calcVertex (quad->vaCoords[i]); + calcVertex (quad->coords[i]); } break; @@ -74,7 +74,7 @@ { LDCondLine* line = static_cast<LDCondLine*> (obj); for (short i = 0; i < 4; ++i) - calcVertex (line->vaCoords[i]); + calcVertex (line->coords[i]); } break;
--- a/src/extprogs.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/extprogs.cpp Thu May 09 17:03:44 2013 +0300 @@ -137,7 +137,7 @@ void writeColorGroup (const short colnum, str fname) { std::vector<LDObject*> objects; for (LDObject*& obj : g_curfile->m_objs) { - if (obj->isColored () == false || obj->dColor != colnum) + if (obj->isColored () == false || obj->color != colnum) continue; objects.push_back (obj);
--- a/src/file.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/file.cpp Thu May 09 17:03:44 2013 +0300 @@ -182,7 +182,7 @@ // Check for parse errors and warn about tthem if (obj->getType() == LDObject::Gibberish) { logf (LOG_Warning, "Couldn't parse line #%lu: %s\n", - lnum, static_cast<LDGibberish*> (obj)->zReason.chars()); + lnum, static_cast<LDGibberish*> (obj)->reason.chars()); logf (LOG_Warning, "- Line was: %s\n", data.chars()); @@ -475,10 +475,10 @@ CHECK_TOKEN_NUMBERS (3, 6) LDVertex* obj = new LDVertex; - obj->dColor = atol (tokens[3]); + obj->color = atol (tokens[3]); for (const Axis ax : g_Axes) - obj->vPosition[ax] = atof (tokens[4 + ax]); // 4 - 6 + obj->pos[ax] = atof (tokens[4 + ax]); // 4 - 6 return obj; } @@ -501,16 +501,16 @@ LDRadial* obj = new LDRadial; - obj->eRadialType = eType; // 3 - obj->dColor = atol (tokens[4]); // 4 - obj->dSegments = atol (tokens[5]); // 5 - obj->dDivisions = atol (tokens[6]); // 6 - obj->dRingNum = atol (tokens[7]); // 7 + obj->radType = eType; // 3 + obj->color = atol (tokens[4]); // 4 + obj->segs = atol (tokens[5]); // 5 + obj->divs = atol (tokens[6]); // 6 + obj->ringNum = atol (tokens[7]); // 7 - obj->vPosition = parseVertex (tokens, 8); // 8 - 10 + obj->pos = parseVertex (tokens, 8); // 8 - 10 for (short i = 0; i < 9; ++i) - obj->mMatrix[i] = atof (tokens[i + 11]); // 11 - 19 + obj->transform[i] = atof (tokens[i + 11]); // 11 - 19 return obj; } @@ -535,14 +535,14 @@ return new LDGibberish (zLine, "Could not open referred file"); LDSubfile* obj = new LDSubfile; - obj->dColor = atol (tokens[1]); - obj->vPosition = parseVertex (tokens, 2); // 2 - 4 + obj->color = atol (tokens[1]); + obj->pos = parseVertex (tokens, 2); // 2 - 4 for (short i = 0; i < 9; ++i) - obj->mMatrix[i] = atof (tokens[i + 5]); // 5 - 13 + obj->transform[i] = atof (tokens[i + 5]); // 5 - 13 - obj->zFileName = tokens[14]; - obj->pFile = pFile; + obj->fileName = tokens[14]; + obj->fileInfo = pFile; return obj; } @@ -553,9 +553,9 @@ // Line LDLine* obj = new LDLine; - obj->dColor = atol (tokens[1]); + obj->color = atol (tokens[1]); for (short i = 0; i < 2; ++i) - obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 7 + obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 7 return obj; } @@ -566,10 +566,10 @@ // Triangle LDTriangle* obj = new LDTriangle; - obj->dColor = atol (tokens[1]); + obj->color = atol (tokens[1]); for (short i = 0; i < 3; ++i) - obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 10 + obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 10 return obj; } @@ -581,10 +581,10 @@ // Quadrilateral LDQuad* obj = new LDQuad; - obj->dColor = atol (tokens[1]); + obj->color = atol (tokens[1]); for (short i = 0; i < 4; ++i) - obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 + obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 return obj; } @@ -596,10 +596,10 @@ // Conditional line LDCondLine* obj = new LDCondLine; - obj->dColor = atol (tokens[1]); + obj->color = atol (tokens[1]); for (short i = 0; i < 4; ++i) - obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 + obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 return obj; } @@ -641,10 +641,10 @@ if (obj->getType() == LDObject::Subfile) { // Note: ref->pFile is invalid right now since all subfiles were closed. LDSubfile* ref = static_cast<LDSubfile*> (obj); - OpenFile* pFile = loadSubfile (ref->zFileName); + OpenFile* pFile = loadSubfile (ref->fileName); if (pFile) - ref->pFile = pFile; + ref->fileInfo = pFile; else { // Couldn't load the file, mark it an error ref->replace (new LDGibberish (ref->getContents (), "Could not open referred file")); @@ -654,7 +654,7 @@ // Reparse gibberish files. It could be that they are invalid because // the file could not be opened. Circumstances may be different now. if (obj->getType() == LDObject::Gibberish) - obj->replace (parseLine (static_cast<LDGibberish*> (obj)->zContents)); + obj->replace (parseLine (static_cast<LDGibberish*> (obj)->contents)); } }
--- a/src/gldraw.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/gldraw.cpp Thu May 09 17:03:44 2013 +0300 @@ -245,34 +245,34 @@ } #endif - if (obj->dColor == maincolor) + if (obj->color == maincolor) qcol = getMainColor (); else { - color* col = getColor (obj->dColor); + color* col = getColor (obj->color); qcol = col->qColor; } - if (obj->dColor == edgecolor) { + if (obj->color == edgecolor) { qcol = Qt::black; color* col; - if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->dColor)) != null) + if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->color)) != null) qcol = col->qEdge; } if (qcol.isValid () == false) { // The color was unknown. Use main color to make the object at least // not appear pitch-black. - if (obj->dColor != edgecolor) + if (obj->color != edgecolor) qcol = getMainColor (); // Warn about the unknown colors, but only once. for (short i : g_daWarnedColors) - if (obj->dColor == i) + if (obj->color == i) return; - printf ("%s: Unknown color %d!\n", __func__, obj->dColor); - g_daWarnedColors.push_back (obj->dColor); + printf ("%s: Unknown color %d!\n", __func__, obj->color); + g_daWarnedColors.push_back (obj->color); return; } @@ -638,7 +638,7 @@ const short numverts = (obj->getType () != LDObject::CondLine) ? obj->vertices () : 2; for (short i = 0; i < numverts; ++i) - compileVertex (obj->vaCoords[i]); + compileVertex (obj->coords[i]); glEnd (); } @@ -703,21 +703,21 @@ { LDVertex* pVert = static_cast<LDVertex*> (obj); LDTriangle* pPoly; - vertex* vPos = &(pVert->vPosition); + vertex* vPos = &(pVert->pos); const double fPolyScale = max (fZoom, 1.0); #define BIPYRAMID_COORD(N) ((((i + N) % 4) >= 2 ? 1 : -1) * 0.3f * fPolyScale) for (int i = 0; i < 8; ++i) { pPoly = new LDTriangle; - pPoly->vaCoords[0] = {vPos->x, vPos->y + ((i >= 4 ? 1 : -1) * 0.4f * fPolyScale), vPos->z}; - pPoly->vaCoords[1] = { + pPoly->coords[0] = {vPos->x, vPos->y + ((i >= 4 ? 1 : -1) * 0.4f * fPolyScale), vPos->z}; + pPoly->coords[1] = { vPos->x + BIPYRAMID_COORD (0), vPos->y, vPos->z + BIPYRAMID_COORD (1) }; - pPoly->vaCoords[2] = { + pPoly->coords[2] = { vPos->x + BIPYRAMID_COORD (1), vPos->y, vPos->z + BIPYRAMID_COORD (2) @@ -1078,8 +1078,8 @@ { // 1 vertex - add a vertex object obj = new LDVertex; - static_cast<LDVertex*> (obj)->vPosition = verts[0]; - obj->dColor = maincolor; + static_cast<LDVertex*> (obj)->pos = verts[0]; + obj->color = maincolor; } break; @@ -1087,9 +1087,9 @@ { // 2 verts - make a line obj = new LDLine; - obj->dColor = edgecolor; + obj->color = edgecolor; for (ushort i = 0; i < 2; ++i) - obj->vaCoords[i] = verts[i]; + obj->coords[i] = verts[i]; } break; @@ -1100,9 +1100,9 @@ static_cast<LDObject*> (new LDTriangle) : static_cast<LDObject*> (new LDQuad); - obj->dColor = maincolor; + obj->color = maincolor; for (ushort i = 0; i < obj->vertices (); ++i) - obj->vaCoords[i] = verts[i]; + obj->coords[i] = verts[i]; } break; }
--- a/src/gui.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/gui.cpp Thu May 09 17:03:44 2013 +0300 @@ -557,8 +557,8 @@ { LDLine* line = static_cast<LDLine*> (obj); descr.format ("%s, %s", - line->vaCoords[0].stringRep (true).chars(), - line->vaCoords[1].stringRep (true).chars()); + line->coords[0].stringRep (true).chars(), + line->coords[1].stringRep (true).chars()); } break; @@ -566,9 +566,9 @@ { LDTriangle* triangle = static_cast<LDTriangle*> (obj); descr.format ("%s, %s, %s", - triangle->vaCoords[0].stringRep (true).chars(), - triangle->vaCoords[1].stringRep (true).chars(), - triangle->vaCoords[2].stringRep (true).chars()); + triangle->coords[0].stringRep (true).chars(), + triangle->coords[1].stringRep (true).chars(), + triangle->coords[2].stringRep (true).chars()); } break; @@ -576,10 +576,10 @@ { LDQuad* quad = static_cast<LDQuad*> (obj); descr.format ("%s, %s, %s, %s", - quad->vaCoords[0].stringRep (true).chars(), - quad->vaCoords[1].stringRep (true).chars(), - quad->vaCoords[2].stringRep (true).chars(), - quad->vaCoords[3].stringRep (true).chars()); + quad->coords[0].stringRep (true).chars(), + quad->coords[1].stringRep (true).chars(), + quad->coords[2].stringRep (true).chars(), + quad->coords[3].stringRep (true).chars()); } break; @@ -587,20 +587,20 @@ { LDCondLine* line = static_cast<LDCondLine*> (obj); descr.format ("%s, %s, %s, %s", - line->vaCoords[0].stringRep (true).chars(), - line->vaCoords[1].stringRep (true).chars(), - line->vaCoords[2].stringRep (true).chars(), - line->vaCoords[3].stringRep (true).chars()); + line->coords[0].stringRep (true).chars(), + line->coords[1].stringRep (true).chars(), + line->coords[2].stringRep (true).chars(), + line->coords[3].stringRep (true).chars()); } break; case LDObject::Gibberish: descr.format ("ERROR: %s", - static_cast<LDGibberish*> (obj)->zContents.chars()); + static_cast<LDGibberish*> (obj)->contents.chars()); break; case LDObject::Vertex: - descr.format ("%s", static_cast<LDVertex*> (obj)->vPosition.stringRep (true).chars()); + descr.format ("%s", static_cast<LDVertex*> (obj)->pos.stringRep (true).chars()); break; case LDObject::Subfile: @@ -608,11 +608,11 @@ LDSubfile* ref = static_cast<LDSubfile*> (obj); descr.format ("%s %s, (", - ref->zFileName.chars(), ref->vPosition.stringRep (true).chars()); + ref->fileName.chars(), ref->pos.stringRep (true).chars()); for (short i = 0; i < 9; ++i) descr.appendformat ("%s%s", - ftoa (ref->mMatrix[i]).chars(), + ftoa (ref->transform[i]).chars(), (i != 8) ? " " : ""); descr += ')'; @@ -629,12 +629,12 @@ case LDObject::Radial: { LDRadial* pRad = static_cast<LDRadial*> (obj); - descr.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName()); + descr.format ("%d / %d %s", pRad->segs, pRad->divs, pRad->radialTypeName()); - if (pRad->eRadialType == LDRadial::Ring || pRad->eRadialType == LDRadial::Cone) - descr.appendformat (" %d", pRad->dRingNum); + if (pRad->radType == LDRadial::Ring || pRad->radType == LDRadial::Cone) + descr.appendformat (" %d", pRad->ringNum); - descr.appendformat (" %s", pRad->vPosition.stringRep (true).chars ()); + descr.appendformat (" %s", pRad->pos.stringRep (true).chars ()); } break; @@ -657,11 +657,11 @@ item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); } else if (lv_colorize && obj->isColored () && - obj->dColor != maincolor && obj->dColor != edgecolor) + obj->color != maincolor && obj->color != edgecolor) { // If the object isn't in the main or edge color, draw this // list entry in said color. - color* col = getColor (obj->dColor); + color* col = getColor (obj->color); if (col) item->setForeground (col->qColor); } @@ -759,13 +759,13 @@ short newColor = col->index (); for (LDObject* obj : m_sel) { - if (obj->dColor == -1) + if (obj->color == -1) continue; // uncolored object indices.push_back (obj->getIndex (g_curfile)); - colors.push_back (obj->dColor); + colors.push_back (obj->color); - obj->dColor = newColor; + obj->color = newColor; } History::addEntry (new SetColorHistory (indices, colors, newColor)); @@ -832,14 +832,14 @@ short result = -1; for (LDObject* obj : m_sel) { - if (obj->dColor == -1) + if (obj->color == -1) continue; // doesn't use color - if (result != -1 && obj->dColor != result) + if (result != -1 && obj->color != result) return -1; // No consensus in object color if (result == -1) - result = obj->dColor; + result = obj->color; } return result; @@ -852,7 +852,7 @@ LDObject::Type eResult = LDObject::Unidentified; for (LDObject* obj : m_sel) { - if (eResult != LDObject::Unidentified && obj->dColor != eResult) + if (eResult != LDObject::Unidentified && obj->color != eResult) return LDObject::Unidentified; if (eResult == LDObject::Unidentified) @@ -936,7 +936,7 @@ DelHistory* ForgeWindow::deleteByColor (const short colnum) { vector<LDObject*> objs; for (LDObject* obj : g_curfile->m_objs) { - if (!obj->isColored () || obj->dColor != colnum) + if (!obj->isColored () || obj->color != colnum) continue; objs.push_back (obj); @@ -1025,10 +1025,10 @@ if (!obj->isColored ()) continue; - if (counts.find (obj->dColor) == counts.end ()) - counts[obj->dColor] = 1; + if (counts.find (obj->color) == counts.end ()) + counts[obj->color] = 1; else - counts[obj->dColor]++; + counts[obj->color]++; } box->clear ();
--- a/src/gui_actions.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/gui_actions.cpp Thu May 09 17:03:44 2013 +0300 @@ -209,7 +209,7 @@ g_win->sel ().clear (); for (LDObject* obj : g_curfile->m_objs) - if (obj->dColor == dColor) + if (obj->color == dColor) g_win->sel ().push_back (obj); g_win->updateSelection (); @@ -232,10 +232,10 @@ str zRefName; if (eType == LDObject::Subfile) { - zRefName = static_cast<LDSubfile*> (g_win->sel ()[0])->zFileName; + zRefName = static_cast<LDSubfile*> (g_win->sel ()[0])->fileName; for (LDObject* pObj : g_win->sel ()) - if (static_cast<LDSubfile*> (pObj)->zFileName != zRefName) + if (static_cast<LDSubfile*> (pObj)->fileName != zRefName) return; } @@ -244,7 +244,7 @@ if (obj->getType() != eType) continue; - if (eType == LDObject::Subfile && static_cast<LDSubfile*> (obj)->zFileName != zRefName) + if (eType == LDObject::Subfile && static_cast<LDSubfile*> (obj)->fileName != zRefName) continue; g_win->sel ().push_back (obj);
--- a/src/gui_editactions.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/gui_editactions.cpp Thu May 09 17:03:44 2013 +0300 @@ -203,11 +203,11 @@ // Create the replacement primitive. LDSubfile* prim = new LDSubfile; - memcpy (&prim->vPosition, &rad->vPosition, sizeof rad->vPosition); // inherit position - memcpy (&prim->mMatrix, &rad->mMatrix, sizeof rad->mMatrix); // inherit matrix - prim->dColor = rad->dColor; // inherit color - prim->zFileName = name; - prim->pFile = file; + memcpy (&prim->pos, &rad->pos, sizeof rad->pos); // inherit position + memcpy (&prim->transform, &rad->transform, sizeof rad->transform); // inherit matrix + prim->color = rad->color; // inherit color + prim->fileName = name; + prim->fileInfo = file; // Add the history entry - this must be done while both objects are still valid. history->addEntry (rad, prim); @@ -306,11 +306,11 @@ std::vector<short> daColors; for (LDObject* obj : objs) { - if (obj->dColor != -1) { + if (obj->color != -1) { ulaIndices.push_back (obj->getIndex (g_curfile)); - daColors.push_back (obj->dColor); + daColors.push_back (obj->color); - obj->dColor = dColor; + obj->color = dColor; } } @@ -341,23 +341,23 @@ dNumLines = 4; LDQuad* quad = static_cast<LDQuad*> (obj); - lines[0] = new LDLine (quad->vaCoords[0], quad->vaCoords[1]); - lines[1] = new LDLine (quad->vaCoords[1], quad->vaCoords[2]); - lines[2] = new LDLine (quad->vaCoords[2], quad->vaCoords[3]); - lines[3] = new LDLine (quad->vaCoords[3], quad->vaCoords[0]); + lines[0] = new LDLine (quad->coords[0], quad->coords[1]); + lines[1] = new LDLine (quad->coords[1], quad->coords[2]); + lines[2] = new LDLine (quad->coords[2], quad->coords[3]); + lines[3] = new LDLine (quad->coords[3], quad->coords[0]); } else { dNumLines = 3; LDTriangle* tri = static_cast<LDTriangle*> (obj); - lines[0] = new LDLine (tri->vaCoords[0], tri->vaCoords[1]); - lines[1] = new LDLine (tri->vaCoords[1], tri->vaCoords[2]); - lines[2] = new LDLine (tri->vaCoords[2], tri->vaCoords[0]); + lines[0] = new LDLine (tri->coords[0], tri->coords[1]); + lines[1] = new LDLine (tri->coords[1], tri->coords[2]); + lines[2] = new LDLine (tri->coords[2], tri->coords[0]); } for (short i = 0; i < dNumLines; ++i) { ulong idx = obj->getIndex (g_curfile) + i + 1; - lines[i]->dColor = edgecolor; + lines[i]->color = edgecolor; g_curfile->insertObj (idx, lines[i]); ulaIndices.push_back (idx); @@ -385,8 +385,8 @@ ulong idx = obj->getIndex (g_curfile); for (short i = 0; i < obj->vertices(); ++i) { LDVertex* vert = new LDVertex; - vert->vPosition = obj->vaCoords[i]; - vert->dColor = obj->dColor; + vert->pos = obj->coords[i]; + vert->color = obj->color; g_curfile->insertObj (++idx, vert); ulaIndices.push_back (idx); @@ -516,11 +516,11 @@ // For lines, we swap the vertices. I don't think that a // cond-line's control points need to be swapped, do they? LDLine* pLine = static_cast<LDLine*> (obj); - vertex vTemp = pLine->vaCoords[0]; + vertex vTemp = pLine->coords[0]; pOldCopy = pLine->clone (); - pLine->vaCoords[0] = pLine->vaCoords[1]; - pLine->vaCoords[1] = vTemp; + pLine->coords[0] = pLine->coords[1]; + pLine->coords[1] = vTemp; pNewCopy = pLine->clone (); bEdited = true; } @@ -531,11 +531,11 @@ // Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1. // Thus, we swap 1 and 2. LDTriangle* pTri = static_cast<LDTriangle*> (obj); - vertex vTemp = pTri->vaCoords[1]; + vertex vTemp = pTri->coords[1]; pOldCopy = pTri->clone (); - pTri->vaCoords[1] = pTri->vaCoords[2]; - pTri->vaCoords[2] = vTemp; + pTri->coords[1] = pTri->coords[2]; + pTri->coords[2] = vTemp; pNewCopy = pTri->clone (); bEdited = true; } @@ -547,11 +547,11 @@ // rev: 0 -> 3 -> 2 -> 1 // Thus, we swap 1 and 3. LDQuad* pQuad = static_cast<LDQuad*> (obj); - vertex vTemp = pQuad->vaCoords[1]; + vertex vTemp = pQuad->coords[1]; pOldCopy = pQuad->clone (); - pQuad->vaCoords[1] = pQuad->vaCoords[3]; - pQuad->vaCoords[3] = vTemp; + pQuad->coords[1] = pQuad->coords[3]; + pQuad->coords[3] = vTemp; pNewCopy = pQuad->clone (); bEdited = true; } @@ -637,9 +637,9 @@ // Calculate center vertex for (LDObject* obj : sel) { if (obj->getType () == LDObject::Subfile) - box << static_cast<LDSubfile*> (obj)->vPosition; + box << static_cast<LDSubfile*> (obj)->pos; else if (obj->getType () == LDObject::Radial) - box << static_cast<LDRadial*> (obj)->vPosition; + box << static_cast<LDRadial*> (obj)->pos; else box << obj; } @@ -650,19 +650,19 @@ for (LDObject* obj : sel) { if (obj->vertices ()) for (short i = 0; i < obj->vertices (); ++i) - queue.push_back (&obj->vaCoords[i]); + queue.push_back (&obj->coords[i]); else if (obj->getType () == LDObject::Subfile) { LDSubfile* ref = static_cast<LDSubfile*> (obj); - queue.push_back (&ref->vPosition); - ref->mMatrix = ref->mMatrix * transform; + queue.push_back (&ref->pos); + ref->transform = ref->transform * transform; } else if (obj->getType () == LDObject::Radial) { LDRadial* rad = static_cast<LDRadial*> (obj); - queue.push_back (&rad->vPosition); - rad->mMatrix = rad->mMatrix * transform; + queue.push_back (&rad->pos); + rad->transform = rad->transform * transform; } else if (obj->getType () == LDObject::Vertex) - queue.push_back (&static_cast<LDVertex*> (obj)->vPosition); + queue.push_back (&static_cast<LDVertex*> (obj)->pos); } for (vertex* v : queue) { @@ -707,7 +707,7 @@ for (LDObject* obj : g_win->sel ()) for (short i = 0; i < obj->vertices (); ++i) for (const Axis ax : g_Axes) - obj->vaCoords[i][ax] = atof (fmt ("%.3f", obj->vaCoords[i][ax])); + obj->coords[i][ax] = atof (fmt ("%.3f", obj->coords[i][ax])); g_win->refresh (); } @@ -726,7 +726,7 @@ indices.push_back (obj->getIndex (g_curfile)); oldCopies.push_back (obj->clone ()); - obj->dColor = (obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor; + obj->color = (obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor; newCopies.push_back (obj->clone ()); }
--- a/src/history.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/history.cpp Thu May 09 17:03:44 2013 +0300 @@ -132,7 +132,7 @@ void SetColorHistory::undo () { // Restore colors for (ulong i = 0; i < ulaIndices.size (); ++i) - g_curfile->m_objs[ulaIndices[i]]->dColor = daColors[i]; + g_curfile->m_objs[ulaIndices[i]]->color = daColors[i]; g_win->refresh (); } @@ -140,7 +140,7 @@ void SetColorHistory::redo () { // Re-set post color for (ulong i = 0; i < ulaIndices.size (); ++i) - g_curfile->m_objs[ulaIndices[i]]->dColor = dNewColor; + g_curfile->m_objs[ulaIndices[i]]->color = dNewColor; g_win->refresh (); }
--- a/src/ldtypes.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/ldtypes.cpp Thu May 09 17:03:44 2013 +0300 @@ -65,8 +65,8 @@ } LDGibberish::LDGibberish (str _zContent, str _zReason) { - zContents = _zContent; - zReason = _zReason; + contents = _zContent; + reason = _zReason; } // ============================================================================= @@ -75,56 +75,56 @@ } str LDSubfile::getContents () { - str val = fmt ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); - val += mMatrix.stringRep (); + str val = fmt ("1 %d %s ", color, pos.stringRep (false).chars ()); + val += transform.stringRep (); val += ' '; - val += zFileName; + val += fileName; return val; } str LDLine::getContents () { - str val = fmt ("2 %d", dColor); + str val = fmt ("2 %d", color); for (ushort i = 0; i < 2; ++i) - val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); + val.appendformat (" %s", coords[i].stringRep (false).chars ()); return val; } str LDTriangle::getContents () { - str val = fmt ("3 %d", dColor); + str val = fmt ("3 %d", color); for (ushort i = 0; i < 3; ++i) - val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); + val.appendformat (" %s", coords[i].stringRep (false).chars ()); return val; } str LDQuad::getContents () { - str val = fmt ("4 %d", dColor); + str val = fmt ("4 %d", color); for (ushort i = 0; i < 4; ++i) - val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); + val.appendformat (" %s", coords[i].stringRep (false).chars ()); return val; } str LDCondLine::getContents () { - str val = fmt ("5 %d", dColor); + str val = fmt ("5 %d", color); // Add the coordinates for (ushort i = 0; i < 4; ++i) - val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); + val.appendformat (" %s", coords[i].stringRep (false).chars ()); return val; } str LDGibberish::getContents () { - return zContents; + return contents; } str LDVertex::getContents () { - return fmt ("0 !LDFORGE VERTEX %d %s", dColor, vPosition.stringRep (false).chars()); + return fmt ("0 !LDFORGE VERTEX %d %s", color, pos.stringRep (false).chars()); } str LDEmpty::getContents () { @@ -158,17 +158,17 @@ // | | |/ / | // 1---2 1 1---2 LDTriangle* tri1 = new LDTriangle; - tri1->vaCoords[0] = vaCoords[0]; - tri1->vaCoords[1] = vaCoords[1]; - tri1->vaCoords[2] = vaCoords[3]; + tri1->coords[0] = coords[0]; + tri1->coords[1] = coords[1]; + tri1->coords[2] = coords[3]; LDTriangle* tri2 = new LDTriangle; - tri2->vaCoords[0] = vaCoords[1]; - tri2->vaCoords[1] = vaCoords[2]; - tri2->vaCoords[2] = vaCoords[3]; + tri2->coords[0] = coords[1]; + tri2->coords[1] = coords[2]; + tri2->coords[2] = coords[3]; // The triangles also inherit the quad's color - tri1->dColor = tri2->dColor = dColor; + tri1->color = tri2->color = color; vector<LDTriangle*> triangles; triangles.push_back (tri1); @@ -202,8 +202,8 @@ } LDLine::LDLine (vertex v1, vertex v2) { - vaCoords[0] = v1; - vaCoords[1] = v2; + coords[0] = v1; + coords[1] = v2; } LDObject::~LDObject () { @@ -223,16 +223,16 @@ case LDObject::Triangle: case LDObject::Quad: for (short i = 0; i < obj->vertices (); ++i) - obj->vaCoords[i].transform (transform, pos); + obj->coords[i].transform (transform, pos); break; case LDObject::Subfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); - matrix<3> newMatrix = transform * ref->mMatrix; - ref->vPosition.transform (transform, pos); - ref->mMatrix = newMatrix; + matrix<3> newMatrix = transform * ref->transform; + ref->pos.transform (transform, pos); + ref->transform = newMatrix; } break; @@ -240,8 +240,8 @@ break; } - if (obj->dColor == maincolor) - obj->dColor = parentcolor; + if (obj->color == maincolor) + obj->color = parentcolor; } // ============================================================================= @@ -251,14 +251,14 @@ vector<LDObject*> objs, cache; // If we have this cached, just clone that - if (bDeepInline && pFile->m_objCache.size ()) { - for (LDObject* obj : pFile->m_objCache) + if (bDeepInline && fileInfo->m_objCache.size ()) { + for (LDObject* obj : fileInfo->m_objCache) objs.push_back (obj->clone ()); } else { if (!bDeepInline) bCache = false; - for (LDObject* obj : pFile->m_objs) { + for (LDObject* obj : fileInfo->m_objs) { // Skip those without schemantic meaning switch (obj->getType ()) { case LDObject::Comment: @@ -302,7 +302,7 @@ } if (bCache) - pFile->m_objCache = cache; + fileInfo->m_objCache = cache; } // Transform the objects @@ -310,7 +310,7 @@ // Set the parent now so we know what inlined this. obj->parent = this; - transformObject (obj, mMatrix, vPosition, dColor); + transformObject (obj, transform, pos, color); } return objs; @@ -417,35 +417,35 @@ void LDGibberish::move (vertex vVector) { vVector = vVector; } void LDVertex::move (vertex vVector) { - vPosition += vVector; + pos += vVector; } void LDSubfile::move (vertex vVector) { - vPosition += vVector; + pos += vVector; } void LDRadial::move (vertex vVector) { - vPosition += vVector; + pos += vVector; } void LDLine::move (vertex vVector) { for (short i = 0; i < 2; ++i) - vaCoords[i] += vVector; + coords[i] += vVector; } void LDTriangle::move (vertex vVector) { for (short i = 0; i < 3; ++i) - vaCoords[i] += vVector; + coords[i] += vVector; } void LDQuad::move (vertex vVector) { for (short i = 0; i < 4; ++i) - vaCoords[i] += vVector; + coords[i] += vVector; } void LDCondLine::move (vertex vVector) { for (short i = 0; i < 4; ++i) - vaCoords[i] += vVector; + coords[i] += vVector; } // ============================================================================= @@ -462,7 +462,7 @@ }; char const* LDRadial::radialTypeName () { - return g_saRadialTypeNames[eRadialType]; + return g_saRadialTypeNames[radType]; } char const* LDRadial::radialTypeName (const LDRadial::Type eType) { @@ -472,30 +472,30 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -std::vector<LDObject*> LDRadial::decompose (bool bTransform) { +std::vector<LDObject*> LDRadial::decompose (bool applyTransform) { std::vector<LDObject*> paObjects; - for (short i = 0; i < dSegments; ++i) { - double x0 = cos ((i * 2 * pi) / dDivisions), - x1 = cos (((i + 1) * 2 * pi) / dDivisions), - z0 = sin ((i * 2 * pi) / dDivisions), - z1 = sin (((i + 1) * 2 * pi) / dDivisions); + for (short i = 0; i < segs; ++i) { + double x0 = cos ((i * 2 * pi) / divs), + x1 = cos (((i + 1) * 2 * pi) / divs), + z0 = sin ((i * 2 * pi) / divs), + z1 = sin (((i + 1) * 2 * pi) / divs); - switch (eRadialType) { + switch (radType) { case LDRadial::Circle: { vertex v0 (x0, 0.0f, z0), v1 (x1, 0.0f, z1); - if (bTransform) { - v0.transform (mMatrix, vPosition); - v1.transform (mMatrix, vPosition); + if (applyTransform) { + v0.transform (transform, pos); + v1.transform (transform, pos); } LDLine* pLine = new LDLine; - pLine->vaCoords[0] = v0; - pLine->vaCoords[1] = v1; - pLine->dColor = edgecolor; + pLine->coords[0] = v0; + pLine->coords[1] = v1; + pLine->color = edgecolor; pLine->parent = this; paObjects.push_back (pLine); @@ -509,7 +509,7 @@ double x2, x3, z2, z3; double y0, y1, y2, y3; - if (eRadialType == LDRadial::Cylinder) { + if (radType == LDRadial::Cylinder) { x2 = x1; x3 = x0; z2 = z1; @@ -518,17 +518,17 @@ y0 = y1 = 0.0f; y2 = y3 = 1.0f; } else { - x2 = x1 * (dRingNum + 1); - x3 = x0 * (dRingNum + 1); - z2 = z1 * (dRingNum + 1); - z3 = z0 * (dRingNum + 1); + x2 = x1 * (ringNum + 1); + x3 = x0 * (ringNum + 1); + z2 = z1 * (ringNum + 1); + z3 = z0 * (ringNum + 1); - x0 *= dRingNum; - x1 *= dRingNum; - z0 *= dRingNum; - z1 *= dRingNum; + x0 *= ringNum; + x1 *= ringNum; + z0 *= ringNum; + z1 *= ringNum; - if (eRadialType == LDRadial::Ring) { + if (radType == LDRadial::Ring) { y0 = y1 = y2 = y3 = 0.0f; } else { y0 = y1 = 1.0f; @@ -541,19 +541,19 @@ v2 (x2, y2, z2), v3 (x3, y3, z3); - if (bTransform) { - v0.transform (mMatrix, vPosition); - v1.transform (mMatrix, vPosition); - v2.transform (mMatrix, vPosition); - v3.transform (mMatrix, vPosition); + if (applyTransform) { + v0.transform (transform, pos); + v1.transform (transform, pos); + v2.transform (transform, pos); + v3.transform (transform, pos); } LDQuad* pQuad = new LDQuad; - pQuad->vaCoords[0] = v0; - pQuad->vaCoords[1] = v1; - pQuad->vaCoords[2] = v2; - pQuad->vaCoords[3] = v3; - pQuad->dColor = dColor; + pQuad->coords[0] = v0; + pQuad->coords[1] = v1; + pQuad->coords[2] = v2; + pQuad->coords[3] = v3; + pQuad->color = color; pQuad->parent = this; paObjects.push_back (pQuad); @@ -565,7 +565,7 @@ { double x2, z2; - if (eRadialType == LDRadial::Disc) { + if (radType == LDRadial::Disc) { x2 = z2 = 0.0f; } else { x2 = (x0 >= 0.0f) ? 1.0f : -1.0f; @@ -576,17 +576,17 @@ v1 (x1, 0.0f, z1), v2 (x2, 0.0f, z2); - if (bTransform) { - v0.transform (mMatrix, vPosition); - v1.transform (mMatrix, vPosition); - v2.transform (mMatrix, vPosition); + if (applyTransform) { + v0.transform (transform, pos); + v1.transform (transform, pos); + v2.transform (transform, pos); } LDTriangle* pSeg = new LDTriangle; - pSeg->vaCoords[0] = v0; - pSeg->vaCoords[1] = v1; - pSeg->vaCoords[2] = v2; - pSeg->dColor = dColor; + pSeg->coords[0] = v0; + pSeg->coords[1] = v1; + pSeg->coords[2] = v2; + pSeg->color = color; pSeg->parent = this; paObjects.push_back (pSeg); @@ -607,8 +607,8 @@ str LDRadial::getContents () { return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", str (radialTypeName()).toupper ().strip (' ').chars (), - dColor, dSegments, dDivisions, dRingNum, - vPosition.stringRep (false).chars(), mMatrix.stringRep().chars()); + color, segs, divs, ringNum, + pos.stringRep (false).chars(), transform.stringRep().chars()); } char const* g_saRadialNameRoots[] = { @@ -625,8 +625,8 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= str LDRadial::makeFileName () { - short numer = dSegments, - denom = dDivisions; + short numer = segs, + denom = divs; // Simplify the fractional part, but the denominator must be at least 4. simplify (numer, denom); @@ -639,18 +639,18 @@ } // Compose some general information: prefix, fraction, root, ring number - str prefix = (dDivisions == 16) ? "" : fmt ("%d/", dDivisions); + str prefix = (divs == 16) ? "" : fmt ("%d/", divs); str frac = fmt ("%d-%d", numer, denom); - str root = g_saRadialNameRoots[eRadialType]; - str ringNum = (eRadialType == Ring || eRadialType == Cone) ? fmt ("%d", dRingNum) : ""; + str root = g_saRadialNameRoots[radType]; + str num = (radType == Ring || radType == Cone) ? fmt ("%d", ringNum) : ""; // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters. - short extra = (~frac + ~ringNum + ~root) - 8; + short extra = (~frac + ~num + ~root) - 8; root -= min<short> (max<short> (extra, 0), 2); // Stick them all together and return the result. - return fmt ("%s%s%s%s.dat", prefix.chars(), frac.chars (), root.chars (), ringNum.chars ()); + return fmt ("%s%s%s%s.dat", prefix.chars(), frac.chars (), root.chars (), num.chars ()); } // =============================================================================
--- a/src/ldtypes.h Thu May 09 04:01:37 2013 +0300 +++ b/src/ldtypes.h Thu May 09 17:03:44 2013 +0300 @@ -81,13 +81,13 @@ // Color used by this object. Comments, gibberish and empty entries // do not use this field. - short dColor; + short color; // OpenGL list for this object uint glLists[3]; // Vertices of this object - vertex vaCoords[4]; + vertex coords[4]; // Object this object was referenced from, if any LDObject* parent; @@ -115,7 +115,7 @@ void swap (LDObject* other); // Moves this object using the given vertex as a movement vector - virtual void move (vertex vVector); + virtual void move (vertex vect); // What object in the current file ultimately references this? LDObject* topLevelParent (); @@ -165,10 +165,10 @@ LDGibberish (str _zContent, str _zReason); // Content of this unknown line - str zContents; + str contents; // Why is this gibberish? - str zReason; + str reason; }; // ============================================================================= @@ -195,7 +195,7 @@ LDOBJ_UNCOLORED LDOBJ_NON_SCHEMANTIC - LDComment (str zText) : text (zText) {} + LDComment (str text) : text (text) {} str text; // The text of this comment }; @@ -222,7 +222,7 @@ LDOBJ_UNCOLORED LDOBJ_CUSTOM_SCHEMANTIC { return (type == InvertNext); } - LDBFC (const LDBFC::Type eType) : type (eType) {} + LDBFC (const LDBFC::Type type) : type (type) {} // Statement strings static const char* statements[]; @@ -241,14 +241,14 @@ LDOBJ_COLORED LDOBJ_SCHEMANTIC - vertex vPosition; // Position of the subpart (FIXME: should get rid of this) - matrix<3> mMatrix; // Transformation matrix for the subpart - str zFileName; // Filename of the subpart - OpenFile* pFile; // Pointer to opened file for this subfile. null if unopened. + vertex pos; // Position of the subpart (TODO: should get rid of this) + matrix<3> transform; // Transformation matrix for the subpart + str fileName; // Filename of the subpart (TODO: rid this too - use fileInfo->fileName instead) + OpenFile* fileInfo; // Pointer to opened file for this subfile. null if unopened. // Inlines this subfile. Note that return type is an array of heap-allocated // LDObject-clones, they must be deleted one way or another. - std::vector<LDObject*> inlineContents (bool bDeepInline, bool bCache); + std::vector<LDObject*> inlineContents (bool deep, bool cache); }; // ============================================================================= @@ -294,9 +294,9 @@ LDOBJ_SCHEMANTIC LDTriangle (vertex _v0, vertex _v1, vertex _v2) { - vaCoords[0] = _v0; - vaCoords[1] = _v1; - vaCoords[2] = _v2; + coords[0] = _v0; + coords[1] = _v1; + coords[2] = _v2; } }; @@ -326,11 +326,11 @@ // ============================================================================= class LDVertex : public LDObject { public: - IMPLEMENT_LDTYPE (Vertex, 0) // TODO: move vPosition to vaCoords[0] + IMPLEMENT_LDTYPE (Vertex, 0) // TODO: move pos to vaCoords[0] LDOBJ_COLORED LDOBJ_NON_SCHEMANTIC - vertex vPosition; + vertex pos; }; // ============================================================================= @@ -358,25 +358,23 @@ LDOBJ_COLORED LDOBJ_SCHEMANTIC - LDRadial::Type eRadialType; - vertex vPosition; - matrix<3> mMatrix; - short dDivisions, dSegments, dRingNum; + LDRadial::Type radType; + vertex pos; + matrix<3> transform; + short divs, segs, ringNum; - LDRadial (LDRadial::Type eRadialType, vertex vPosition, matrix<3> mMatrix, - short dDivisions, short dSegments, short dRingNum) : - eRadialType (eRadialType), vPosition (vPosition), mMatrix (mMatrix), - dDivisions (dDivisions), dSegments (dSegments), dRingNum (dRingNum) {} + LDRadial (LDRadial::Type radType, vertex pos, matrix<3> transform, short divs, short segs, short ringNum) : + radType (radType), pos (pos), transform (transform), divs (divs), segs (segs), ringNum (ringNum) {} // Returns a set of objects that provide the equivalent of this radial. // Note: objects are heap-allocated. - std::vector<LDObject*> decompose (bool bTransform); + std::vector<LDObject*> decompose (bool applyTransform); // Compose a file name for this radial. str makeFileName (); char const* radialTypeName (); - static char const* radialTypeName (const LDRadial::Type eType); + static char const* radialTypeName (const LDRadial::Type type); }; // =============================================================================
--- a/src/misc.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/misc.cpp Thu May 09 17:03:44 2013 +0300 @@ -148,8 +148,8 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -bool isNumber (str& zToken) { - char* cpPointer = &zToken[0]; +bool isNumber (str& tok) { + char* cpPointer = &tok[0]; bool bGotDot = false; // Allow leading hyphen for negatives
--- a/src/misc.h Thu May 09 04:01:37 2013 +0300 +++ b/src/misc.h Thu May 09 17:03:44 2013 +0300 @@ -32,13 +32,13 @@ extern const ushort g_primes[NUM_PRIMES]; // Returns whether a given string represents a floating point number. -bool isNumber (str& zToken); +bool isNumber (str& tok); // Converts a float value to a string value. str ftoa (double fCoord); // Simplifies the given fraction. -void simplify (short& dNum, short& dDenom); +void simplify (short& numer, short& denom); // Grid stuff typedef struct { @@ -99,8 +99,8 @@ void seek (short amount, bool rel); bool tokenCompare (short inPos, const char* sOther); - str operator[] (const size_t uIndex) { - return m_tokens[uIndex]; + str operator[] (const size_t idx) { + return m_tokens[idx]; } private:
--- a/src/radiobox.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/radiobox.cpp Thu May 09 17:03:44 2013 +0300 @@ -25,24 +25,24 @@ } void RadioBox::init (Qt::Orientation orient) { - dir = makeDirection (orient); + m_dir = makeDirection (orient); - buttonGroup = new QButtonGroup; - currentId = 0; - coreLayout = null; + m_buttonGroup = new QButtonGroup; + m_curId = 0; + m_coreLayout = null; - coreLayout = new QBoxLayout (makeDirection (orient, true)); - setLayout (coreLayout); + m_coreLayout = new QBoxLayout (makeDirection (orient, true)); + setLayout (m_coreLayout); // Init the first row with a break rowBreak (); - connect (buttonGroup, SIGNAL (buttonPressed (QAbstractButton*)), this, SLOT (slot_buttonPressed (QAbstractButton*))); - connect (buttonGroup, SIGNAL (buttonPressed (int)), this, SLOT (slot_buttonPressed (int))); + connect (m_buttonGroup, SIGNAL (buttonPressed (QAbstractButton*)), this, SLOT (slot_buttonPressed (QAbstractButton*))); + connect (m_buttonGroup, SIGNAL (buttonPressed (int)), this, SLOT (slot_buttonPressed (int))); } RadioBox::RadioBox (const QString& title, initlist<char const*> entries, int const defaultId, - const Qt::Orientation orient, QWidget* parent) : QGroupBox (title, parent), defaultId (defaultId) + const Qt::Orientation orient, QWidget* parent) : QGroupBox (title, parent), m_defId (defaultId) { init (orient); @@ -51,11 +51,11 @@ } void RadioBox::rowBreak () { - QBoxLayout* newLayout = new QBoxLayout (dir); - currentLayout = newLayout; - layouts.push_back (newLayout); + QBoxLayout* newLayout = new QBoxLayout (m_dir); + m_currentLayout = newLayout; + m_layouts.push_back (newLayout); - coreLayout->addLayout (newLayout); + m_coreLayout->addLayout (newLayout); } void RadioBox::addButton (const char* entry) { @@ -64,11 +64,11 @@ } void RadioBox::addButton (QRadioButton* button) { - bool const selectThis = (currentId == defaultId); + bool const selectThis = (m_curId == m_defId); - objects.push_back (button); - buttonGroup->addButton (button, currentId++); - currentLayout->addWidget (button); + m_objects.push_back (button); + m_buttonGroup->addButton (button, m_curId++); + m_currentLayout->addWidget (button); if (selectThis) button->setChecked (true); @@ -85,7 +85,7 @@ } void RadioBox::setCurrentRow (uint row) { - currentLayout = layouts[row]; + m_currentLayout = m_layouts[row]; } void RadioBox::slot_buttonPressed (int btn) {
--- a/src/radiobox.h Thu May 09 04:01:37 2013 +0300 +++ b/src/radiobox.h Thu May 09 17:03:44 2013 +0300 @@ -60,35 +60,35 @@ RadioBox& operator<< (const char* entry); int value () const { - return buttonGroup->checkedId (); + return m_buttonGroup->checkedId (); } void setValue (int val) { - buttonGroup->button (val)->setChecked (true); + m_buttonGroup->button (val)->setChecked (true); } std::vector<QRadioButton*>::iterator begin () { - return objects.begin (); + return m_objects.begin (); } std::vector<QRadioButton*>::iterator end () { - return objects.end (); + return m_objects.end (); } QRadioButton* operator[] (uint n) const { - return objects[n]; + return m_objects[n]; } bool exclusive () const { - return buttonGroup->exclusive (); + return m_buttonGroup->exclusive (); } void setExclusive (bool val) { - buttonGroup->setExclusive (val); + m_buttonGroup->setExclusive (val); } bool isChecked (int n) const { - return buttonGroup->checkedId () == n; + return m_buttonGroup->checkedId () == n; } signals: @@ -96,14 +96,13 @@ void sig_buttonPressed (QAbstractButton* btn); private: - std::vector<QRadioButton*> objects; - std::vector<QBoxLayout*> layouts; - QBoxLayout* coreLayout; - QBoxLayout* currentLayout; - QBoxLayout::Direction dir; - int currentId; - int defaultId; - QButtonGroup* buttonGroup; + std::vector<QRadioButton*> m_objects; + std::vector<QBoxLayout*> m_layouts; + QBoxLayout* m_coreLayout; + QBoxLayout* m_currentLayout; + QBoxLayout::Direction m_dir; + int m_curId, m_defId; + QButtonGroup* m_buttonGroup; Q_DISABLE_COPY (RadioBox)
--- a/src/setContentsDialog.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/setContentsDialog.cpp Thu May 09 17:03:44 2013 +0300 @@ -43,7 +43,7 @@ if (obj->getType() == LDObject::Gibberish) { lb_error = new QLabel; lb_error->setText (fmt ("<span style=\"color: #900\">%s</span>", - static_cast<LDGibberish*> (obj)->zReason.chars())); + static_cast<LDGibberish*> (obj)->reason.chars())); QPixmap qErrorPixmap = getIcon ("error").scaledToHeight (16);
--- a/src/str.cpp Thu May 09 04:01:37 2013 +0300 +++ b/src/str.cpp Thu May 09 17:03:44 2013 +0300 @@ -21,52 +21,51 @@ #include <string.h> #include <stdarg.h> #include <assert.h> -// #include <initializer_list> #include "str.h" #include "common.h" #include "misc.h" #define ITERATE_STRING(u) \ - for (unsigned int u = 0; u < strlen (text); u++) + for (uint u = 0; u < strlen (m_text); u++) // ============================================================================ // vdynformat: Try to write to a formatted string with size bytes first, if // that fails, double the size and keep recursing until it works. -char* vdynformat (const char* csFormat, va_list vArgs, long lSize) { - char* buffer = new char[lSize]; - int r = vsnprintf (buffer, lSize - 1, csFormat, vArgs); - if (r > (signed)(lSize - 1) || r < 0) { +char* vdynformat (const char* fmtstr, va_list va, long size) { + char* buffer = new char[size]; + int r = vsnprintf (buffer, size - 1, fmtstr, va); + if (r > (signed)(size - 1) || r < 0) { delete[] buffer; - buffer = vdynformat (csFormat, vArgs, lSize * 2); + buffer = vdynformat (fmtstr, va, size * 2); } return buffer; } // ============================================================================ str::str () { - text = new char[1]; + m_text = new char[1]; clear(); - alloclen = strlen (text); + m_allocated = strlen (m_text); } str::str (const char* c) { - text = new char[1]; - text[0] = '\0'; - curs = alloclen = 0; + m_text = new char[1]; + m_text[0] = '\0'; + m_writepos = m_allocated = 0; append (c); } str::str (char c) { - text = new char[1]; - text[0] = '\0'; - curs = alloclen = 0; + m_text = new char[1]; + m_text[0] = '\0'; + m_writepos = m_allocated = 0; append (c); } str::str (QString c) { - text = new char[1]; - text[0] = '\0'; - curs = alloclen = 0; + m_text = new char[1]; + m_text[0] = '\0'; + m_writepos = m_allocated = 0; append (c); } @@ -76,49 +75,49 @@ // ============================================================================ void str::clear () { - delete[] text; - text = new char[1]; - text[0] = '\0'; - curs = 0; - alloclen = 0; + delete[] m_text; + m_text = new char[1]; + m_text[0] = '\0'; + m_writepos = 0; + m_allocated = 0; } // ============================================================================ -void str::resize (unsigned int len) { - unsigned int oldlen = strlen (text); +void str::resize (uint len) { + uint oldlen = strlen (m_text); char* oldtext = new char[oldlen]; - strncpy (oldtext, text, oldlen); + strncpy (oldtext, m_text, oldlen); - delete[] text; - text = new char[len+1]; - for (unsigned int u = 0; u < len+1; u++) - text[u] = 0; - strncpy (text, oldtext, len); + delete[] m_text; + m_text = new char[len+1]; + for (uint u = 0; u < len+1; u++) + m_text[u] = 0; + strncpy (m_text, oldtext, len); delete[] oldtext; - alloclen = len; + m_allocated = len; } // ============================================================================ void str::dump () { - for (unsigned int u = 0; u <= alloclen; u++) - printf ("\t%u. %u (%c)\n", u, text[u], text[u]); + for (uint u = 0; u <= m_allocated; u++) + printf ("\t%u. %u (%c)\n", u, m_text[u], m_text[u]); } // ============================================================================ // Adds a new character at the end of the string. void str::append (const char c) { // Out of space, thus resize - if (curs == alloclen) - resize (alloclen + 1); - text[curs] = c; - curs++; + if (m_writepos == m_allocated) + resize (m_allocated + 1); + m_text[m_writepos] = c; + m_writepos++; } void str::append (const char* c) { - resize (alloclen + strlen (c)); + resize (m_allocated + strlen (c)); - for (unsigned int u = 0; u < strlen (c); u++) { + for (uint u = 0; u < strlen (c); u++) { if (c[u] != 0) append (c[u]); } @@ -159,15 +158,15 @@ // ============================================================================ char* str::chars () { - return text; + return m_text; } // ============================================================================ -int str::first (const char* c, unsigned int a) { - unsigned int r = 0; - unsigned int index = 0; - for (; a < alloclen; a++) { - if (text[a] == c[r]) { +int str::first (const char* c, uint a) { + uint r = 0; + uint index = 0; + for (; a < m_allocated; a++) { + if (m_text[a] == c[r]) { if (r == 0) index = a; @@ -198,7 +197,7 @@ int r = max; for (; a >= 0; a--) { - if (text[a] == c[r]) { + if (m_text[a] == c[r]) { r--; if (r == -1) return a; @@ -214,7 +213,7 @@ } // ============================================================================ -str str::substr (unsigned int a, unsigned int b) { +str str::substr (uint a, uint b) { if (a > len()) a = len(); if (b > len()) b = len(); @@ -225,13 +224,13 @@ printf ("str::substring:: indices %u and %u given, should be the other way around, swapping..\n", a, b); // Swap the variables - unsigned int c = a; + uint c = a; a = b; b = c; } char* s = new char[b - a + 1]; - strncpy (s, text + a, b - a); + strncpy (s, m_text + a, b - a); s[b - a] = '\0'; str other = s; @@ -240,7 +239,7 @@ } // ============================================================================ -void str::remove (unsigned int idx, unsigned int dellen) { +void str::remove (uint idx, uint dellen) { str s1 = substr (0, idx); str s2 = substr (idx + dellen, -1); @@ -258,7 +257,7 @@ } // ============================================================================ -void str::replace (const char* o, const char* n, unsigned int a) { +void str::replace (const char* o, const char* n, uint a) { for (int idx; (idx = first (o, a)) != -1;) { str s1 = substr (0, idx); str s2 = substr (idx + strlen (o), len()); @@ -277,7 +276,7 @@ } str str::strip (std::initializer_list<char> unwanted) { - str cache = text; + str cache = m_text; uint oldlen = len(); char* buf = new char[oldlen]; @@ -285,11 +284,11 @@ for (uint i = 0; i < oldlen; i++) { bool valid = true; for (const char* j = unwanted.begin(); j < unwanted.end() && valid; j++) - if (text[i] == *j) + if (m_text[i] == *j) valid = false; if (valid) - *bufptr++ = text[i]; + *bufptr++ = m_text[i]; } *bufptr = '\0'; @@ -301,7 +300,7 @@ return zResult; } -void str::insert (char* c, unsigned int pos) { +void str::insert (char* c, uint pos) { str s1 = substr (0, pos); str s2 = substr (pos, len()); @@ -315,7 +314,7 @@ char* buf = new char[len() + 1]; for (uint i = 0; i < len(); i++) - buf[i] = text[len() - i - 1]; + buf[i] = m_text[len() - i - 1]; buf[len()] = '\0'; str other = buf; @@ -328,7 +327,7 @@ str other; for (int i = 0; i < n; i++) - other += text; + other += m_text; return other; } @@ -336,10 +335,10 @@ bool str::isnumber () { ITERATE_STRING (u) { // Minus sign as the first character is allowed for negatives - if (!u && text[u] == '-') + if (!u && m_text[u] == '-') continue; - if (text[u] < '0' || text[u] > '9') + if (m_text[u] < '0' || m_text[u] > '9') return false; } return true; @@ -349,11 +348,11 @@ bool str::isword () { ITERATE_STRING (u) { // lowercase letters - if (text[u] >= 'a' || text[u] <= 'z') + if (m_text[u] >= 'a' || m_text[u] <= 'z') continue; // uppercase letters - if (text[u] >= 'A' || text[u] <= 'Z') + if (m_text[u] >= 'A' || m_text[u] <= 'Z') continue; return false; @@ -362,11 +361,11 @@ } int str::instanceof (const char* c, uint n) { - unsigned int r = 0; - unsigned int index = 0; - unsigned int x = 0; - for (uint a = 0; a < alloclen; a++) { - if (text[a] == c[r]) { + uint r = 0; + uint index = 0; + uint x = 0; + for (uint a = 0; a < m_allocated; a++) { + if (m_text[a] == c[r]) { if (r == 0) index = a; @@ -388,7 +387,7 @@ // ============================================================================ int str::compare (const char* c) { - return strcmp (text, c); + return strcmp (m_text, c); } int str::compare (str c) { @@ -405,11 +404,11 @@ // ============================================================================ str str::tolower () { - str n = text; + str n = m_text; for (uint u = 0; u < len(); u++) { if (n[u] >= 'A' && n[u] < 'Z') - n.text[u] += ('a' - 'A'); + n.m_text[u] += ('a' - 'A'); } return n; @@ -417,30 +416,30 @@ // ============================================================================ str str::toupper () { - str n = text; + str n = m_text; for (uint u = 0; u < len(); u++) { if (n[u] >= 'a' && n[u] < 'z') - n.text[u] -= ('a' - 'A'); + n.m_text[u] -= ('a' - 'A'); } return n; } // ============================================================================ -unsigned str::count (char c) { - unsigned n = 0; +uint str::count (char c) { + uint n = 0; ITERATE_STRING (u) - if (text[u] == c) + if (m_text[u] == c) n++; return n; } -unsigned str::count (char* c) { - unsigned int r = 0; - unsigned int tmp = 0; +uint str::count (char* c) { + uint r = 0; + uint tmp = 0; ITERATE_STRING (u) { - if (text[u] == c[r]) { + if (m_text[u] == c[r]) { r++; if (r == strlen (c)) { r = 0; @@ -459,7 +458,7 @@ // ============================================================================ std::vector<str> str::split (str del, bool bNoBlanks) { std::vector<str> res; - unsigned int a = 0; + uint a = 0; // Find all separators and store the text left to them. while (1) {
--- a/src/str.h Thu May 09 04:01:37 2013 +0300 +++ b/src/str.h Thu May 09 17:03:44 2013 +0300 @@ -25,7 +25,7 @@ #include <vector> #include <QString> -char* vdynformat (const char* csFormat, va_list vArgs, long int lSize); +char* vdynformat (const char* fmtstr, va_list va, long size); class vertex; @@ -33,17 +33,10 @@ // features a good bunch of manipulation methods class str { private: - // The actual message - char* text; - - // Where will append() place new characters? - unsigned short curs; - - // Allocated length - unsigned short alloclen; - - // Resize the text buffer to len characters - void resize (unsigned int len); + char* m_text; + ushort m_writepos; + ushort m_allocated; + void resize (uint len); public: // ====================================================================== @@ -53,133 +46,65 @@ str (QString c); ~str (); - // ====================================================================== - // METHODS - - // Empty the string void clear (); - - // Length of the string - size_t len () { - return strlen (text); - } - - // The char* form of the string + size_t len () { return strlen (m_text); } char* chars (); - - // Dumps the character table of the string void dump (); - - // Appends text to the string void append (const char c); void append (const char* c); void append (str c); void append (QString c); - - // Formats text to the string. void format (const char* fmt, ...); - - // Appends formatted text to the string. void appendformat (const char* c, ...); - - // Returns the first occurrence of c in the string, optionally starting - // from a certain position rather than the start. - int first (const char* c, unsigned int a = 0); - - // Returns the last occurrence of c in the string, optionally starting - // from a certain position rather than the end. + int first (const char* c, uint a = 0); int last (const char* c, int a = -1); - - // Returns a substring of the string, from a to b. - str substr (unsigned int a, unsigned int b); - - // Replace a substring with another substring. - void replace (const char* o, const char* n, unsigned int a = 0); - - // Removes a given index from the string, optionally more characters than just 1. - void remove (unsigned int idx, unsigned int dellen=1); - - // Trims the given amount of characters. If negative, the characters - // are removed from the beginning of the string, if positive, from the - // end of the string. + str substr (uint a, uint b); + void replace (const char* o, const char* n, uint a = 0); + void remove (uint idx, uint dellen = 1); str trim (int dellen); - - // Inserts a substring into a certain position. - void insert (char* c, unsigned int pos); - - // Reverses the string. + void insert (char* c, uint pos); str reverse (); - - // Repeats the string a given amount of times. str repeat (int n); - - // Is the string a number? bool isnumber (); - - // Is the string a word, i.e consists only of alphabetic letters? bool isword (); - - // Convert string to lower case str tolower (); - - // Convert string to upper case str toupper (); - - // Compare this string with another int compare (const char* c); int compare (str c); int icompare (str c); int icompare (const char* c); - - // Counts the amount of substrings in the string - unsigned int count (char* s); - unsigned int count (char s); - - // Counts where the given substring is seen for the nth time - int instanceof (const char* s, unsigned n); - - char subscript (uint pos) { - return operator[] (pos); - } - + uint count (char* c); + uint count (char s); + int instanceof (const char* s, uint n); + char subscript (uint pos) { return operator[] (pos); } std::vector<str> split (str del, bool bNoBlanks = false); - str strip (char c); str strip (std::initializer_list<char> unwanted); - - // ====================================================================== - // OPERATORS - str operator+ (str& c) { - append (c); - return *this; - } - - str& operator+= (char c) { - append (c); - return *this; - } + char* begin () { return &m_text[0]; } + char* end () { return &m_text[len () - 1]; } - str& operator+= (const char* c) { - append (c); - return *this; - } - - str& operator+= (const str c) { - append (c); - return *this; - } - - str& operator+= (const QString c) { - append (c); - return *this; - } - + str operator+ (str& c) { append (c); return *this; } + str& operator+= (char c) { append (c); return *this; } + str& operator+= (const char* c) { append (c); return *this; } + str& operator+= (const str c) { append (c); return *this; } + str& operator+= (const QString c) { append (c); return *this; } str& operator+= (vertex vrt); - - str operator* (const int repcount) { - repeat (repcount); - return *this; - } + str operator* (const int repcount) { repeat (repcount); return *this; } + str operator- (const int trimcount) { return trim (trimcount); }std::vector<str> operator/ (str splitstring); + std::vector<str> operator/ (char* splitstring); + std::vector<str> operator/ (const char* splitstring); + int operator% (str splitstring) { return count (splitstring.chars()); } + int operator% (char* splitstring) { return count (splitstring); } + int operator% (const char* splitstring) { return count (str (splitstring).chars()); } + str operator+ () { return toupper (); } + str operator- () { return tolower (); } + str operator! () { return reverse (); } + size_t operator~ () { return len (); } + char& operator[] (int pos) { return m_text[pos]; } + operator char* () const { return m_text; } + operator QString () const { return m_text; } + operator int () const { return atoi (m_text); } + operator uint () const { return operator int(); } str& operator*= (const int repcount) { str other = repeat (repcount); @@ -188,10 +113,6 @@ return *this; } - str operator- (const int trimcount) { - return trim (trimcount); - } - str& operator-= (const int trimcount) { str other = trim (trimcount); clear (); @@ -199,38 +120,6 @@ return *this; } - std::vector<str> operator/ (str splitstring); - std::vector<str> operator/ (char* splitstring); - std::vector<str> operator/ (const char* splitstring); - - int operator% (str splitstring) { - return count (splitstring.chars()); - } - - int operator% (char* splitstring) { - return count (splitstring); - } - - int operator% (const char* splitstring) { - return count (str (splitstring).chars()); - } - - str operator+ () { - return toupper (); - } - - str operator- () { - return tolower (); - } - - str operator! () { - return reverse (); - } - - size_t operator~ () { - return len (); - } - #define DEFINE_OPERATOR_TYPE(OPER, TYPE) \ bool operator OPER (TYPE other) {return compare(other) OPER 0;} #define DEFINE_OPERATOR(OPER) \ @@ -244,26 +133,6 @@ DEFINE_OPERATOR (<) DEFINE_OPERATOR (>=) DEFINE_OPERATOR (<=) - - char& operator[] (int pos) { - return text[pos]; - } - - operator char* () const { - return text; - } - - operator QString () const { - return text; - } - - operator int () const { - return atoi (text); - } - - operator uint () const { - return operator int(); - } }; str fmt (const char* fmt, ...);
--- a/src/types.h Thu May 09 04:01:37 2013 +0300 +++ b/src/types.h Thu May 09 17:03:44 2013 +0300 @@ -23,8 +23,8 @@ #include "misc.h" typedef unsigned int uint; -typedef short unsigned int ushort; -typedef long unsigned int ulong; +typedef unsigned short ushort; +typedef unsigned long ulong; // Typedef out the _t suffices :) typedef int8_t int8;