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

Base class for Application. More...

#include <OGF/scene_graph/skin/application_base.h>

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

Classes

class  ApplicationBaseLoggerClient
 A LoggerClient that redirects all messages to an ApplicationBase. More...
 
class  ApplicationBaseProgressClient
 A ProgressClient that redirects all messages to an ApplicationBase. More...
 

Public Member Functions

 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.
 
virtual void stop ()
 Stops the application. More...
 
virtual void set_style (const std::string &value)
 Sets the style to be used for widgets. More...
 
virtual void set_font_size (index_t value)
 Sets the size of fonts in the application. More...
 
void declare_preference_variable (const std::string &name, const std::string &value, const std::string &help="")
 Declares a preference variable. More...
 
virtual void save_preferences ()
 Saves the preferences to home directory / graphite.ini.
 
virtual void load_preferences (const std::string &filename)
 Loads preference variables from a file. More...
 
virtual bool preferences_loaded ()
 Tests whether preferences were loaded. More...
 
virtual void cancel_current_job ()
 Cancels the current job. More...
 
virtual void draw ()
 Redraws the main window. More...
 
virtual void update ()
 Indicates that the main window should be redrawn.
 
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 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 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
 

Protected Member Functions

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

static void set_stopping_flag ()
 Indicates that the application is stopping, i.e. processes the last events from the event queue. More...
 

Protected Attributes

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

static ApplicationBaseinstance_
 
static bool stopping_
 

Detailed Description

Base class for Application.

Contains all the toolkit-independent material.

Definition at line 58 of file application_base.h.

Constructor & Destructor Documentation

◆ ApplicationBase()

OGF::ApplicationBase::ApplicationBase ( Interpreter interpreter = nullptr)

ApplicationBase constructor.

Parameters
[in]interpretera pointer to the main Interpreter.

Member Function Documentation

◆ begin()

virtual void OGF::ApplicationBase::begin ( )
virtual

ProgressClient overload, callback called by ProgressTask.

Called when a ProgressTask starts.

◆ cancel_current_job()

virtual void OGF::ApplicationBase::cancel_current_job ( )
virtual

Cancels the current job.

This function is called when the 'stop' button near the progress bar is pushed.

See also
GEO::ProgressTask

◆ declare_preference_variable()

void OGF::ApplicationBase::declare_preference_variable ( const std::string &  name,
const std::string &  value,
const std::string &  help = "" 
)

Declares a preference variable.

Parameters
[in]namethe name of the variable.
[in]valuethe default value to be used, if the variable does not already exist in the environment.
[in]helpthe optional help string.

◆ div()

void OGF::ApplicationBase::div ( const std::string &  value)

A signal that is triggered when a 'separation div' should be displayed in the logger.

Overloads LoggerClient::div()

Parameters
[in]valuethe name of the 'separation div'

◆ draw()

virtual void OGF::ApplicationBase::draw ( )
virtual

Redraws the main window.

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

Reimplemented in OGF::Application.

◆ end()

virtual void OGF::ApplicationBase::end ( bool  canceled)
virtual

ProgressClient overload, callback called by ProgressTask.

Called when a ProgressTask is terminated.

Parameters
[in]canceledindicates whether the ProgressTask was interupted by the user.

◆ err()

void OGF::ApplicationBase::err ( const std::string &  value)

A signal that is triggered when the logger displays an error message.

Overloads LoggerClient::err()

Parameters
[in]valuethe message to be displayed.

◆ find_file()

std::string OGF::ApplicationBase::find_file ( const std::string &  filename) const

Finds a file in the OGF_PATH.

Returns
the found file or the empty string if no such file was found.

◆ get_can_redo()

bool OGF::ApplicationBase::get_can_redo ( ) const

Tests whether redo() can be called.

Return values
trueif undo is activated and there is a saved state \false otherwise

◆ interpreter()

Interpreter* OGF::ApplicationBase::interpreter ( )
inline

Gets the main Interpreter.

Returns
a pointer to the main Interpreter.

Definition at line 76 of file application_base.h.

◆ is_stopping()

static bool OGF::ApplicationBase::is_stopping ( )
inlinestatic

Tests whether the application is stopping.

When the application is stopping, it processes the last events from the queue before exiting the event loop. Some event handlers need to test this flag in order to avoid sending new events (else the application will be never able to stop).

Return values
trueif the application is stopping
falseotherwise

Definition at line 346 of file application_base.h.

◆ load_preferences()

virtual void OGF::ApplicationBase::load_preferences ( const std::string &  filename)
virtual

Loads preference variables from a file.

Parameters
[in]filenamethe full path to the file.

Reimplemented in OGF::Application.

◆ notify_progress()

void OGF::ApplicationBase::notify_progress ( index_t  value)

A signal that is triggered when a ProgressTask is updated.

Parameters
[in]valuethe value of the progress, in percent.

◆ notify_progress_begin()

void OGF::ApplicationBase::notify_progress_begin ( const std::string &  value)

A signal that is triggered when a ProgressTask starts.

Parameters
[in]valuethe name of the ProgressTask

◆ out()

void OGF::ApplicationBase::out ( const std::string &  value)

A signal that is triggered when the logger displays a message.

Overloads LoggerClient::out()

Parameters
[in]valuethe message to be displayed.

◆ preferences_loaded()

virtual bool OGF::ApplicationBase::preferences_loaded ( )
virtual

Tests whether preferences were loaded.

This function returns false if there was no user defined graphite.ini preferences file.

Return values
trueif preferences were loaded.
falseotherwise.

◆ progress()

virtual void OGF::ApplicationBase::progress ( index_t  step,
index_t  percent 
)
virtual

ProgressClient overload, callback called by ProgressTask.

Called when a ProgressTask is updated.

Parameters
[in]stepcurrent step
[in]percentcurrent percentage

◆ set_font_size()

virtual void OGF::ApplicationBase::set_font_size ( index_t  value)
virtual

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 in OGF::Application.

◆ set_stopping_flag()

static void OGF::ApplicationBase::set_stopping_flag ( )
inlinestaticprotected

Indicates that the application is stopping, i.e. processes the last events from the event queue.

Implementations of the application class are supposed to set the stopping flag, then process the last events from the event queue, then exit the event loop.

Definition at line 383 of file application_base.h.

◆ set_style()

virtual void OGF::ApplicationBase::set_style ( const std::string &  value)
virtual

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 in OGF::Application.

◆ state_buffer_filename()

std::string OGF::ApplicationBase::state_buffer_filename ( index_t  i) const
protected

Gets the file name to be used to store a state buffer.

Used by undo() / redo(). State buffers are stored as .graphite files, that store the scene graph and the complete state of Graphite.

Parameters
[in]ithe index of the state buffer
Returns
the file name to be used to store or retreive the state buffer.

◆ status()

void OGF::ApplicationBase::status ( const std::string &  value)

A signal that is triggered when the message in the status bar should be updated.

Parameters
[in]valuethe message to be displayed.

◆ stop()

virtual void OGF::ApplicationBase::stop ( )
virtual

Stops the application.

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

Reimplemented in OGF::Application.

◆ warn()

void OGF::ApplicationBase::warn ( const std::string &  value)

A signal that is triggered when the logger displays a warning message.

Overloads LoggerClient::warn()

Parameters
[in]valuethe message to be displayed.

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