AverageTextRep.cxx
Go to the documentation of this file.
1 
12 #include "AverageTextRep.h"
13 
14 #include "graphics/ViewBase.h"
15 #include "pattern/string_convert.h"
17 
18 using namespace hippodraw;
19 
20 using std::string;
21 
23  : TextRepBase ( "averagex" )
24 {
25  m_axis = Axes::X;
26 }
27 
30  : TextRepBase ( "averagex" )
31 {
32  m_axis = axis;
33  if ( axis == Axes::Y ) m_name = "averagey" ;
34 }
35 
37  : TextRepBase( rep )
38 {
39  m_axis = rep.m_axis;
40 }
41 
42 /* virtual */
44 {
45  return new AverageTextRep ( *this );
46 }
47 
48 void
51  ViewBase & view )
52 
53 {
54  double average = projector.getAverage ( m_axis );
55 
56  string text ( "average " );
57 
58  if (m_axis == Axes::X ) {
59  text += "X";
60  }
61  if (m_axis == Axes::Y ) {
62  text += "Y";
63  }
64  text += "-value ";
65  text += String::convert ( average );
66 
67  view.drawText ( text, 5, 10, m_size, 0, 'l', 't', true, 0, &m_color );
68 }
A TextRepBase class that draws the projected values as a calculated average.
A base class for representations that draws a value as text.
Definition: TextRepBase.h:27
return rep
Definition: Inspector.cxx:3843
The namespace for conversion to string.
std::string m_name
The name of the representation.
Definition: RepBase.h:51
virtual RepBase * clone()
Returns a copy of the object.
string convert(int i)
Converts an integer to a string.
Color m_color
The color of the representation.
Definition: RepBase.h:57
float m_size
The size of the representation.
Definition: RepBase.h:63
virtual double getAverage(Axes::Type axis) const
Get the Average of all projected values on the specified axis.
hippodraw::Axes::Type m_axis
The axis for which the average is calculated.
The base class for the Projector hierarchy.
Definition: ProjectorBase.h:56
The abstract base class for views.
Definition: ViewBase.h:62
virtual void drawText(const std::string &s, float x, float y, float fontsize, float angle=0.0, char xp= 'l', char yp= 't', bool resize=false, const FontBase *font=0, const Color *color=0)=0
Draws a text string at a point in the view's coordinate system.
virtual void drawProjectedValues(ProjectorBase &projector, ViewBase &view)
Draws the values from the projector to the view.
hippodraw::AverageTextRep class interface
hippodraw::ViewBase class interface
AverageTextRep()
The default constructor.
hippodraw::NTupleProjector class interface
Type
Axes constants.
Definition: AxesType.h:31
The base class for the point representation hierarchy.
Definition: RepBase.h:45

Generated for HippoDraw Class Library by doxygen