LineFunctionRep.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 // include max() and min() missing from MicroSoft Visual C++
14 #include "msdevstudio/MSconfig.h"
15 #endif //_MSC_VER
16 
17 #include "LineFunctionRep.h"
18 
19 #include "axes/Range.h"
20 #include "functions/FunctionBase.h"
21 #include "graphics/ViewBase.h"
23 
24 using namespace hippodraw;
25 
28  : LinePointRep ( "FunctionLine", 1.0 )
29 {
30 }
31 
34  : LinePointRep ( "FunctionLine", size )
35 {
36 }
37 
39 LineFunctionRep ( const LineFunctionRep & point_rep )
40  : LinePointRep ( point_rep )
41 {
42 }
43 
45 {
46 }
47 
49 {
50  return new LineFunctionRep( *this );
51 }
52 
53 void
55 drawProjectedValues ( const Range & range,
56  const FunctionBase * function,
57  TransformBase * transform,
58  ViewBase * view )
59 {
60  smoothCurve ( range, transform, function );
61  drawValues ( view );
62 }
63 
64 void
66 smoothCurve ( const Range & range,
67  TransformBase * transform,
68  const FunctionBase * function )
69 {
70  const BinaryTransform * t
71  = dynamic_cast < const BinaryTransform * > ( transform );
72 
73  unsigned int size = 50;
74  m_x.resize ( size );
75  m_y.resize ( size );
76 
77  double tx = range.low ();
78  double ty = function -> operator () ( tx );
79  t -> transform ( tx, ty ); // changes them.
80  double txx = range.high ();
81  double tyy = function -> operator () ( txx );
82  t -> transform ( txx, tyy ); // changes them.
83 
84  double x = tx;
85  double delta = ( txx - tx ) / ( size - 1 );
86 
87  for ( unsigned int i = 0; i < size; i++ ) {
88  tx = x + 0.1 * delta;
89  t -> inverseTransform ( tx, ty ); // changes them.
90  ty = function -> operator () ( tx );
91  t -> transform ( tx, ty ); // transform them back
92  m_x [ i ] = tx;
93  m_y [ i ] = ty;
94 
95  x += delta;
96  }
97 }
unsigned int i
void drawValues(ViewBase *view)
Draws the projected values from protected transformed copy to view.
A LinePointRep class that draws a function by trying to make a smooth line after the transform to the...
double high() const
Returns the maximum of the range object.
Definition: Range.cxx:100
std::vector< double > m_y
A cache of the points along the Y axis to be drawn.
Definition: LinePointRep.h:95
A transform that transforms coordinates from one coordinate system to another.
Definition: TransformBase.h:35
virtual ~LineFunctionRep()
The destructor.
std::vector< double > m_x
A cache of the points along the X axis to be drawn.
Definition: LinePointRep.h:87
void smoothCurve(const Range &range, TransformBase *transform, const FunctionBase *function)
Smooths the curve.
hippodraw::BinaryTransform class interface
LineFunctionRep class interface.
intp size(numeric::array arr)
Definition: num_util.cpp:296
The abstract base class for views.
Definition: ViewBase.h:62
A function that can be added to a DataRep and used in a fitter.
Definition: FunctionBase.h:90
void drawProjectedValues(const Range &range, const FunctionBase *function, TransformBase *transform, ViewBase *view)
Draw the projected values.
virtual RepBase * clone()
The clone function returns an object of its own kind which is a copy of this object at this moment...
A transform that transforms coordinates from one 2D coordinate system to another. ...
hippodraw::Range class interface
double low() const
Returns the minimum of the range object.
Definition: Range.cxx:87
LineFunctionRep()
The default constructor.
Expresses a range of values.
Definition: Range.h:33
hippodraw::FunctionBase class interface
A PointRep class that draws a column to represent the value.
Definition: LinePointRep.h:34
hippodraw::ViewBase class interface
float size() const
Returns the size of the representation.
Definition: RepBase.cxx:91
The base class for the point representation hierarchy.
Definition: RepBase.h:45

Generated for HippoDraw Class Library by doxygen