Sat, 01 Jun 2013 20:31:33 +0300
Make LDRadial's members accessed properties
src/addObjectDialog.cpp | file | annotate | diff | comparison | revisions | |
src/common.h | file | annotate | diff | comparison | revisions | |
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/ldtypes.cpp | file | annotate | diff | comparison | revisions | |
src/ldtypes.h | file | annotate | diff | comparison | revisions |
--- a/src/addObjectDialog.cpp Sat Jun 01 20:09:31 2013 +0300 +++ b/src/addObjectDialog.cpp Sat Jun 01 20:31:33 2013 +0300 @@ -172,10 +172,10 @@ if (obj) { LDRadial* rad = static_cast<LDRadial*> (obj); - 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); + rb_radType->setValue (rad->type ()); + sb_radSegments->setValue (rad->segments ()); + cb_radHiRes->setChecked ((rad->divisions () == hires) ? Qt::Checked : Qt::Unchecked); + sb_radRingNum->setValue (rad->number ()); } break; @@ -430,16 +430,16 @@ case LDObject::Radial: { - LDRadial* pRad = initObj<LDRadial> (obj); + LDRadial* rad = initObj<LDRadial> (obj); for (const Axis ax : g_Axes) - pRad->pos[ax] = dlg.dsb_coords[ax]->value (); + rad->pos[ax] = dlg.dsb_coords[ax]->value (); - 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; + rad->setDivisions (dlg.cb_radHiRes->isChecked () ? hires : lores); + rad->setSegments (min<short> (dlg.sb_radSegments->value (), rad->divisions ())); + rad->setType ((LDRadial::Type) dlg.rb_radType->value ()); + rad->setNumber (dlg.sb_radRingNum->value ()); + rad->transform = transform; } break;
--- a/src/common.h Sat Jun 01 20:09:31 2013 +0300 +++ b/src/common.h Sat Jun 01 20:31:33 2013 +0300 @@ -178,6 +178,9 @@ static const short maincolor = 16; static const short edgecolor = 24; +static const short lores = 16; +static const short hires = 48; + static const bool yup = true; static const bool nope = false;
--- a/src/file.cpp Sat Jun 01 20:09:31 2013 +0300 +++ b/src/file.cpp Sat Jun 01 20:31:33 2013 +0300 @@ -653,12 +653,11 @@ LDRadial* obj = new LDRadial; - obj->radType = eType; + obj->setType (eType); obj->setColor (atol (tokens[4])); - obj->segs = atol (tokens[5]); - obj->divs = atol (tokens[6]); - obj->ringNum = atol (tokens[7]); - + obj->setSegments (atol (tokens[5])); + obj->setDivisions (atol (tokens[6])); + obj->setNumber (atol (tokens[7])); obj->pos = parseVertex (tokens, 8); // 8 - 10 for (short i = 0; i < 9; ++i)
--- a/src/gui.cpp Sat Jun 01 20:09:31 2013 +0300 +++ b/src/gui.cpp Sat Jun 01 20:31:33 2013 +0300 @@ -651,13 +651,13 @@ case LDObject::Radial: { - LDRadial* pRad = static_cast<LDRadial*> (obj); - descr.format ("%d / %d %s", pRad->segs, pRad->divs, pRad->radialTypeName()); + LDRadial* rad = static_cast<LDRadial*> (obj); + descr.format ("%d / %d %s", rad->segments (), rad->divisions (), rad->radialTypeName ()); - if (pRad->radType == LDRadial::Ring || pRad->radType == LDRadial::Cone) - descr += fmt (" %d", pRad->ringNum); + if (rad->type () == LDRadial::Ring || rad->type () == LDRadial::Cone) + descr += fmt (" %d", rad->number ()); - descr += fmt (" %s", pRad->pos.stringRep (true).chars ()); + descr += fmt (" %s", rad->pos.stringRep (true).chars ()); } break;
--- a/src/ldtypes.cpp Sat Jun 01 20:09:31 2013 +0300 +++ b/src/ldtypes.cpp Sat Jun 01 20:31:33 2013 +0300 @@ -502,11 +502,11 @@ }; char const* LDRadial::radialTypeName () { - return g_saRadialTypeNames[radType]; + return g_saRadialTypeNames[type ()]; } -char const* LDRadial::radialTypeName (const LDRadial::Type eType) { - return g_saRadialTypeNames[eType]; +char const* LDRadial::radialTypeName (const LDRadial::Type typeval) { + return g_saRadialTypeNames[typeval]; } // ============================================================================= @@ -515,13 +515,13 @@ vector<LDObject*> LDRadial::decompose (bool applyTransform) { vector<LDObject*> objs; - 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); + for (short i = 0; i < segments (); ++i) { + double x0 = cos ((i * 2 * pi) / divisions ()), + x1 = cos (((i + 1) * 2 * pi) / divisions ()), + z0 = sin ((i * 2 * pi) / divisions ()), + z1 = sin (((i + 1) * 2 * pi) / divisions ()); - switch (radType) { + switch (type ()) { case LDRadial::Circle: { vertex v0 (x0, 0.0f, z0), @@ -549,7 +549,7 @@ double x2, x3, z2, z3; double y0, y1, y2, y3; - if (radType == LDRadial::Cylinder) { + if (type () == LDRadial::Cylinder) { x2 = x1; x3 = x0; z2 = z1; @@ -558,17 +558,17 @@ y0 = y1 = 0.0f; y2 = y3 = 1.0f; } else { - x2 = x1 * (ringNum + 1); - x3 = x0 * (ringNum + 1); - z2 = z1 * (ringNum + 1); - z3 = z0 * (ringNum + 1); + x2 = x1 * (number () + 1); + x3 = x0 * (number () + 1); + z2 = z1 * (number () + 1); + z3 = z0 * (number () + 1); - x0 *= ringNum; - x1 *= ringNum; - z0 *= ringNum; - z1 *= ringNum; + x0 *= number (); + x1 *= number (); + z0 *= number (); + z1 *= number (); - if (radType == LDRadial::Ring) { + if (type () == LDRadial::Ring) { y0 = y1 = y2 = y3 = 0.0f; } else { y0 = y1 = 1.0f; @@ -605,7 +605,7 @@ { double x2, z2; - if (radType == LDRadial::Disc) { + if (type () == LDRadial::Disc) { x2 = z2 = 0.0f; } else { x2 = (x0 >= 0.0f) ? 1.0f : -1.0f; @@ -646,8 +646,8 @@ // ============================================================================= str LDRadial::getContents () { return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", - str (radialTypeName()).upper ().strip (' ').c (), - color (), segs, divs, ringNum, + str (radialTypeName ()).upper ().strip (' ').c (), + color (), segments (), divisions (), number (), pos.stringRep (false).chars(), transform.stringRep().chars()); } @@ -665,8 +665,8 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= str LDRadial::makeFileName () { - short numer = segs, - denom = divs; + short numer = segments (), + denom = divisions (); // Simplify the fractional part, but the denominator must be at least 4. simplify (numer, denom); @@ -679,10 +679,10 @@ } // Compose some general information: prefix, fraction, root, ring number - str prefix = (divs == 16) ? "" : fmt ("%d/", divs); + str prefix = (divisions () == lores) ? "" : fmt ("%d/", divisions ()); str frac = fmt ("%d-%d", numer, denom); - str root = g_radialNameRoots[radType]; - str num = (radType == Ring || radType == Cone) ? fmt ("%d", ringNum) : ""; + str root = g_radialNameRoots[type ()]; + str num = (type () == Ring || type () == Cone) ? fmt ("%d", number ()) : ""; // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters.
--- a/src/ldtypes.h Sat Jun 01 20:09:31 2013 +0300 +++ b/src/ldtypes.h Sat Jun 01 20:31:33 2013 +0300 @@ -384,17 +384,21 @@ NumTypes }; + PROPERTY (LDRadial::Type, type, setType) + PROPERTY (short, divisions, setDivisions) + PROPERTY (short, segments, setSegments) + PROPERTY (short, number, setNumber) + +public: LDOBJ (Radial) LDOBJ_VERTICES (0) LDOBJ_COLORED LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX - LDRadial::Type radType; - short divs, segs, ringNum; - LDRadial (LDRadial::Type radType, vertex pos, matrix transform, short divs, short segs, short ringNum) : - LDMatrixObject (transform, pos), radType (radType), divs (divs), segs (segs), ringNum (ringNum) {} + LDMatrixObject (transform, pos), PROP_NAME (type) (radType), PROP_NAME (divisions) (divs), + PROP_NAME (segments) (segs), PROP_NAME (number) (ringNum) {} // Returns a set of objects that provide the equivalent of this radial. // Note: objects are heap-allocated.