Wed, 15 Jun 2022 13:03:20 +0300
refactor
#include <QCheckBox> #include <QLineEdit> #include <QFormLayout> #include "objecteditor.h" #include "document.h" #include "widgets/colorbutton.h" #include "widgets/colorindexinput.h" #include "widgets/vec3editor.h" #include "ui_objecteditor.h" using PropertyValue = std::variant< const glm::vec3*, const glm::mat4*, const QString*, ldraw::Color>; enum PropertyKey { Point1, Point2, Point3, Point4, Control1, Control2, Color, Transformation, Name, Text, Code, }; std::map<PropertyKey, PropertyValue> getProperties(const ModelElement& element) { std::map<PropertyKey, PropertyValue> result; std::visit<void>(overloaded{ [&](const Colored<LineSegment>& edge) { result[Point1] = &edge.p1; result[Point2] = &edge.p2; result[Color] = edge.color; }, [&](const Colored<Triangle>& tri) { result[Point1] = &tri.p1; result[Point2] = &tri.p2; result[Point3] = &tri.p3; result[Color] = tri.color; }, [&](const Colored<Quadrilateral>& quad) { result[Point1] = &quad.p1; result[Point2] = &quad.p2; result[Point3] = &quad.p3; result[Point4] = &quad.p4; result[Color] = quad.color; }, [&](const Colored<ConditionalEdge>& cedge) { result[Point1] = &cedge.p1; result[Point2] = &cedge.p2; result[Control1] = &cedge.c1; result[Control2] = &cedge.c2; result[Color] = cedge.color; }, [&](const Colored<SubfileReference>& ref) { result[Transformation] = &ref.transformation; result[Name] = &ref.name; result[Color] = ref.color; }, [&](Empty) {}, [&](const Comment& comment) { result[Text] = &comment.text; }, [&](const ParseError& parseError) { result[Code] = &parseError.code; }, }, element); return result; }