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 *_datagraph; 00106 XYGraph *_ellipse; 00107 bool _ellipse_enable; 00108 00109 Colormap *_colormap; 00110 std::vector<double> _zdata; 00111 00112 size_t _histogram_n; 00113 size_t _histogram_m; 00114 histogram_accumulation_e _histogram_accumulation; 00115 bool _histogram_style; 00116 interpolation_e _interpolation; 00117 double _dot_size; 00118 00119 void build_data( void ); 00120 void merge_bbox( double bbox[4], const double bb[4] ); 00121 00122 public: 00123 00132 ParticleDiagPlot( Frame &frame, const Geometry &geom, const ParticleDataBase &pdb, 00133 coordinate_axis_e axis, double level, 00134 particle_diag_plot_type_e type, 00135 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy = DIAG_NONE ); 00136 00146 ParticleDiagPlot( Frame &frame, const Geometry &geom, const ParticleDataBase &pdb, 00147 const Vec3D &c, const Vec3D &o, const Vec3D &p, 00148 particle_diag_plot_type_e type, 00149 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy = DIAG_NONE ); 00150 00153 ~ParticleDiagPlot(); 00154 00157 void set_emittance_ellipse( bool enable ) { 00158 _ellipse_enable = enable; 00159 } 00160 00163 bool get_emittance_ellipse( void ) { 00164 return( _ellipse_enable ); 00165 } 00166 00169 void set_view( coordinate_axis_e axis, double level ) { 00170 _update = true; 00171 _axis = axis; 00172 _level = level; 00173 } 00174 00177 void get_view( coordinate_axis_e &axis, double &level ) { 00178 axis = _axis; 00179 level = _level; 00180 } 00181 00184 void set_type( particle_diag_plot_type_e type ) { 00185 _update = true; 00186 _type = type; 00187 } 00188 00191 particle_diag_plot_type_e get_type( void ) { 00192 return( _type ); 00193 } 00194 00197 void set_plot( particle_diag_plot_type_e type, 00198 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy ) { 00199 _update = true; 00200 _type = type; 00201 _diagx = diagx; 00202 _diagy = diagy; 00203 } 00204 00207 void get_plot( particle_diag_plot_type_e &type, 00208 trajectory_diagnostic_e &diagx, trajectory_diagnostic_e &diagy ) { 00209 type = _type; 00210 diagx = _diagx; 00211 diagy = _diagy; 00212 } 00213 00216 void set_histogram_n( size_t n ) { 00217 _update = true; 00218 _histogram_n = n; 00219 } 00220 00223 size_t get_histogram_n( void ) { 00224 return( _histogram_n ); 00225 } 00226 00229 void set_histogram_m( size_t m ) { 00230 _update = true; 00231 _histogram_m = m; 00232 } 00233 00236 size_t get_histogram_m( void ) { 00237 return( _histogram_m ); 00238 } 00239 00242 void set_histogram_accumulation( histogram_accumulation_e accumulation ) { 00243 _update = true; 00244 _histogram_accumulation = accumulation; 00245 } 00246 00249 histogram_accumulation_e get_histogram_accumulation( void ) { 00250 return( _histogram_accumulation ); 00251 } 00252 00255 void set_histogram_style( bool style ) { 00256 _histogram_style = style; 00257 } 00258 00261 bool get_histogram_style( void ) { 00262 return( _histogram_style ); 00263 } 00264 00267 void set_colormap_interpolation( interpolation_e interpolation ) { 00268 _interpolation = interpolation; 00269 if( _colormap ) 00270 _colormap->set_interpolation( interpolation ); 00271 } 00272 00275 interpolation_e get_colormap_interpolation( void ) { 00276 return( _interpolation ); 00277 } 00278 00281 const Colormap *get_colormap( void ) const { 00282 return( _colormap ); 00283 } 00284 00287 void set_dot_size( double size ) { 00288 _dot_size = size; 00289 if( _datagraph ) 00290 _datagraph->set_point_style( XYGRAPH_POINT_CIRCLE, true, _dot_size ); 00291 } 00292 00295 double get_dot_size( void ) { 00296 return( _dot_size ); 00297 } 00298 00303 const Histogram *get_histogram( void ) { 00304 return( _histo ); 00305 } 00306 00309 const Emittance &calculate_emittance( void ); 00310 00318 void export_data( const std::string &filename ); 00319 00322 void build_plot( void ); 00323 }; 00324 00325 00326 #endif 00327