Graphite  Version 3
An experimental 3D geometry processing program
OGF::Application Class Reference

Implementation of Skin application using ImGui. More...

#include <OGF/skin_imgui/types/application.h>

Inheritance diagram for OGF::Application:
OGF::ApplicationBase OGF::Object GEO::Counted

Public Member Functions

 Application (Interpreter *interpreter)
 Application constructor.
 
 ~Application () override
 Application destructor.
 
 Application (const Application &rhs)=delete
 Forbid copy.
 
Applicationoperator= (const Application &rhs)=delete
 Forbid copy.
 
IconRepositoryicon_repository ()
 Gets the icon repository. More...
 
const IconRepositoryicon_repository () const
 Gets the icon repository. More...
 
void start () override
 
void stop () override
 Stops the application. More...
 
void set_style (const std::string &value) override
 Sets the style to be used for widgets. More...
 
void set_font_size (index_t value) override
 Sets the size of fonts in the application. More...
 
void lock_updates ()
 Lock updates. More...
 
void unlock_updates ()
 Unlock updates. More...
 
void draw () override
 Redraws the main window. More...
 
void update () override
 Indicates that the main window should be redrawn. More...
 
void save_preferences () override
 Saves the preferences to home directory / graphite.ini. More...
 
void load_preferences (const std::string &filename) override
 Loads preference variables from a file. More...
 
void flush_command_queue ()
 Executes all commands in command queue.
 
void * impl_window () const
 Gets a pointer to the underlying window. More...
 
const std::string & get_style () const
 Gets the style. More...
 
Cameracamera ()
 Gets the Camera. More...
 
index_t resolve_icon (const std::string &name, bool mipmap=false) const
 Finds an icon by name. More...
 
void exec_command (const std::string &command, bool add_to_history=true)
 Executes a command. More...
 
void exec_command_now (const std::string &command, bool add_to_history=false)
 Executes a command immediatly. More...
 
double scaling () const
 Gets the global scaling to be applied to all GUI elements. More...
 
double margin () const
 
double status_bar_height () const
 
bool draw_console (bool visible)
 Draws the console. More...
 
bool status_bar_is_active () const
 Tests if the status bar should be displayed. More...
 
void draw_status_bar ()
 Draw the status bar. More...
 
void set_full_screen_mode (index_t w=0, index_t h=0, index_t hz=0, index_t monitor=0)
 Sets full-screen mode. More...
 
void set_windowed_mode (index_t w=0, index_t h=0)
 Sets windowed mode. More...
 
void list_video_modes ()
 Lists the video modes that can be used for set_full_screen_mode() More...
 
void iconify ()
 Iconifies this application.
 
void restore ()
 Restores this application.
 
void reset_latest_error ()
 Resets the latest error to the empty string.
 
void notify_error (const std::string &message)
 Notifies than an error occured. More...
 
void set_gui_state (std::string x)
 Sets the gui state. More...
 
std::string get_gui_state () const
 Gets the gui state. More...
 
void set_full_screen (bool x)
 Sets full-screen mode. More...
 
bool get_full_screen () const
 Tests whether this application is in full-screen mode. More...
 
index_t get_width () const
 Gets the width of the window. More...
 
index_t get_height () const
 Gets the height of the window. More...
 
index_t get_frame_buffer_width () const
 Gets the width of the window. More...
 
index_t get_frame_buffer_height () const
 Gets the height of the window. More...
 
void set_accept_drops (bool value)
 Sets whether drag and drop events should be taken into account. More...
 
bool get_accept_drops () const
 Tests whether drag and drop events are taken into account. More...
 
void set_picked_grob (Grob *value)
 Used by the arrow tool, memorizes the picked grob. More...
 
Grobget_picked_grob () const
 Used by the arrow tool, gets the memorized picked grob. More...
 
const std::string & get_latest_error () const
 Gets the latest error message. More...
 
void error_occured (const std::string &error)
 This signal is triggered when the console displays an error message. More...
 
- Public Member Functions inherited from OGF::ApplicationBase
 ApplicationBase (Interpreter *interpreter=nullptr)
 ApplicationBase constructor. More...
 
 ~ApplicationBase () override
 ApplicationBase destructor.
 
Interpreterinterpreter ()
 Gets the main Interpreter. More...
 
 for (size_t index=tooltip_.find("\\n");index !=std::string::npos;index=tooltip_.find("\\n", index+2))
 
const std::string & get_tooltip () const
 Gets the tooltip to be displayed near the cursor in the rendering area, or an empty string if there is no tooltip.
 
void declare_preference_variable (const std::string &name, const std::string &value, const std::string &help="")
 Declares a preference variable. More...
 
virtual bool preferences_loaded ()
 Tests whether preferences were loaded. More...
 
virtual void cancel_current_job ()
 Cancels the current job. More...
 
virtual void begin ()
 ProgressClient overload, callback called by ProgressTask. More...
 
virtual void progress (index_t step, index_t percent)
 ProgressClient overload, callback called by ProgressTask. More...
 
virtual void end (bool canceled)
 ProgressClient overload, callback called by ProgressTask. More...
 
std::string find_file (const std::string &filename) const
 Finds a file in the OGF_PATH. More...
 
virtual void save_state ()
 Saves state before applying command or tool, for undo()/redo().
 
virtual void undo ()
 Restores last saved state if available.
 
virtual void redo ()
 Restores next saved state if available.
 
virtual void progress_cancel ()
 Cancels current progress tastk.
 
virtual void post_draw ()
 Called after each frame.
 
bool get_can_redo () const
 Tests whether redo() can be called. More...
 
void div (const std::string &value)
 A signal that is triggered when a 'separation div' should be displayed in the logger. More...
 
void out (const std::string &value)
 A signal that is triggered when the logger displays a message. More...
 
void warn (const std::string &value)
 A signal that is triggered when the logger displays a warning message. More...
 
void err (const std::string &value)
 A signal that is triggered when the logger displays an error message. More...
 
void status (const std::string &value)
 A signal that is triggered when the message in the status bar should be updated. More...
 
void notify_progress_begin (const std::string &value)
 A signal that is triggered when a ProgressTask starts. More...
 
void notify_progress (index_t value)
 A signal that is triggered when a ProgressTask is updated. More...
 
void notify_progress_end ()
 A signal that is triggered when a ProgressTask finishes.
 
- Public Member Functions inherited from OGF::Object
 Object (bool transient=false)
 Object constructor. More...
 
virtual ~Object ()
 Object destructor.
 
virtual MetaClassmeta_class () const
 Gets the meta class. More...
 
virtual void set_meta_class (MetaClass *mclass)
 Sets the meta class. More...
 
unsigned int id () const
 Gets the identifier of this object. More...
 
std::string string_id () const
 Gets the unique string identifier. More...
 
bool has_method (const std::string &method_name) const
 Tests whether a method is defined. More...
 
virtual bool invoke_method (const std::string &method_name, const ArgList &args, Any &ret_val)
 Invokes a method by method name and argument list, and gets the return value. More...
 
bool invoke_method (const std::string &method_name, const ArgList &args)
 Invokes a method by method name and argument list. More...
 
bool invoke_method (const std::string &method_name)
 Invokes a method by method name. More...
 
bool has_property (const std::string &prop_name) const
 Tests whether a property is defined. More...
 
virtual bool get_property (const std::string &prop_name, std::string &prop_value) const
 Gets a property. More...
 
virtual Connectionconnect_signal_to_slot (const std::string &signal_name, Object *to, const std::string &slot_name)
 Connects a signal with a slot of another object. More...
 
virtual void add_connection (Connection *connection)
 Adds a connection to this object. More...
 
virtual void remove_connection (Connection *connection)
 Removes a connection to this object. More...
 
virtual void get_element (index_t i, Any &value) const
 Gets an element by index. More...
 
virtual void set_element (index_t i, const Any &value)
 Sets an element by index. More...
 
virtual void search (const std::string &needle, const std::string &path="")
 Displays the names of all objects that contain a substring. More...
 
bool get_signals_enabled () const
 Tests wheter signals are enabled. More...
 
void set_signals_enabled (bool value)
 Enables or disables signals. More...
 
bool get_slots_enabled () const
 Tests wheter slots are enabled. More...
 
void set_slots_enabled (bool value)
 Enables or disables slots. More...
 
MetaClassget_meta_class () const
 Gets the meta class. More...
 
std::string get_string_id () const
 Gets the unique string identifier. More...
 
virtual std::string get_doc () const
 Gets the documentation. More...
 
virtual Sign compare (const Object *other) const
 Compares this object with another one. More...
 
virtual bool is_a (const MetaType *type) const
 Tests whether this object inherits a given type. More...
 
void disconnect ()
 Removes all connections from signals of this objects. More...
 
void enable_signals ()
 Enables signals.
 
void disable_signals ()
 Disables signals.
 
void enable_slots ()
 Enables slots.
 
void disable_slots ()
 Disables slots.
 
void set_properties (const ArgList &args)
 Sets several properties in a single call. More...
 
virtual bool set_property (const std::string &name, const std::string &value)
 Sets an individual property. More...
 
void help () const
 Displays some help about this object. More...
 
virtual bool set_property (const std::string &name, const Any &value)
 Sets an individual property. More...
 
virtual bool get_property (const std::string &prop_name, Any &prop_value) const
 Gets a property. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Static Public Member Functions

static Applicationinstance ()
 Gets the instance. More...
 
- Static Public Member Functions inherited from OGF::ApplicationBase
static ApplicationBaseinstance ()
 
static bool is_stopping ()
 Tests whether the application is stopping. More...
 
- Static Public Member Functions inherited from OGF::Object
static Objectid_to_object (unsigned int id)
 Gets an object from a unique object id. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Public Attributes

 __pad0__: void draw_dock_space()
 
 __pad1__: RenderArea* get_render_area() const { return render_area_
 
gom_signals __pad2__: void redraw_request()
 
- Public Attributes inherited from OGF::ApplicationBase
 __pad0__: void set_tooltip(const std::string& x) { tooltip_ = x
 
 __pad1__: virtual void start()
 
 __pad2__: bool get_can_undo() const
 
gom_signals __pad3__: void started()
 
- Public Attributes inherited from OGF::Object
 __pad0__: virtual index_t get_nb_elements() const
 
 __pad1__: bool equals(const Object* other) const
 

Additional Inherited Members

- Protected Member Functions inherited from OGF::ApplicationBase
virtual void save_state_to_file (const std::string &filename)
 Saves Graphite state to a file.
 
virtual void load_state_from_file (const std::string &filename)
 Saves Graphite state to a file.
 
std::string state_buffer_filename (index_t i) const
 Gets the file name to be used to store a state buffer. More...
 
- Protected Member Functions inherited from OGF::Object
virtual bool emit_signal (const std::string &signal_name, const ArgList &args, bool called_from_slot=false)
 Emits a signal and calls the slots it is connected to. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 
- Static Protected Member Functions inherited from OGF::ApplicationBase
static void set_stopping_flag ()
 Indicates that the application is stopping, i.e. processes the last events from the event queue. More...
 
- Protected Attributes inherited from OGF::ApplicationBase
Interpreterinterpreter_
 
LoggerClient_var logger_client_
 
ProgressClient_var progress_client_
 
std::string tooltip_
 
index_t state_buffer_begin_
 
index_t state_buffer_end_
 
index_t state_buffer_size_
 
index_t state_buffer_current_
 
bool undo_redo_called_
 
bool started_callback_called_
 
- Static Protected Attributes inherited from OGF::ApplicationBase
static ApplicationBaseinstance_
 
static bool stopping_
 

Detailed Description

Implementation of Skin application using ImGui.

Note
Client code should not use this class directly. It should be only used through the GOM abstraction layer.

Definition at line 56 of file application.h.

Member Function Documentation

◆ camera()

Camera* OGF::Application::camera ( )
inline

Gets the Camera.

Returns
a pointer to the Camera.

Definition at line 189 of file application.h.

◆ draw()

void OGF::Application::draw ( )
overridevirtual

Redraws the main window.

This function is called by commands that animate objects during computation, by the progress bar and by console output.

Reimplemented from OGF::ApplicationBase.

◆ draw_console()

bool OGF::Application::draw_console ( bool  visible)

Draws the console.

Parameters
[in]visibletrue if the console is visible, false otherwise.
Return values
trueif the console is still visible.
falseotherwise, e.g., when the user clicks on the close button of the console.

◆ draw_status_bar()

void OGF::Application::draw_status_bar ( )

Draw the status bar.

Ignored if the status bar is not active.

◆ error_occured()

void OGF::Application::error_occured ( const std::string &  error)

This signal is triggered when the console displays an error message.

Parameters
[in]errorthe error message to be displayed.

◆ exec_command()

void OGF::Application::exec_command ( const std::string &  command,
bool  add_to_history = true 
)

Executes a command.

The command is queued so that it is executed right after the current frame (and not nested in the current frame). This allows updating the progress bar.

Parameters
[in]commanda string with the LUA command to be executed.
[in]add_to_historytrue if the command should be recorded in the history.

◆ exec_command_now()

void OGF::Application::exec_command_now ( const std::string &  command,
bool  add_to_history = false 
)

Executes a command immediatly.

Unlike in exec_command(), the command is not queued and is immediatly executed.

Parameters
[in]commanda string with the LUA command to be executed.
[in]add_to_historytrue if the command should be recorded in the history.

◆ get_accept_drops()

bool OGF::Application::get_accept_drops ( ) const

Tests whether drag and drop events are taken into account.

Return values
trueif drag and drop events are taken into account
falseotherwise

◆ get_frame_buffer_height()

index_t OGF::Application::get_frame_buffer_height ( ) const

Gets the height of the window.

Returns
the height of the frame buffer in pixels.

◆ get_frame_buffer_width()

index_t OGF::Application::get_frame_buffer_width ( ) const

Gets the width of the window.

Returns
the width of the frame buffer in pixels.

◆ get_full_screen()

bool OGF::Application::get_full_screen ( ) const

Tests whether this application is in full-screen mode.

Return values
trueif full-screen mode is used.
falseif windowed mode is used.

◆ get_gui_state()

std::string OGF::Application::get_gui_state ( ) const

Gets the gui state.

Returns
a string that encodes the position of all windows.

◆ get_height()

index_t OGF::Application::get_height ( ) const

Gets the height of the window.

Returns
the height of the window in pixels.

◆ get_latest_error()

const std::string& OGF::Application::get_latest_error ( ) const
inline

Gets the latest error message.

Returns
the latest error message.

Definition at line 418 of file application.h.

◆ get_picked_grob()

Grob* OGF::Application::get_picked_grob ( ) const
inline

Used by the arrow tool, gets the memorized picked grob.

Returns
the latest picked grob

Definition at line 410 of file application.h.

◆ get_style()

const std::string& OGF::Application::get_style ( ) const

Gets the style.

Returns
a string with the current style;

◆ get_width()

index_t OGF::Application::get_width ( ) const

Gets the width of the window.

Returns
the width of the window in pixels.

◆ icon_repository() [1/2]

IconRepository* OGF::Application::icon_repository ( )
inline

Gets the icon repository.

Returns
a pointer to the IconRepository

Definition at line 91 of file application.h.

◆ icon_repository() [2/2]

const IconRepository* OGF::Application::icon_repository ( ) const
inline

Gets the icon repository.

Returns
a const pointer to the IconRepository

Definition at line 99 of file application.h.

◆ impl_window()

void* OGF::Application::impl_window ( ) const

Gets a pointer to the underlying window.

Returns
an implementation-specific pointer to the window.

Some callbacks in RenderArea need it to query modifiers state.

◆ instance()

static Application* OGF::Application::instance ( )
inlinestatic

Gets the instance.

Returns
a pointer to the unique instance

Definition at line 83 of file application.h.

◆ list_video_modes()

void OGF::Application::list_video_modes ( )

Lists the video modes that can be used for set_full_screen_mode()

The video modes are listed in the terminal.

◆ load_preferences()

void OGF::Application::load_preferences ( const std::string &  filename)
overridevirtual

Loads preference variables from a file.

Parameters
[in]filenamethe full path to the file.

Reimplemented from OGF::ApplicationBase.

◆ lock_updates()

void OGF::Application::lock_updates ( )

Lock updates.

If this function is called, updates are ignored. It is useful when a RenderingContext operation is occuring, to prevent the Console for triggering a drawing operation.

◆ notify_error()

void OGF::Application::notify_error ( const std::string &  message)
inline

Notifies than an error occured.

Parameters
[in]messagethe error message.

Definition at line 313 of file application.h.

◆ resolve_icon()

index_t OGF::Application::resolve_icon ( const std::string &  name,
bool  mipmap = false 
) const

Finds an icon by name.

Parameters
[in]namethe name of the icon, without file extension
[in]mipmapif true, use mipmapping (filtering)

Icons are loaded from XPM files in lib/icons/

Returns
the OpenGL texture id of the icon, or 0 if no such icon was found.

◆ save_preferences()

void OGF::Application::save_preferences ( )
overridevirtual

Saves the preferences to home directory / graphite.ini.

Reimplemented from OGF::ApplicationBase.

◆ scaling()

double OGF::Application::scaling ( ) const

Gets the global scaling to be applied to all GUI elements.

Returns
1.0 if the default font is used, more/less if a larger/ smaller font is used.

◆ set_accept_drops()

void OGF::Application::set_accept_drops ( bool  value)

Sets whether drag and drop events should be taken into account.

Parameters
[in]valuetrue if drag and drop events should be taken into account, false otherwise

◆ set_font_size()

void OGF::Application::set_font_size ( index_t  value)
overridevirtual

Sets the size of fonts in the application.

Default implementation does nothing but storing the font size in the preferences. Can be overloaded in implementations.

Parameters
[in]valuethe size of fonts

Reimplemented from OGF::ApplicationBase.

◆ set_full_screen()

void OGF::Application::set_full_screen ( bool  x)

Sets full-screen mode.

Parameters
[in]xtrue if full-screen mode should be used, false if windowed-mode should be used.

◆ set_full_screen_mode()

void OGF::Application::set_full_screen_mode ( index_t  w = 0,
index_t  h = 0,
index_t  hz = 0,
index_t  monitor = 0 
)

Sets full-screen mode.

All arguments to zero sets default mode.

Parameters
[in]w,hwidth and height in pixels
[in]hzrefresh rate in Hz
[in]monitorthe id of the monitor

◆ set_gui_state()

void OGF::Application::set_gui_state ( std::string  x)

Sets the gui state.

Parameters
[in]xa string that encores the positions of all windows, previously obtained through get_gui_state()
See also
get_gui_state()

◆ set_picked_grob()

void OGF::Application::set_picked_grob ( Grob value)
inline

Used by the arrow tool, memorizes the picked grob.

Parameters
[in]valuethe picked grob to memorized

Definition at line 402 of file application.h.

◆ set_style()

void OGF::Application::set_style ( const std::string &  value)
overridevirtual

Sets the style to be used for widgets.

Some toolkits can have different styles. Default implementation does nothing but storing the style in the preferences. Can be overloaded in implementations.

Parameters
[in]valuethe name of the widgets style

Reimplemented from OGF::ApplicationBase.

◆ set_windowed_mode()

void OGF::Application::set_windowed_mode ( index_t  w = 0,
index_t  h = 0 
)

Sets windowed mode.

Parameters
[in]w,hwidth and height in pixels. If zero, use current dimensions.

◆ start()

void OGF::Application::start ( )
override

◆ status_bar_is_active()

bool OGF::Application::status_bar_is_active ( ) const

Tests if the status bar should be displayed.

Return values
trueif the status bar should be displayed, i.e. when there is an active ProgressLogger.
falseotherwise.

◆ stop()

void OGF::Application::stop ( )
overridevirtual

Stops the application.

In derived classes, it exits the main event loop of the widgets toolkit.

Reimplemented from OGF::ApplicationBase.

◆ unlock_updates()

void OGF::Application::unlock_updates ( )

Unlock updates.

See also
lock_updates()

◆ update()

void OGF::Application::update ( )
overridevirtual

Indicates that the main window should be redrawn.

Reimplemented from OGF::ApplicationBase.


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