20#ifndef SDFORMAT_EDITOR_GUI_HH_
21#define SDFORMAT_EDITOR_GUI_HH_
26#include "imgui_impl_glfw.h"
27#include "imgui_impl_opengl3.h"
28#include <GLFW/glfw3.h>
30#include <interfaces/gui_interface.h>
31#include "command_factory.h"
41 public:
GUI(
const std::string &window_name, std::shared_ptr<SDFormatParserI>
sdformat_parser,
bool &success);
50 private:
void Initialize(
const std::string &window_name, std::shared_ptr<SDFormatParserI>
sdformat_parser,
bool &success)
override;
58 private: std::unique_ptr<CommandI>
Update(std::shared_ptr<CommandFactoryI> command_factory)
override;
79 std::shared_ptr<CommandFactoryI> command_factory);
88 private:
void DrawCoreFrame(std::unique_ptr<CommandI>& command, std::shared_ptr<CommandFactoryI> command_factory);
96 std::shared_ptr<CommandFactoryI> command_factory,
int& unique_id);
104 std::shared_ptr<CommandFactoryI> command_factory,
int& unique_id);
112 std::shared_ptr<CommandFactoryI> command_factory,
int& unique_id);
119 private:
void CreateDropdown(
const std::vector<std::string>& items,
const std::vector<std::string>& item_descriptions,
int& selected_item,
int& unique_id);
122 private: std::unique_lock<std::mutex>
LockMutex()
override;
124 private: std::shared_ptr<CommandFactory> command_factory;
139 private: ImGuiIO *
io =
nullptr;
Interface for the SDFormat Editor's Graphical User Interface Note that this class also inherits from ...
Definition gui_interface.h:39
Implementation of GUII.
Definition gui.h:35
bool use_dropdown_for_editing_element
Indicates if a dropdown is used for editing attributes.
Definition gui.h:163
bool model_viewer_running
Flag to indicate if the model viewer is currently running.
Definition gui.h:130
void CreateAppendElementDropdown(sdf::ElementPtr element, std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory, int &unique_id)
Create a dropdown list for an element.
Definition gui.cpp:652
std::atomic< bool > prevent_input_flag
Flag which can be set to prevent the GUI from taking user input.
Definition gui.h:127
void DrawCoreFrame(std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory)
Draw the core part of the ImGUI frame.
Definition gui.cpp:148
void DisplaySDFRootElement(std::unique_ptr< CommandI > &command, std::shared_ptr< SDFormatParserI > sdformat_parser, std::shared_ptr< CommandFactoryI > command_factory)
Function to display the SDF root element in the GUI in a tree format.
Definition gui.cpp:314
GLFWwindow * window
Pointer to the GLFW window object, used to manage for rendering and handling window events.
Definition gui.h:136
bool use_dropdown_for_editing_attribute
Indicates if a dropdown is used for editing attributes.
Definition gui.h:154
std::mutex gui_mutex
Mutex to protect shared resources.
Definition gui.h:151
ImVec4 background_colour
The background color used in the GUI.
Definition gui.h:148
void OpenChoiceDialog(DialogMessage dialogMessage, std::vector< std::pair< std::string, bool > > &choices) override
Implementation of interface method.
Definition gui.cpp:733
void SetPreventInputFlag(bool set) override
Implementation of flag setting method.
Definition gui.cpp:39
sdf::ParamPtr attribute_to_edit
Holds a reference to the attribute the user is currently editing.
Definition gui.h:157
void Initialize(const std::string &window_name, std::shared_ptr< SDFormatParserI > sdformat_parser, bool &success) override
Implementation of interface method, wrapped by constructor.
Definition gui.cpp:49
std::unique_lock< std::mutex > LockMutex() override
Implementation of lock method.
Definition gui.cpp:44
bool SetupNewFrame()
Sets up a new ImGUI frame.
Definition gui.cpp:131
void CreateModifyElementDropdown(sdf::ElementPtr element, std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory, int &unique_id)
Create a dropdown list.
Definition gui.cpp:619
void CreateDropdown(const std::vector< std::string > &items, const std::vector< std::string > &item_descriptions, int &selected_item, int &unique_id)
Create a dropdown list.
Definition gui.cpp:692
bool ShouldClose() override
Implementation of interface method.
Definition gui.cpp:34
std::unique_ptr< CommandI > Update(std::shared_ptr< CommandFactoryI > command_factory) override
Implementation of interface method.
Definition gui.cpp:299
void CreateModifyAttributeDropdown(sdf::ParamPtr attribute, std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory, int &unique_id)
Create a dropdown list.
Definition gui.cpp:586
sdf::ElementPtr element_to_edit
Holds a reference to the element the user is currently editing.
Definition gui.h:160
sdf::ElementPtr element_to_append_to
An element for which we want to show the "append_to" dropdown.
Definition gui.h:145
std::shared_ptr< SDFormatParserI > sdformat_parser
Pointer to the sdformat_parser object.
Definition gui.h:142
ImGuiIO * io
Reference to the ImGuiIO structure, which handles input/output operations for ImGui.
Definition gui.h:139
~GUI()
Destructor.
Definition gui.cpp:785
static void GLFWErrorCallback(int error, const char *description)
Function for handling GLFW Error (required to be static by GLFW)
Definition gui.cpp:29
bool render_collisions_in_model_viewer
Flag to indicate if collisions should be loaded in the model viewer.
Definition gui.h:133
Struct representing a dialog message. This struct encapsulates the components of a dialog message.
Definition gui_interface.h:61