SDFormat Editor
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
GUI Class Reference

Implementation of GUII. More...

#include <gui.h>

Inheritance diagram for GUI:
Inheritance graph
Collaboration diagram for GUI:
Collaboration graph

Public Member Functions

 GUI (const std::string &window_name, std::shared_ptr< SDFormatParserI > sdformat_parser, bool &success)
 Constructor that wraps the Initialize method.
 
 ~GUI ()
 Destructor.
 

Private Member Functions

void Initialize (const std::string &window_name, std::shared_ptr< SDFormatParserI > sdformat_parser, bool &success) override
 Implementation of interface method, wrapped by constructor.
 
bool ShouldClose () override
 Implementation of interface method.
 
std::unique_ptr< CommandIUpdate (std::shared_ptr< CommandFactoryI > command_factory) override
 Implementation of interface method.
 
void SetPreventInputFlag (bool set) override
 Implementation of flag setting method.
 
void OpenChoiceDialog (DialogMessage dialogMessage, std::vector< std::pair< std::string, bool > > &choices) override
 Implementation of interface method.
 
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.
 
bool SetupNewFrame ()
 Sets up a new ImGUI frame.
 
void DrawCoreFrame (std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory)
 Draw the core part of the ImGUI frame.
 
void CreateModifyAttributeDropdown (sdf::ParamPtr attribute, std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory, int &unique_id)
 Create a dropdown list.
 
void CreateModifyElementDropdown (sdf::ElementPtr element, std::unique_ptr< CommandI > &command, std::shared_ptr< CommandFactoryI > command_factory, int &unique_id)
 Create a dropdown list.
 
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.
 
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.
 
std::unique_lock< std::mutex > LockMutex () override
 Implementation of lock method.
 

Static Private Member Functions

static void GLFWErrorCallback (int error, const char *description)
 Function for handling GLFW Error (required to be static by GLFW)
 

Private Attributes

std::shared_ptr< CommandFactorycommand_factory
 
std::atomic< bool > prevent_input_flag = false
 Flag which can be set to prevent the GUI from taking user input.
 
bool model_viewer_running = false
 Flag to indicate if the model viewer is currently running.
 
bool render_collisions_in_model_viewer = false
 Flag to indicate if collisions should be loaded in the model viewer.
 
GLFWwindow * window = nullptr
 Pointer to the GLFW window object, used to manage for rendering and handling window events.
 
ImGuiIO * io = nullptr
 Reference to the ImGuiIO structure, which handles input/output operations for ImGui.
 
std::shared_ptr< SDFormatParserIsdformat_parser
 Pointer to the sdformat_parser object.
 
sdf::ElementPtr element_to_append_to
 An element for which we want to show the "append_to" dropdown.
 
ImVec4 background_colour
 The background color used in the GUI.
 
std::mutex gui_mutex
 Mutex to protect shared resources.
 
bool use_dropdown_for_editing_attribute = false
 Indicates if a dropdown is used for editing attributes.
 
sdf::ParamPtr attribute_to_edit
 Holds a reference to the attribute the user is currently editing.
 
sdf::ElementPtr element_to_edit
 Holds a reference to the element the user is currently editing.
 
bool use_dropdown_for_editing_element = false
 Indicates if a dropdown is used for editing attributes.
 

Additional Inherited Members

Detailed Description

Implementation of GUII.

Constructor & Destructor Documentation

◆ GUI()

GUI::GUI ( const std::string &  window_name,
std::shared_ptr< SDFormatParserI sdformat_parser,
bool &  success 
)

Constructor that wraps the Initialize method.

Parameters
[in]window_nameThe name to be given to the SDFormatEditor Window
[in]sdformat_parserA pointer to the sdformat parser object
[out]successtrue if window initalization is successful

Member Function Documentation

◆ CreateAppendElementDropdown()

void GUI::CreateAppendElementDropdown ( sdf::ElementPtr  element,
std::unique_ptr< CommandI > &  command,
std::shared_ptr< CommandFactoryI command_factory,
int &  unique_id 
)
private

Create a dropdown list for an element.

Parameters
[in]elementA pointer to the element for which to create a dropdown
[out]commanda pointer to the command resulting from the user's action during this frame
[in]command_factoryused for creating command objects
[out]unique_ida unique id for the ImGUI dropdowm

◆ CreateDropdown()

void GUI::CreateDropdown ( const std::vector< std::string > &  items,
const std::vector< std::string > &  item_descriptions,
int &  selected_item,
int &  unique_id 
)
private

Create a dropdown list.

Parameters
[in]itemsA vector of strings to include in the dropdown
[in]item_descriptionsA vector of strings for the descriptions of each item
[out]selected_iteman integer representing the selected item
[out]unique_ida unique id for the ImGUI dropdowm

◆ CreateModifyAttributeDropdown()

void GUI::CreateModifyAttributeDropdown ( sdf::ParamPtr  attribute,
std::unique_ptr< CommandI > &  command,
std::shared_ptr< CommandFactoryI command_factory,
int &  unique_id 
)
private

Create a dropdown list.

Parameters
[in]attributeA pointer to the attribute for which to create a dropdown
[out]commanda pointer to the command resulting from the user's action during this frame
[in]command_factoryused for creating command objects
[out]unique_ida unique id for the ImGUI dropdowm

◆ CreateModifyElementDropdown()

void GUI::CreateModifyElementDropdown ( sdf::ElementPtr  element,
std::unique_ptr< CommandI > &  command,
std::shared_ptr< CommandFactoryI command_factory,
int &  unique_id 
)
private

Create a dropdown list.

Parameters
[in]elementA pointer to the element for which to create a dropdown
[out]commanda pointer to the command resulting from the user's action during this frame
[in]command_factoryused for creating command objects
[out]unique_ida unique id for the ImGUI dropdowm

◆ DisplaySDFRootElement()

void GUI::DisplaySDFRootElement ( std::unique_ptr< CommandI > &  command,
std::shared_ptr< SDFormatParserI sdformat_parser,
std::shared_ptr< CommandFactoryI command_factory 
)
private

Function to display the SDF root element in the GUI in a tree format.

Parameters
[out]commanda pointer to the command resulting from the user's action during this frame
[in]sdformat_parseran SDFormatParserI instance containing an sdf element
[in]command_factoryused for creating command objects

◆ DrawCoreFrame()

void GUI::DrawCoreFrame ( std::unique_ptr< CommandI > &  command,
std::shared_ptr< CommandFactoryI command_factory 
)
private

Draw the core part of the ImGUI frame.

Parameters
[out]commanda pointer to the command resulting from the user's action during this frame
[in]command_factoryused for creating command objects

◆ GLFWErrorCallback()

void GUI::GLFWErrorCallback ( int  error,
const char *  description 
)
staticprivate

Function for handling GLFW Error (required to be static by GLFW)

Parameters
[in]errorError code from GLFW
[in]descriptionDescription of the error from GLFW

◆ Initialize()

void GUI::Initialize ( const std::string &  window_name,
std::shared_ptr< SDFormatParserI sdformat_parser,
bool &  success 
)
overrideprivatevirtual

Implementation of interface method, wrapped by constructor.

Parameters
[in]window_nameThe name to be given to the SDFormatEditor Window
[in]sdformat_parserA pointer to the sdformat parser object
[out]successtrue if window initalization is successful

Implements GUII.

◆ LockMutex()

std::unique_lock< std::mutex > GUI::LockMutex ( )
overrideprivatevirtual

Implementation of lock method.

Implements GUII.

◆ OpenChoiceDialog()

void GUI::OpenChoiceDialog ( DialogMessage  dialogMessage,
std::vector< std::pair< std::string, bool > > &  choices 
)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]dialogMessagestruct containing the strings to display
[out]choicesa vector of string,bools pairs where one bool will be set true, corresponding to the user's choice

Implements GUII.

◆ SetPreventInputFlag()

void GUI::SetPreventInputFlag ( bool  set)
overrideprivatevirtual

Implementation of flag setting method.

Parameters
[in]setvalue to set the flag

Implements GUII.

◆ SetupNewFrame()

bool GUI::SetupNewFrame ( )
private

Sets up a new ImGUI frame.

Returns
false if the window is minimized

◆ ShouldClose()

bool GUI::ShouldClose ( )
overrideprivatevirtual

Implementation of interface method.

Implements GUII.

◆ Update()

std::unique_ptr< CommandI > GUI::Update ( std::shared_ptr< CommandFactoryI command_factory)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]command_factoryused for creating command objects
Returns
The a pointer to the command resulting from the user's action during this frame

Implements GUII.


The documentation for this class was generated from the following files: