Gtkmm-PLplot 3.0
A scientific plotting library for Gtkmm
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Gtk::PLplot::Legend Class Reference

a class providing legends for plot classes with multiple datasets More...

#include <gtkmm-plplot/legend.h>

Inheritance diagram for Gtk::PLplot::Legend:
Inheritance graph
[legend]

Public Member Functions

void set_legend_background_color (Gdk::RGBA legend_background_color)
 
Gdk::RGBA get_legend_background_color ()
 
void set_legend_bounding_box_color (Gdk::RGBA legend_bounding_box_color)
 
Gdk::RGBA get_legend_bounding_box_color ()
 
void set_legend_position (double legend_pos_x, double legend_pos_y)
 
void get_legend_position (double &legend_pos_x, double &legend_pos_y)
 
void set_legend_corner_position (LegendCornerPosition legend_corner_position)
 
LegendCornerPosition get_legend_corner_position ()
 
void show_legend ()
 
void hide_legend ()
 
bool is_showing_legend ()
 

Protected Member Functions

 Legend (const Legend &legend)=default
 
 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"))
 
virtual ~Legend ()
 
virtual void draw_legend (const Cairo::RefPtr< Cairo::Context > &cr, std::vector< PlotData * > &plot_data, plstream *pls)
 

Private Member Functions

Legendoperator= (const Legend &)=delete
 no move constructor
 

Private Attributes

bool showing_legend
 true will render the legend, while false will hide it
 
double legend_pos_x
 the position of the selected corner of the legend along the X-axis in normalized coordinates
 
double legend_pos_y
 the position of the selected corner of the legend along the Y-axis in normalized coordinates
 
Gdk::RGBA legend_background_color
 the background color of the legend
 
Gdk::RGBA legend_bounding_box_color
 the color of the bounding box of the legend
 
LegendCornerPosition 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Legend() [1/2]

Gtk::PLplot::Legend::Legend ( const Legend legend)
protecteddefault

Copy constructor

Parameters
legendcopy source

◆ 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_positionThe corner that will be used to determine the legend coordinate system
legend_pos_xThe position of the right top corner of the legend along the X-axis in normalized coordinates
legend_pos_yThe position of the right top corner of the legend along the Y-axis in normalized coordinates
legend_background_colorThe default background color of the legend
legend_bounding_box_colorThe default color of the bounding box color of the legend

◆ ~Legend()

virtual Gtk::PLplot::Legend::~Legend ( )
protectedvirtual

Destructor

Member Function Documentation

◆ 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
crthe cairo context to draw to.
plot_datathe vector of PlotData.
plspointer 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()

LegendCornerPosition Gtk::PLplot::Legend::get_legend_corner_position ( )

Gets the current legend corner position

Set set_legend_corner_position() for more information.

Returns
the 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_xthe current position of the selected corner of the legend along the X-axis in normalized coordinates
legend_pos_ythe current position of the selected corner of the legend along the Y-axis in normalized coordinates

◆ hide_legend()

void Gtk::PLplot::Legend::hide_legend ( )

Hides the legend

◆ is_showing_legend()

bool Gtk::PLplot::Legend::is_showing_legend ( )

Returns whether or not the legend is currently showing

◆ operator=()

Legend & Gtk::PLplot::Legend::operator= ( const Legend )
privatedelete

no move constructor

◆ 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_colorthe 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_colorthe legend bounding color

◆ set_legend_corner_position()

void Gtk::PLplot::Legend::set_legend_corner_position ( LegendCornerPosition  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_positionthe 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_xthe new position of the selected corner of the legend along the X-axis in normalized coordinates
legend_pos_ythe new position of the selected corner of the legend along the Y-axis in normalized coordinates
Exceptions
Gtk::PLplot::Exception

◆ show_legend()

void Gtk::PLplot::Legend::show_legend ( )

Show the legend

Member Data Documentation

◆ 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

LegendCornerPosition Gtk::PLplot::Legend::legend_corner_position
private

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