Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AverageTextRep.cxx

Go to the documentation of this file.
00001 
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #else
00015 #ifdef _MSC_VER
00016 // include max() and min() missing from MicroSoft Visual C++
00017 #include "msdevstudio/MSconfig.h"
00018 #endif //_MSC_VER
00019 
00020 #endif
00021 
00022 #include "AverageTextRep.h"
00023 
00024 #include "graphics/ViewBase.h"
00025 #include "projectors/NTupleProjector.h"
00026 
00027 using namespace hippodraw;
00028 
00029 #ifdef SSTREAM_DEFECT
00030 #include <strstream>
00031 using std::ostrstream;
00032 #else
00033 #include <sstream>
00034 using std::ostringstream;
00035 #endif
00036 
00037 using std::string;
00038 
00039 AverageTextRep::AverageTextRep ( )
00040   : TextRepBase ( "averagex" )
00041 {
00042   m_axis = Axes::X;
00043 }
00044 
00045 AverageTextRep::
00046 AverageTextRep ( hippodraw::Axes::Type axis )
00047   : TextRepBase ( "averagex" )
00048 {
00049   m_axis = axis;
00050   if ( axis == Axes::Y ) m_name = "averagey" ;
00051 }
00052 
00053 AverageTextRep::AverageTextRep ( const AverageTextRep & rep )
00054   : TextRepBase( rep )
00055 {
00056   m_axis = rep.m_axis;
00057 }
00058 
00059 /* virtual */
00060 RepBase * AverageTextRep::clone ()
00061 {
00062   return new AverageTextRep ( *this );
00063 }
00064 
00065 void
00066 AverageTextRep::
00067 drawProjectedValues ( ProjectorBase & projector,
00068                       ViewBase & view )
00069 
00070 {
00071   double average = projector.getAverage ( m_axis );
00072 
00073 #ifdef SSTREAM_DEFECT
00074   ostrstream strm_text;
00075 #else
00076   std::ostringstream strm_text;
00077 #endif
00078  
00079   if (m_axis == Axes::X ) {
00080     strm_text << "Average X-value = " << average << std::ends;
00081   }
00082   if (m_axis == Axes::Y ) {
00083     strm_text << "Average Y-value = " << average << std::ends;
00084   }
00085 
00086   const string str_text ( strm_text.str () );
00087 
00088   view.drawText ( str_text, 5, 0, m_size, 0, 'l', 't', true );
00089 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3