particlediagplot.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 PARTICLEDIAGPLOT_HPP 00044 #define PARTICLEDIAGPLOT_HPP 1 00045 00046 00047 #include "frame.hpp" 00048 #include "geometry.hpp" 00049 #include "particledatabase.hpp" 00050 #include "types.hpp" 00051 #include "histogram.hpp" 00052 #include "trajectorydiagnostics.hpp" 00053 00054 #include "xygraph.hpp" 00055 #include "colormap.hpp" 00056 00057 00058 00059 enum particle_diag_plot_type_e { 00060 PARTICLE_DIAG_PLOT_NONE = 0, 00061 PARTICLE_DIAG_PLOT_SCATTER, 00062 PARTICLE_DIAG_PLOT_HISTO2D, 00063 PARTICLE_DIAG_PLOT_HISTO1D 00064 }; 00065 00066 00078 class ParticleDiagPlot { 00079 00080 Frame *_frame; 00081 00082 const Geometry *_geom; 00083 const ParticleDataBase *_pdb; 00084 00085 bool _free_plane; 00086 00087 coordinate_axis_e _axis; 00088 double _level; 00089 00090 Vec3D _c; 00091 Vec3D _o; 00092 Vec3D _p; 00093 00094 particle_diag_plot_type_e _type; 00095 trajectory_diagnostic_e _diagx; 00096 trajectory_diagnostic_e _diagy; 00097 trajectory_diagnostic_e _diagz; 00098 00099 int _pdb_it_no; 00100 bool _update; 00101 TrajectoryDiagnosticData *_tdata; 00102 Histogram *_histo; 00103 Emittance *_emit; 00105 XYGraph *_scatter; 00106 00107 XYGraph *_ellipse; 00108 bool _ellipse_enable; 00109 00110 Colormap *_colormap; 00111 std::vector<double> _zdata; 00112 00113 XYGraph *_profile; 00114 00115 size_t _histogram_n; 00116 size_t _histogram_m; 00117 interpolation_e _interpolation; 00118 double _dot_size; 00119 00120 void build_data( void ); 00121 void merge_bbox( double bbox[4], const double bb[4] ); 00122 00123 public: 00124 00133 ParticleDiagPlot( Frame *frame, const Geometry *geom, const ParticleDataBase *pdb, 00134 coordinate_axis_e axis, double level, 00135 particle_diag_plot_type_e type, 00136 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy = DIAG_NONE ); 00137 00147 ParticleDiagPlot( Frame *frame, const Geometry *geom, const ParticleDataBase *pdb, 00148 const Vec3D &c, const Vec3D &o, const Vec3D &p, 00149 particle_diag_plot_type_e type, 00150 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy = DIAG_NONE ); 00151 00154 ~ParticleDiagPlot(); 00155 00158 void set_emittance_ellipse( bool enable ) { 00159 _ellipse_enable = enable; 00160 } 00161 00164 bool get_emittance_ellipse( void ) { 00165 return( _ellipse_enable ); 00166 } 00167 00170 void set_view( coordinate_axis_e axis, double level ) { 00171 _update = true; 00172 _axis = axis; 00173 _level = level; 00174 } 00175 00178 void get_view( coordinate_axis_e &axis, double &level ) { 00179 axis = _axis; 00180 level = _level; 00181 } 00182 00185 void set_type( particle_diag_plot_type_e type ) { 00186 _update = true; 00187 _type = type; 00188 } 00189 00192 particle_diag_plot_type_e get_type( void ) { 00193 return( _type ); 00194 } 00195 00198 void set_plot( particle_diag_plot_type_e type, 00199 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy ) { 00200 _update = true; 00201 _type = type; 00202 _diagx = diagx; 00203 _diagy = diagy; 00204 } 00205 00208 void get_plot( particle_diag_plot_type_e &type, 00209 trajectory_diagnostic_e &diagx, trajectory_diagnostic_e &diagy ) { 00210 type = _type; 00211 diagx = _diagx; 00212 diagy = _diagy; 00213 } 00214 00217 void set_histogram_n( size_t n ) { 00218 _update = true; 00219 _histogram_n = n; 00220 } 00221 00224 size_t get_histogram_n( void ) { 00225 return( _histogram_n ); 00226 } 00227 00230 void set_histogram_m( size_t m ) { 00231 _update = true; 00232 _histogram_m = m; 00233 } 00234 00237 size_t get_histogram_m( void ) { 00238 return( _histogram_m ); 00239 } 00240 00243 void set_colormap_interpolation( interpolation_e interpolation ) { 00244 _interpolation = interpolation; 00245 if( _colormap ) 00246 _colormap->set_interpolation( interpolation ); 00247 } 00248 00251 interpolation_e get_colormap_interpolation( void ) { 00252 return( _interpolation ); 00253 } 00254 00257 const Colormap *get_colormap( void ) const { 00258 return( _colormap ); 00259 } 00260 00263 void set_dot_size( double size ) { 00264 _dot_size = size; 00265 if( _scatter ) 00266 _scatter->set_point_style( XYGRAPH_POINT_CIRCLE, true, _dot_size ); 00267 } 00268 00271 double get_dot_size( void ) { 00272 return( _dot_size ); 00273 } 00274 00279 const Histogram *get_histogram( void ) { 00280 return( _histo ); 00281 } 00282 00285 const Emittance &calculate_emittance( void ); 00286 00294 void export_data( const std::string &filename ); 00295 00298 void build_plot( void ); 00299 }; 00300 00301 00302 #endif