a class providing legends for plot classes with multiple datasets
More...
#include <gtkmm-plplot/legend.h>
a class providing legends for plot classes with multiple datasets
Plot2D, PlotPolar and other plot classes can handle several datasets simultaneously. To facilitate distinction between the different datasets, this class extends these plots by adding support for a legend that shows a short string with a description of each dataset. Such a legend consists of a box which contains a list of these descrptions, along with a small plot of the line and/or symbol that was used to render the corresponding dataset. This is demonstrated in examples Example 2: Logarithmic axes and box styles, Example 5: Mixing plot lines and symbols plus adding datapoints and Example 6: Polar coordinate systems.
◆ Legend() [1/2]
Gtk::PLplot::Legend::Legend |
( |
const Legend & |
legend | ) |
|
|
protecteddefault |
Copy constructor
- Parameters
-
◆ Legend() [2/2]
Gtk::PLplot::Legend::Legend |
( |
LegendCornerPosition |
legend_corner_position = LegendCornerPosition::TOP_RIGHT , |
|
|
double |
legend_pos_x = 0.0 , |
|
|
double |
legend_pos_y = 0.0 , |
|
|
Gdk::RGBA |
legend_background_color = Gdk::RGBA("White") , |
|
|
Gdk::RGBA |
legend_bounding_box_color = Gdk::RGBA("Black") |
|
) |
| |
|
protected |
Constructor
This class offers a single, protected constructor. To be called from the constructors of classes that derive from this class through multiple inheritance.
- Parameters
-
legend_corner_position | The corner that will be used to determine the legend coordinate system |
legend_pos_x | The position of the right top corner of the legend along the X-axis in normalized coordinates |
legend_pos_y | The position of the right top corner of the legend along the Y-axis in normalized coordinates |
legend_background_color | The default background color of the legend |
legend_bounding_box_color | The default color of the bounding box color of the legend |
◆ ~Legend()
virtual Gtk::PLplot::Legend::~Legend |
( |
| ) |
|
|
protectedvirtual |
◆ draw_legend()
virtual void Gtk::PLplot::Legend::draw_legend |
( |
const Cairo::RefPtr< Cairo::Context > & |
cr, |
|
|
std::vector< PlotData * > & |
plot_data, |
|
|
plstream * |
pls |
|
) |
| |
|
protectedvirtual |
Method to draw the legend
To be called from within draw_plot(). This method is virtual allowing inheriting classes to implement their own method with the same signature.
- Parameters
-
cr | the cairo context to draw to. |
plot_data | the vector of PlotData. |
pls | pointer to the plstream connected to the Plot. |
◆ get_legend_background_color()
Gdk::RGBA Gtk::PLplot::Legend::get_legend_background_color |
( |
| ) |
|
Get the currently selected background color of the legend
- Returns
- the legend background color
◆ get_legend_bounding_box_color()
Gdk::RGBA Gtk::PLplot::Legend::get_legend_bounding_box_color |
( |
| ) |
|
Get the currently selected legend bounding box color
- Returns
- the legend bounding box color
◆ get_legend_corner_position()
◆ get_legend_position()
void Gtk::PLplot::Legend::get_legend_position |
( |
double & |
legend_pos_x, |
|
|
double & |
legend_pos_y |
|
) |
| |
Gets the current position of the legend
See set_legend_position() for more information.
- Parameters
-
legend_pos_x | the current position of the selected corner of the legend along the X-axis in normalized coordinates |
legend_pos_y | the current position of the selected corner of the legend along the Y-axis in normalized coordinates |
◆ hide_legend()
void Gtk::PLplot::Legend::hide_legend |
( |
| ) |
|
◆ is_showing_legend()
bool Gtk::PLplot::Legend::is_showing_legend |
( |
| ) |
|
Returns whether or not the legend is currently showing
◆ operator=()
◆ set_legend_background_color()
void Gtk::PLplot::Legend::set_legend_background_color |
( |
Gdk::RGBA |
legend_background_color | ) |
|
Set the background color of the legend
- Parameters
-
legend_background_color | the new color |
◆ set_legend_bounding_box_color()
void Gtk::PLplot::Legend::set_legend_bounding_box_color |
( |
Gdk::RGBA |
legend_bounding_box_color | ) |
|
Set the bounding box color of the legend
- Parameters
-
legend_bounding_box_color | the legend bounding color |
◆ set_legend_corner_position()
Sets the new legend corner position
This corner will be used to determine the origin and direction of the normalized legend coordinate system.
- Parameters
-
legend_corner_position | the new legend corner |
◆ set_legend_position()
void Gtk::PLplot::Legend::set_legend_position |
( |
double |
legend_pos_x, |
|
|
double |
legend_pos_y |
|
) |
| |
Sets the new position of the legend
This position corresponds to the normalized coordinates of the selected corner of the legend, measured with respect to the corresponding corner of the plot box.
- Parameters
-
legend_pos_x | the new position of the selected corner of the legend along the X-axis in normalized coordinates |
legend_pos_y | the new position of the selected corner of the legend along the Y-axis in normalized coordinates |
- Exceptions
-
◆ show_legend()
void Gtk::PLplot::Legend::show_legend |
( |
| ) |
|
◆ legend_background_color
Gdk::RGBA Gtk::PLplot::Legend::legend_background_color |
|
private |
the background color of the legend
◆ legend_bounding_box_color
Gdk::RGBA Gtk::PLplot::Legend::legend_bounding_box_color |
|
private |
the color of the bounding box of the legend
◆ legend_corner_position
the corner of the legend box that will be used to determine the origin and direction of the normalized legend coordinate system
◆ legend_pos_x
double Gtk::PLplot::Legend::legend_pos_x |
|
private |
the position of the selected corner of the legend along the X-axis in normalized coordinates
◆ legend_pos_y
double Gtk::PLplot::Legend::legend_pos_y |
|
private |
the position of the selected corner of the legend along the Y-axis in normalized coordinates
◆ showing_legend
bool Gtk::PLplot::Legend::showing_legend |
|
private |
true
will render the legend, while false
will hide it