Thu, 21 Jun 2018 17:02:58 +0300
fixed compile errors in some cases, bezier curve now stores the segment count in each object (not editable yet)
--- a/src/glcompiler.cpp Wed Jun 20 00:00:26 2018 +0300 +++ b/src/glcompiler.cpp Thu Jun 21 17:02:58 2018 +0300 @@ -372,14 +372,6 @@ } break; - case LDObjectType::BezierCurve: - { - LDBezierCurve* curve = static_cast<LDBezierCurve*>(object); - for (LDPolygon& polygon : curve->rasterizePolygons(grid()->bezierCurveSegments())) - compilePolygon (polygon, index, info); - } - break; - default: if (object->isRasterizable()) {
--- a/src/headerhistorymodel.h Wed Jun 20 00:00:26 2018 +0300 +++ b/src/headerhistorymodel.h Thu Jun 21 17:02:58 2018 +0300 @@ -19,7 +19,7 @@ #pragma once #include <QAbstractTableModel> -class LDHeader; +struct LDHeader; class HeaderHistoryModel : public QAbstractTableModel {
--- a/src/linetypes/modelobject.cpp Wed Jun 20 00:00:26 2018 +0300 +++ b/src/linetypes/modelobject.cpp Thu Jun 21 17:02:58 2018 +0300 @@ -465,9 +465,9 @@ return Vertex(); } -void LDBezierCurve::rasterize(Model& model, int segments) +void LDBezierCurve::rasterize(DocumentManager* context, Winding winding, Model& model, bool, bool) { - QVector<LDPolygon> polygons = rasterizePolygons(segments); + QVector<LDPolygon> polygons = rasterizePolygons(context, winding); for (LDPolygon& poly : polygons) { @@ -476,21 +476,21 @@ } } -QVector<LDPolygon> LDBezierCurve::rasterizePolygons(int segments) +QVector<LDPolygon> LDBezierCurve::rasterizePolygons(DocumentManager*, Winding) { QVector<LDPolygon> result; QVector<Vertex> parms; parms.append (pointAt (0.0)); - for (int i = 1; i < segments; ++i) - parms.append (pointAt (double (i) / segments)); + for (int i = 1; i < m_segments; ++i) + parms.append (pointAt (double (i) / m_segments)); parms.append (pointAt (1.0)); LDPolygon poly; poly.color = color().index(); poly.type = LDPolygon::Type::EdgeLine; - for (int i = 0; i < segments; ++i) + for (int i = 0; i < m_segments; ++i) { poly.vertices[0] = parms[i]; poly.vertices[1] = parms[i + 1]; @@ -500,6 +500,22 @@ return result; } +void LDBezierCurve::serialize(Serializer& serializer) +{ + LDObject::serialize(serializer); + serializer << m_segments; +} + +int LDBezierCurve::segments() const +{ + return m_segments; +} + +void LDBezierCurve::setSegments(int newSegments) +{ + changeProperty(&m_segments, newSegments); +} + LDSubfileReference::LDSubfileReference( QString referenceName, const QMatrix4x4& matrix
--- a/src/linetypes/modelobject.h Wed Jun 20 00:00:26 2018 +0300 +++ b/src/linetypes/modelobject.h Thu Jun 21 17:02:58 2018 +0300 @@ -221,11 +221,17 @@ virtual QString asText() const override; Vertex pointAt (qreal t) const; - void rasterize(Model& model, int segments); - QVector<LDPolygon> rasterizePolygons (int segments); + void rasterize(DocumentManager*context, Winding winding, Model&, bool, bool) override; + QVector<LDPolygon> rasterizePolygons(DocumentManager*, Winding) override; int numVertices() const override { return 4; } LDColor defaultColor() const override { return EdgeColor; } QString iconName() const override { return "beziercurve"; } + void serialize(class Serializer& serializer) override; + int segments() const; + void setSegments(int newSegments); + +private: + int m_segments = 8; }; enum
--- a/src/parser.h Wed Jun 20 00:00:26 2018 +0300 +++ b/src/parser.h Thu Jun 21 17:02:58 2018 +0300 @@ -20,7 +20,7 @@ #include "main.h" #include "lddocument.h" -class LDHeader; +struct LDHeader; class Model; class Parser : public QObject
--- a/src/toolsets/basictoolset.cpp Wed Jun 20 00:00:26 2018 +0300 +++ b/src/toolsets/basictoolset.cpp Thu Jun 21 17:02:58 2018 +0300 @@ -137,13 +137,6 @@ } } } - - for (LDBezierCurve* curve : filterByType<LDBezierCurve> (selectedObjects())) - { - Model curveModel {m_documents}; - curve->rasterize(curveModel, grid()->bezierCurveSegments()); - currentDocument()->replace(curve, curveModel); - } } void BasicToolset::inlineShallow()
--- a/src/toolsets/extprogramtoolset.cpp Wed Jun 20 00:00:26 2018 +0300 +++ b/src/toolsets/extprogramtoolset.cpp Thu Jun 21 17:02:58 2018 +0300 @@ -158,13 +158,6 @@ obj->rasterize(m_documents, CounterClockwise, model, true, false); writeObjects(model.objects(), f); } - else if (obj->type() == LDObjectType::BezierCurve) - { - LDBezierCurve* curve = static_cast<LDBezierCurve*> (obj); - Model model {m_documents}; - curve->rasterize(model, grid()->bezierCurveSegments()); - writeObjects(model.objects(), f); - } else f.write ((obj->asText() + "\r\n").toUtf8()); }