Gtkmm-PLplot 3.0
A scientific plotting library for Gtkmm
|
a class providing support for selecting a region in a plot More...
#include <gtkmm-plplot/regionselection.h>
Public Member Functions | |
virtual | ~RegionSelection () |
void | set_region (double xmin, double xmax, double ymin, double ymax) |
void | get_region (double &xmin, double &xmax, double &ymin, double &ymax) |
bool | get_region_selectable () |
void | set_region_selectable (bool selectable=true) |
bool | get_region_zoomable () |
void | set_region_zoomable (bool zoomable=true) |
double | get_region_zoom_scale_factor () |
void | set_region_zoom_scale_factor (double scale_factor) |
Gdk::RGBA | get_region_selection_color () |
void | set_region_selection_color (Gdk::RGBA color) |
double | get_region_selection_width () |
void | set_region_selection_width (double line_width) |
bool | get_region_pannable () |
void | set_region_pannable (bool pannable=true) |
sigc::signal< void(double, double, double, double)> | signal_select_region () |
sigc::signal< void(double, double)> | signal_cursor_motion () |
sigc::signal< void(double, double)> | signal_cursor_enter () |
sigc::signal< void(void)> | signal_cursor_leave () |
sigc::signal< std::vector< double >(double, double, double, double)> | signal_pan () |
sigc::signal< void(double, double)> | signal_double_press () |
sigc::signal< void(double, double, GdkScrollDirection)> | signal_zoom_region () |
Protected Member Functions | |
virtual void | coordinate_transform_plplot_to_cairo (double x_pl, double y_pl, double &x_cr, double &y_cr) final |
virtual void | coordinate_transform_cairo_to_plplot (double x_cr, double y_cr, double &x_pl, double &y_pl) final |
virtual void | coordinate_transform_world_to_cairo (double x_wr, double y_wr, double &x_cr, double &y_cr) final |
virtual void | coordinate_transform_cairo_to_world (double x_cr, double y_cr, double &x_wr, double &y_wr) final |
virtual void | coordinate_transform_world_to_plplot (double x_wr, double y_wr, double &x_pl, double &y_pl) |
virtual void | coordinate_transform_plplot_to_world (double x_pl, double y_pl, double &x_wr, double &y_wr) |
virtual void | on_select_region (double xmin, double xmax, double ymin, double ymax) |
virtual void | on_zoom_region (double x, double y, GdkScrollDirection direction) |
virtual void | on_cursor_motion (double x, double y) |
virtual void | on_cursor_enter (double x, double y) |
virtual void | on_cursor_leave () |
virtual std::vector< double > | on_pan (double old_x, double old_y, double new_x, double new_y) |
virtual void | on_double_press (double x, double y) |
RegionSelection () | |
RegionSelection (const RegionSelection ®ion_selection)=default | |
Static Protected Member Functions | |
static void | ensure_valid_range (double &val0, double &val1) |
internal function that ensures valid ranges are always plotted, mostly avoiding case where for either x or y, data min is equal to data max. | |
Protected Attributes | |
double | cairo_range_x [2] |
the current range shown on the plot for the X-axis in Cairo coordinates | |
double | cairo_range_y [2] |
the current range shown on the plot for the Y-axis in Cairo coordinates | |
double | plotted_range_x [2] |
the current range shown on the plot for the X-axis in PLplot coordinates (NOT world!!!) | |
double | plotted_range_y [2] |
the current range shown on the plot for the Y-axis in PLplot coordinates (NOT world!!!) | |
double | plot_data_range_x [2] |
the maximum range covered by the X-values of the datasets in PLplot coordinates (NOT world!!!) | |
double | plot_data_range_y [2] |
the maximum range covered by the Y-values of the datasets in PLplot coordinates (NOT world!!!) | |
sigc::signal< void(double, double, double, double)> | _signal_select_region |
signal that gets emitted whenever a new region was selected using the mouse pointer in Canvas::on_button_release_event() | |
sigc::signal< void(double, double, GdkScrollDirection)> | _signal_zoom_region |
signal that gets emitted whenever one zooms in on the plot using the mouse scroll wheel in Canvas::on_scroll_event() | |
sigc::signal< void(double, double)> | _signal_cursor_motion |
signal that will be emitted whenever the cursor (usually the mouse) is moved. | |
sigc::signal< void(double, double)> | _signal_cursor_enter |
signal that will be emitted whenever the cursor (usually the mouse) enter. | |
sigc::signal< void(void)> | _signal_cursor_leave |
signal that will be emitted whenever the cursor (usually the mouse) leave. | |
sigc::signal< std::vector< double >(double, double, double, double)> | _signal_pan |
signal that will be emitted whenever the cursor is moved within a pannable plot while the SHIFT key is pressed in and the left mouse button is pressed. | |
sigc::signal< void(double, double)> | _signal_double_press |
signal that will emitted whenever a double mouse-click event was recorded within the plot box. Default response will be to reset the region to a range determined by the minima and maxima of the X- and Y- datasets. | |
Private Attributes | |
bool | region_selectable |
true indicates that a region on the plot can be selected by dragging a box with the mouse button pressed in when showing, or if double mouse button pressed event zooms out, false means not possible. The default is true | |
bool | region_zoomable |
true indicates that one can zoom in on a region on the plot by using the mouse scroll wheel (or trackpad), false means not possible. The default is true | |
bool | region_pannable |
true indicates that one can pan a plot around by simultaneously pressing Shift and the left mouse button while moving the mouse cursor around. false means not possible. The default is true | |
double | region_zoom_scale_factor |
scale factor that will be used for scroll wheel based zooming | |
Gdk::RGBA | region_selection_color |
color that will be used to draw the selection box | |
double | region_selection_width |
width of the selection box frame | |
Friends | |
class | Canvas |
a class providing support for selecting a region in a plot
Several plot classes (Plot2D, PlotPolar, PlotContour and PlotContourShades) that represent data in a two-dimensional grid inherit from this class, allowing users to drag a selection box using a mouse gesture (mouse button press, drag, mouse button release), to zoom in or out by using the scroll button, or to pan the plotdata around in its plot box by pressing in Shift and pressing the left mouse button in, while moving the mouse around. The default signal handler will initiate a redrawing of the plot, with the visible region set to correspond to the initially drawn box. This is shown in Example 1: Plot data properties and zooming and others.
Anyone interested in deriving this library (or classes that inherit from RegionSelection), will notice that there are three coordinate systems in use.
Methods have been provided that allow for coordinate transformations between these three coordinate systems. Regular users of the library (not hackers!), will only ever be dealing with the World coordinate system, as all transformations are taken care of by Gtkmm-PLplot.
|
protected |
Constructor
|
protecteddefault |
Copy constructor
region_selection | copy source |
|
virtual |
Destructor
|
finalprotectedvirtual |
|
finalprotectedvirtual |
Transform Cairo coordinate system coordinates to World
This method cannot be overridden in derived classed.
x_cr | Cairo X-coordinate |
y_cr | Cairo Y-coordinate |
x_wr | World X-coordinate |
y_wr | World Y-coordinate |
|
finalprotectedvirtual |
|
protectedvirtual |
Transform PLplot coordinate system coordinates to world
This method takes care of coordinate transformations when using non-linear axes When a plot has logarithmic axes or polar plot style, PLplot requires the user to transform the dataset into the linear cartesian coordinate system which it uses internally. The default implementation does returns output coordinates that is identical to the input.
x_pl | the x PLplot coordinate to be transformed |
y_pl | the y PLplot coordinate to be transformed |
x_wr | the new x world coordinate |
y_wr | the new y world coordinate |
Reimplemented in Gtk::PLplot::Plot2D, and Gtk::PLplot::PlotPolar.
|
finalprotectedvirtual |
Transform World coordinate system coordinates to Cairo
This method cannot be overridden in derived classed.
x_wr | World X-coordinate |
y_wr | World Y-coordinate |
x_cr | Cairo X-coordinate |
y_cr | Cairo Y-coordinate |
|
protectedvirtual |
Transform World coordinate system coordinates to PLplot
This method takes care of coordinate transformations when using non-linear axes When a plot has logarithmic axes or polar plot style, PLplot requires the user to transform the dataset into the linear cartesian coordinate system which it uses internally. The default implementation does returns output coordinates that is identical to the input.
x_wr | the x world coordinate to be transformed |
y_wr | the y world coordinate to be transformed |
x_pl | the new x PLplot coordinate |
y_pl | the new y PLplot coordinate |
Reimplemented in Gtk::PLplot::Plot2D, and Gtk::PLplot::PlotPolar.
|
staticprotected |
internal function that ensures valid ranges are always plotted, mostly avoiding case where for either x or y, data min is equal to data max.
void Gtk::PLplot::RegionSelection::get_region | ( | double & | xmin, |
double & | xmax, | ||
double & | ymin, | ||
double & | ymax | ||
) |
Get the currently visible plotted region
(xmin, ymin) corresponds to the World coordinates of the lower left corner of the visible region, while (xmax, ymax) corresponds to the World coordinates of the upper right corner of the visible region.
xmin | left X-coordinate |
xmax | right X-coordinate |
ymin | lower Y-coordinate |
ymax | upper Y-coordinate |
Gtk::PLplot::Exception |
bool Gtk::PLplot::RegionSelection::get_region_pannable | ( | ) |
Get whether plotdata can be panned on the plot by clicking the left mouse button and the shift key
true
if plotdate is draggable in the plot, false
if not bool Gtk::PLplot::RegionSelection::get_region_selectable | ( | ) |
Get whether regions can be selected on the plot by dragging the mouse while the button is clicked in.
true
if a region is selectable in the plot, false
if not Gdk::RGBA Gtk::PLplot::RegionSelection::get_region_selection_color | ( | ) |
Gets the currently used selection box color
The default color is black
double Gtk::PLplot::RegionSelection::get_region_selection_width | ( | ) |
Gets the currently used selection box line width
The default width is 2.0
double Gtk::PLplot::RegionSelection::get_region_zoom_scale_factor | ( | ) |
Gets the currently used zoom scale factor
The default value is 2.0. If a value lower than 1.0 is chosen, zoom-in and zoom-out will exchange behavior.
bool Gtk::PLplot::RegionSelection::get_region_zoomable | ( | ) |
Get whether regions can be selected on the plot by scrolling the mouse wheel (or trackpad)
true
if a region is zoomable in the plot, false
if not
|
protectedvirtual |
This is a default handler for signal_cursor_enter()
This signal is emitted whenever the cursor (usually the mouse) is enter within the plot. x and y correspond to the new data coordinates. Currently this method does nothing, and users are encouraged to write their own signal handler or override the method in a new class.
x | The X-value corresponding to the current cursor position |
y | The Y-value corresponding to the current cursor position |
|
protectedvirtual |
This is a default handler for signal_cursor_enter()
This signal is emitted whenever the cursor (usually the mouse) leave the plot. Currently this method does nothing, and users are encouraged to write their own signal handler or override the method in a new class.
|
protectedvirtual |
This is a default handler for signal_cursor_motion()
This signal is emitted whenever the cursor (usually the mouse) is moved within the plot. x and y correspond to the new data coordinates. Currently this method does nothing, and users are encouraged to write their own signal handler or override the method in a new class.
x | The X-value corresponding to the current cursor position |
y | The Y-value corresponding to the current cursor position |
|
protectedvirtual |
This is a default handler for signal_double_press()
This signal is emitted whenever a double mouse-click event is recorded within the plot box. Default response will be the resetting of the plot region to a range determined by the minima and maxima of the X- and Y- datasets
x | X-plot-coordinate of the position where the double click event occurred. |
y | Y-plot-coordinate of the position where the double click event occurred. |
|
protectedvirtual |
This is a default handler for signal_pan()
This signal is emitted whenever the cursor is moved within a pannable plot, with the Shift key and left mouse button pressed in. old_x and old_y correspond to the old data coordinates, before the motion, while new_x and new_y refer to the new data coordinates. Currently this method will cause the plot to move around in its box (panning). If this behavior is not desired, derive the class and implement your own on_pan method.
old_x | The X-value corresponding to the previous cursor position |
old_y | The Y-value corresponding to the previous cursor position |
new_x | The X-value corresponding to the previous cursor position |
new_y | The Y-value corresponding to the previous cursor position |
|
protectedvirtual |
This is a default handler for signal_select_region()
This method passes the plot (data) coordinates of the selection box to set_region, in order to set the plotted range corresponding to the selection box. If this behavior is not desired, derive the class and implement your own on_select_region method.
xmin | left X-coordinate |
xmax | right X-coordinate |
ymin | lower Y-coordinate |
ymax | upper Y-coordinate |
Gtk::PLplot::Exception |
|
protectedvirtual |
This is a default handler for signal_zoom_region()
This method passes the plot (data) coordinates corresponding to the position where the user produced a scroll event. Depending on the direction of the scroll movement, the region will be zoomed in or out. If this behavior is not desired, derive the class and implement your own on_zoom_region method.
x | X-coordinate |
y | Y-coordinate |
direction | Movement direction |
Gtk::PLplot::Exception |
void Gtk::PLplot::RegionSelection::set_region | ( | double | xmin, |
double | xmax, | ||
double | ymin, | ||
double | ymax | ||
) |
Changes the visible plotted region
Sets the axes range of the plotted box to the provided world coordinates.
xmin | left X-coordinate |
xmax | right X-coordinate |
ymin | lower Y-coordinate |
ymax | upper Y-coordinate |
Gtk::PLplot::Exception |
void Gtk::PLplot::RegionSelection::set_region_pannable | ( | bool | pannable = true | ) |
Sets whether plots can be panned within the plot by simultaneously clicking the left mouse button and the shift key
pannable | pass true if plotdata is pannable, false if not |
void Gtk::PLplot::RegionSelection::set_region_selectable | ( | bool | selectable = true | ) |
Sets whether regions can be selected on the plot by dragging the mouse while the button is clicked in.
selectable | pass true if a region has to be selectable, false if not |
void Gtk::PLplot::RegionSelection::set_region_selection_color | ( | Gdk::RGBA | color | ) |
Sets the selection box color
color | the new region selection box color |
void Gtk::PLplot::RegionSelection::set_region_selection_width | ( | double | line_width | ) |
Sets the selection box line width
line_width | the new region selection box line width |
Gtk::PLplot::Exception |
void Gtk::PLplot::RegionSelection::set_region_zoom_scale_factor | ( | double | scale_factor | ) |
Sets a new zoom scale factor
scale_factor | the new zoom scale factor |
Gtk::PLplot::Exception |
void Gtk::PLplot::RegionSelection::set_region_zoomable | ( | bool | zoomable = true | ) |
Sets whether regions can be selected on the plot by scrolling the mouse wheel (or trackpad)
zoomable | pass true if a region has to be zoomable, false if not |
|
inline |
signal_cursor_enter is emitted whenever the cursor enters within the plot
See default handler on_cursor_enter()
|
inline |
signal_cursor_leave is emitted whenever the cursor leaves the plot
See default handler on_cursor_leave()
|
inline |
signal_cursor_motion is emitted whenever the cursor is moved within the plot
See default handler on_cursor_motion()
|
inline |
signal_double_press is emitted whenever a double-click event on the plot is recorded.
See default handler on_double_press()
|
inline |
signal_pan is emitted whenever the cursor is moved within the plot and Shift is pressed in.
See default handler on_pan()
|
inline |
signal_select_region is emitted whenever a selection box is dragged across a plot
See default handler on_select_region()
|
inline |
signal_zoom_region is emitted whenever a mouse scroll event on the plot is recorded.
See default handler on_zoom_region()
|
friend |
|
protected |
signal that will be emitted whenever the cursor (usually the mouse) enter.
|
protected |
signal that will be emitted whenever the cursor (usually the mouse) leave.
|
protected |
signal that will be emitted whenever the cursor (usually the mouse) is moved.
|
protected |
signal that will emitted whenever a double mouse-click event was recorded within the plot box. Default response will be to reset the region to a range determined by the minima and maxima of the X- and Y- datasets.
|
protected |
signal that will be emitted whenever the cursor is moved within a pannable plot while the SHIFT key is pressed in and the left mouse button is pressed.
|
protected |
signal that gets emitted whenever a new region was selected using the mouse pointer in Canvas::on_button_release_event()
|
protected |
signal that gets emitted whenever one zooms in on the plot using the mouse scroll wheel in Canvas::on_scroll_event()
|
protected |
the current range shown on the plot for the X-axis in Cairo coordinates
|
protected |
the current range shown on the plot for the Y-axis in Cairo coordinates
|
protected |
the maximum range covered by the X-values of the datasets in PLplot coordinates (NOT world!!!)
|
protected |
the maximum range covered by the Y-values of the datasets in PLplot coordinates (NOT world!!!)
|
protected |
the current range shown on the plot for the X-axis in PLplot coordinates (NOT world!!!)
|
protected |
the current range shown on the plot for the Y-axis in PLplot coordinates (NOT world!!!)
|
private |
true
indicates that one can pan a plot around by simultaneously pressing Shift and the left mouse button while moving the mouse cursor around. false
means not possible. The default is true
|
private |
true
indicates that a region on the plot can be selected by dragging a box with the mouse button pressed in when showing, or if double mouse button pressed event zooms out, false
means not possible. The default is true
|
private |
color that will be used to draw the selection box
|
private |
width of the selection box frame
|
private |
scale factor that will be used for scroll wheel based zooming
|
private |
true
indicates that one can zoom in on a region on the plot by using the mouse scroll wheel (or trackpad), false
means not possible. The default is true