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

ruler.hpp

Go to the documentation of this file.
00001 
00005 /* Copyright (c) 2005-2009 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 RULER_HPP
00044 #define RULER_HPP 1
00045 
00046 
00047 #include <cairo.h>
00048 #include <vector>
00049 #include <string>
00050 #include <stdio.h>
00051 #include <iostream>
00052 #include "color.hpp"
00053 #include "label.hpp"
00054 #include "coordmapper.hpp"
00055 
00056 
00062 class Ruler {
00063 
00066     struct Tic {
00067         double               _x;            
00068         Label                _label;        
00072         Tic( double x, const std::string &label ) : _x(x), _label(label) {}
00073     };
00074 
00075     Color                    _color;        
00076     double                   _ticlen_in;    
00077     double                   _ticlen_out;   
00078     double                   _labelspace;   
00080     double                   _range[2];     
00081     bool                     _autorange[2]; 
00083     double                   _endpt[4];     
00085     double                   _fontsize;     
00086     Label                    _axislabel;    
00088     bool                     _label_enabled;
00089     bool                     _indir;        
00090     std::vector<Tic>         _tic;          
00092     int                      _cind;         
00095     static bool tic_labels_bbox_crash_x( const double bbox[4], const double obbox[4] );
00096     static bool tic_labels_bbox_crash_y( const double bbox[4], const double obbox[4] );
00097     bool add_tic( double x, cairo_t *cairo, const Coordmapper1D &cm, 
00098                   bool ruler_tic_bbox_test, double &maxsize, double obbox[4] );
00099 
00100 public:
00101 
00104     Ruler();
00105 
00108     Ruler( int cind );
00109 
00112     Ruler( const Ruler &ruler );
00113 
00116     Ruler &operator=( const Ruler &ruler );
00117 
00120     ~Ruler() {}
00121 
00124     void copy_tics( const Ruler &ruler );
00125 
00128     void set_font_size( double size );
00129 
00132     void set_color( const Color &color );
00133 
00136     void set_ticlen( double inlen, double outlen );
00137 
00140     void set_autorange( bool autorange_min, bool autorange_max );
00141 
00144     void get_autorange( bool &autorange_min, bool &autorange_max ) const;
00145 
00153     void set_ranges( double min, double max );
00154 
00159     void get_ranges( double &min, double &max ) const;
00160 
00163     void set_endpoints( double x1, double y1, double x2, double y2 );
00164 
00167     void set_axis_label( const std::string &label );
00168 
00171     void enable_labels( bool enable );
00172 
00177     void set_coord_index( int cind );
00178 
00181     void set_indir( bool ccw );
00182 
00189     void calculate( cairo_t *cairo, Coordmapper1D &cm, bool ruler_tic_bbox_test );
00190 
00197     void draw( cairo_t *cairo, Coordmapper1D &cm, bool recalculate = true );
00198 
00205     void get_bbox( cairo_t *cairo, double bbox[4], Coordmapper1D &cm, bool recalculate = true );
00206 
00209     void debug_print( std::ostream &os ) const ;
00210 };
00211 
00212 
00213 #endif
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 


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