IBSimu 1.0.4
|
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 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 coordinate_axis_e _axis; 00086 double _level; 00087 00088 particle_diag_plot_type_e _type; 00089 trajectory_diagnostic_e _diagx; 00090 trajectory_diagnostic_e _diagy; 00091 trajectory_diagnostic_e _diagz; 00092 00093 int _pdb_it_no; 00094 bool _update; 00095 TrajectoryDiagnosticData *_tdata; 00096 Histogram *_histo; 00097 Emittance *_emit; 00099 XYGraph *_scatter; 00100 00101 XYGraph *_ellipse; 00102 bool _ellipse_enable; 00103 00104 Colormap *_colormap; 00105 std::vector<double> _zdata; 00106 00107 XYGraph *_profile; 00108 00109 size_t _histogram_n; 00110 size_t _histogram_m; 00111 interpolation_e _interpolation; 00112 double _dot_size; 00113 00114 void build_data( void ); 00115 void merge_bbox( double bbox[4], const double bb[4] ); 00116 00117 public: 00118 00119 ParticleDiagPlot( Frame *frame, const Geometry *geom, const ParticleDataBase *pdb, 00120 coordinate_axis_e axis, double level, 00121 particle_diag_plot_type_e type, 00122 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy = DIAG_NONE ); 00123 00124 ~ParticleDiagPlot(); 00125 00126 void set_emittance_ellipse( bool enable ) { 00127 _ellipse_enable = enable; 00128 } 00129 00130 bool get_emittance_ellipse( void ) { 00131 return( _ellipse_enable ); 00132 } 00133 00134 void set_view( coordinate_axis_e axis, double level ) { 00135 _update = true; 00136 _axis = axis; 00137 _level = level; 00138 } 00139 00140 void get_view( coordinate_axis_e &axis, double &level ) { 00141 axis = _axis; 00142 level = _level; 00143 } 00144 00145 void set_type( particle_diag_plot_type_e type ) { 00146 _update = true; 00147 _type = type; 00148 } 00149 00150 particle_diag_plot_type_e get_type( void ) { 00151 return( _type ); 00152 } 00153 00154 void set_plot( particle_diag_plot_type_e type, 00155 trajectory_diagnostic_e diagx, trajectory_diagnostic_e diagy ) { 00156 _update = true; 00157 _type = type; 00158 _diagx = diagx; 00159 _diagy = diagy; 00160 } 00161 00162 void get_plot( particle_diag_plot_type_e &type, 00163 trajectory_diagnostic_e &diagx, trajectory_diagnostic_e &diagy ) { 00164 type = _type; 00165 diagx = _diagx; 00166 diagy = _diagy; 00167 } 00168 00169 void set_histogram_n( size_t n ) { 00170 _update = true; 00171 _histogram_n = n; 00172 } 00173 00174 size_t get_histogram_n( void ) { 00175 return( _histogram_n ); 00176 } 00177 00178 void set_histogram_m( size_t m ) { 00179 _update = true; 00180 _histogram_m = m; 00181 } 00182 00183 size_t get_histogram_m( void ) { 00184 return( _histogram_m ); 00185 } 00186 00187 void set_colormap_interpolation( interpolation_e interpolation ) { 00188 _interpolation = interpolation; 00189 if( _colormap ) 00190 _colormap->set_interpolation( interpolation ); 00191 } 00192 00193 interpolation_e get_colormap_interpolation( void ) { 00194 return( _interpolation ); 00195 } 00196 00197 const Colormap *get_colormap( void ) const { 00198 return( _colormap ); 00199 } 00200 00201 void set_dot_size( double size ) { 00202 _dot_size = size; 00203 if( _scatter ) 00204 _scatter->set_point_style( XYGRAPH_POINT_CIRCLE, true, _dot_size ); 00205 } 00206 00207 double get_dot_size( void ) { 00208 return( _dot_size ); 00209 } 00210 00215 const Histogram *get_histogram( void ) { 00216 return( _histo ); 00217 } 00218 00221 const Emittance &calculate_emittance( void ); 00222 00225 void export_data( const std::string &filename ); 00226 00229 void build_plot( void ); 00230 }; 00231 00232 00233 #endif 00234 00235 00236 00237 00238