Loading...
Searching...
No Matches
plugins/score-plugin-nodal/Nodal/commands.hpp
1#pragma once
2#include <score_plugin_nodal_export.h>
3#include <Process/ProcessList.hpp>
4
5#include <Scenario/Document/ScenarioDocument/ScenarioDocumentModel.hpp>
6
7#include <Dataflow/Commands/CableHelpers.hpp>
8#include <Nodal/CommandFactory.hpp>
9#include <Nodal/Process.hpp>
10
11#include <score/application/ApplicationContext.hpp>
12#include <score/command/AggregateCommand.hpp>
13#include <score/command/PropertyCommand.hpp>
14#include <score/document/DocumentContext.hpp>
15#include <score/plugins/SerializableHelpers.hpp>
16#include <score/tools/IdentifierGeneration.hpp>
17
18#include <score_plugin_deviceexplorer_export.h>
19
20namespace Nodal
21{
22class Model;
23
25{
26 SCORE_COMMAND_DECL(CommandFactoryName(), DropNodesMacro, "Drop nodes")
27};
28
29class SCORE_PLUGIN_NODAL_EXPORT CreateNode final : public score::Command
30{
31 SCORE_COMMAND_DECL(CommandFactoryName(), CreateNode, "Create a node")
32public:
34 const Nodal::Model& process, QPointF position,
35 const UuidKey<Process::ProcessModel>& uuid, const QString& dat,
37
38 void undo(const score::DocumentContext& ctx) const override;
39 void redo(const score::DocumentContext& ctx) const override;
40
41 const Id<Process::ProcessModel>& nodeId() const noexcept { return m_createdNodeId; }
42
43protected:
44 void serializeImpl(DataStreamInput&) const override;
45 void deserializeImpl(DataStreamOutput&) override;
46
47private:
48 Path<Nodal::Model> m_path;
49 QPointF m_pos;
51 QString m_data;
52
53 Id<Process::ProcessModel> m_createdNodeId;
54};
55
56class SCORE_PLUGIN_NODAL_EXPORT RemoveNode final : public score::Command
57{
58 SCORE_COMMAND_DECL(CommandFactoryName(), RemoveNode, "Remove a node")
59public:
61
62private:
63 void undo(const score::DocumentContext& ctx) const override;
64
65 void redo(const score::DocumentContext& ctx) const override;
66
67 void serializeImpl(DataStreamInput& s) const override;
68
69 void deserializeImpl(DataStreamOutput& s) override;
70
71 Path<Nodal::Model> m_path;
73 QByteArray m_block;
74 Dataflow::SerializedCables m_cables;
75};
76
78{
79 SCORE_COMMAND_DECL(CommandFactoryName(), RemoveNodes, "Remove nodes")
80};
81
82class ReplaceAllNodes final : public score::Command
83{
84 SCORE_COMMAND_DECL(CommandFactoryName(), ReplaceAllNodes, "Replace all nodes")
85public:
86 // Expected data format: see Nodal::Model::savePreset
87 ReplaceAllNodes(const Nodal::Model& p, const QByteArray& new_data);
88
89 void undo(const score::DocumentContext& ctx) const override;
90 void redo(const score::DocumentContext& ctx) const override;
91
92 void serializeImpl(DataStreamInput& s) const override;
93 void deserializeImpl(DataStreamOutput& s) override;
94
95private:
96 Path<Nodal::Model> m_path;
97 QByteArray m_old_block, m_new_block;
98 Dataflow::SerializedCables m_old_cables, m_new_cables;
99};
100}
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:30
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:25
Definition score-plugin-nodal/Nodal/Process.hpp:15
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:57
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:78
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:83
The Path class is a typesafe wrapper around ObjectPath.
Definition Path.hpp:52
The Process class.
Definition score-lib-process/Process/Process.hpp:80
Definition UuidKey.hpp:345
The id_base_t class.
Definition Identifier.hpp:59
Allows for grouping of multiple commands in a single one.
Definition AggregateCommand.hpp:15
The Command class.
Definition Command.hpp:34
Definition DataStreamHelpers.hpp:99
Definition DataStreamHelpers.hpp:103
Definition DocumentContext.hpp:18