SDFormat Editor
Loading...
Searching...
No Matches
ModifyElementCommand.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_ELEMENT_COMMAND_HH_
21#define SDFORMAT_EDITOR_MODIFY_ELEMENT_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{
40 public: ModifyElementCommand(std::shared_ptr<GUII> gui, std::shared_ptr<SDFormatParserI> sdformatParser, sdf::ElementPtr element_to_modify, T new_value);
41
44 private: bool Execute() override;
45
48 private: bool ExecuteUndo() override;
49
52 private: bool ExecuteRedo() override;
53
56 private: bool IsUndoable() override;
57
60 private: bool IsRedoable() override;
61
66 private: bool IsThreaded(bool& prevent_user_input) override;
67
70 private: bool ChangesProgramStateIrreversibly() override;
71
73 private: std::string file_path;
74
76 private: std::shared_ptr<GUII> gui;
77
79 private: std::shared_ptr<SDFormatParserI> sdformatParser;
80
82 private: sdf::ElementPtr element_to_modify;
83
85 private: T new_value;
86
88 private: T old_value;
89
91 private: bool is_currently_undoable = true;
92
94 private: bool is_currently_redoable = true;
95};
96
97#endif
The command class encapsulates the interactions between the various interfaces of the SDFormat Editor...
Definition command_interface.h:29
Modify Element command implementation of CommandI.
Definition ModifyElementCommand.h:33
bool Execute() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:27
T new_value
The value that will be given to the element.
Definition ModifyElementCommand.h:85
bool is_currently_redoable
Store if the command is currently redo-able.
Definition ModifyElementCommand.h:94
bool IsThreaded(bool &prevent_user_input) override
Implementation of interface method.
Definition ModifyElementCommand.cpp:144
bool IsUndoable() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:134
std::string file_path
Filepath of the model.
Definition ModifyElementCommand.h:73
std::shared_ptr< GUII > gui
Pointer to the gui interface.
Definition ModifyElementCommand.h:76
std::shared_ptr< SDFormatParserI > sdformatParser
Pointer to the sdformat parser interface.
Definition ModifyElementCommand.h:79
bool ExecuteRedo() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:122
bool IsRedoable() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:139
bool ChangesProgramStateIrreversibly() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:150
bool ExecuteUndo() override
Implementation of interface method.
Definition ModifyElementCommand.cpp:110
bool is_currently_undoable
Store if the command is currently undo-able.
Definition ModifyElementCommand.h:91
T old_value
The value that will be overridden in the element.
Definition ModifyElementCommand.h:88
sdf::ElementPtr element_to_modify
Pointer to the element to modify.
Definition ModifyElementCommand.h:82