9 #include "hippoconfig.h"
12 #include "msdevstudio/MSconfig.h"
34 using namespace hippodraw;
57 ViewBase::setPlotter ( plotter );
58 plotter -> addObserver (
this );
63 return ViewBase::getPlotter ();
68 const std::vector< double > & y,
70 const Color & color ,
float)
73 std::cout <<
" debug : drawLines " << std::endl;
76 float r = (float)(color.
getRed() / 255.0);
77 float g = (float)(color.
getGreen() / 255.0);
78 float b = (float)(color.
getBlue() / 255.0);
83 std::cout <<
"debug : drawLines : color "
104 for (
unsigned int i = 0;
i < x.size();
i =
i+2 ) {
110 std::cout <<
"debug : " << x[
i] <<
" " << y[
i] << std::endl;
111 std::cout <<
"debug : " << x[i+1] <<
" " << y[i+1] << std::endl;
119 const std::vector< double > & y,
121 const std::vector< Color > & colors,
125 std::cout <<
"hippodraw::OpenGLView::drawColorLines :" << std::endl;
128 for (
unsigned int i = 0;
i < x.size();
i+=2 ){
130 const Color & color = colors[
i];
131 float r = color.
getRed () / 255.0;
132 float g = color.
getGreen () / 255.0;
133 float b = color.
getBlue () / 255.0;
161 const std::vector< double > & x
162 ,
const std::vector< double > & y
169 std::cout <<
" debug : drawViewLines" << std::endl;
186 for (
unsigned int i = 0;
i < x.size();
i =
i+2 ) {
188 glVertex3f (
toX(x[
i]),
toY(y[i]),0 );
189 glVertex3f (
toX(x[i+1]),
toY(y[i+1]),0 );
197 const std::vector< double > & y,
199 const Color & color,
float)
202 std::cout <<
" debug : drawViewLines 2" << std::endl;
205 float r = (float)(color.
getRed() / 255.0);
206 float g = (float)(color.
getGreen() / 255.0);
207 float b = (float)(color.
getBlue() / 255.0);
224 for (
unsigned int i = 0;
i < x.size();
i =
i+2 ) {
226 glVertex3d (
toX(x[
i]),
toY(y[i]),0 );
227 glVertex3d (
toX(x[i+1]),
toY(y[i+1]),0 );
233 const std::vector< double > & ypoints,
235 const Color & color,
float)
238 std::cout <<
" debug : drawPolyLine" << std::endl;
241 float r = (float)(color.
getRed() / 255.0);
242 float g = (float)(color.
getGreen() / 255.0);
243 float b = (float)(color.
getBlue() / 255.0);
260 glBegin (GL_LINE_STRIP);
261 for (
unsigned int i = 0;
i < xpoints.size();
i++ ) {
271 int red,
int green,
int blue )
274 std::cout <<
" debug : drawSquare " << std::endl;
277 float r = (float)(red / 255.0);
278 float g = (float)(green / 255.0);
279 float b = (float)(blue / 255.0);
292 int red,
int green,
int blue ){
294 std::cout <<
"hippodraw::OpenGLView::drawViewSquare : " << std::endl;
297 float r = (float)(red / 255.0);
298 float g = (float)(green / 255.0);
299 float b = (float)(blue / 255.0);
304 glVertex3f(
toX(x1),
toY(y1),0);
305 glVertex3f(
toX(x2),
toY(y1),0);
306 glVertex3f(
toX(x2),
toY(y2),0);
307 glVertex3f(
toX(x1),
toY(y2),0);
313 const std::vector<double> & y,
316 const Color & color )
319 std::cout <<
" debug : drawPoints " << std::endl;
324 float r = (float)(color.
getRed() / 255.0);
325 float g = (float)(color.
getGreen() / 255.0);
326 float b = (float)(color.
getBlue() / 255.0);
332 for (
unsigned int i = 0;
i < x.size();
i++) {
335 glBegin(GL_LINE_STRIP);
337 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
338 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
339 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
340 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
345 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
346 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
347 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
348 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
352 glBegin(GL_LINE_STRIP);
353 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
354 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
356 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
361 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
362 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
368 std::cout <<
" debug : drawPoints : circle : dummy." << std::endl;
369 glBegin(GL_LINE_STRIP);
390 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
391 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
392 glVertex3f(
toViewX(x[i])+(sym_size/2),
toViewY(y[i])-(sym_size/2),0);
393 glVertex3f(
toViewX(x[i])-(sym_size/2),
toViewY(y[i])+(sym_size/2),0);
403 const std::vector< double > &
404 ,
const std::vector< double > &
405 ,
const std::vector< Color > &
411 std::cout <<
" debug : drawPoints 2" << std::endl;
413 std::cout <<
" debug : drawPoints 2 : dummy" << std::endl;
503 #ifdef SSTREAM_DEFECT
506 std::ostringstream ost;
509 ost << mag << std::ends;
510 const std::string s(ost.str());
512 std::cout <<
" debug : drawMag " << s
513 <<
" x " << x <<
" y " << y
514 <<
" fontsize " << fontsize
531 draw_Text ( std::string(
"x10"),
toX(x),
toY(y), fontsize, 0,
'l',
't' );
533 draw_Text ( s,
toX(x+2*fontsize),
toY(y+fontsize*0.2), fontsize, 0,
'l',
't' );
547 float fontsize,
float angle,
548 char xp,
char yp ,
bool)
551 std::cout <<
" debug : drawText " << s << std::endl;
557 float fontsize,
float angle,
558 char xp,
char yp,
bool,
560 const Color * color )
563 std::cout <<
" debug : drawText2 " << s << std::endl;
604 std::cout <<
"hippodraw::OpenGLView::setDrawRect : dummy " << std::endl;
623 std::cout <<
" debug : draw_Text \"" << s
626 <<
" fontsize " << fontsize
627 <<
" angle " << angle
633 std::cout <<
" debug : draw_Text \"" << font->
family()
634 <<
"\" : pointSize " << font->
pointSize()
637 glRasterPos2f(x+12,y);
679 float pointSize = fontsize * 0.8;
702 float s1 = 2 * m_boundingRect.
getY() + m_boundingRect.getHeight();
723 return static_cast <
float > ( dx );
728 return static_cast <
float > ( dy );
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
void render()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
virtual float userToMarginColor(double c) const
Converts the user Z coordinate into the margin color (X) coordinate.
double getHeight() const
A shortcut to get size.height.
void draw_Text(const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, const hippodraw::FontBase *font=0)
TextTTF permits to render text in the pixmap buffer by using the freetype fonts.
virtual void drawPolyLine(const std::vector< double > &xpoints, const std::vector< double > &ypoints, hippodraw::Line::Style style, const hippodraw::Color &color, float)
Draws a polyline.
float toCanvasY(double datY) const
void setRect(double x, double y, double w, double h)
Type
Enumeration of the type of symbols supported by this class.
float userToDrawColor(double c) const
Converts a coordinate in user space to drawing space along the color (X) axis.
void setJustification(Justification, Justification)
float userToDrawX(double x) const
Converts a coordinate in user space to drawing space along the X axis.
virtual void drawViewSquare(float x1, float y1, float x2, float y2, int red, int green, int blue)
Draws a colored square in view space.
virtual float userToMarginX(double x) const
Converts the user X coordinate into the margin X coordinate.
virtual void drawPoints(const std::vector< double > &x, const std::vector< double > &y, hippodraw::Symbol::Type type, float sym_size, const hippodraw::Color &color)
Draws symbol points.
hippodraw::Rect m_draw_rect
float userToDrawY(double x) const
Converts a coordinate in user space to drawing space along the Y axis.
virtual void setDrawRect(float x, float y, float w, float h)
Sets the drawing Rectangle in the devices coordinate system.
double getWidth() const
A shortcut to get size.width.
virtual void drawViewLines(const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, bool color, float)
Draws multiple line segments.
A abstract base class for font handling.
A Color class for creating the color object following the standard RGB color space.
float toViewY(double datY) const
The base class for the PlotterBase hierarchy.
virtual std::string family() const =0
Get the family associated with the font.
void setRect(double x, double y, double width, double height)
Set the parameters of 2D Rectangle.
PyArray_TYPES type(numeric::array arr)
virtual hippodraw::Rect getDrawRect() const
Returns the drawing Rectangle in the devices coordinate system.
Class representing a rectangle.
Style
Line style constants.
hippodraw::CompositePlotter class interface
virtual void drawLines(const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, const hippodraw::Color &color, float)
Draws multiple line segments - that is, a line between x0,y0 and x1,y2, another between x2...
hippodraw::TextTTF * m_TTF
virtual void drawMag(float x, float y, int mag, float fontsize)
FontBase class interface.
virtual void drawSquare(double x1, double y1, double x2, double y2, int red, int green, int blue)
Draws a colored square.
virtual float userToMarginY(double y) const
Converts the user Y coordinate into the margin Y coordinate.
hippodraw::PlotterBase * getPlotter() const
double getX() const
A shortcut to get origin.X.
const Rect & getMarginRect() const
Returns the rectangle area in which data points are drawn.
float toX(double x) const
virtual void update(const hippodraw::Observable *)
Implements the update method of the Observer pattern.
virtual float userToInvertedMarginY(double y) const
Converts the user Y coordinate into the top-left based margin Y coordinate.
virtual int pointSize() const =0
Get the pointsize of the font.
float toViewX(double datX) const
virtual void drawText(const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, bool resize=false)
void setString(const std::string &)
virtual void drawColorLines(const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, const std::vector< hippodraw::Color > &colors, float size)
Draws multiple line segments, each with a different color - that is, a line between x0...
float toCanvasX(double datX) const
void setPlotter(hippodraw::PlotterBase *)
Sets the PlotterBase object to plotter.
double getY() const
A shortcut to get origin.Y.
float toY(double y) const
hippodraw::PlotterBase class interface.