#include <frame.hpp>
Public Member Functions | |
Frame () | |
Default constructor. | |
~Frame () | |
Destructor. | |
void | set_geometry (int width, int height, int offx, int offy) |
Set size of plot. | |
void | set_font_size (double size) |
Set font size used for tics and labels. | |
double | get_font_size (void) |
Get font size used for tics and labels. | |
void | set_background (Color &bg) |
Set background color. | |
void | set_foreground (Color &fg) |
Set foreground color. | |
Coordmapper | get_coordmapper (PlotAxis xaxis, PlotAxis yaxis) const |
Get a 2d coordinate mapper for selected axes. | |
void | get_margins (double margin[4]) const |
Get margins. | |
void | get_frame_edges (double edge[4]) const |
Get frame edge locations. | |
void | set_title (const std::string &title) |
Set title for plot. | |
void | set_axis_label (PlotAxis axis, const std::string &label) |
Set axis label. | |
void | force_enable_ruler (PlotAxis axis, bool force) |
Force enable ruler for axis. | |
void | ruler_autorange_enable (PlotAxis axis, bool min, bool max) |
Enable/disable ruler autorange. | |
void | set_ranges (PlotAxis axis, double min, double max) |
Set coordinate ranges for axis. | |
void | get_ranges (PlotAxis axis, double &min, double &max) const |
Get coordinate ranges for axis. | |
void | set_fixed_aspect (PlotFixedMode mode) |
Set fixed aspect ratio mode. | |
void | set_automargin (bool enable) |
Set automatic margin setting on or off. | |
void | add_graph (PlotAxis xaxis, PlotAxis yaxis, Graph *drawable) |
Add graph to frame. | |
void | clear_graphs (void) |
Clear all graphs from frame. | |
void | draw (cairo_t *cairo) |
Draw frame and plot contents. | |
Classes | |
struct | DObj |
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 and removed into the plot.
Ruler autorange is different from frame/graph autorange:
Frame::Frame | ( | ) |
Default constructor.
Frame::~Frame | ( | ) | [inline] |
Destructor.
Add graph to frame.
A pointer to the graph is added to frame. The graph is not freed by frame.
void Frame::clear_graphs | ( | void | ) |
Clear all graphs from frame.
The list of graphs is cleared. The graphs are not freed, only the references to the graphs 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.
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_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.