00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef FRAME_HPP
00044 #define FRAME_HPP 1
00045
00046
00047 #include <string>
00048 #include <vector>
00049 #include <cairo.h>
00050 #include "color.hpp"
00051 #include "ruler.hpp"
00052 #include "coordmapper.hpp"
00053 #include "graph.hpp"
00054
00055
00056
00057 enum PlotFixedMode {
00058 PLOT_FIXED_ASPECT_DISABLED = 0,
00059 PLOT_FIXED_ASPECT_EXTEND_RANGE,
00060 PLOT_FIXED_ASPECT_INCREASE_MARGIN
00061 };
00062
00063
00064 enum PlotAxis {
00065 PLOT_AXIS_X1 = 0,
00066 PLOT_AXIS_Y1,
00067 PLOT_AXIS_X2,
00068 PLOT_AXIS_Y2,
00069 PLOT_AXIS_Z
00070 };
00071
00072
00073
00090 class Frame {
00091
00092 struct DObj {
00093 PlotAxis _xaxis;
00094 PlotAxis _yaxis;
00095 Graph *_graph;
00097 DObj( PlotAxis xaxis, PlotAxis yaxis, Graph *graph )
00098 : _xaxis(xaxis), _yaxis(yaxis), _graph(graph) {}
00099 };
00100
00101 Ruler _ruler[4];
00102 Coordmapper1D _cm[4];
00103 bool _enable[4];
00104 bool _fenable[4];
00105 bool _autorange[8];
00107 int _offx;
00108 int _offy;
00110 int _width;
00111 int _height;
00113 double _fontsize;
00114 double _titlespace;
00115 Color _bg;
00116 Color _fg;
00118 std::vector<DObj> _dobj;
00120 Label _title;
00122 PlotFixedMode _fixedaspect;
00124 bool _automargin;
00125 double _tmargin[4];
00133 void calculate_autoranging( void );
00134 void calculate_ruler_autoenable( void );
00135 void calculate_rulers( cairo_t *cairo, bool ruler_tic_bbox_test );
00136 void calculate_frame( cairo_t *cairo );
00137 void draw_frame( cairo_t *cairo );
00138 void mirror_rulers( void );
00139 void set_frame_clipping( cairo_t *cairo );
00140 void unset_frame_clipping( cairo_t *cairo );
00141
00142 public:
00143
00146 Frame();
00147
00150 ~Frame() {}
00151
00159 void set_geometry( int width, int height, int offx, int offy ) {
00160 _width = width;
00161 _height = height;
00162 _offx = offx;
00163 _offy = offy;
00164 }
00165
00168 void set_font_size( double size );
00169
00172 double get_font_size( void ) {
00173 return( _fontsize );
00174 }
00175
00178 void set_background( Color &bg ) {
00179 _bg = bg;
00180 }
00181
00184 void set_foreground( Color &fg ) {
00185 _fg = fg;
00186 }
00187
00193 Coordmapper get_coordmapper( PlotAxis xaxis, PlotAxis yaxis ) const;
00194
00197 void get_margins( double margin[4] ) const;
00198
00204 void get_frame_edges( double edge[4] ) const;
00205
00208 void set_title( const std::string &title );
00209
00212 void set_axis_label( PlotAxis axis, const std::string &label );
00213
00220 void force_enable_ruler( PlotAxis axis, bool force );
00221
00228 void ruler_autorange_enable( PlotAxis axis, bool min, bool max );
00229
00236 void set_ranges( PlotAxis axis, double min, double max );
00237
00243 void get_ranges( PlotAxis axis, double &min, double &max ) const;
00244
00256 void set_fixed_aspect( PlotFixedMode mode );
00257
00270 void set_automargin( bool enable );
00271
00277 void add_graph( PlotAxis xaxis, PlotAxis yaxis, Graph *drawable );
00278
00284 void clear_graphs( void );
00285
00296 void draw( cairo_t *cairo );
00297 };
00298
00299
00300 #endif
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318