AverageTextRep.cxx

Go to the documentation of this file.
00001 
00012 #include "AverageTextRep.h"
00013 
00014 #include "graphics/ViewBase.h"
00015 #include "pattern/string_convert.h"
00016 #include "projectors/NTupleProjector.h"
00017 
00018 using namespace hippodraw;
00019 
00020 using std::string;
00021 
00022 AverageTextRep::AverageTextRep ( )
00023   : TextRepBase ( "averagex" )
00024 {
00025   m_axis = Axes::X;
00026 }
00027 
00028 AverageTextRep::
00029 AverageTextRep ( hippodraw::Axes::Type axis )
00030   : TextRepBase ( "averagex" )
00031 {
00032   m_axis = axis;
00033   if ( axis == Axes::Y ) m_name = "averagey" ;
00034 }
00035 
00036 AverageTextRep::AverageTextRep ( const AverageTextRep & rep )
00037   : TextRepBase( rep )
00038 {
00039   m_axis = rep.m_axis;
00040 }
00041 
00042 /* virtual */
00043 RepBase * AverageTextRep::clone ()
00044 {
00045   return new AverageTextRep ( *this );
00046 }
00047 
00048 void
00049 AverageTextRep::
00050 drawProjectedValues ( ProjectorBase & projector,
00051                       ViewBase & view )
00052 
00053 {
00054   double average = projector.getAverage ( m_axis );
00055 
00056   string text ( "average " );
00057  
00058   if (m_axis == Axes::X ) {
00059     text += "X"; 
00060   }
00061   if (m_axis == Axes::Y ) {
00062     text += "Y";
00063   }
00064   text += "-value ";
00065   text += String::convert ( average );
00066 
00067   view.drawText ( text, 5, 10, m_size, 0, 'l', 't', true, 0, &m_color );
00068 }

Generated for HippoDraw Class Library by doxygen