Graphite
Version 3
An experimental 3D geometry processing program
|
Implementation of RenderArea using ImGui. More...
#include <OGF/skin_imgui/widgets/render_area.h>
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 mat4 & | get_projection_matrix () const |
Gets the projection matrix. More... | |
void | set_viewing_matrix (const mat4 &value) |
Sets the viewing matrix. More... | |
const mat4 & | get_viewing_matrix () const |
Gets the viewing matrix. More... | |
void | set_background_color_1 (const Color &value) |
Sets the primary background color. More... | |
const Color & | get_background_color_1 () const |
Gets the background color. More... | |
void | set_background_color_2 (const Color &value) |
Sets the secondary background color. More... | |
const Color & | get_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 mat4 & | get_lighting_matrix () const |
Gets the lighting matrix. More... | |
RenderingContext * | get_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 MetaClass * | meta_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 Connection * | connect_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... | |
MetaClass * | get_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 Object * | id_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... | |
Implementation of RenderArea using ImGui.
Definition at line 56 of file render_area.h.
RenderArea constructor.
[in] | w,h | window width and height in pixels. |
[in] | fb_w,fb_h | frame buffer width and height in pixels. |
void OGF::RenderArea::button_down | ( | int | value | ) |
A signal that is triggered each time a mouse button is pressed.
[in] | value | the button (see MouseButton) |
void OGF::RenderArea::button_up | ( | int | value | ) |
A signal that is triggered each time a mouse button is released.
[in] | value | the button (see MouseButton) |
void OGF::RenderArea::dropped_file | ( | const std::string & | value | ) |
A signal that is triggered whenever a file is drag-dropped into this RenderArea.
[in] | value | the name of the file that was dropped |
const Color& OGF::RenderArea::get_background_color_1 | ( | ) | const |
Gets the background color.
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.
const std::string& OGF::RenderArea::get_background_image | ( | ) | const |
Gets the background image.
|
inline |
Gets the current clipping configuration.
Definition at line 306 of file render_area.h.
|
inline |
Gets the height of the window.
Definition at line 187 of file render_area.h.
|
inline |
Gets the width of the window.
Definition at line 179 of file render_area.h.
std::string OGF::RenderArea::get_gpu_extensions | ( | ) | const |
Gets GPU extensions.
std::string OGF::RenderArea::get_gpu_information | ( | ) | const |
Gets the GPU information.
|
inline |
Gets the height of the window.
Definition at line 171 of file render_area.h.
const mat4& OGF::RenderArea::get_lighting_matrix | ( | ) | const |
Gets the lighting matrix.
const mat4& OGF::RenderArea::get_projection_matrix | ( | ) | const |
Gets the projection matrix.
RenderingContext* OGF::RenderArea::get_rendering_context | ( | ) | const |
Gets the rendering context.
const mat4& OGF::RenderArea::get_viewing_matrix | ( | ) | const |
Gets the viewing matrix.
void OGF::RenderArea::key_down | ( | const std::string & | value | ) |
A signal that is triggered each time a key is pushed.
[in] | value | a string with the pressed key, or "shift", "control", "alt", "left", "right", "up", "down" for special keys. |
void OGF::RenderArea::key_up | ( | const std::string & | value | ) |
A signal that is triggered each time a key is released.
[in] | value | a string with the pressed key, or "shift", "control", "alt", "left", "right", "up", "down" for special keys. |
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.
[in] | rendering_context | a pointer to the RenderingContext |
[in] | point_ndc | the picked point, in normalized device coordinates |
[in] | point_wc | the picked point, in world coordinates |
[in] | button | the pushed button (see MouseButton) |
[in] | control | true if the control key is pushed |
[in] | shift | true if the shift key is pushed |
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.
[in] | rendering_context | a pointer to the RenderingContext |
[in] | point_ndc | the picked point, in normalized device coordinates |
[in] | point_wc | the picked point, in world coordinates |
[in] | delta_ndc | the displacement vector in normalized device coordinates |
[in] | delta_x_ndc | the x component of the displacement vector in normalized device coordinates |
[in] | delta_y_ndc | the y component of the displacement vector in normalized device coordinates |
[in] | delta_wc | the displacement vector in world coordinates |
[in] | button | the pushed button (see MouseButton) |
[in] | control | true if the control key is pushed |
[in] | shift | true if the shift key is pushed |
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.
[in] | rendering_context | a pointer to the RenderingContext |
[in] | point_ndc | the picked point, in normalized device coordinates |
[in] | point_wc | the picked point, in world coordinates |
[in] | button | the pushed button (see MouseButton) |
[in] | control | true if the control key is pushed |
[in] | shift | true if the shift key is pushed |
|
inline |
Tests whether the window needs to be redrawn.
true | if the window needs to be redrawn. |
false | if the window is up to date. |
Definition at line 86 of file render_area.h.
Resizes this RenderArea.
[in] | w,h | the new window width and height in pixels. |
[in] | fb_w,fb_h | the 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.
void OGF::RenderArea::resize_request | ( | RenderingContext * | rendering_context, |
int | width, | ||
int | height | ||
) |
A signal that is triggered each time the render area is resized.
[in] | rendering_context | a pointer to the RenderingContext |
[in] | width | the new width |
[in] | height | the new height |
void OGF::RenderArea::set_background_color_1 | ( | const Color & | value | ) |
Sets the primary background color.
[in] | value | the background color |
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.
[in] | value | the secondary background color |
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).
[in] | value | the path to a file that contains the image or the empty string if no background image should be used |
|
inline |
Sets the current clipping configuration.
[in] | clipping_config | a ';'-separated string with the following fields:
|
Definition at line 320 of file render_area.h.
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.
[in] | value | a const reference to the 4x4 homongeneous coordinates lighting matrix to be used |
void OGF::RenderArea::set_projection_matrix | ( | const mat4 & | value | ) |
Sets the projection matrix.
[in] | value | the projection matrix, as a 4x4 homogeneous coordinates matrix. |
void OGF::RenderArea::set_viewing_matrix | ( | const mat4 & | value | ) |
Sets the viewing matrix.
[in] | value | the viewing matrix, as a 4x4 homogeneous coordinates matrix. |
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.
[in] | filename | a string with the name of the image file. |
[in] | make_current | if true, makes the associated rendering context current, else use the current rendering context. |
[in] | with_gui | if set, the gui of graphite is rendereed in the image with the 3D objects, else only the 3D objects are rendered |
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.
[in] | ptr | a pointer to image data |
[in] | color_encoding | the color encoding of the data |
[in] | component_encoding | the data type used for the color components |
[in] | width | image width |
[in] | height | image height |