Loading...
Searching...
No Matches
UpdateCurve.hpp
1#pragma once
2#include <Curve/Commands/CurveCommandFactory.hpp>
3#include <Curve/Segment/CurveSegmentData.hpp>
4
5#include <score/command/Command.hpp>
6#include <score/model/path/Path.hpp>
7
8#include <optional>
9#include <vector>
10
11namespace Curve
12{
13class Model;
14
18{
20 std::optional<SegmentData> before;
21 std::optional<SegmentData> after;
22};
23
26class SCORE_PLUGIN_CURVE_EXPORT UpdateCurve final : public score::Command
27{
28 SCORE_COMMAND_DECL(CommandFactoryName(), UpdateCurve, "Update Curve")
29public:
30 UpdateCurve(const Model& model, const std::vector<SegmentData>& segments);
31
32 void undo(const score::DocumentContext& ctx) const override;
33 void redo(const score::DocumentContext& ctx) const override;
34
36 void update(const Model& model, const std::vector<SegmentData>& segments);
37
38 const std::vector<CurveChange>& changes() const noexcept { return m_changes; }
39
40protected:
41 void serializeImpl(DataStreamInput& s) const override;
42 void deserializeImpl(DataStreamOutput& s) override;
43
44private:
46 bool setChanges(const Model& model, const std::vector<SegmentData>& segments);
47 void apply(const score::DocumentContext& ctx, bool forward) const;
48
49 Path<Model> m_model;
50 std::vector<CurveChange> m_changes;
53 mutable std::vector<CurveChange> m_revert;
54};
55}
Definition CurveModel.hpp:26
Definition UpdateCurve.hpp:27
The Path class is a typesafe wrapper around ObjectPath.
Definition Path.hpp:52
The id_base_t class.
Definition Identifier.hpp:59
The Command class.
Definition Command.hpp:34
Utilities and base classes for 1D curves.
Definition FocusDispatcher.hpp:12
Definition UpdateCurve.hpp:18
Definition DataStreamHelpers.hpp:99
Definition DataStreamHelpers.hpp:103
Definition DocumentContext.hpp:18