Classes | Public Member Functions | List of all members
Frame Class Reference

General purpose plotter frame for cairographics surfaces. More...

#include <frame.hpp>

Public Member Functions

 Frame ()
 Default constructor. More...
 
 ~Frame ()
 Destructor. More...
 
void set_geometry (int width, int height, int offx, int offy)
 Set size of plot. More...
 
void set_font_size (double size)
 Set font size used for tics and labels. More...
 
double get_font_size (void)
 Get font size used for tics and labels. More...
 
void set_background (Color &bg)
 Set background color. More...
 
void set_foreground (Color &fg)
 Set foreground color. More...
 
Coordmapper get_coordmapper (PlotAxis xaxis, PlotAxis yaxis) const
 Get a 2d coordinate mapper for selected axes. More...
 
void get_margins (double margin[4]) const
 Get margins. More...
 
void get_frame_edges (double edge[4]) const
 Get frame edge locations. More...
 
void set_title (const std::string &title)
 Set title for plot. More...
 
void set_axis_label (PlotAxis axis, const std::string &label)
 Set axis label. More...
 
void force_enable_ruler (PlotAxis axis, bool force)
 Force enable ruler for axis. More...
 
void ruler_autorange_enable (PlotAxis axis, bool min, bool max)
 Enable/disable ruler autorange. More...
 
void set_ranges (PlotAxis axis, double min, double max)
 Set coordinate ranges for axis. More...
 
void get_ranges (PlotAxis axis, double &min, double &max) const
 Get coordinate ranges for axis. More...
 
void set_fixed_aspect (PlotFixedMode mode)
 Set fixed aspect ratio mode. More...
 
void set_automargin (bool enable)
 Set automatic margin setting on or off. More...
 
void add_graph (PlotAxis xaxis, PlotAxis yaxis, Graph *graph, LegendEntry *legend=NULL)
 Add graph to frame. More...
 
void clear_graphs (void)
 Clear all graphs from frame. More...
 
void enable_legend (bool enable)
 Set legend enable/disable. More...
 
void set_legend_position (legend_position_e pos)
 Set legend position. More...
 
void draw (cairo_t *cairo)
 Draw frame and plot contents. More...
 

Detailed Description

General purpose plotter frame for cairographics surfaces.

Plotter frame provides a coordinate frame and simple linear independent coordinate transformations for axes from logical plot coordinates to canvas coordinates. Also the plotter can do numbered tics to the frame and labels for x- and y-axes. Frame x- and y-ranges can be set and coordinates can be forced to fixed aspect ratio. Content to the plot is drawn with Graph objects, which can be inserted into and removed from the plot.

Ruler autorange is different from frame/graph autorange:

Constructor & Destructor Documentation

Frame::Frame ( )

Default constructor.

Frame::~Frame ( )
inline

Destructor.

Member Function Documentation

void Frame::add_graph ( PlotAxis  xaxis,
PlotAxis  yaxis,
Graph graph,
LegendEntry legend = NULL 
)

Add graph to frame.

Add a graph to be plotted in the frame. The graph uses the axes xaxis and yaxis. A legend for the graph may be defined. Legend defaults to NULL (no legend). A pointers to graph and legend is added to frame. The graph/legend is not freed by frame.

void Frame::clear_graphs ( void  )

Clear all graphs from frame.

The list of graphs and legend entries is cleared. The graphs/legends are not freed, only the references are erased.

void Frame::draw ( cairo_t *  cairo)

Draw frame and plot contents.

The graphs inside the frame are asked for bounding boxes. The frame geometry is then calculated according to margin, size settings and the ranges. The coordinate transformation is initialized and the graphs are called to plot themselves.

The frame guarantees to call Graph::get_bbox() once and Graph::plot() once for each call to this function.

Graphs are plotted in the order of definition. Last definition is on the top.

void Frame::enable_legend ( bool  enable)

Set legend enable/disable.

void Frame::force_enable_ruler ( PlotAxis  axis,
bool  force 
)

Force enable ruler for axis.

Normally rulers for axes that are not referenced by graphs are not shown and mirrored tics from the other ruler are shown instead. Ruler enable is automatic by default.

Coordmapper Frame::get_coordmapper ( PlotAxis  xaxis,
PlotAxis  yaxis 
) const

Get a 2d coordinate mapper for selected axes.

The returned coordinate mapper is the last mapper used and built while drawing a plot.

double Frame::get_font_size ( void  )
inline

Get font size used for tics and labels.

void Frame::get_frame_edges ( double  edge[4]) const

Get frame edge locations.

Frame edge location coordinates are returned in order (left(x), top(y), right(x), bottom(y)).

void Frame::get_margins ( double  margin[4]) const

Get margins.

void Frame::get_ranges ( PlotAxis  axis,
double &  min,
double &  max 
) const

Get coordinate ranges for axis.

After draw() has been called, this function returns real ranges used.

void Frame::ruler_autorange_enable ( PlotAxis  axis,
bool  min,
bool  max 
)

Enable/disable ruler autorange.

Autoranging in rulers rounds up/down ("outwards") the ruler ranges to the next closest tic mark. Ruler autorange is enabled by default.

void Frame::set_automargin ( bool  enable)

Set automatic margin setting on or off.

When automargin is enabled the margins set by user are increased to fit in labels and tics. In other words the plot including all tics and labels are made to fit inside the area inside user set margins.

When automargin is disabled the plot window (plot frame) is drawn exactly at the plot size minus user set margins area.

Automargin is enabled by default.

void Frame::set_axis_label ( PlotAxis  axis,
const std::string &  label 
)

Set axis label.

void Frame::set_background ( Color bg)
inline

Set background color.

void Frame::set_fixed_aspect ( PlotFixedMode  mode)

Set fixed aspect ratio mode.

When fixed aspect ratio mode is enabled, the coordinates are guarateed to have fixed 1:1 aspect ratio. If extend is true, the ranges are adjusted for plot. The coordinate axis to be adjusted is chosen so that the image size is increased, never decreased. If extend is false, the ranges will stay fixed, but the margins of the plot are adjusted for correct aspect ratio.

Fixed aspect ratio mode is disabled by default.

void Frame::set_font_size ( double  size)

Set font size used for tics and labels.

void Frame::set_foreground ( Color fg)
inline

Set foreground color.

void Frame::set_geometry ( int  width,
int  height,
int  offx,
int  offy 
)
inline

Set size of plot.

Sets the size of the plot to width by height and offsets offx and offy. Inside this size are the user defined margins and possibly automatic margin and the plot area itself. See set_automargin() for more information.

void Frame::set_legend_position ( legend_position_e  pos)

Set legend position.

void Frame::set_ranges ( PlotAxis  axis,
double  min,
double  max 
)

Set coordinate ranges for axis.

Use plus or minus infinite for full autoranging according to graph bounding boxes. Use finite numbers for manual range setting.

void Frame::set_title ( const std::string &  title)

Set title for plot.


The documentation for this class was generated from the following file: