diff --git a/src/mainwindow/pathactions.cpp b/src/mainwindow/pathactions.cpp index 7741d46ff..e2661e711 100644 --- a/src/mainwindow/pathactions.cpp +++ b/src/mainwindow/pathactions.cpp @@ -1,12 +1,4 @@ #include "mainwindow/pathactions.h" - } else { - worker.sub(EMPTY_POINTER)->set_value(false); - worker.sub(PATH_ID_POINTER)->set_value(path_points.front()->path_vector()->path_object()->id()); - worker.set_value(path_points, [](const auto* path_point, auto& worker) { - worker.set_value(path_point->index()); - }); - } -} #include "commands/addcommand.h" #include "commands/joinpointscommand.h" #include "commands/modifypointscommand.h" @@ -181,24 +173,6 @@ void remove_selected_faces(Application& app) Q_UNUSED(app) } -void convert_objects(Application& app) -{ - const auto convertibles = util::remove_if(app.scene->item_selection(), [](const Object* o) { - return !(o->flags() & Flag::Convertible); - }); - if (!convertibles.empty()) { - Scene& scene = *app.scene; - auto macro = scene.history().start_macro(QObject::tr("convert")); - scene.submit(*app.scene, convertibles); - const auto converted_objects = convert_objects_recursively(app, convertibles); - scene.submit(*app.scene, converted_objects); - const auto is_path = [](auto&& object) { return object->type() == PathObject::TYPE; }; - if (std::all_of(converted_objects.begin(), converted_objects.end(), is_path)) { - scene.set_mode(SceneMode::Vertex); - } - } -} - void remove_selected_items(Application& app) { switch (app.scene_mode()) { diff --git a/src/path/face.h b/src/path/face.h index 2336f66eb..303fb37c5 100644 --- a/src/path/face.h +++ b/src/path/face.h @@ -1,5 +1,6 @@ #pragma once +#include "path/edge.h" #include #include #include @@ -10,9 +11,14 @@ class QPainterPath; namespace omm { +namespace serialization +{ +class SerializerWorker; +class DeserializerWorker; +} // namespace serialization + class Point; class PathPoint; -class Edge; class Face { @@ -59,6 +65,10 @@ class Face [[nodiscard]] bool operator!=(const Face& other) const; [[nodiscard]] bool operator<(const Face& other) const; + class ReferencePolisher; + void serialize(serialization::SerializerWorker& worker) const; + void deserialize(serialization::DeserializerWorker& worker); + private: std::deque m_edges; }; diff --git a/src/properties/facelistproperty.cpp b/src/properties/facelistproperty.cpp index 4decd98cc..c0b4f4ecd 100644 --- a/src/properties/facelistproperty.cpp +++ b/src/properties/facelistproperty.cpp @@ -1,16 +1,10 @@ #include "properties/facelistproperty.h" -#include namespace omm { const Property::PropertyDetail FaceListProperty::detail{nullptr}; -FaceListProperty::FaceListProperty(const FaceList& default_value) - : TypedProperty(default_value) -{ -} - void FaceListProperty::deserialize(serialization::DeserializerWorker &worker) { TypedProperty::deserialize(worker); diff --git a/src/properties/facelistproperty.h b/src/properties/facelistproperty.h index 4a3af007e..c556a08a2 100644 --- a/src/properties/facelistproperty.h +++ b/src/properties/facelistproperty.h @@ -9,10 +9,9 @@ namespace omm class FaceListProperty : public TypedProperty { public: - explicit FaceListProperty(const FaceList& default_value = FaceList{}); + using TypedProperty::TypedProperty; void deserialize(serialization::DeserializerWorker& worker) override; void serialize(serialization::SerializerWorker& worker) const override; - static constexpr auto MODE_PROPERTY_KEY = "mode"; static const PropertyDetail detail; }; diff --git a/src/properties/facesproperty.cpp b/src/properties/facesproperty.cpp new file mode 100644 index 000000000..e20d1fe49 --- /dev/null +++ b/src/properties/facesproperty.cpp @@ -0,0 +1,21 @@ +//#include "properties/facesproperty.h" + + +//namespace omm +//{ + +//const Property::PropertyDetail FacesProperty::detail{nullptr}; + +//void FacesProperty::deserialize(serialization::DeserializerWorker& worker) +//{ +// TypedProperty::deserialize(worker); +// set(worker.sub(TypedPropertyDetail::VALUE_POINTER)->get()); +//} + +//void FacesProperty::serialize(serialization::SerializerWorker& worker) const +//{ +// TypedProperty::serialize(worker); +// worker.sub(TypedPropertyDetail::VALUE_POINTER)->set_value(value()); +//} + +//} // namespace omm diff --git a/src/properties/facesproperty.h b/src/properties/facesproperty.h new file mode 100644 index 000000000..6968abac3 --- /dev/null +++ b/src/properties/facesproperty.h @@ -0,0 +1,19 @@ +//#pragma once + +//#include "path/face.h" +//#include "properties/typedproperty.h" + + +//namespace omm +//{ + +//class FacesProperty : public TypedProperty +//{ +//public: +// using TypedProperty::TypedProperty; +// void deserialize(serialization::DeserializerWorker& worker) override; +// void serialize(serialization::SerializerWorker& worker) const override; +// static const PropertyDetail detail; +//}; + +//} // namespace omm diff --git a/src/properties/splineproperty.cpp b/src/properties/splineproperty.cpp index a4acf1fdd..d4a8242d8 100644 --- a/src/properties/splineproperty.cpp +++ b/src/properties/splineproperty.cpp @@ -2,12 +2,8 @@ namespace omm { -const Property::PropertyDetail SplineProperty::detail{nullptr}; -SplineProperty::SplineProperty(const omm::SplineType& default_value) - : TypedProperty(default_value) -{ -} +const Property::PropertyDetail SplineProperty::detail{nullptr}; void SplineProperty::deserialize(serialization::DeserializerWorker& worker) { diff --git a/src/properties/splineproperty.h b/src/properties/splineproperty.h index 45eccbf69..0165781c5 100644 --- a/src/properties/splineproperty.h +++ b/src/properties/splineproperty.h @@ -2,14 +2,14 @@ #include "properties/typedproperty.h" #include "splinetype.h" -#include namespace omm { + class SplineProperty : public TypedProperty { public: - explicit SplineProperty(const SplineType& default_value = SplineType()); + using TypedProperty::TypedProperty; void deserialize(serialization::DeserializerWorker& worker) override; void serialize(serialization::SerializerWorker& worker) const override; static constexpr auto MODE_PROPERTY_KEY = "mode"; diff --git a/src/propertytypeenum.h b/src/propertytypeenum.h index 685f05984..72bd254b0 100644 --- a/src/propertytypeenum.h +++ b/src/propertytypeenum.h @@ -16,7 +16,7 @@ class FaceList; enum class Type{ Invalid, Float, Integer, Option, FloatVector, - IntegerVector, String, Color, Reference, Bool, Spline, Trigger, FaceList + IntegerVector, String, Color, Reference, Bool, Spline, Trigger, Faces, }; constexpr bool is_integral(const Type type) @@ -47,7 +47,7 @@ constexpr bool is_color(const Type type) constexpr auto variant_types = std::array{ Type::Bool, Type::Float, Type::Color, Type::Integer, Type::IntegerVector, Type::FloatVector, Type::Reference, Type::String, Type::Option, Type::Trigger, - Type::FloatVector, Type::IntegerVector, Type::Spline, Type::FaceList, Type::Invalid + Type::FloatVector, Type::IntegerVector, Type::Spline, Type::Faces, Type::Invalid }; constexpr std::string_view variant_type_name(const Type type) noexcept @@ -75,8 +75,8 @@ constexpr std::string_view variant_type_name(const Type type) noexcept return QT_TRANSLATE_NOOP("DataType", "IntegerVector"); case Type::Spline: return QT_TRANSLATE_NOOP("DataType", "Spline"); - case Type:: FaceList: - return QT_TRANSLATE_NOOP("DataType", "FaceList"); + case Type::Faces: + return QT_TRANSLATE_NOOP("DataType", "Faces"); case Type:: Invalid: return QT_TRANSLATE_NOOP("DataType", "Invalid"); } @@ -111,7 +111,7 @@ template constexpr Type get_variant_type() noexcept } else if constexpr (std::is_same_v) { return Type::Spline; } else if constexpr (std::is_same_v) { - return Type::FaceList; + return Type::Faces; } else { return Type::Invalid; } diff --git a/src/renderers/offscreenrenderer.cpp b/src/renderers/offscreenrenderer.cpp index 31bc06a98..9b48bd20e 100644 --- a/src/renderers/offscreenrenderer.cpp +++ b/src/renderers/offscreenrenderer.cpp @@ -190,7 +190,7 @@ void set_uniform(omm::OffscreenRenderer& self, const QString& name, const T& val const auto mat = value.to_qmatrix3x3(); program->setUniformValue(location, mat); } else if constexpr (std::is_same_v) { - // FaceList is not available in GLSL + // faces is not available in GLSL } else { // statically fail here. If you're data type is not supported, add it explicitely. static_assert(std::is_same_v && !std::is_same_v); diff --git a/src/scene/disjointpathpointsetforest.cpp b/src/scene/disjointpathpointsetforest.cpp index e91d4ff56..54c76de69 100644 --- a/src/scene/disjointpathpointsetforest.cpp +++ b/src/scene/disjointpathpointsetforest.cpp @@ -8,13 +8,14 @@ #include "objects/pathobject.h" #include "scene/scene.h" -static constexpr auto FOREST_POINTER = "forest"; -static constexpr auto PATH_ID_POINTER = "path-id"; -static constexpr auto INDEX_POINTER = "index"; namespace { +static constexpr auto FOREST_POINTER = "forest"; +static constexpr auto PATH_ID_POINTER = "path-id"; +static constexpr auto INDEX_POINTER = "index"; + struct PathPointId { constexpr explicit PathPointId(const std::size_t path_id, const std::size_t point_index) @@ -51,8 +52,8 @@ class DisjointPathPointSetForest::ReferencePolisher : public omm::serialization: for (const auto& set : m_joined_point_indices) { auto& forest_set = m_ref.m_forest.emplace_back(); for (const auto& [path_id, point_index] : set) { - auto* path_object = dynamic_cast(map.at(path_id)); - auto& path_point = path_object->geometry().point_at_index(point_index); + const auto& path_object = dynamic_cast(*map.at(path_id)); + auto& path_point = path_object.geometry().point_at_index(point_index); forest_set.insert(&path_point); } } diff --git a/src/serializers/deserializerworker.cpp b/src/serializers/deserializerworker.cpp index 56c20fd27..b187ea265 100644 --- a/src/serializers/deserializerworker.cpp +++ b/src/serializers/deserializerworker.cpp @@ -87,6 +87,8 @@ variant_type DeserializerWorker::get(const QString& type) return get(); } else if (type == "IntegerVector") { return get(); + } else if (type == "FacesList") { + return get(); } else if (type == "SplineType") { return get(); } else if (type == "Reference") { diff --git a/src/variant.h b/src/variant.h index 1b047fc1f..02b7c0f0b 100644 --- a/src/variant.h +++ b/src/variant.h @@ -1,12 +1,14 @@ #pragma once #include "color/color.h" +#include "path/face.h" #include "geometry/vec2.h" #include "logging.h" #include "splinetype.h" #include "facelist.h" #include #include +#include namespace omm { @@ -23,8 +25,8 @@ class TriggerPropertyDummyValueType { return false; } -} -; +}; + using variant_type = std::variant