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 | Friends | List of all members
Gtk::PLplot::Plot3D Class Reference

a class for three-dimensional plots More...

#include <gtkmm-plplot/plot3d.h>

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

Public Member Functions

 Plot3D (PlotData3D &data, const Glib::ustring &axis_title_x="X-axis", const Glib::ustring &axis_title_y="Y-axis", const Glib::ustring &axis_title_z="Z-axis", const Glib::ustring &plot_title="", const double plot_width_norm=1.0, const double plot_height_norm=1.0, const double plot_offset_horizontal_norm=0.0, const double plot_offset_vertical_norm=0.0)
 
virtual ~Plot3D ()
 
void set_altitude (double altitude)
 
double get_altitude ()
 
void set_azimuth (double azimuth)
 
double get_azimuth ()
 
virtual void add_data (PlotData3D &data)
 
virtual void draw_plot (const Cairo::RefPtr< Cairo::Context > &cr, const int width, const int height) override
 
- Public Member Functions inherited from Gtk::PLplot::Plot
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
 
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 ()
 
- Public Member Functions inherited from Gtk::PLplot::Legend
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

virtual void plot_data_modified () override
 a method that will update the _range variables when datasets are added, modified or removed.
 
 Plot3D (const Glib::ustring &axis_title_x, const Glib::ustring &axis_title_y, const Glib::ustring &axis_title_z, 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::Plot
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 Member Functions inherited from Gtk::PLplot::Legend
 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

 Plot3D ()=delete
 no default constructor
 
 Plot3D (const Plot3D &)=delete
 no default copy constructor
 
Plot3Doperator= (const Plot3D &)=delete
 no assignment operator
 

Private Attributes

Glib::ustring axis_title_z
 Z-axis title.
 
double plotted_range_x [2]
 the current range shown on the plot for the X-axis
 
double plotted_range_y [2]
 the current range shown on the plot for the Y-axis
 
double plotted_range_z [2]
 the current range shown on the plot for the Z-axis
 
double plot_data_range_x [2]
 the maximum range covered by the X-values of the datasets
 
double plot_data_range_y [2]
 the maximum range covered by the Y-values of the datasets
 
double plot_data_range_z [2]
 the maximum range covered by the Z-values of the datasets
 
double altitude
 the viewing altitude
 
double azimuth
 the viewing azimuth
 

Friends

class Canvas
 

Additional Inherited Members

- Protected Attributes inherited from Gtk::PLplot::Plot
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.
 

Detailed Description

a class for three-dimensional plots

A class for conventional three-dimensional plots. Construction requires one PlotData3D dataset, meaning it is not possible to generate an empty plot. Afterwards, other datasets may be added using the add_data() method. Several properties may be set such as the axes and plot titles. Important is that whenever a property is changed, signal_changed() is emitted, which will eventually be picked up by the canvas that will hold the plot. For more information, the reader is referred to the examples Example 9: a Three-dimensional plot.

Constructor & Destructor Documentation

◆ Plot3D() [1/4]

Gtk::PLplot::Plot3D::Plot3D ( )
privatedelete

no default constructor

◆ Plot3D() [2/4]

Gtk::PLplot::Plot3D::Plot3D ( const Plot3D )
privatedelete

no default copy constructor

◆ Plot3D() [3/4]

Gtk::PLplot::Plot3D::Plot3D ( const Glib::ustring &  axis_title_x,
const Glib::ustring &  axis_title_y,
const Glib::ustring &  axis_title_z,
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 protected constructor is meant to be used in derived classes only to circumvent the problem of calling add_data() in a constructor which calls Plot3D's public constructor.

Parameters
axis_title_xX-axis title
axis_title_yY-axis title
axis_title_zZ-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

◆ Plot3D() [4/4]

Gtk::PLplot::Plot3D::Plot3D ( PlotData3D data,
const Glib::ustring &  axis_title_x = "X-axis",
const Glib::ustring &  axis_title_y = "Y-axis",
const Glib::ustring &  axis_title_z = "Z-axis",
const Glib::ustring &  plot_title = "",
const double  plot_width_norm = 1.0,
const double  plot_height_norm = 1.0,
const double  plot_offset_horizontal_norm = 0.0,
const double  plot_offset_vertical_norm = 0.0 
)

Constructor

This class provides a single public constructor, which takes an existing PlotData3D 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 c

Parameters
dataa PlotData3D object containing a plot dataset
axis_title_xX-axis title
axis_title_yY-axis title
axis_title_zZ-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

◆ ~Plot3D()

virtual Gtk::PLplot::Plot3D::~Plot3D ( )
virtual

Destructor

Member Function Documentation

◆ add_data()

virtual void Gtk::PLplot::Plot3D::add_data ( PlotData3D data)
virtual

Add a single PlotData3D dataset to the plot

The dataset must be a PlotData3D instance: this will be verified and an exception will be thrown if the type is incorrect.

Parameters
datadataset to be added to the plot
Returns
a pointer to the PlotData3D in the plot_data vector.
Exceptions
Gtk::PLplot::Exception

◆ draw_plot()

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

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

Implements Gtk::PLplot::Plot.

◆ get_altitude()

double Gtk::PLplot::Plot3D::get_altitude ( )

Get the current viewing altitude in degrees above the XY plane

Returns
the current viewing altitude

◆ get_azimuth()

double Gtk::PLplot::Plot3D::get_azimuth ( )

Get the current viewing azimuth in degrees

When the azimuth is zero, the observer is looking face onto the ZX plane, and as azimuth is increased, the observer moves clockwise around the box when viewed from above the XY plane.

Returns
the current viewing azimuth

◆ operator=()

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

no assignment operator

◆ plot_data_modified()

virtual void Gtk::PLplot::Plot3D::plot_data_modified ( )
overrideprotectedvirtual

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

Implements Gtk::PLplot::Plot.

◆ set_altitude()

void Gtk::PLplot::Plot3D::set_altitude ( double  altitude)

Set the viewing altitude in degrees above the XY plane

Parameters
altitudethe new viewing altitude

◆ set_azimuth()

void Gtk::PLplot::Plot3D::set_azimuth ( double  azimuth)

Set the viewing azimuth in degrees

When the azimuth is zero, the observer is looking face onto the ZX plane, and as azimuth is increased, the observer moves clockwise around the box when viewed from above the XY plane.

Parameters
azimuththe new viewing azimuth

Friends And Related Symbol Documentation

◆ Canvas

friend class Canvas
friend

Member Data Documentation

◆ altitude

double Gtk::PLplot::Plot3D::altitude
private

the viewing altitude

◆ axis_title_z

Glib::ustring Gtk::PLplot::Plot3D::axis_title_z
private

Z-axis title.

◆ azimuth

double Gtk::PLplot::Plot3D::azimuth
private

the viewing azimuth

◆ plot_data_range_x

double Gtk::PLplot::Plot3D::plot_data_range_x[2]
private

the maximum range covered by the X-values of the datasets

◆ plot_data_range_y

double Gtk::PLplot::Plot3D::plot_data_range_y[2]
private

the maximum range covered by the Y-values of the datasets

◆ plot_data_range_z

double Gtk::PLplot::Plot3D::plot_data_range_z[2]
private

the maximum range covered by the Z-values of the datasets

◆ plotted_range_x

double Gtk::PLplot::Plot3D::plotted_range_x[2]
private

the current range shown on the plot for the X-axis

◆ plotted_range_y

double Gtk::PLplot::Plot3D::plotted_range_y[2]
private

the current range shown on the plot for the Y-axis

◆ plotted_range_z

double Gtk::PLplot::Plot3D::plotted_range_z[2]
private

the current range shown on the plot for the Z-axis