SDFormat Editor
Loading...
Searching...
No Matches
ModifyAttributeCommand.h
1/*
2* sdformat-editor
3* Copyright 2025 sdformat-editor
4*
5* Licensed under the Apache License, Version 2.0 (the "License");
6* you may not use this file except in compliance with the License.
7* You may obtain a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*
17* Developer: Zaid Duraid, Ean Wheeler, Evan Vokey
18*/
19
20#ifndef SDFORMAT_EDITOR_MODIFY_ATTRIBUTE_COMMAND_HH_
21#define SDFORMAT_EDITOR_MODIFY_ATTRIBUTE_COMMAND_HH_
22
23
24#include <interfaces/command_interface.h>
25#include <interfaces/sdformat_parser_interface.h>
26#include <interfaces/gui_interface.h>
27
28#include <vector>
29
31template <typename T>
33{
34
41 public: ModifyAttributeCommand(std::shared_ptr<GUII> gui, std::shared_ptr<SDFormatParserI> sdformatParser, sdf::ParamPtr attribute_to_modify, T new_value);
42
45 private: bool Execute() override;
46
49 private: bool ExecuteUndo() override;
50
53 private: bool ExecuteRedo() override;
54
57 private: bool IsUndoable() override;
58
61 private: bool IsRedoable() override;
62
67 private: bool IsThreaded(bool& prevent_user_input) override;
68
71 private: bool ChangesProgramStateIrreversibly() override;
72
74 private: std::string file_path;
75
77 private: std::shared_ptr<GUII> gui;
78
80 private: std::shared_ptr<SDFormatParserI> sdformatParser;
81
83 private: sdf::ParamPtr attribute_to_modify;
84
86 private: T new_value;
87
89 private: T old_value;
90
92 private: bool is_currently_undoable = true;
93
95 private: bool is_currently_redoable = true;
96};
97
98#endif
The command class encapsulates the interactions between the various interfaces of the SDFormat Editor...
Definition command_interface.h:29
Modify Attribute command implementation of CommandI.
Definition ModifyAttributeCommand.h:33
bool IsRedoable() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:136
T old_value
The value that will be overridden in the attribute.
Definition ModifyAttributeCommand.h:89
bool IsThreaded(bool &prevent_user_input) override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:141
T new_value
The value that will be given to the element.
Definition ModifyAttributeCommand.h:86
std::shared_ptr< SDFormatParserI > sdformatParser
Pointer to the sdformat parser interface.
Definition ModifyAttributeCommand.h:80
bool ChangesProgramStateIrreversibly() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:147
std::string file_path
Filepath of the model.
Definition ModifyAttributeCommand.h:74
bool Execute() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:27
bool ExecuteUndo() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:107
bool is_currently_redoable
Store if the command is currently redo-able.
Definition ModifyAttributeCommand.h:95
std::shared_ptr< GUII > gui
Pointer to the gui interface.
Definition ModifyAttributeCommand.h:77
bool IsUndoable() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:131
sdf::ParamPtr attribute_to_modify
Pointer to the attribute to modify.
Definition ModifyAttributeCommand.h:83
bool ExecuteRedo() override
Implementation of interface method.
Definition ModifyAttributeCommand.cpp:119
bool is_currently_undoable
Store if the command is currently undo-able.
Definition ModifyAttributeCommand.h:92