TextPlotter.cxx
Go to the documentation of this file.
1 
12 // for truncation warning in debug mode
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "TextPlotter.h"
18 
19 #include "datareps/TextDataRep.h"
20 
21 #include <cassert>
22 
23 using std::list;
24 using std::swap;
25 using std::string;
26 
27 using namespace hippodraw;
28 
30  : PlotterBase ( "TextPlotter" )
31 {
32  m_datarep = new TextDataRep ( 0 );
33  m_title = "none";
34 }
35 
37  : PlotterBase ( plotter )
38 {
39 }
40 
42 {
43  if ( m_datarep != 0 ) delete m_datarep;
44 }
45 
47 {
48  return new TextPlotter ( *this );
49 }
50 
51 /* virtual */
53 {
54  TextDataRep * textrep = dynamic_cast < TextDataRep * > ( rep );
55  assert ( textrep != 0 );
56 
57  m_datarep = textrep;
58 }
59 
61 {
62  return 1;
63 }
64 
66 {
67  return m_datarep;
68 }
69 
71 {
72  m_datarep->drawProjectedValues ( 0, view );
73 }
74 
76 {
77  return false;
78 }
79 
81 {
82  m_datarep->setPointRep ( rep );
83 }
84 
86 {
87  return m_datarep->getRepresentation ();
88 }
89 
91 void
94 {
95  assert ( false );
96 }
97 
99 bool
102 {
103  return false;
104 }
105 
107 {
108 }
109 
110 void TextPlotter::setRepColor ( const Color & color )
111 {
112  m_datarep->setRepColor ( color );
113  notifyObservers ();
114 }
115 
116 const Color & TextPlotter::repColor () const
117 {
118  return m_datarep->getRepColor();
119 }
120 
121 float TextPlotter::userToMarginX ( double x ) const
122 {
123  return x;
124 }
125 
126 float TextPlotter::userToMarginY ( double y ) const
127 {
128  return y;
129 }
130 
131 float TextPlotter::userToInvertedMarginY ( double y ) const
132 {
133  return y;
134 }
135 
136 void
138 toUserXY ( double mx, double my, bool,
139  double & ux, double & uy ) const
140 {
141  ux = mx;
142  uy = my;
143 }
144 
146 {
147  return m_datarep -> getParentDataRep ();
148 }
149 
151 {
152  m_datarep -> setParentDataRep ( rep );
153  rep -> addObserver ( this );
154 }
155 
156 void TextPlotter::willDelete ( const Observable * observable )
157 {
158  const DataRep * rep = dynamic_cast < const DataRep * > ( observable );
159  if ( getParentDataRep() == rep ){
161  }
162 }
163 
165 {
166  return 0;
167 }
168 
170 NTuple *
172 createNTuple () const
173 {
174  return 0;
175 }
176 
177 void
180 {
181  m_datarep -> update ();
182 }
183 
184 bool
187 {
188  return true;
189 }
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
Definition: Observable.h:39
virtual float userToInvertedMarginY(double y) const
Does nothing.
virtual PlotterBase * clone()
The clone function returns an object of its own kind which is a copy of this object at this moment...
Definition: TextPlotter.cxx:46
const Color & getRepColor() const
Returns the color used for the representation.
Definition: DataRep.cxx:263
virtual void notifyObservers() const
Notifies Observer objects of a change.
Definition: Observable.cxx:93
A transform that transforms coordinates from one coordinate system to another.
Definition: TransformBase.h:35
virtual void drawIn(ViewBase *view)
Starts the drawing in view view.
Definition: TextPlotter.cxx:70
virtual void setPointRep(RepBase *pointrep)
Sets the representation of the data points.
Definition: DataRep.cxx:217
virtual void drawProjectedValues(TransformBase *transform, ViewBase *view)
Overrides the base class implementation to draw the values based on the target DataRep.
Definition: TextDataRep.cxx:72
void setParentDataRep(hippodraw::DataRep *)
Sets the target DataRep of its own TextDataRep object.
TextPlotter class interface.
virtual NTuple * createNTuple() const
hippodraw::TextDataRep class interface
virtual bool isTextPlotter() const
Return true if it&#39;s a text plotter.
virtual float userToMarginX(double x) const
Does nothing.
const Color & repColor() const
Returns the color used for the representation.
virtual void setRepresentation(RepBase *)
Sets the PointRep.
Definition: TextPlotter.cxx:80
return rep
Definition: Inspector.cxx:3843
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
TextDataRep * m_datarep
The DataRep object being used.
Definition: TextPlotter.h:44
virtual void willDelete(const Observable *observable)
Notifies this Observer object that one of its Observable objects is about to be deleted.
The base class for the PlotterBase hierarchy.
Definition: PlotterBase.h:55
virtual hippodraw::DataRep * getDataRep(int) const
Returns the specified DataRep or null pointer if it doesn&#39;t exits.
Definition: TextPlotter.cxx:65
The base class for data representations.
Definition: DataRep.h:68
virtual void update()
Updates the plotter.
virtual TransformBase * getTransform()
virtual int getNumDataReps() const
Returns the number of DataRep objects contained in the plot.
Definition: TextPlotter.cxx:60
The AxisModelBase class maintains the Range and scaling of an axis.
Definition: AxisModelBase.h:33
virtual void setErrorDisplay(hippodraw::Axes::Type axis, bool)
Definition: TextPlotter.cxx:93
std::string m_title
The main label; the title of the plot.
Definition: PlotterBase.h:86
void setRepColor(const Color &)
Sets the representation&#39;s color.
virtual void toUserXY(double mx, double my, bool scaled, double &ux, double &uy) const
A DataSource class implemented with std::vector&lt;double&gt; to store the column data. ...
Definition: NTuple.h:33
bool hasNTupleBindings() const
Returns false since TextPlotter does not have ntuple bindings.
Definition: TextPlotter.cxx:75
The abstract base class for views.
Definition: ViewBase.h:62
A Plotter class that draws text.
Definition: TextPlotter.h:38
~TextPlotter()
The destructor.
Definition: TextPlotter.cxx:41
void setRepColor(const Color &)
Sets the color of the data representation.
Definition: DataRep.cxx:249
virtual void addDataRep(hippodraw::DataRep *rep)
Adds a DataRep object to the plotter.
Definition: TextPlotter.cxx:52
const hippodraw::DataRep * getParentDataRep() const
Returns the target DataRep of its own TextDataRep object.
virtual float userToMarginY(double y) const
Does nothing.
virtual RepBase * representation() const
Returns the representation used by the plotter.
Definition: TextPlotter.cxx:85
void addObserver(Observer *)
Adds an Observer to the Observer list.
Definition: Observable.cxx:52
TextPlotter()
The default constructor.
Definition: TextPlotter.cxx:29
Displays data in textual representation.
Definition: TextDataRep.h:32
virtual bool errorDisplay(hippodraw::Axes::Type axis) const
void setAxisModel(AxisModelBase *, hippodraw::Axes::Type)
Sets the AxisModel on the specified axis.
Type
Axes constants.
Definition: AxesType.h:31
The base class for the point representation hierarchy.
Definition: RepBase.h:45
RepBase * getRepresentation() const
Returns the representation used to draw the data points.
Definition: DataRep.cxx:234
virtual void setParentDataRep(DataRep *parent_datarep)
Sets the parent DataRep.
Definition: DataRep.cxx:84

Generated for HippoDraw Class Library by doxygen