00001
00012
00013 #ifdef _MSC_VER
00014 #include "msdevstudio/MSconfig.h"
00015 #endif
00016
00017 #include "StripChartProjector.h"
00018
00019 #include "datasrcs/DataPointTuple.h"
00020 #include "datasrcs/DataSource.h"
00021
00022 #include <algorithm>
00023
00024 #include <cassert>
00025
00026 using std::distance;
00027 using std::min_element;
00028 using std::vector;
00029
00030 namespace hippodraw {
00031
00032 StripChartProjector::StripChartProjector( )
00033 : Map2Projector()
00034 {
00035 addPointReps();
00036 }
00037
00042 StripChartProjector::
00043 StripChartProjector ( const StripChartProjector & projector )
00044 : ProjectorBase ( projector ),
00045 Map2Projector( projector )
00046 {
00047 addPointReps();
00048 }
00049
00050 ProjectorBase * StripChartProjector::clone()
00051 {
00052 return new StripChartProjector ( *this );
00053 }
00054
00055 void StripChartProjector::addPointReps()
00056 {
00057 m_pointreps.clear();
00058 m_pointreps.push_back ( "Line" );
00059 m_pointreps.push_back ( "Symbol" );
00060 }
00061
00062 namespace dp = hippodraw::DataPoint2DTuple;
00063
00066 void
00067 StripChartProjector::
00068 fillProjectedValues ( DataSource * ntuple, bool ) const
00069 {
00070 ntuple -> clear();
00071
00072 unsigned int x_col = m_columns[0];
00073 unsigned int y_col = m_columns[1];
00074 unsigned int x_err = m_columns[2];
00075 unsigned int y_err = m_columns[3];
00076
00077 unsigned int min_row = m_ntuple -> indexOfMinElement ( x_col );
00078
00079 unsigned int size = m_ntuple -> rows ();
00080
00081 vector < double > row ( dp::SIZE );
00082 for ( unsigned int i = min_row; i < size; i++ ) {
00083
00084
00085 if ( acceptRow ( i, m_cut_list ) == false ) continue;
00086
00087 row[dp::X] = m_ntuple -> valueAt ( i, x_col );
00088 row[dp::Y] = m_ntuple -> valueAt ( i, y_col );
00089
00090 double xe
00091 = x_err < UINT_MAX ? m_ntuple -> valueAt ( i, x_err ) : 0.0;
00092 double ye
00093 = y_err < UINT_MAX ? m_ntuple -> valueAt ( i, y_err ) : 0.0;
00094
00095 row[dp::XERR] = xe;
00096 row[dp::YERR] = ye;
00097 ntuple -> addRow ( row );
00098 }
00099 for ( unsigned int i = 0; i < min_row; i++ ) {
00100 if ( acceptRow ( i, m_cut_list ) == false ||
00101 inRange ( i ) == false ) continue;
00102
00103 row[dp::X] = m_ntuple -> valueAt ( i, x_col );
00104 row[dp::Y] = m_ntuple -> valueAt ( i, y_col );
00105 double xe
00106 = x_err < UINT_MAX ? m_ntuple -> valueAt ( i, x_err ) : 0.0;
00107 double ye
00108 = y_err < UINT_MAX ? m_ntuple -> valueAt ( i, y_err ) : 0.0;
00109
00110 row[dp::XERR] = xe;
00111 row[dp::YERR] = ye;
00112
00113 ntuple -> addRow ( row );
00114 }
00115 }
00116
00117 }
00118