Mercurial > hg > octave-nkf
changeset 20338:e05fe4260252
Handle mouse interaction with image objects (bug #44691)
* gl-select.h (opengl_selector::draw_image): new method
* gl-select.cc (opengl_selector::draw_image): draw a GL_QUAD to indicate the image area in GL_SELECT mode
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Thu, 16 Apr 2015 22:52:09 +0200 |
parents | a42de4173533 |
children | 1784bf79ed43 |
files | libgui/graphics/gl-select.cc libgui/graphics/gl-select.h |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/gl-select.cc +++ b/libgui/graphics/gl-select.cc @@ -201,3 +201,35 @@ return Matrix (1, 4, 0.0); #endif } + +void +opengl_selector::draw_image (const image::properties& props) +{ + Matrix xd = props.get_xdata ().matrix_value (); + octave_idx_type nc = props.get_cdata ().matrix_value ().columns (); + double x_pix_size = (xd(1) - xd(0)) / (nc - 1); + + Matrix yd = props.get_ydata ().matrix_value (); + octave_idx_type nr = props.get_cdata ().matrix_value ().rows (); + double y_pix_size = (yd(1) - yd(0)) / (nr - 1); + + ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0); + p1(0) = xd(0) - x_pix_size/2; + p1(1) = yd(0) - y_pix_size/2; + + p2(0) = xd(1) + x_pix_size/2; + p2(1) = yd(0) - y_pix_size/2; + + p3(0) = xd(1) + x_pix_size/2; + p3(1) = yd(1) + y_pix_size/2; + + p4(0) = xd(0) - x_pix_size/2; + p4(1) = yd(1) + y_pix_size/2; + + glBegin (GL_QUADS); + glVertex3dv (p1.data ()); + glVertex3dv (p2.data ()); + glVertex3dv (p3.data ()); + glVertex3dv (p4.data ()); + glEnd (); +}
--- a/libgui/graphics/gl-select.h +++ b/libgui/graphics/gl-select.h @@ -48,6 +48,8 @@ protected: virtual void draw_text (const text::properties& props); + virtual void draw_image (const image::properties& props); + virtual void setup_opengl_transformation (const axes::properties& props); virtual void init_marker (const std::string& m, double size, float width);