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);
35
36 void undo(const score::DocumentContext& ctx) const override;
37 void redo(const score::DocumentContext& ctx) const override;
38
39 const Id<Process::ProcessModel>& nodeId() const noexcept { return m_createdNodeId; }
40
41protected:
42 void serializeImpl(DataStreamInput&) const override;
43 void deserializeImpl(DataStreamOutput&) override;
44
45private:
46 Path<Nodal::Model> m_path;
47 QPointF m_pos;
49 QString m_data;
50
51 Id<Process::ProcessModel> m_createdNodeId;
52};
53
54class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT RemoveNode final : public score::Command
55{
56 SCORE_COMMAND_DECL(CommandFactoryName(), RemoveNode, "Remove a node")
57public:
59
60private:
61 void undo(const score::DocumentContext& ctx) const override;
62
63 void redo(const score::DocumentContext& ctx) const override;
64
65 void serializeImpl(DataStreamInput& s) const override;
66
67 void deserializeImpl(DataStreamOutput& s) override;
68
69 Path<Nodal::Model> m_path;
71 QByteArray m_block;
72 Dataflow::SerializedCables m_cables;
73};
74
76{
77 SCORE_COMMAND_DECL(CommandFactoryName(), RemoveNodes, "Remove nodes")
78};
79
80class ReplaceAllNodes final : public score::Command
81{
82 SCORE_COMMAND_DECL(CommandFactoryName(), ReplaceAllNodes, "Replace all nodes")
83public:
84 // Expected data format: see Nodal::Model::savePreset
85 ReplaceAllNodes(const Nodal::Model& p, const QByteArray& new_data);
86
87 void undo(const score::DocumentContext& ctx) const override;
88 void redo(const score::DocumentContext& ctx) const override;
89
90 void serializeImpl(DataStreamInput& s) const override;
91 void deserializeImpl(DataStreamOutput& s) override;
92
93private:
94 Path<Nodal::Model> m_path;
95 QByteArray m_old_block, m_new_block;
96 Dataflow::SerializedCables m_old_cables, m_new_cables;
97};
98}
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:55
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:76
Definition plugins/score-plugin-nodal/Nodal/commands.hpp:81
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:57
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