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 }

Generated for HippoDraw Class Library by doxygen