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

Implementation of RenderArea using ImGui. More...

#include <OGF/skin_imgui/widgets/render_area.h>

Inheritance diagram for OGF::RenderArea:
OGF::Object GEO::Counted

Public Member Functions

 RenderArea (index_t w, index_t h, index_t fb_w, index_t fb_h)
 RenderArea constructor. More...
 
 ~RenderArea () override
 RenderArea destructor.
 
void resize (index_t w, index_t h, index_t fb_w, index_t fb_h)
 Resizes this RenderArea. More...
 
bool needs_to_redraw () const
 Tests whether the window needs to be redrawn. More...
 
void update ()
 Invalidates the memorized frame so that it will be updated on the next call to draw().
 
void update_memorized_frame ()
 Re-generates the memorized frame.
 
void draw_memorized_frame ()
 Draws the latest memorized frame.
 
void snapshot (const std::string &filename, bool make_current=true, bool with_gui=false)
 Saves a snapshot of this rendering area to an image file. More...
 
void update_view_parameters ()
 Call this function if perspective mode is changed.
 
void update_background_image_from_data (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height)
 Updates the background image from raw image data. 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_projection_matrix (const mat4 &value)
 Sets the projection matrix. More...
 
const mat4get_projection_matrix () const
 Gets the projection matrix. More...
 
void set_viewing_matrix (const mat4 &value)
 Sets the viewing matrix. More...
 
const mat4get_viewing_matrix () const
 Gets the viewing matrix. More...
 
void set_background_color_1 (const Color &value)
 Sets the primary background color. More...
 
const Colorget_background_color_1 () const
 Gets the background color. More...
 
void set_background_color_2 (const Color &value)
 Sets the secondary background color. More...
 
const Colorget_background_color_2 () const
 Gets the secondary background color. More...
 
void set_background_image (const std::string &value)
 Sets the background image. More...
 
const std::string & get_background_image () const
 Gets the background image. More...
 
void set_lighting_matrix (const mat4 &value)
 Sets the lighting matrix. More...
 
const mat4get_lighting_matrix () const
 Gets the lighting matrix. More...
 
RenderingContextget_rendering_context () const
 Gets the rendering context. More...
 
std::string get_gpu_information () const
 Gets the GPU information. More...
 
std::string get_gpu_extensions () const
 Gets GPU extensions. More...
 
const std::string & get_clipping_config () const
 Gets the current clipping configuration. More...
 
void set_clipping_config (const std::string &clipping_config)
 Sets the current clipping configuration. More...
 
void resize_request (RenderingContext *rendering_context, int width, int height)
 A signal that is triggered each time the render area is resized. More...
 
void mouse_down (RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, int button, bool control, bool shift)
 A signal that is triggered each time a mouse button is pushed. More...
 
void mouse_move (RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, const vec2 &delta_ndc, double delta_x_ndc, double delta_y_ndc, const vec2 &delta_wc, int button, bool control, bool shift)
 A signal that is triggered when the mouse is dragged with a pushed button. More...
 
void mouse_up (RenderingContext *rendering_context, const vec2 &point_ndc, const vec2 &point_wc, int button, bool control, bool shift)
 A signal that is triggered each time a mouse button is released. More...
 
void key_down (const std::string &value)
 A signal that is triggered each time a key is pushed. More...
 
void key_up (const std::string &value)
 A signal that is triggered each time a key is released. More...
 
void button_down (int value)
 A signal that is triggered each time a mouse button is pressed. More...
 
void button_up (int value)
 A signal that is triggered each time a mouse button is released. More...
 
void dropped_file (const std::string &value)
 A signal that is triggered whenever a file is drag-dropped into this RenderArea. More...
 
void mouse_button_callback (int button, int action, int mods)
 
void scroll_callback (double xoffset, double yoffset)
 
void cursor_pos_callback (double xf, double yf)
 
void drop_callback (int nb, const char **p)
 
void char_callback (unsigned int c)
 
void key_callback (int key, int scancode, int action, int mods)
 
- 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...
 

Public Attributes

 __pad0__: void draw()
 
 __pad1__: index_t get_width() const { return width_
 
gom_signals __pad2__: void redraw_request(RenderingContext* rendering_context=nullptr)
 
- Public Attributes inherited from OGF::Object
 __pad0__: virtual index_t get_nb_elements() const
 
 __pad1__: bool equals(const Object* other) const
 

Protected Member Functions

void GL_initialize ()
 Initializes OpenGL and GLUP objects.
 
void GL_terminate ()
 Deallocates OpenGL and GLUP objects.
 
void update_clipping_config ()
 
- 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...
 

Additional Inherited Members

- 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...
 

Detailed Description

Implementation of RenderArea 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 render_area.h.

Constructor & Destructor Documentation

◆ RenderArea()

OGF::RenderArea::RenderArea ( index_t  w,
index_t  h,
index_t  fb_w,
index_t  fb_h 
)

RenderArea constructor.

Parameters
[in]w,hwindow width and height in pixels.
[in]fb_w,fb_hframe buffer width and height in pixels.

Member Function Documentation

◆ button_down()

void OGF::RenderArea::button_down ( int  value)

A signal that is triggered each time a mouse button is pressed.

Parameters
[in]valuethe button (see MouseButton)

◆ button_up()

void OGF::RenderArea::button_up ( int  value)

A signal that is triggered each time a mouse button is released.

Parameters
[in]valuethe button (see MouseButton)

◆ dropped_file()

void OGF::RenderArea::dropped_file ( const std::string &  value)

A signal that is triggered whenever a file is drag-dropped into this RenderArea.

Parameters
[in]valuethe name of the file that was dropped
See also
set_accept_drops(), get_accept_drops()

◆ get_background_color_1()

const Color& OGF::RenderArea::get_background_color_1 ( ) const

Gets the background color.

Returns
the background color

◆ get_background_color_2()

const Color& OGF::RenderArea::get_background_color_2 ( ) const

Gets the secondary background color.

If different from the (primary) background color, then a color-ramp between both is generated.

◆ get_background_image()

const std::string& OGF::RenderArea::get_background_image ( ) const

Gets the background image.

Returns
the path to a file that contains the image, or the empty string if no background image is used.

◆ get_clipping_config()

const std::string& OGF::RenderArea::get_clipping_config ( ) const
inline

Gets the current clipping configuration.

Returns
a ';'-separated string with the following fields:
  • active (one of "true","false")
  • axis (one of "x","y","z","d")
  • volume-mode (one of "std.","cell","strad.","slice")
  • shift (an integer in [-250, 250])
  • rotation (the 16 coefficients of a rotation matrix)

Definition at line 306 of file render_area.h.

◆ get_frame_buffer_height()

index_t OGF::RenderArea::get_frame_buffer_height ( ) const
inline

Gets the height of the window.

Returns
the height of the frame buffer in pixels.

Definition at line 187 of file render_area.h.

◆ get_frame_buffer_width()

index_t OGF::RenderArea::get_frame_buffer_width ( ) const
inline

Gets the width of the window.

Returns
the width of the frame buffer in pixels.

Definition at line 179 of file render_area.h.

◆ get_gpu_extensions()

std::string OGF::RenderArea::get_gpu_extensions ( ) const

Gets GPU extensions.

Returns
a string with the list of supported OpenGL extensions

◆ get_gpu_information()

std::string OGF::RenderArea::get_gpu_information ( ) const

Gets the GPU information.

Returns
a string with GPU name, vendor, version

◆ get_height()

index_t OGF::RenderArea::get_height ( ) const
inline

Gets the height of the window.

Returns
the height of the window.

Definition at line 171 of file render_area.h.

◆ get_lighting_matrix()

const mat4& OGF::RenderArea::get_lighting_matrix ( ) const

Gets the lighting matrix.

Returns
a const reference to the 4x4 homogeneous coordinates lighting matrix

◆ get_projection_matrix()

const mat4& OGF::RenderArea::get_projection_matrix ( ) const

Gets the projection matrix.

Returns
a const reference to the 4x4 homogeneous coordinates projection matrix.

◆ get_rendering_context()

RenderingContext* OGF::RenderArea::get_rendering_context ( ) const

Gets the rendering context.

Returns
a pointer to the RenderingContext

◆ get_viewing_matrix()

const mat4& OGF::RenderArea::get_viewing_matrix ( ) const

Gets the viewing matrix.

Returns
a const reference to the 4x4 homogeneous coordinates viewing matrix.

◆ key_down()

void OGF::RenderArea::key_down ( const std::string &  value)

A signal that is triggered each time a key is pushed.

Parameters
[in]valuea string with the pressed key, or "shift", "control", "alt", "left", "right", "up", "down" for special keys.

◆ key_up()

void OGF::RenderArea::key_up ( const std::string &  value)

A signal that is triggered each time a key is released.

Parameters
[in]valuea string with the pressed key, or "shift", "control", "alt", "left", "right", "up", "down" for special keys.

◆ mouse_down()

void OGF::RenderArea::mouse_down ( RenderingContext rendering_context,
const vec2 point_ndc,
const vec2 point_wc,
int  button,
bool  control,
bool  shift 
)

A signal that is triggered each time a mouse button is pushed.

Parameters
[in]rendering_contexta pointer to the RenderingContext
[in]point_ndcthe picked point, in normalized device coordinates
[in]point_wcthe picked point, in world coordinates
[in]buttonthe pushed button (see MouseButton)
[in]controltrue if the control key is pushed
[in]shifttrue if the shift key is pushed

◆ mouse_move()

void OGF::RenderArea::mouse_move ( RenderingContext rendering_context,
const vec2 point_ndc,
const vec2 point_wc,
const vec2 delta_ndc,
double  delta_x_ndc,
double  delta_y_ndc,
const vec2 delta_wc,
int  button,
bool  control,
bool  shift 
)

A signal that is triggered when the mouse is dragged with a pushed button.

Parameters
[in]rendering_contexta pointer to the RenderingContext
[in]point_ndcthe picked point, in normalized device coordinates
[in]point_wcthe picked point, in world coordinates
[in]delta_ndcthe displacement vector in normalized device coordinates
[in]delta_x_ndcthe x component of the displacement vector in normalized device coordinates
[in]delta_y_ndcthe y component of the displacement vector in normalized device coordinates
[in]delta_wcthe displacement vector in world coordinates
[in]buttonthe pushed button (see MouseButton)
[in]controltrue if the control key is pushed
[in]shifttrue if the shift key is pushed

◆ mouse_up()

void OGF::RenderArea::mouse_up ( RenderingContext rendering_context,
const vec2 point_ndc,
const vec2 point_wc,
int  button,
bool  control,
bool  shift 
)

A signal that is triggered each time a mouse button is released.

Parameters
[in]rendering_contexta pointer to the RenderingContext
[in]point_ndcthe picked point, in normalized device coordinates
[in]point_wcthe picked point, in world coordinates
[in]buttonthe pushed button (see MouseButton)
[in]controltrue if the control key is pushed
[in]shifttrue if the shift key is pushed

◆ needs_to_redraw()

bool OGF::RenderArea::needs_to_redraw ( ) const
inline

Tests whether the window needs to be redrawn.

Return values
trueif the window needs to be redrawn.
falseif the window is up to date.

Definition at line 86 of file render_area.h.

◆ resize()

void OGF::RenderArea::resize ( index_t  w,
index_t  h,
index_t  fb_w,
index_t  fb_h 
)

Resizes this RenderArea.

Parameters
[in]w,hthe new window width and height in pixels.
[in]fb_w,fb_hthe new frame buffer width and height in pixels. May be different from w and h on retina displays.

Called whenenver the size of the window does not match the current size.

◆ resize_request()

void OGF::RenderArea::resize_request ( RenderingContext rendering_context,
int  width,
int  height 
)

A signal that is triggered each time the render area is resized.

Parameters
[in]rendering_contexta pointer to the RenderingContext
[in]widththe new width
[in]heightthe new height

◆ set_background_color_1()

void OGF::RenderArea::set_background_color_1 ( const Color value)

Sets the primary background color.

Parameters
[in]valuethe background color

◆ set_background_color_2()

void OGF::RenderArea::set_background_color_2 ( const Color value)

Sets the secondary background color.

If different from the (primary) background color, then a color-ramp between both is generated.

Parameters
[in]valuethe secondary background color

◆ set_background_image()

void OGF::RenderArea::set_background_image ( const std::string &  value)

Sets the background image.

If a background image is specified, then it is used to fill the background (instead of the background color).

Parameters
[in]valuethe path to a file that contains the image or the empty string if no background image should be used

◆ set_clipping_config()

void OGF::RenderArea::set_clipping_config ( const std::string &  clipping_config)
inline

Sets the current clipping configuration.

Parameters
[in]clipping_configa ';'-separated string with the following fields:
  • active (one of "true","false")
  • axis (one of "x","y","z","d")
  • volume-mode (one of "std.","cell","strad.","slice")
  • shift (an integer in [-250, 250])
  • rotation (the 16 coefficients of a rotation matrix)

Definition at line 320 of file render_area.h.

◆ set_lighting_matrix()

void OGF::RenderArea::set_lighting_matrix ( const mat4 value)

Sets the lighting matrix.

The light source is transformed by the lighting matrix. This transform occurs in normalized device coordinates.

Parameters
[in]valuea const reference to the 4x4 homongeneous coordinates lighting matrix to be used

◆ set_projection_matrix()

void OGF::RenderArea::set_projection_matrix ( const mat4 value)

Sets the projection matrix.

Parameters
[in]valuethe projection matrix, as a 4x4 homogeneous coordinates matrix.

◆ set_viewing_matrix()

void OGF::RenderArea::set_viewing_matrix ( const mat4 value)

Sets the viewing matrix.

Parameters
[in]valuethe viewing matrix, as a 4x4 homogeneous coordinates matrix.

◆ snapshot()

void OGF::RenderArea::snapshot ( const std::string &  filename,
bool  make_current = true,
bool  with_gui = false 
)

Saves a snapshot of this rendering area to an image file.

Parameters
[in]filenamea string with the name of the image file.
[in]make_currentif true, makes the associated rendering context current, else use the current rendering context.
[in]with_guiif set, the gui of graphite is rendereed in the image with the 3D objects, else only the 3D objects are rendered

◆ update_background_image_from_data()

void OGF::RenderArea::update_background_image_from_data ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width,
index_t  height 
)

Updates the background image from raw image data.

Image data is in Cairo format (ARGB). Note that it is different from the convention in Graphite (RGBA). Note also that the Y axis is flipped as compared to the rest of Graphite.

Parameters
[in]ptra pointer to image data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widthimage width
[in]heightimage height

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