Sun, 03 Nov 2019 18:09:47 +0200
renamings
--- a/src/documentmanager.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/documentmanager.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -127,7 +127,7 @@ Model* model = this->findModelByName(modelName); for (int i = 0; i < model->size(); i += 1) { - const QString referenceName = model->getObjectProperty(i, modelobjects::Property::ReferenceName).toString(); + const QString referenceName = model->getObjectProperty(i, linetypes::Property::ReferenceName).toString(); if (not referenceName.isEmpty() and openModels.find(referenceName) == std::end(openModels) and not missing.contains(referenceName))
--- a/src/model.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/model.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -26,7 +26,7 @@ QVariant Model::data(const QModelIndex& index, int role) const { const int row = index.row(); - modelobjects::BaseObject* object = this->body[row].get(); + linetypes::Object* object = this->body[row].get(); switch(role) { case Qt::DisplayRole: @@ -53,9 +53,9 @@ } } -QVariant Model::getObjectProperty(const int index, const modelobjects::Property property) const +QVariant Model::getObjectProperty(const int index, const linetypes::Property property) const { - const modelobjects::BaseObject* object = this->body[index].get(); + const linetypes::Object* object = this->body[index].get(); return object->getProperty(property); }
--- a/src/model.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/model.h Sun Nov 03 18:09:47 2019 +0200 @@ -23,11 +23,11 @@ QVariant data(const QModelIndex& index, int role) const override; QVariant getHeaderProperty(const HeaderProperty property); const QString& getName() const; - QVariant getObjectProperty(const int index, const modelobjects::Property property) const; + QVariant getObjectProperty(const int index, const linetypes::Property property) const; signals: - void objectAdded(modelobjects::Id id, int position); + void objectAdded(linetypes::Id id, int position); private: - using ModelObjectPointer = std::unique_ptr<modelobjects::BaseObject>; + using ModelObjectPointer = std::unique_ptr<linetypes::Object>; template<typename T, typename... Args> T* append(Args&&... args); void append(ModelObjectPointer&& object); @@ -37,7 +37,7 @@ QString path; LDHeader header; std::vector<ModelObjectPointer> body; - std::map<modelobjects::Id, modelobjects::BaseObject*> objectsById; + std::map<linetypes::Id, linetypes::Object*> objectsById; }; template<typename T, typename... Args>
--- a/src/modeleditcontext.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/modeleditcontext.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -5,14 +5,14 @@ { } -void Model::EditContext::append(std::unique_ptr<modelobjects::BaseObject>&& object) +void Model::EditContext::append(std::unique_ptr<linetypes::Object>&& object) { this->model.append(std::move(object)); } void Model::EditContext::setObjectProperty( - modelobjects::BaseObject* object, - modelobjects::Property property, + linetypes::Object* object, + linetypes::Property property, const QVariant& value) { object->setProperty(property, value);
--- a/src/modeleditcontext.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/modeleditcontext.h Sun Nov 03 18:09:47 2019 +0200 @@ -7,12 +7,12 @@ public: template<typename T, typename... Args> T* append(Args&&... args); - void append(std::unique_ptr<modelobjects::BaseObject>&& object); + void append(std::unique_ptr<linetypes::Object>&& object); template<typename T, typename... Args> T* insert(int position, Args&&... args); void setObjectProperty( - modelobjects::BaseObject* object, - modelobjects::Property property, + linetypes::Object* object, + linetypes::Property property, const QVariant &value); private: EditContext(Model& model);
--- a/src/objecttypes/comment.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/comment.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,7 +1,7 @@ #include <QFont> #include "comment.h" -QFont modelobjects::Comment::textRepresentationFont() const +QFont linetypes::Comment::textRepresentationFont() const { QFont font; font.setItalic(true);
--- a/src/objecttypes/comment.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/comment.h Sun Nov 03 18:09:47 2019 +0200 @@ -2,12 +2,12 @@ #include "modelobject.h" #include "metacommand.h" -namespace modelobjects +namespace linetypes { class Comment; } -class modelobjects::Comment : public MetaCommand +class linetypes::Comment : public MetaCommand { using MetaCommand::MetaCommand; QFont textRepresentationFont() const override;
--- a/src/objecttypes/conditionaledge.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/conditionaledge.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,6 +1,6 @@ #include "conditionaledge.h" -modelobjects::ConditionalEdge::ConditionalEdge( +linetypes::ConditionalEdge::ConditionalEdge( const Vertex& point_1, const Vertex& point_2, const Vertex& controlPoint_1, @@ -12,14 +12,14 @@ { } -modelobjects::ConditionalEdge::ConditionalEdge(const QVector<Vertex>& vertices, const Color color) : +linetypes::ConditionalEdge::ConditionalEdge(const QVector<Vertex>& vertices, const Color color) : Edge{vertices[0], vertices[1], color}, controlPoint_1{vertices[2]}, controlPoint_2{vertices[3]} { } -QVariant modelobjects::ConditionalEdge::getProperty(Property property) const +QVariant linetypes::ConditionalEdge::getProperty(Property property) const { switch (property) { @@ -32,7 +32,7 @@ } } -auto modelobjects::ConditionalEdge::setProperty( +auto linetypes::ConditionalEdge::setProperty( Property property, const QVariant& value) -> SetPropertyResult @@ -48,7 +48,7 @@ } } -QString modelobjects::ConditionalEdge::textRepresentation() const +QString linetypes::ConditionalEdge::textRepresentation() const { return Edge::textRepresentation() + utility::format("%1 %2", vertexToStringParens(controlPoint_1),
--- a/src/objecttypes/conditionaledge.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/conditionaledge.h Sun Nov 03 18:09:47 2019 +0200 @@ -1,12 +1,12 @@ #pragma once #include "edge.h" -namespace modelobjects +namespace linetypes { class ConditionalEdge; } -class modelobjects::ConditionalEdge : public Edge +class linetypes::ConditionalEdge : public Edge { public: ConditionalEdge() = default; @@ -15,7 +15,7 @@ const Vertex& point_2, const Vertex& controlPoint_1, const Vertex& controlPoint_2, - const Color color_index = colors::edge); + const Color colorIndex = colors::edge); ConditionalEdge(const QVector<Vertex>& vertices, const Color color); QVariant getProperty(Property property) const override; SetPropertyResult setProperty(
--- a/src/objecttypes/edge.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/edge.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,21 +1,21 @@ #include "edge.h" -modelobjects::Edge::Edge( +linetypes::Edge::Edge( const Vertex& point_1, const Vertex& point_2, const Color color_index) : - ColoredBaseObject{color_index}, + ColoredObject{color_index}, point_1{point_1}, point_2{point_2} {} -modelobjects::Edge::Edge(const QVector<Vertex>& vertices, const Color color) : - ColoredBaseObject{color}, +linetypes::Edge::Edge(const QVector<Vertex>& vertices, const Color color) : + ColoredObject{color}, point_1{vertices[0]}, point_2{vertices[1]} { } -QVariant modelobjects::Edge::getProperty(Property property) const +QVariant linetypes::Edge::getProperty(Property property) const { switch (property) { @@ -28,7 +28,7 @@ } } -auto modelobjects::Edge::setProperty(Property property, const QVariant& value) +auto linetypes::Edge::setProperty(Property property, const QVariant& value) -> SetPropertyResult { switch (property) @@ -44,7 +44,7 @@ } } -QString modelobjects::Edge::textRepresentation() const +QString linetypes::Edge::textRepresentation() const { return utility::format("%1 %2", vertexToStringParens(point_1), vertexToStringParens(point_2)); }
--- a/src/objecttypes/edge.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/edge.h Sun Nov 03 18:09:47 2019 +0200 @@ -1,18 +1,18 @@ #pragma once #include "objecttypes/modelobject.h" -namespace modelobjects +namespace linetypes { class Edge; } -class modelobjects::Edge : public ColoredBaseObject +class linetypes::Edge : public ColoredObject { public: - using BaseClass = ColoredBaseObject; + using BaseClass = ColoredObject; Edge() = default; Edge(const Vertex& point_1, const Vertex& point_2, - const Color color_index = colors::edge); + const Color colorIndex = colors::edge); Edge(const QVector<Vertex>& vertices, const Color color); QVariant getProperty(Property property) const override; SetPropertyResult setProperty(
--- a/src/objecttypes/errorline.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/errorline.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,13 +1,13 @@ #include <QBrush> #include "errorline.h" -modelobjects::ErrorLine::ErrorLine(QStringView text, QStringView message) : +linetypes::ErrorLine::ErrorLine(QStringView text, QStringView message) : text{text.toString()}, message{message.toString()} { } -QVariant modelobjects::ErrorLine::getProperty(Property property) const +QVariant linetypes::ErrorLine::getProperty(Property property) const { switch (property) { @@ -16,11 +16,11 @@ case Property::ErrorMessage: return this->message; default: - return BaseObject::getProperty(property); + return Object::getProperty(property); } } -auto modelobjects::ErrorLine::setProperty( +auto linetypes::ErrorLine::setProperty( Property property, const QVariant& value) -> SetPropertyResult @@ -34,21 +34,21 @@ this->message = value.toString(); return SetPropertyResult::Success; default: - return BaseObject::setProperty(property, value); + return Object::setProperty(property, value); } } -QString modelobjects::ErrorLine::textRepresentation() const +QString linetypes::ErrorLine::textRepresentation() const { return this->text; } -QBrush modelobjects::ErrorLine::textRepresentationForeground() const +QBrush linetypes::ErrorLine::textRepresentationForeground() const { return QBrush{Qt::yellow}; } -QBrush modelobjects::ErrorLine::textRepresentationBackground() const +QBrush linetypes::ErrorLine::textRepresentationBackground() const { return QBrush{Qt::red}; }
--- a/src/objecttypes/errorline.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/errorline.h Sun Nov 03 18:09:47 2019 +0200 @@ -1,12 +1,12 @@ #pragma once #include "modelobject.h" -namespace modelobjects +namespace linetypes { class ErrorLine; } -class modelobjects::ErrorLine : public BaseObject +class linetypes::ErrorLine : public Object { public: ErrorLine(QStringView text = u"", QStringView message = u"");
--- a/src/objecttypes/metacommand.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/metacommand.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,21 +1,21 @@ #include "metacommand.h" -modelobjects::MetaCommand::MetaCommand(QStringView text) : - BaseObject{}, +linetypes::MetaCommand::MetaCommand(QStringView text) : + Object{}, storedText{text.toString()} {} -QVariant modelobjects::MetaCommand::getProperty(Property property) const +QVariant linetypes::MetaCommand::getProperty(Property property) const { switch (property) { case Property::Text: return storedText; default: - return BaseObject::getProperty(property); + return Object::getProperty(property); } } -auto modelobjects::MetaCommand::setProperty(Property property, const QVariant& value) +auto linetypes::MetaCommand::setProperty(Property property, const QVariant& value) -> SetPropertyResult { switch (property) @@ -24,11 +24,11 @@ storedText = value.toString(); return SetPropertyResult::Success; default: - return BaseObject::setProperty(property, value); + return Object::setProperty(property, value); } } -QString modelobjects::MetaCommand::textRepresentation() const +QString linetypes::MetaCommand::textRepresentation() const { return this->storedText; }
--- a/src/objecttypes/metacommand.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/metacommand.h Sun Nov 03 18:09:47 2019 +0200 @@ -1,11 +1,11 @@ #pragma once #include "modelobject.h" -namespace modelobjects +namespace linetypes { class MetaCommand; } -class modelobjects::MetaCommand : public BaseObject +class linetypes::MetaCommand : public Object { public: MetaCommand() = default;
--- a/src/objecttypes/modelobject.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/modelobject.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -18,27 +18,27 @@ return id; } -modelobjects::BaseObject::BaseObject() : +linetypes::Object::Object() : id {getIdForNewObject()} { } -modelobjects::BaseObject::~BaseObject() +linetypes::Object::~Object() { } -bool modelobjects::BaseObject::hasColor() const +bool linetypes::Object::hasColor() const { return false; } -QVariant modelobjects::BaseObject::getProperty(Property id) const +QVariant linetypes::Object::getProperty(Property id) const { Q_UNUSED(id); return {}; } -auto modelobjects::BaseObject::setProperty(Property id, const QVariant& value) +auto linetypes::Object::setProperty(Property id, const QVariant& value) -> SetPropertyResult { Q_UNUSED(id) @@ -46,43 +46,43 @@ return SetPropertyResult::PropertyNotHandled; } -QBrush modelobjects::BaseObject::textRepresentationForeground() const +QBrush linetypes::Object::textRepresentationForeground() const { return {}; } -QBrush modelobjects::BaseObject::textRepresentationBackground() const +QBrush linetypes::Object::textRepresentationBackground() const { return {}; } -QFont modelobjects::BaseObject::textRepresentationFont() const +QFont linetypes::Object::textRepresentationFont() const { return {}; } -modelobjects::ColoredBaseObject::ColoredBaseObject(const Color color_index) : - color_index{color_index} +linetypes::ColoredObject::ColoredObject(const Color color_index) : + colorIndex{color_index} { } -bool modelobjects::ColoredBaseObject::hasColor() const +bool linetypes::ColoredObject::hasColor() const { return true; } -QVariant modelobjects::ColoredBaseObject::getProperty(Property id) const +QVariant linetypes::ColoredObject::getProperty(Property id) const { switch (id) { case Property::Color: - return color_index.index; + return colorIndex.index; default: - return BaseObject::getProperty(id); + return Object::getProperty(id); } } -auto modelobjects::ColoredBaseObject::setProperty(Property id, const QVariant& value) +auto linetypes::ColoredObject::setProperty(Property id, const QVariant& value) -> SetPropertyResult { switch (id) @@ -93,7 +93,7 @@ const int value_int = value.toInt(&ok); if (ok) { - color_index.index = value_int; + colorIndex.index = value_int; return SetPropertyResult::Success; } else @@ -102,11 +102,11 @@ } } default: - return BaseObject::setProperty(id, value); + return Object::setProperty(id, value); } } -QString modelobjects::Empty::textRepresentation() const +QString linetypes::Empty::textRepresentation() const { return ""; }
--- a/src/objecttypes/modelobject.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/modelobject.h Sun Nov 03 18:09:47 2019 +0200 @@ -6,32 +6,35 @@ #include "colors.h" #include "vertex.h" -namespace modelobjects +namespace linetypes { enum class Property; - class BaseObject; - class ColoredBaseObject; + class Object; + class ColoredObject; class Empty; } -enum class modelobjects::Property +/** + * @brief Different properties that can be queried with getProperty + */ +enum class linetypes::Property { - Color, - Text, - Point1, - Point2, - Point3, - Point4, - ControlPoint1, - ControlPoint2, - Position, - Transformation, - ReferenceName, - IsInverted, - ErrorMessage + Color, // Color of the object + Text, // Text contained in a comment + Point1, // First vertex in a polygon or edge line + Point2, // Second vertex in a polygon or edge line + Point3, // Third vertex in a polygon + Point4, // Fourth vertex in a quadrilateral + ControlPoint1, // First control point in a conditional edge line + ControlPoint2, // Second control point in a conditional edge line + Position, // Position of a subfile reference + Transformation, // Transformation matrix of a subfile reference + ReferenceName, // Subfile reference name + IsInverted, // Whether or not the object has been inverted with BFC INVERTNEXT + ErrorMessage // For error lines, why parsing failed }; -class modelobjects::BaseObject +class linetypes::Object { public: enum class SetPropertyResult @@ -40,9 +43,9 @@ PropertyNotHandled, InvalidValue }; - BaseObject(); - BaseObject(const BaseObject&) = delete; - virtual ~BaseObject(); + Object(); + Object(const Object&) = delete; + virtual ~Object(); const unsigned int id; //virtual void toString(QTextStream &out) = 0; virtual bool hasColor() const; @@ -54,23 +57,26 @@ virtual QFont textRepresentationFont() const; }; -class modelobjects::ColoredBaseObject : public BaseObject +class linetypes::ColoredObject : public Object { public: - ColoredBaseObject(const Color color_index = colors::main); + ColoredObject(const Color colorIndex = colors::main); bool hasColor() const override final; QVariant getProperty(Property id) const override; SetPropertyResult setProperty(Property id, const QVariant& value) override; private: - Color color_index = colors::main; + Color colorIndex = colors::main; }; -class modelobjects::Empty : public BaseObject +/** + * @brief Represents an empty line. + */ +class linetypes::Empty : public Object { QString textRepresentation() const override; }; -namespace modelobjects +namespace linetypes { - using Id = std::remove_const_t<decltype(BaseObject::id)>; + using Id = std::decay_t<decltype(Object::id)>; }
--- a/src/objecttypes/polygon.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/polygon.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,22 +1,22 @@ #include "polygon.h" -modelobjects::Triangle::Triangle( +linetypes::Triangle::Triangle( const Vertex& point_1, const Vertex& point_2, const Vertex& point_3, Color color_index) : - ColoredBaseObject{color_index}, + ColoredObject{color_index}, points{point_1, point_2, point_3} { } -modelobjects::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) : - ColoredBaseObject{color}, +linetypes::Triangle::Triangle(const QVector<Vertex>& vertices, const Color color) : + ColoredObject{color}, points{vertices[0], vertices[1], vertices[2]} { } -QVariant modelobjects::Triangle::getProperty(const Property id) const +QVariant linetypes::Triangle::getProperty(const Property id) const { switch (id) { @@ -27,11 +27,11 @@ case Property::Point3: return points[2]; default: - return ColoredBaseObject::getProperty(id); + return ColoredObject::getProperty(id); } } -auto modelobjects::Triangle::setProperty(Property id, const QVariant& value) +auto linetypes::Triangle::setProperty(Property id, const QVariant& value) -> SetPropertyResult { switch (id) @@ -46,11 +46,11 @@ points[2] = value.value<Vertex>(); return SetPropertyResult::Success; default: - return ColoredBaseObject::setProperty(id, value); + return ColoredObject::setProperty(id, value); } } -QString modelobjects::Triangle::textRepresentation() const +QString linetypes::Triangle::textRepresentation() const { return utility::format("%1 %2 %3", vertexToStringParens(points[0]), @@ -58,24 +58,24 @@ vertexToStringParens(points[2])); } -modelobjects::Quadrilateral::Quadrilateral( +linetypes::Quadrilateral::Quadrilateral( const Vertex& point_1, const Vertex& point_2, const Vertex& point_3, const Vertex& point_4, Color color_index) : - ColoredBaseObject{color_index}, + ColoredObject{color_index}, points{point_1, point_2, point_3, point_4} { } -modelobjects::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) : - ColoredBaseObject{color}, +linetypes::Quadrilateral::Quadrilateral(const QVector<Vertex>& vertices, const Color color) : + ColoredObject{color}, points{vertices[0], vertices[1], vertices[2], vertices[3]} { } -QVariant modelobjects::Quadrilateral::getProperty(const Property id) const +QVariant linetypes::Quadrilateral::getProperty(const Property id) const { switch (id) { @@ -88,11 +88,11 @@ case Property::Point4: return points[3]; default: - return ColoredBaseObject::getProperty(id); + return ColoredObject::getProperty(id); } } -auto modelobjects::Quadrilateral::setProperty( +auto linetypes::Quadrilateral::setProperty( const Property id, const QVariant& value) -> SetPropertyResult @@ -112,11 +112,11 @@ points[3] = value.value<Vertex>(); return SetPropertyResult::Success; default: - return ColoredBaseObject::setProperty(id, value); + return ColoredObject::setProperty(id, value); } } -QString modelobjects::Quadrilateral::textRepresentation() const +QString linetypes::Quadrilateral::textRepresentation() const { return utility::format("%1 %2 %3 %4", vertexToStringParens(points[0]),
--- a/src/objecttypes/polygon.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/polygon.h Sun Nov 03 18:09:47 2019 +0200 @@ -1,13 +1,13 @@ #include <array> #include "modelobject.h" -namespace modelobjects +namespace linetypes { class Triangle; class Quadrilateral; } -class modelobjects::Triangle : public ColoredBaseObject +class linetypes::Triangle : public ColoredObject { public: Triangle() = default; @@ -15,7 +15,7 @@ const Vertex &point_1, const Vertex &point_2, const Vertex &point_3, - Color color_index = colors::main); + Color colorIndex = colors::main); Triangle(const QVector<Vertex>& vertices, const Color color); QVariant getProperty(Property id) const override; SetPropertyResult setProperty(Property id, const QVariant& value) override; @@ -24,7 +24,7 @@ Vertex points[3] = {{}}; }; -class modelobjects::Quadrilateral : public ColoredBaseObject +class linetypes::Quadrilateral : public ColoredObject { public: Quadrilateral() = default; @@ -33,7 +33,7 @@ const Vertex &point_2, const Vertex &point_3, const Vertex &point_4, - Color color_index = colors::main); + Color colorIndex = colors::main); Quadrilateral(const QVector<Vertex>& vertices, const Color color); QVariant getProperty(Property id) const override; SetPropertyResult setProperty(Property id, const QVariant& value) override;
--- a/src/objecttypes/subfilereference.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/subfilereference.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -1,18 +1,18 @@ #include "subfilereference.h" -modelobjects::SubfileReference::SubfileReference( +linetypes::SubfileReference::SubfileReference( const Vertex& position, const Matrix3x3& transformation, const QString& referenceName, const Color color) : - ColoredBaseObject{color}, + ColoredObject{color}, position{position}, transformation{transformation}, referenceName{referenceName} { } -QVariant modelobjects::SubfileReference::getProperty(Property property) const +QVariant linetypes::SubfileReference::getProperty(Property property) const { switch (property) { @@ -23,11 +23,11 @@ case Property::ReferenceName: return this->referenceName; default: - return ColoredBaseObject::getProperty(property); + return ColoredObject::getProperty(property); } } -auto modelobjects::SubfileReference::setProperty( +auto linetypes::SubfileReference::setProperty( Property property, const QVariant& value) -> SetPropertyResult @@ -44,11 +44,11 @@ this->referenceName = value.toString(); return SetPropertyResult::Success; default: - return ColoredBaseObject::setProperty(property, value); + return ColoredObject::setProperty(property, value); } } -QString modelobjects::SubfileReference::textRepresentation() const +QString linetypes::SubfileReference::textRepresentation() const { return referenceName + " " + vertexToStringParens(this->position); }
--- a/src/objecttypes/subfilereference.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/objecttypes/subfilereference.h Sun Nov 03 18:09:47 2019 +0200 @@ -2,12 +2,12 @@ #include "modelobject.h" #include "matrix.h" -namespace modelobjects +namespace linetypes { class SubfileReference; } -class modelobjects::SubfileReference : public ColoredBaseObject +class linetypes::SubfileReference : public ColoredObject { public: SubfileReference() = default;
--- a/src/parser.cpp Sun Nov 03 17:57:21 2019 +0200 +++ b/src/parser.cpp Sun Nov 03 18:09:47 2019 +0200 @@ -254,10 +254,10 @@ invertNext = true; continue; } - std::unique_ptr<modelobjects::BaseObject> object = parseFromString(line); + std::unique_ptr<linetypes::Object> object = parseFromString(line); if (invertNext) { - editor.setObjectProperty(object.get(), modelobjects::Property::IsInverted, true); + editor.setObjectProperty(object.get(), linetypes::Property::IsInverted, true); } editor.append(std::move(object)); invertNext = false; @@ -317,22 +317,22 @@ return result; } -static std::unique_ptr<modelobjects::BaseObject> parseType0Line( +static std::unique_ptr<linetypes::Object> parseType0Line( const QString& line, const QStringList& tokens) { Q_UNUSED(tokens) if (line.startsWith("0 //")) { - return std::make_unique<modelobjects::Comment>(line.mid(std::strlen("0 //")).simplified()); + return std::make_unique<linetypes::Comment>(line.mid(std::strlen("0 //")).simplified()); } else { - return std::make_unique<modelobjects::MetaCommand>(line.mid(1).simplified()); + return std::make_unique<linetypes::MetaCommand>(line.mid(1).simplified()); } } -static std::unique_ptr<modelobjects::SubfileReference> parseType1Line( +static std::unique_ptr<linetypes::SubfileReference> parseType1Line( const QString& line, const QStringList& tokens) { @@ -349,7 +349,7 @@ const Vertex position = vertexFromStrings(tokens, positionPosition); const Matrix3x3 transform = matrixFromStrings(tokens, transformPosition); const QString& name = tokens[namePosition]; - return std::make_unique<modelobjects::SubfileReference>(position, transform, name, color); + return std::make_unique<linetypes::SubfileReference>(position, transform, name, color); } template<typename T, int NumVertices> @@ -374,7 +374,7 @@ return std::make_unique<T>(vertices, color); } -std::unique_ptr<modelobjects::BaseObject> Parser::parseFromString(QString line) +std::unique_ptr<linetypes::Object> Parser::parseFromString(QString line) { line = line.simplified(); try @@ -382,7 +382,7 @@ const QStringList tokens = line.split(QRegExp{R"(\s+)"}); if (tokens.empty() or tokens == QStringList{{""}}) { - return std::make_unique<modelobjects::Empty>(); + return std::make_unique<linetypes::Empty>(); } bool ok_code; const int code = tokens[0].toInt(&ok_code); @@ -397,19 +397,19 @@ case 1: return parseType1Line(line, tokens); case 2: - return parsePolygon<modelobjects::Edge, 2>(line, tokens); + return parsePolygon<linetypes::Edge, 2>(line, tokens); case 3: - return parsePolygon<modelobjects::Triangle, 3>(line, tokens); + return parsePolygon<linetypes::Triangle, 3>(line, tokens); case 4: - return parsePolygon<modelobjects::Quadrilateral, 4>(line, tokens); + return parsePolygon<linetypes::Quadrilateral, 4>(line, tokens); case 5: - return parsePolygon<modelobjects::ConditionalEdge, 4>(line, tokens); + return parsePolygon<linetypes::ConditionalEdge, 4>(line, tokens); default: throw BodyParseError{utility::format("bad line type '%1'", code)}; } } catch(const BodyParseError& error) { - return std::make_unique<modelobjects::ErrorLine>(line, error.message); + return std::make_unique<linetypes::ErrorLine>(line, error.message); } }
--- a/src/parser.h Sun Nov 03 17:57:21 2019 +0200 +++ b/src/parser.h Sun Nov 03 18:09:47 2019 +0200 @@ -31,7 +31,7 @@ Parser(QIODevice& device, QObject* parent = nullptr); LDHeader parseHeader(Winding& winding); void parseBody(Model::EditContext& editor); - static std::unique_ptr<modelobjects::BaseObject> parseFromString(QString line); + static std::unique_ptr<linetypes::Object> parseFromString(QString line); private: enum HeaderParseResult {ParseSuccess, ParseFailure, StopParsing}; QString readLine();