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

an abstract base class for all plots More...

#include <gtkmm-plplot/plot.h>

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

Public Member Functions

virtual ~Plot ()
 
virtual void remove_data (unsigned int plot_data_index)
 
virtual void remove_data (PlotData &plot_data_member)
 
virtual void remove_object (unsigned int plot_object_index)
 
virtual void remove_object (PlotObject &plot_object_member)
 
virtual PlotDataget_data (unsigned int data_index=0) final
 
virtual void draw_plot (const Cairo::RefPtr< Cairo::Context > &cr, const int width, const int height)=0
 
void set_axis_title_x (Glib::ustring title)
 
void set_axis_title_y (Glib::ustring title)
 
Glib::ustring get_axis_title_x ()
 
Glib::ustring get_axis_title_y ()
 
void set_plot_title (Glib::ustring title)
 
Glib::ustring get_plot_title ()
 
void show ()
 
void hide ()
 
bool is_showing () const
 
Gdk::RGBA get_background_color ()
 
void set_background_color (Gdk::RGBA color)
 
Gdk::RGBA get_axes_color ()
 
void set_axes_color (Gdk::RGBA color)
 
Gdk::RGBA get_titles_color ()
 
void set_titles_color (Gdk::RGBA color)
 
sigc::signal< void(void)> signal_changed ()
 
sigc::signal< void(PlotData *)> signal_data_added ()
 
sigc::signal< void(PlotData *)> signal_data_removed ()
 
sigc::signal< void(PlotObject *)> signal_object_added ()
 
sigc::signal< void(PlotObject *)> signal_object_removed ()
 
- Public Member Functions inherited from Gtk::PLplot::Object
virtual void set_manage ()
 

Protected Member Functions

virtual void plot_data_modified ()=0
 a method that will update the _range variables when datasets are added, modified or removed.
 
virtual void on_changed ()
 
virtual void on_data_added (PlotData *new_data)
 
virtual void on_data_removed (PlotData *removed_data)
 
virtual void on_object_added (PlotObject *new_object)
 
virtual void on_object_removed (PlotObject *removed_object)
 
virtual void draw_plot_init (const Cairo::RefPtr< Cairo::Context > &cr, const int width, const int height) final
 
 Plot (const Glib::ustring &axis_title_x, const Glib::ustring &axis_title_y, const Glib::ustring &plot_title, const double plot_width_norm, const double plot_height_norm, const double plot_offset_horizontal_norm, const double plot_offset_vertical_norm)
 
- Protected Member Functions inherited from Gtk::PLplot::Object
 Object ()
 

Protected Attributes

std::vector< PlotData * > plot_data
 vector that contains pointers to the PlotData datasets
 
std::vector< PlotObject * > plot_objects
 vector that contains pointers to the PlotObject datasets
 
Glib::ustring axis_title_x
 X-axis title.
 
Glib::ustring axis_title_y
 Y-axis title.
 
Glib::ustring plot_title
 Plot title.
 
plstream * pls
 the plstream object that will ensure the connection with PLplot
 
int canvas_width
 the width of the canvas in Cairo units
 
int canvas_height
 the height of the canvas in Cairo units
 
int plot_offset_x
 the offset of the plot with respect to the top left corner of the canvas, measured along the horizontal (X-) axis in Cairo units
 
int plot_offset_y
 the offset of the plot with respect to the top left corner of the canvas, measured along the vertical (Y-) axis in Cairo units
 
int plot_width
 the current width of the plot in Cairo units
 
int plot_height
 the current height of the plot in Cairo units
 
bool shown
 true means the plot is currently visible, false means it is not plotted
 
Gdk::RGBA background_color
 the currently used background color of the plot (default = fully transparent white, meaning that the background will be determined by the canvas)
 
const double plot_width_norm
 the normalized plot width, calculated relative to the canvas width
 
const double plot_height_norm
 the normalized plot height, calculated relative to the canvas height
 
const double plot_offset_horizontal_norm
 the normalized horizontal offset from the canvas top left corner, calculated relative to the canvas width
 
const double plot_offset_vertical_norm
 the normalized vertical offset from the canvas top left corner, calculated relative to the canvas height
 
Gdk::RGBA axes_color
 the currently used color to draw the axes, the box and gridlines. Default is opaque black
 
Gdk::RGBA titles_color
 the currently used color to draw the axes and plot titles. Default is opaque black
 
sigc::signal< void(void)> _signal_changed
 signal that gets emitted whenever any of the plot parameters, or any of the contained PlotData datasets is changed.
 
sigc::signal< void(PlotData *)> _signal_data_added
 signal emitted whenever a PlotData dataset is added to the plot
 
sigc::signal< void(PlotData *)> _signal_data_removed
 signal emitted whenever data is removed from the plot.
 
sigc::signal< void(PlotObject *)> _signal_object_added
 signal emitted whenever a PlotObject is added to the plot
 
sigc::signal< void(PlotObject *)> _signal_object_removed
 signal emitted whenever a PlotObject is removed from the plot.
 

Private Member Functions

Plotoperator= (const Plot &)=delete
 no assignment operator
 
 Plot (const Plot &)=delete
 no default copy constructor
 
 Plot ()=delete
 

Friends

class Canvas
 
class RegionSelection
 

Detailed Description

an abstract base class for all plots

This is the base class from which all other plots classes are derived. It contains several pure virtual methods that have to be implemented by all derived classes. This class cannot be instantiated directly, meaning that instances returned by Canvas::get_plot() and Canvas::add_plot() need to be cast to access methods offered only by the derived class.

Constructor & Destructor Documentation

◆ Plot() [1/3]

Gtk::PLplot::Plot::Plot ( const Plot )
privatedelete

no default copy constructor

◆ Plot() [2/3]

Gtk::PLplot::Plot::Plot ( )
privatedelete

◆ Plot() [3/3]

Gtk::PLplot::Plot::Plot ( const Glib::ustring &  axis_title_x,
const Glib::ustring &  axis_title_y,
const Glib::ustring &  plot_title,
const double  plot_width_norm,
const double  plot_height_norm,
const double  plot_offset_horizontal_norm,
const double  plot_offset_vertical_norm 
)
protected

Constructor

This class provides a single constructor, which takes an existing PlotData dataset to construct a plot. Optionally, the constructor takes additional arguments to set the axes and plot titles, as well as normalized coordinates that will determine the position and dimensions of the plot within the canvas. The default corresponds to the plot taking up the full space.

Parameters
axis_title_xX-axis title
axis_title_yY-axis title
plot_titleplot title
plot_width_normthe normalized plot width, calculated relative to the canvas width
plot_height_normthe normalized plot height, calculated relative to the canvas height
plot_offset_horizontal_normthe normalized horizontal offset from the canvas top left corner, calculated relative to the canvas width
plot_offset_vertical_normthe normalized vertical offset from the canvas top left corner, calculated relative to the canvas height

◆ ~Plot()

virtual Gtk::PLplot::Plot::~Plot ( )
virtual

Destructor

Member Function Documentation

◆ draw_plot()

virtual void Gtk::PLplot::Plot::draw_plot ( const Cairo::RefPtr< Cairo::Context > &  cr,
const int  width,
const int  height 
)
pure virtual

Method to draw the plot with all of its datasets

This method is virtual allowing inheriting classes to implement their own method with the same signature.

Parameters
crthe cairo context to draw to.
widththe width of the Canvas widget
heightthe height of the Canvas widget

Implemented in Gtk::PLplot::Plot2D, Gtk::PLplot::Plot3D, Gtk::PLplot::PlotContour, Gtk::PLplot::PlotContourShades, Gtk::PLplot::PlotHistogram, and Gtk::PLplot::PlotPolar.

◆ draw_plot_init()

virtual void Gtk::PLplot::Plot::draw_plot_init ( const Cairo::RefPtr< Cairo::Context > &  cr,
const int  width,
const int  height 
)
finalprotectedvirtual

Initialization method for draw_plot.

Should be called by all draw_plot() methods in derived classes.

Parameters
crCairo context
widthwidth of the plot in normalized coordinates
heightheight of the plot in normalized coordinates

◆ get_axes_color()

Gdk::RGBA Gtk::PLplot::Plot::get_axes_color ( )

Get the color to draw the axes, the box and gridlines

Returns
The currently selected axes color.

◆ get_axis_title_x()

Glib::ustring Gtk::PLplot::Plot::get_axis_title_x ( )

Get the X-axis title

Returns
the current X-axis title

◆ get_axis_title_y()

Glib::ustring Gtk::PLplot::Plot::get_axis_title_y ( )

Get the Y-axis title

Returns
the current Y-axis title

◆ get_background_color()

Gdk::RGBA Gtk::PLplot::Plot::get_background_color ( )

Get the plot background color

Returns
The currently selected plot background color.

◆ get_data()

virtual PlotData * Gtk::PLplot::Plot::get_data ( unsigned int  data_index = 0)
finalvirtual

Get a pointer to a dataset included in the plot

Throws an exception when data_index is invalid.

Parameters
data_indexindex of the dataset in the plot_data vector
Returns
a pointer to the PlotData in the plot_data vector.
Exceptions
Gtk::PLplot::Exception

◆ get_plot_title()

Glib::ustring Gtk::PLplot::Plot::get_plot_title ( )

Get the plot title

Returns
the current plot title

◆ get_titles_color()

Gdk::RGBA Gtk::PLplot::Plot::get_titles_color ( )

Get the color to draw the plot and axes titles

Returns
The currently selected plot and axes color.

◆ hide()

void Gtk::PLplot::Plot::hide ( )

Hide the plot on the canvas

◆ is_showing()

bool Gtk::PLplot::Plot::is_showing ( ) const

Returns whether or not the plot is showing on the canvas

Returns
true if the plot is visible, false if not

◆ on_changed()

virtual void Gtk::PLplot::Plot::on_changed ( )
protectedvirtual

This is a default handler for signal_changed()

This signal is emitted whenever any of the plot properties, or the properties of the PlotData datasets therein, is changed. Currently it does nothing but the signal will get caught by Canvas, and will eventually trigger a redrawing of the entire widget.

◆ on_data_added()

virtual void Gtk::PLplot::Plot::on_data_added ( PlotData new_data)
protectedvirtual

This is a default handler for signal_data_added()

This signal is emitted whenever a new PlotData dataset is added to the plot. It will call the private method plot_data_modified, which will update *_range_* properties, and emit signal_changed.

Parameters
new_dataa pointer to the newly added PlotData dataset, after it has been added to the plot_data vector.

◆ on_data_removed()

virtual void Gtk::PLplot::Plot::on_data_removed ( PlotData removed_data)
protectedvirtual

This is a default handler for signal_data_removed()

This signal is emitted whenever a PlotData dataset is removed from the plot with remove_data. It will first delete removed_data, provided its memory is managed, followed by a call to the private method plot_data_modified, which will update *_range_* properties, and emit signal_changed.

Parameters
removed_dataa pointer to the PlotData dataset that was just removed. It should be deleted in this method or a memory leak will be created.

◆ on_object_added()

virtual void Gtk::PLplot::Plot::on_object_added ( PlotObject new_object)
protectedvirtual

This is a default handler for signal_object_added()

This signal is emitted whenever a new PlotObject instance is added to the plot.

Parameters
new_objecta pointer to the newly added PlotObject instance, after it has been added to the plot_objects vector.

◆ on_object_removed()

virtual void Gtk::PLplot::Plot::on_object_removed ( PlotObject removed_object)
protectedvirtual

This is a default handler for signal_object_removed()

This signal is emitted whenever a PlotObject instance is removed from the plot with remove_object. It will first delete removed_object, provided its memory is managed, followed by a emitting signal_changed.

Parameters
removed_objecta pointer to the PlotObject objectset that was just removed. It should be deleted in this method or a memory leak will be created.

◆ operator=()

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

no assignment operator

◆ plot_data_modified()

virtual void Gtk::PLplot::Plot::plot_data_modified ( )
protectedpure virtual

a method that will update the _range variables when datasets are added, modified or removed.

Implemented in Gtk::PLplot::Plot2D, Gtk::PLplot::Plot3D, Gtk::PLplot::PlotContour, Gtk::PLplot::PlotHistogram, and Gtk::PLplot::PlotPolar.

◆ remove_data() [1/2]

virtual void Gtk::PLplot::Plot::remove_data ( PlotData plot_data_member)
virtual

Remove a single dataset from the plot

Parameters
plot_data_memberpointer to the plotdata in the plot_data vector
Exceptions
Gtk::PLplot::Exception

Reimplemented in Gtk::PLplot::Plot2D, and Gtk::PLplot::PlotPolar.

◆ remove_data() [2/2]

virtual void Gtk::PLplot::Plot::remove_data ( unsigned int  plot_data_index)
virtual

Remove a single dataset from the plot

Parameters
plot_data_indexindex of the plotdata in the plot_data vector
Exceptions
Gtk::PLplot::Exception

Reimplemented in Gtk::PLplot::Plot2D, and Gtk::PLplot::PlotPolar.

◆ remove_object() [1/2]

virtual void Gtk::PLplot::Plot::remove_object ( PlotObject plot_object_member)
virtual

Remove a single object from the plot

Parameters
plot_object_memberpointer to the plotobject in the plot_data vector
Exceptions
Gtk::PLplot::Exception

◆ remove_object() [2/2]

virtual void Gtk::PLplot::Plot::remove_object ( unsigned int  plot_object_index)
virtual

Remove a single object from the plot

Parameters
plot_object_indexindex of the plotobject in the plot_objects vector
Exceptions
Gtk::PLplot::Exception

◆ set_axes_color()

void Gtk::PLplot::Plot::set_axes_color ( Gdk::RGBA  color)

Set the color to draw the axes, the box and gridlines

Parameters
colorSet a new axes color.

◆ set_axis_title_x()

void Gtk::PLplot::Plot::set_axis_title_x ( Glib::ustring  title)

Set the X-axis title

Parameters
titlethe new X-axis title

◆ set_axis_title_y()

void Gtk::PLplot::Plot::set_axis_title_y ( Glib::ustring  title)

Set the Y-axis title

Parameters
titlethe new Y-axis title

◆ set_background_color()

void Gtk::PLplot::Plot::set_background_color ( Gdk::RGBA  color)

Set the background color

Parameters
colorSet a new plot background color.

◆ set_plot_title()

void Gtk::PLplot::Plot::set_plot_title ( Glib::ustring  title)

Set the plot title

Parameters
titlethe new plot title (may be an empty string)

◆ set_titles_color()

void Gtk::PLplot::Plot::set_titles_color ( Gdk::RGBA  color)

Set the color to draw the plot and axes titles

Parameters
colorSet a new titles color.

◆ show()

void Gtk::PLplot::Plot::show ( )

Make the plot visible on the canvas

◆ signal_changed()

sigc::signal< void(void)> Gtk::PLplot::Plot::signal_changed ( )
inline

signal_changed is emitted whenever any of the plot properties or any of the dataset properties has changed.

See default handler on_changed()

◆ signal_data_added()

sigc::signal< void(PlotData *)> Gtk::PLplot::Plot::signal_data_added ( )
inline

signal_data_added is emitted whenever a new dataset is added to the plot

See default handler on_data_added()

◆ signal_data_removed()

sigc::signal< void(PlotData *)> Gtk::PLplot::Plot::signal_data_removed ( )
inline

signal_data_removed is emitted whenever a dataset is removed from the plot

See default handler on_data_removed()

◆ signal_object_added()

sigc::signal< void(PlotObject *)> Gtk::PLplot::Plot::signal_object_added ( )
inline

signal_object_added is emitted whenever a new object is added to the plot

See default handler on_object_added()

◆ signal_object_removed()

sigc::signal< void(PlotObject *)> Gtk::PLplot::Plot::signal_object_removed ( )
inline

signal_object_removed is emitted whenever an object is removed from the plot

See default handler on_object_removed()

Friends And Related Symbol Documentation

◆ Canvas

friend class Canvas
friend

◆ RegionSelection

friend class RegionSelection
friend

Member Data Documentation

◆ _signal_changed

sigc::signal<void(void)> Gtk::PLplot::Plot::_signal_changed
protected

signal that gets emitted whenever any of the plot parameters, or any of the contained PlotData datasets is changed.

◆ _signal_data_added

sigc::signal<void(PlotData *)> Gtk::PLplot::Plot::_signal_data_added
protected

signal emitted whenever a PlotData dataset is added to the plot

◆ _signal_data_removed

sigc::signal<void(PlotData *)> Gtk::PLplot::Plot::_signal_data_removed
protected

signal emitted whenever data is removed from the plot.

◆ _signal_object_added

sigc::signal<void(PlotObject *)> Gtk::PLplot::Plot::_signal_object_added
protected

signal emitted whenever a PlotObject is added to the plot

◆ _signal_object_removed

sigc::signal<void(PlotObject *)> Gtk::PLplot::Plot::_signal_object_removed
protected

signal emitted whenever a PlotObject is removed from the plot.

◆ axes_color

Gdk::RGBA Gtk::PLplot::Plot::axes_color
protected

the currently used color to draw the axes, the box and gridlines. Default is opaque black

◆ axis_title_x

Glib::ustring Gtk::PLplot::Plot::axis_title_x
protected

X-axis title.

◆ axis_title_y

Glib::ustring Gtk::PLplot::Plot::axis_title_y
protected

Y-axis title.

◆ background_color

Gdk::RGBA Gtk::PLplot::Plot::background_color
protected

the currently used background color of the plot (default = fully transparent white, meaning that the background will be determined by the canvas)

◆ canvas_height

int Gtk::PLplot::Plot::canvas_height
protected

the height of the canvas in Cairo units

◆ canvas_width

int Gtk::PLplot::Plot::canvas_width
protected

the width of the canvas in Cairo units

◆ plot_data

std::vector<PlotData *> Gtk::PLplot::Plot::plot_data
protected

vector that contains pointers to the PlotData datasets

◆ plot_height

int Gtk::PLplot::Plot::plot_height
protected

the current height of the plot in Cairo units

◆ plot_height_norm

const double Gtk::PLplot::Plot::plot_height_norm
protected

the normalized plot height, calculated relative to the canvas height

◆ plot_objects

std::vector<PlotObject *> Gtk::PLplot::Plot::plot_objects
protected

vector that contains pointers to the PlotObject datasets

◆ plot_offset_horizontal_norm

const double Gtk::PLplot::Plot::plot_offset_horizontal_norm
protected

the normalized horizontal offset from the canvas top left corner, calculated relative to the canvas width

◆ plot_offset_vertical_norm

const double Gtk::PLplot::Plot::plot_offset_vertical_norm
protected

the normalized vertical offset from the canvas top left corner, calculated relative to the canvas height

◆ plot_offset_x

int Gtk::PLplot::Plot::plot_offset_x
protected

the offset of the plot with respect to the top left corner of the canvas, measured along the horizontal (X-) axis in Cairo units

◆ plot_offset_y

int Gtk::PLplot::Plot::plot_offset_y
protected

the offset of the plot with respect to the top left corner of the canvas, measured along the vertical (Y-) axis in Cairo units

◆ plot_title

Glib::ustring Gtk::PLplot::Plot::plot_title
protected

Plot title.

◆ plot_width

int Gtk::PLplot::Plot::plot_width
protected

the current width of the plot in Cairo units

◆ plot_width_norm

const double Gtk::PLplot::Plot::plot_width_norm
protected

the normalized plot width, calculated relative to the canvas width

◆ pls

plstream* Gtk::PLplot::Plot::pls
protected

the plstream object that will ensure the connection with PLplot

◆ shown

bool Gtk::PLplot::Plot::shown
protected

true means the plot is currently visible, false means it is not plotted

◆ titles_color

Gdk::RGBA Gtk::PLplot::Plot::titles_color
protected

the currently used color to draw the axes and plot titles. Default is opaque black