src/ui/objecteditor.cpp

Mon, 20 Jun 2022 21:14:27 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Mon, 20 Jun 2022 21:14:27 +0300
changeset 239
74ce5ac84f25
parent 232
8efa3a33172e
child 249
37d3c819cafa
permissions
-rw-r--r--

removed some newlines

#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,
	const CircularFraction*>;

enum PropertyKey
{
	Point1,
	Point2,
	Point3,
	Point4,
	Control1,
	Control2,
	Color,
	Transformation,
	Name,
	Text,
	Code,
	Fraction,
};

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;
		},
		[&](const Colored<CircularPrimitive>& circ) {
			result[Transformation] = &circ.transformation;
			result[Fraction] = &circ.fraction;
			result[Color] = circ.color;
		},
		[&](Empty) {},
		[&](const Comment& comment) {
			result[Text] = &comment.text;
		},
		[&](const ParseError& parseError) {
			result[Code] = &parseError.code;
		},
	}, element);
	return result;
}

mercurial