SDFormat Editor
Loading...
Searching...
No Matches
DeleteElementCommand.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_DELETE_ELEMENT_COMMAND_HH_
21#define SDFORMAT_EDITOR_DELETE_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
32{
33
39 public: DeleteElementCommand(std::shared_ptr<GUII> gui, std::shared_ptr<SDFormatParserI> sdformatParser, sdf::ElementPtr element_to_delete);
40
43 private: bool Execute() override;
44
47 private: bool ExecuteUndo() override;
48
51 private: bool ExecuteRedo() override;
52
55 private: bool IsUndoable() override;
56
59 private: bool IsRedoable() override;
60
65 private: bool IsThreaded(bool& prevent_user_input) override;
66
69 private: bool ChangesProgramStateIrreversibly() override;
70
73 private: bool ElementRequired();
74
76 private: std::shared_ptr<GUII> gui;
77
79 private: std::shared_ptr<SDFormatParserI> sdformatParser;
80
82 private: sdf::ElementPtr element_to_delete;
83
85 private: sdf::ElementPtr element_to_deletes_parent;
86
88 private: bool is_currently_undoable = false;
89
91 private: bool is_currently_redoable = false;
92};
93
94#endif
The command class encapsulates the interactions between the various interfaces of the SDFormat Editor...
Definition command_interface.h:29
Delete Element command implementation of CommandI.
Definition DeleteElementCommand.h:32
sdf::ElementPtr element_to_deletes_parent
Pointer to the parent of the element to delete.
Definition DeleteElementCommand.h:85
bool ExecuteRedo() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:151
bool is_currently_undoable
Store if the command is currently undo-able.
Definition DeleteElementCommand.h:88
bool IsUndoable() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:166
bool IsRedoable() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:171
bool ExecuteUndo() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:141
bool IsThreaded(bool &prevent_user_input) override
Implementation of interface method.
Definition DeleteElementCommand.cpp:176
sdf::ElementPtr element_to_delete
Pointer to the element to delete.
Definition DeleteElementCommand.h:82
std::shared_ptr< SDFormatParserI > sdformatParser
Pointer to the sdformat parser interface.
Definition DeleteElementCommand.h:79
std::shared_ptr< GUII > gui
Pointer to the gui interface.
Definition DeleteElementCommand.h:76
bool is_currently_redoable
Store if the command is currently redo-able.
Definition DeleteElementCommand.h:91
bool ChangesProgramStateIrreversibly() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:182
bool Execute() override
Implementation of interface method.
Definition DeleteElementCommand.cpp:31
bool ElementRequired()
Determine if an element is strictly required.
Definition DeleteElementCommand.cpp:117