ColorSymbolPointRep.cxx
Go to the documentation of this file.
1 
12 // For truncation warning
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "ColorSymbolPointRep.h"
18 
19 #include "colorreps/BinToColor.h"
22 #include "datasrcs/DataSource.h"
23 #include "graphics/ViewBase.h"
25 
26 #include <cassert>
27 
28 using namespace hippodraw;
29 
30 using std::vector;
31 
34  : SymbolPointRep ( symbol, size )
35 {
37  m_color_gen = factory -> create ( "Rainbow" );
38  m_name = "ColorSymbol"; // need to override what base class did
39 }
40 
42  : SymbolPointRep ( )
43 {
45  m_color_gen = factory -> create ( "Rainbow" );
46  m_name = "ColorSymbol"; // need to override what base class did
47 }
48 
50  : SymbolPointRep ( rep ),
51  m_color_gen ( rep.m_color_gen->clone () )
52 {
53 }
54 
56 {
57 }
58 
60 {
61  return new ColorSymbolPointRep( *this );
62 }
63 
64 const BinToColor *
67 {
68  return m_color_gen;
69 }
70 
71 void
74 {
75  delete m_color_gen;
76  m_color_gen = btc;
77 }
78 
79 namespace dp = hippodraw::DataPoint3DTuple;
80 
81 void
84  TransformBase * transform,
85  ViewBase * view )
86 {
87  m_x.clear ();
88  m_y.clear ();
89  m_colors.clear ();
90 
91  unsigned int size = ntuple -> rows ();
92  const BinaryTransform * bt
93  = dynamic_cast < const BinaryTransform * > ( transform );
94 
95  SymbolPointRep::beginPlot ( size, bt, view );
96  const Range & range = view -> getRange ( Axes::Z );
97  double high = range.high();
98  double low = range.low();
99 
100  bt -> transformZ ( high );
101  bt -> transformZ ( low );
102 
103  Range newrange ( low, high, range.pos() );
104 
105  // This needs to be done before we quit.
106  m_color_gen->setRange ( newrange );
107 
108  if ( size == 0 ) return;
109 
110  m_x.reserve ( size );
111  m_y.reserve ( size );
112  m_colors.reserve ( size );
113 
114  for ( unsigned int i = 0; i < size; i++ ) {
115  const vector < double > & row = ntuple -> getRow ( i );
116 
117  double value = row [ dp::Z ];
118 
119  if ( range.includes ( value ) == false ) continue;
120 
121 
122  const Range & limit_z = bt -> limitZ ();
123  bool retval = limit_z.includes ( value );
124  if ( retval == false ) continue;
125  retval = drawProjectedValue ( i, ntuple, bt, view );
126  if ( retval == false ) continue;
127 
128  bt -> transformZ ( value );
129  Color color;
130  m_color_gen -> doubleToColor ( value, color );
131  m_colors.push_back ( color );
132  }
133  const BinaryTransform * bint
134  = dynamic_cast < const BinaryTransform * > ( transform );
135 
136  bint -> transform (m_x, m_y);
137  view -> drawPoints ( m_x, m_y, m_colors, m_plot_symbol, m_size );
138 
139 }
140 
141 bool
144 {
145  return false;
146 }
unsigned int i
double high() const
Returns the maximum of the range object.
Definition: Range.cxx:100
std::vector< Color > m_colors
A cache of the colors to be used.
virtual void setValueTransform(BinToColor *)
Sets the value transform.
A transform that transforms coordinates from one coordinate system to another.
Definition: TransformBase.h:35
The base class for the value to the color transformation.
Definition: BinToColor.h:30
hippodraw::Symbol::Type m_plot_symbol
The PlotSymbol currently used.
static BinToColorFactory * instance()
Returns a pointer to the singleton instance.
Type
Enumeration of the type of symbols supported by this class.
Definition: SymbolType.h:28
ColorSymbolPointRep()
The default constructor.
virtual RepBase * clone()
The clone function returns an object of its own kind which is a copy of this object at this moment...
void beginPlot(unsigned int size, const BinaryTransform *tf, const ViewBase *view)
Sets the value of cached data members.
ColorSymbolPointRep class interface.
bool includes(double value) const
Returns true if the argument value is inside the range.
Definition: Range.cxx:146
return rep
Definition: Inspector.cxx:3843
Value
A few common colors.
Definition: Color.h:51
std::string m_name
The name of the representation.
Definition: RepBase.h:51
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
hippodraw::DataSource class interface.
A PointRep class draws a symbol to represent the value.
std::vector< double > m_y
A cache of the points to be drawn on the Y axis.
hippodraw::BinaryTransform class interface
numeric::array clone(numeric::array arr)
Definition: num_util.cpp:412
hippodraw::BinToColor class interface
intp size(numeric::array arr)
Definition: num_util.cpp:296
virtual const Color & color() const
Returns the representation&#39;s color.
Definition: RepBase.cxx:63
virtual bool uses(Color::Value) const
Returns false as this classes uses color for a Z value.
bool drawProjectedValue(unsigned int i, const DataSource *ntuple, const BinaryTransform *transform, ViewBase *view)
Draws a projected value.
float m_size
The size of the representation.
Definition: RepBase.h:63
virtual void drawProjectedValues(const DataSource *ntuple, TransformBase *transform, ViewBase *view)
virtual const BinToColor * getValueTransform() const
Returns the value transform.
A PointRep class draws a symbol to represent the coordinate in a color that represents the value...
The abstract base class for views.
Definition: ViewBase.h:62
std::vector< double > m_x
A cache of the points to be drawn on the X axis.
A transform that transforms coordinates from one 2D coordinate system to another. ...
A factory for creation of objects whose class is derived from BinToColor.
double low() const
Returns the minimum of the range object.
Definition: Range.cxx:87
Expresses a range of values.
Definition: Range.h:33
BinToColor * m_color_gen
The color scale generator.
hippodraw::DataPointTuple namespace interface
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
double pos() const
Returns the first positive element in range.
Definition: Range.cxx:113
void setRange(const Range &r)
Sets the range of the values passed.
Definition: BinToColor.cxx:47
BinToColorFactory class interface.
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen