Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.4
   Version 1.0.4dev
      Class Index
      File List
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads

frame.hpp

Go to the documentation of this file.
00001 
00005 /* Copyright (c) 2005-2011 Taneli Kalvas. All rights reserved.
00006  *
00007  * You can redistribute this software and/or modify it under the terms
00008  * of the GNU General Public License as published by the Free Software
00009  * Foundation; either version 2 of the License, or (at your option)
00010  * any later version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this library (file "COPYING" included in the package);
00019  * if not, write to the Free Software Foundation, Inc., 51 Franklin
00020  * Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  * 
00022  * If you have questions about your rights to use or distribute this
00023  * software, please contact Berkeley Lab's Technology Transfer
00024  * Department at TTD@lbl.gov. Other questions, comments and bug
00025  * reports should be sent directly to the author via email at
00026  * taneli.kalvas@jyu.fi.
00027  * 
00028  * NOTICE. This software was developed under partial funding from the
00029  * U.S.  Department of Energy.  As such, the U.S. Government has been
00030  * granted for itself and others acting on its behalf a paid-up,
00031  * nonexclusive, irrevocable, worldwide license in the Software to
00032  * reproduce, prepare derivative works, and perform publicly and
00033  * display publicly.  Beginning five (5) years after the date
00034  * permission to assert copyright is obtained from the U.S. Department
00035  * of Energy, and subject to any subsequent five (5) year renewals,
00036  * the U.S. Government is granted for itself and others acting on its
00037  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
00038  * the Software to reproduce, prepare derivative works, distribute
00039  * copies to the public, perform publicly and display publicly, and to
00040  * permit others to do so.
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 
00066 enum PlotFixedMode {
00067     PLOT_FIXED_ASPECT_DISABLED = 0,
00068     PLOT_FIXED_ASPECT_EXTEND_RANGE,
00069     PLOT_FIXED_ASPECT_INCREASE_MARGIN
00070 };
00071 
00072 
00080 enum PlotAxis {
00081     PLOT_AXIS_X1 = 0,
00082     PLOT_AXIS_Y1,
00083     PLOT_AXIS_X2,
00084     PLOT_AXIS_Y2,
00085     PLOT_AXIS_Z
00086 };
00087 
00088 
00089 
00106 class Frame {
00107 
00110     struct DObj {
00111         PlotAxis        _xaxis;         
00112         PlotAxis        _yaxis;         
00113         Graph          *_graph;         
00115         DObj( PlotAxis xaxis, PlotAxis yaxis, Graph *graph )
00116             : _xaxis(xaxis), _yaxis(yaxis), _graph(graph) {}
00117     };
00118 
00119     Ruler               _ruler[4];      
00120     Coordmapper1D       _cm[4];         
00121     bool                _enable[4];     
00122     bool                _fenable[4];    
00123     bool                _autorange[8];  
00125     int                 _offx;          
00126     int                 _offy;          
00128     int                 _width;         
00129     int                 _height;        
00131     double              _fontsize;      
00132     double              _titlespace;    
00133     Color               _bg;            
00134     Color               _fg;            
00136     std::vector<DObj>   _dobj;          
00138     Label               _title;         
00140     PlotFixedMode       _fixedaspect;   
00142     bool                _automargin;    
00143     double              _tmargin[4];    
00151     void calculate_autoranging( void );
00152     void calculate_ruler_autoenable( void );
00153     void calculate_rulers( cairo_t *cairo, bool ruler_tic_bbox_test );
00154     void calculate_frame( cairo_t *cairo );
00155     void draw_frame( cairo_t *cairo );
00156     void mirror_rulers( void );
00157     void set_frame_clipping( cairo_t *cairo );
00158     void unset_frame_clipping( cairo_t *cairo );
00159 
00160 public:
00161 
00164     Frame();
00165 
00168     ~Frame() {}
00169 
00177     void set_geometry( int width, int height, int offx, int offy ) {
00178         _width = width;
00179         _height = height;
00180         _offx = offx;
00181         _offy = offy;
00182     }
00183 
00186     void set_font_size( double size );
00187 
00190     double get_font_size( void ) {
00191         return( _fontsize );
00192     }
00193 
00196     void set_background( Color &bg ) {
00197         _bg = bg;
00198     }    
00199 
00202     void set_foreground( Color &fg ) {
00203         _fg = fg;
00204     }
00205 
00211     Coordmapper get_coordmapper( PlotAxis xaxis, PlotAxis yaxis ) const;
00212 
00215     void get_margins( double margin[4] ) const;
00216 
00222     void get_frame_edges( double edge[4] ) const;
00223 
00226     void set_title( const std::string &title );
00227 
00230     void set_axis_label( PlotAxis axis, const std::string &label );
00231 
00238     void force_enable_ruler( PlotAxis axis, bool force );
00239 
00246     void ruler_autorange_enable( PlotAxis axis, bool min, bool max );
00247 
00254     void set_ranges( PlotAxis axis, double min, double max );
00255 
00261     void get_ranges( PlotAxis axis, double &min, double &max ) const;
00262         
00274     void set_fixed_aspect( PlotFixedMode mode );
00275 
00288     void set_automargin( bool enable );
00289 
00295     void add_graph( PlotAxis xaxis, PlotAxis yaxis, Graph *drawable );
00296 
00302     void clear_graphs( void );
00303 
00314     void draw( cairo_t *cairo );
00315 };
00316 
00317 
00318 #endif


Reference manual for Ion Beam Simulator 1.0.4dev
Generated by Doxygen 1.7.1 on Wed May 18 2011 23:03:47.