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