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