Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OpenGLView Class Reference

#include <OpenGLView.h>

Inheritance diagram for OpenGLView:

Inheritance graph
[legend]
Collaboration diagram for OpenGLView:

Collaboration graph
[legend]
List of all members.

Detailed Description

The ViewBase class using OpenGL for drawing.

Attention:
This class was contributed by its author as an experiment to evaluate the core library classes with OpenGL. The author reports: "Now the plotting is very close to what you have with Qt drawing lib." This class and others in this directory require CMT for its build.
Author:
Guy Barrand <barrand@lal.in2p3.fr>

Definition at line 23 of file OpenGLView.h.

Public Member Functions

virtual void drawColorLines (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, const std::vector< Color > &colors, float size)
 Draws multiple line segments, each with a different color - that is, a line between x0,y0 and x1,y1, with color[0] =color[1] another between x2,y2 and x3,y3 with color[2]=color[3] and so on.
virtual void drawLines (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, const Color &color, float)
 Draws multiple line segments - that is, a line between x0,y0 and x1,y2, another between x2,y2 and x3,y3 and so on.
virtual void drawMag (float x, float y, int mag, float fontsize)
 Draws the exponent on the axis label.
virtual void drawPoints (const std::vector< double > &x, const std::vector< double > &y, const std::vector< Color > &colors, hippodraw::Symbol::Type type, float sym_size)
 Draws symbol points.
virtual void drawPoints (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Symbol::Type type, float sym_size, const Color &color)
 Draws symbol points.
virtual void drawPolyLine (const std::vector< double > &xpoints, const std::vector< double > &ypoints, hippodraw::Line::Style style, const Color &color, float)
 Draws a polyline.
virtual void drawSelf ()
 Draws itself.
virtual void drawSquare (double x1, double y1, double x2, double y2, int red, int green, int blue)
 Draws a colored square.
virtual void drawText (const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, bool resize=false, const FontBase *font=0)
 Draws a text string at a point in the view's coordinate system.
virtual void drawText (const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, bool resize=false)
virtual void drawUserText (const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp)
 Draws a text string at a point in the data coordinate system.
virtual void drawViewLines (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, const Color &color, float)
 Draws multiple line segments.
virtual void drawViewLines (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, bool color, float)
 Draws multiple line segments.
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 void endPlot ()
 Finalizes a view when all drawing has been done.
virtual double getAspectRatio () const
 Get the aspect ratio.
virtual HippoRectangle getDrawRect () const
 Returns the drawing Rectangle in the devices coordinate system.
virtual HippoRectangle getMarginRect () const
 Returns the Rectangle within which points representations are draw.
PlotterBasegetPlotter ()
 Returns the plotter used by this view.
PlotterBasegetPlotter () const
 Returns the plotter used by this view.
const RangegetRange (hippodraw::Axes::Type axis) const
 Returns the range of the data space on specified axis.
const HippoRectanglegetUserRect () const
 Is called by the AxisRepBase object (or one of its derived objects), and returns the rectangle where the drawing is made.
virtual void initPlot (double)
 Initializes a view before drawing.
 OpenGLView ()
virtual void setDrawRect (float x, float y, float w, float h)
 Sets the drawing Rectangle in the devices coordinate system.
void setPlotter (PlotterBase *)
 Sets the PlotterBase object to plotter.
void setRect (double x, double y, double w, double h)
virtual void update (const Observable *)
 Implements the update method of the Observer pattern.
float userToDrawColor (double c) const
 Converts a coordinate in user space to drawing space along the color (X) axis.
float userToDrawX (double x) const
 Converts a coordinate in user space to drawing space along the X axis.
float userToDrawY (double x) const
 Converts a coordinate in user space to drawing space along the Y axis.
virtual void willDelete (const Observable *)
 Notifies this Observer object that one of its Observable objects is about to be deleted.
virtual ~OpenGLView ()

Protected Attributes

PlotterBasem_plotter
 The plotter object used by this view.

Private Member Functions

void draw_Text (const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, const FontBase *font=0)
float toCanvasX (double datX) const
float toCanvasY (double datY) const
float toViewX (double datX) const
float toViewY (double datY) const
float toX (double x) const
float toY (double y) const

Private Attributes

HippoRectangle m_draw_rect
hippodraw::TextTTFm_TTF


Constructor & Destructor Documentation

OpenGLView::OpenGLView  ) 
 

Definition at line 36 of file OpenGLView.cxx.

References m_draw_rect, m_TTF, and HippoRectangle::setRect().

OpenGLView::~OpenGLView  )  [virtual]
 

Definition at line 44 of file OpenGLView.cxx.

References m_TTF.


Member Function Documentation

void OpenGLView::draw_Text const std::string s,
float  x,
float  y,
float  fontsize,
float  angle,
char  xp,
char  yp,
const FontBase font = 0
[private]
 

p = a * f + b

Definition at line 614 of file OpenGLView.cxx.

References hippodraw::TextTTF::BOTTOM, hippodraw::TextTTF::CENTER, FontBase::family(), hippodraw::TextTTF::LEFT, m_TTF, hippodraw::TextTTF::MIDDLE, FontBase::pointSize(), hippodraw::TextTTF::render(), hippodraw::TextTTF::RIGHT, hippodraw::TextTTF::setJustification(), hippodraw::TextTTF::setRotated(), hippodraw::TextTTF::setSize(), hippodraw::TextTTF::setString(), and hippodraw::TextTTF::TOP.

Referenced by drawMag(), drawText(), and drawUserText().

void OpenGLView::drawColorLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const std::vector< Color > &  colors,
float  size
[virtual]
 

Draws multiple line segments, each with a different color - that is, a line between x0,y0 and x1,y1, with color[0] =color[1] another between x2,y2 and x3,y3 with color[2]=color[3] and so on.

x pairs of coordinates in user space on the X axis for the beginning and the end of the line segment.

y pairs of coordinates in user space on the Y axis for the beginning and the end of the line segment.

style the line style.

color The RGB values for the color of the line.

size The thickness of the line.

Bug:
Could call drawPolyLine for each contour with same color.

Implements ViewBase.

Definition at line 127 of file OpenGLView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::Dot, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::Line::Solid, toViewX(), and toViewY().

void OpenGLView::drawLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const Color color,
float 
[virtual]
 

Draws multiple line segments - that is, a line between x0,y0 and x1,y2, another between x2,y2 and x3,y3 and so on.

x pairs of coordinates in user space on the X axis for the beginning and the end of the line segment. y pairs of coordinates in user space on the Y axis for the beginning and the end of the line segment. style the line style. color The color size The thickness of the line.

Implements ViewBase.

Definition at line 76 of file OpenGLView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::Dot, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::Line::Solid, toViewX(), and toViewY().

void OpenGLView::drawMag float  x,
float  y,
int  mag,
float  fontsize
[virtual]
 

Draws the exponent on the axis label.

The arguments stand for the starting position of the writing ( x, y ), for the value of the magnitude ( mag ), and for the font ( fontsize ).

Bug:
@@ This method should not exist.
The x, y coordinates of the position of the magnitude should be calculated in the AxisRepBase class and that class should use drawText.

Implements ViewBase.

Definition at line 510 of file OpenGLView.cxx.

References draw_Text(), toX(), and toY().

void OpenGLView::drawPoints const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< Color > &  colors,
hippodraw::Symbol::Type  type,
float  sym_size
[virtual]
 

Draws symbol points.

x and y are the coordinates, type is the type of symbol, and sym_size is the size. hue is the hue parameters for each point. The saturation and brightness are set to 1.0.

Implements ViewBase.

Definition at line 411 of file OpenGLView.cxx.

void OpenGLView::drawPoints const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Symbol::Type  type,
float  sym_size,
const Color color
[virtual]
 

Draws symbol points.

x and y are the coordinates, type is the type of symbol, and sym_size is the size. All symbols are draw in the same color.

Implements ViewBase.

Definition at line 321 of file OpenGLView.cxx.

References hippodraw::Symbol::CIRCLE, hippodraw::Symbol::FILLED_CIRCLE, hippodraw::Symbol::FILLED_TRIANGLE, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::Symbol::PLUS, hippodraw::Symbol::SOLIDSQUARE, hippodraw::Symbol::SQUARE, hippodraw::Symbol::TIMES, toViewX(), toViewY(), and hippodraw::Symbol::TRIANGLE.

void OpenGLView::drawPolyLine const std::vector< double > &  xpoints,
const std::vector< double > &  ypoints,
hippodraw::Line::Style  style,
const Color color,
float 
[virtual]
 

Draws a polyline.

xpoints points along the X axis. ypoints points along the Y axis. style the line style. color The color. size The thickness of the line.

Implements ViewBase.

Definition at line 241 of file OpenGLView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::Dot, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::Line::Solid, toViewX(), and toViewY().

void ViewBase::drawSelf  )  [virtual, inherited]
 

Draws itself.

Definition at line 60 of file ViewBase.cxx.

References PlotterBase::drawIn(), and ViewBase::m_plotter.

Referenced by QtViewWidget::draw(), QtView::draw(), QtView::drawWithPixmap(), OpenGLWindow::paint(), and QtViewWidget::paintEvent().

void OpenGLView::drawSquare double  x1,
double  y1,
double  x2,
double  y2,
int  red,
int  green,
int  blue
[virtual]
 

Draws a colored square.

Used for shading on the cuts and the gray plot.

Implements ViewBase.

Definition at line 279 of file OpenGLView.cxx.

References toViewX(), and toViewY().

void OpenGLView::drawText const std::string s,
float  x,
float  y,
float  fontsize,
float  angle,
char  xp,
char  yp,
bool  resize = false,
const FontBase font = 0
[virtual]
 

Draws a text string at a point in the view's coordinate system.

Parameters:
s The string to be drawn.
x The x coordinate in the view's coordinate system.
y The y coordinate in the view's coordinate system.
fontsize The font size. If zero, then taken from the font object.
angle The angle to draw. 90 degrees is vertical with the beginning of the text towards the bottom.
xp The horizontal alignment with respect to the coordinate. 'r' means the coordinate is on the right side of the text, 'c' means centered, and 'l' for the left side.
yp The vertical alignment with respect to the coordinate. 't' means toward the top, 'c' means centered, and 'b' means bottom.
resize If true, the bounding rectangle of the view should be resized to fit the text string.
font If not a null pointer, then the font object to be used, otherwise the default font will be used.

Implements ViewBase.

Definition at line 565 of file OpenGLView.cxx.

References draw_Text(), toX(), and toY().

void OpenGLView::drawText const std::string s,
float  x,
float  y,
float  fontsize,
float  angle,
char  xp,
char  yp,
bool  resize = false
[virtual]
 

Definition at line 555 of file OpenGLView.cxx.

References draw_Text(), toX(), and toY().

void OpenGLView::drawUserText const std::string s,
float  x,
float  y,
float  fontsize,
float  angle,
char  xp,
char  yp
[virtual]
 

Draws a text string at a point in the data coordinate system.

See also:
drawText
Bug:
Is this function used somewhere?

Implements ViewBase.

Definition at line 545 of file OpenGLView.cxx.

References draw_Text(), toViewX(), and toViewY().

void OpenGLView::drawViewLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const Color color,
float 
[virtual]
 

Draws multiple line segments.

x pairs of coordinates in view space on the X axis for the beginning and the end of the line segment. y pairs of coordinates in view space on the Y axis for the beginning and the end of the line segment. style the line style. color The color size The thickness of the line.

Implements ViewBase.

Definition at line 205 of file OpenGLView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::Dot, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::Line::Solid, toX(), and toY().

void OpenGLView::drawViewLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
bool  color,
float 
[virtual]
 

Draws multiple line segments.

x pairs of coordinates in view space on the X axis for the beginning and the end of the line segment. y pairs of coordinates in view space on the Y axis for the beginning and the end of the line segment. style the line style. color if true, use the display's point color; otherwise, use the default color. size The thickness of the line.

Implements ViewBase.

Definition at line 169 of file OpenGLView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::Dot, hippodraw::Line::Solid, toX(), and toY().

void OpenGLView::drawViewSquare float  x1,
float  y1,
float  x2,
float  y2,
int  red,
int  green,
int  blue
[virtual]
 

Draws a colored square in view space.

Used for shading on the cuts and the gray plot.

Implements ViewBase.

Definition at line 300 of file OpenGLView.cxx.

References toX(), and toY().

void OpenGLView::endPlot  )  [virtual]
 

Finalizes a view when all drawing has been done.

Implements ViewBase.

Definition at line 71 of file OpenGLView.cxx.

double ViewBase::getAspectRatio  )  const [virtual, inherited]
 

Get the aspect ratio.

Definition at line 85 of file ViewBase.cxx.

References ViewBase::m_plotter.

Referenced by CanvasView::contentsMouseMoveEvent(), and QtView::drawWithPixmap().

HippoRectangle OpenGLView::getDrawRect  )  const [virtual]
 

Returns the drawing Rectangle in the devices coordinate system.

Must be implemented in derived class.

Implements ViewBase.

Definition at line 598 of file OpenGLView.cxx.

References m_draw_rect.

HippoRectangle ViewBase::getMarginRect  )  const [virtual, inherited]
 

Returns the Rectangle within which points representations are draw.

Todo:
It might be better to maintain insets instead of separate Rectangle.
In that way, only one rectangle would move with respect to canvas.

Reimplemented in QtViewImp.

Definition at line 80 of file ViewBase.cxx.

References PlotterBase::getMarginRect(), and ViewBase::m_plotter.

Referenced by AxisRepColor::drawColorScale(), ContourPointRep::drawContourTicks(), AxisRepBase::drawTitle(), AxisRepBase::drawXLabels(), AxisRepBase::drawXTickLabels(), AxisRepBase::drawXTickLines(), AxisRepBase::drawYLabels(), AxisRepBase::drawYMag(), AxisRepBase::drawYTickLines(), AxisRepColor::drawZLabels(), AxisRepColor::drawZTickLabels(), and AxisRepColor::drawZTickLines().

PlotterBase * ViewBase::getPlotter  )  [inherited]
 

Returns the plotter used by this view.

Definition at line 55 of file ViewBase.cxx.

References ViewBase::m_plotter.

PlotterBase * OpenGLView::getPlotter  )  const
 

Returns the plotter used by this view.

Reimplemented from ViewBase.

Definition at line 61 of file OpenGLView.cxx.

References ViewBase::getPlotter().

const Range & ViewBase::getRange hippodraw::Axes::Type  axis  )  const [inherited]
 

Returns the range of the data space on specified axis.

Definition at line 68 of file ViewBase.cxx.

References ViewBase::m_plotter.

Referenced by ContourPointRep::drawContourTicks().

const HippoRectangle & ViewBase::getUserRect  )  const [inherited]
 

Is called by the AxisRepBase object (or one of its derived objects), and returns the rectangle where the drawing is made.

Definition at line 75 of file ViewBase.cxx.

References PlotterBase::getUserRect(), and ViewBase::m_plotter.

Referenced by ContourPointRep::endPlot(), and AxisRepBase::initAxisRect().

void OpenGLView::initPlot double   )  [virtual]
 

Initializes a view before drawing.

The view should check it size. The parameter aspect, if greater than 0.0, sets the aspect ratio of the view, i.e. the ratio of the width to the height.

Implements ViewBase.

Definition at line 66 of file OpenGLView.cxx.

void OpenGLView::setDrawRect float  x,
float  y,
float  w,
float  h
[virtual]
 

Sets the drawing Rectangle in the devices coordinate system.

Implements ViewBase.

Definition at line 602 of file OpenGLView.cxx.

void OpenGLView::setPlotter PlotterBase  )  [virtual]
 

Sets the PlotterBase object to plotter.

The ViewBase object does not own the plotter. If the plotter is being changed, it is up to client code to decide to destroy the previous plotter or not.

Reimplemented from ViewBase.

Definition at line 55 of file OpenGLView.cxx.

References ViewBase::setPlotter().

Referenced by main().

void OpenGLView::setRect double  x,
double  y,
double  w,
double  h
 

Definition at line 49 of file OpenGLView.cxx.

References m_draw_rect, and HippoRectangle::setRect().

Referenced by OpenGLWindow::paint().

float OpenGLView::toCanvasX double  datX  )  const [private]
 

Definition at line 719 of file OpenGLView.cxx.

float OpenGLView::toCanvasY double  datY  )  const [private]
 

Definition at line 724 of file OpenGLView.cxx.

float OpenGLView::toViewX double  datX  )  const [private]
 

Definition at line 692 of file OpenGLView.cxx.

References HippoRectangle::getX(), m_draw_rect, ViewBase::m_plotter, and PlotterBase::userToMarginX().

Referenced by drawColorLines(), drawLines(), drawPoints(), drawPolyLine(), drawSquare(), and drawUserText().

float OpenGLView::toViewY double  datY  )  const [private]
 

Definition at line 698 of file OpenGLView.cxx.

References HippoRectangle::getHeight(), PlotterBase::getMarginRect(), HippoRectangle::getWidth(), HippoRectangle::getX(), HippoRectangle::getY(), m_draw_rect, ViewBase::m_plotter, and PlotterBase::userToMarginY().

Referenced by drawColorLines(), drawLines(), drawPoints(), drawPolyLine(), drawSquare(), and drawUserText().

float OpenGLView::toX double  x  )  const [private]
 

Definition at line 730 of file OpenGLView.cxx.

References HippoRectangle::getX(), and m_draw_rect.

Referenced by drawMag(), drawText(), drawViewLines(), and drawViewSquare().

float OpenGLView::toY double  y  )  const [private]
 

Definition at line 734 of file OpenGLView.cxx.

References HippoRectangle::getHeight(), HippoRectangle::getY(), and m_draw_rect.

Referenced by drawMag(), drawText(), drawViewLines(), and drawViewSquare().

void OpenGLView::update const Observable  )  [virtual]
 

Implements the update method of the Observer pattern.

Derived classes should send a message to what ever object is the parent of this ViewBase object.

Implements ViewBase.

Definition at line 576 of file OpenGLView.cxx.

float OpenGLView::userToDrawColor double  c  )  const [virtual]
 

Converts a coordinate in user space to drawing space along the color (X) axis.

Implements ViewBase.

Definition at line 593 of file OpenGLView.cxx.

References ViewBase::m_plotter, and PlotterBase::userToMarginColor().

float OpenGLView::userToDrawX double  x  )  const [virtual]
 

Converts a coordinate in user space to drawing space along the X axis.

Implements ViewBase.

Definition at line 583 of file OpenGLView.cxx.

References ViewBase::m_plotter, and PlotterBase::userToMarginX().

float OpenGLView::userToDrawY double  x  )  const [virtual]
 

Converts a coordinate in user space to drawing space along the Y axis.

Implements ViewBase.

Definition at line 588 of file OpenGLView.cxx.

References ViewBase::m_plotter, and PlotterBase::userToInvertedMarginY().

void hippodraw::Observer::willDelete const Observable  )  [virtual, inherited]
 

Notifies this Observer object that one of its Observable objects is about to be deleted.

Since most Observable objects are owned by its Observer, it is the Observer that issued the delete. Thus the default implementation here does nothing. Derived classes that observe objects owned by another should implement this method to remove the Observable from the list they are observing.

Reimplemented in FunctionRep, DataSourceController, CutPlotter, TextPlotter, BinningProjector, DyHist1DProjector, DyHist2DProjector, NTupleProjector, Profile2DProjector, and ProfileProjector.

Definition at line 25 of file Observer.cxx.

Referenced by DataRep::~DataRep(), DataSource::~DataSource(), NTuple::~NTuple(), and RTuple::~RTuple().


Member Data Documentation

HippoRectangle OpenGLView::m_draw_rect [private]
 

Definition at line 98 of file OpenGLView.h.

Referenced by getDrawRect(), OpenGLView(), setRect(), toViewX(), toViewY(), toX(), and toY().

PlotterBase* ViewBase::m_plotter [protected, inherited]
 

The plotter object used by this view.

Although the plotter object was created externally, the view owns the plotter object.

Definition at line 66 of file ViewBase.h.

Referenced by QtView::draw(), ViewBase::drawSelf(), QtViewWidget::fillPickedPoint(), QtView::fillPickedPoint(), ViewBase::getAspectRatio(), ViewBase::getMarginRect(), QtViewImp::getMarginRect(), ViewBase::getPlotter(), ViewBase::getRange(), ViewBase::getUserRect(), QtViewWidget::mousePressEvent(), QtViewWidget::paintEvent(), QtView::QtView(), QtViewImp::setCrossX(), QtViewImp::setCrossY(), ViewBase::setPlotter(), QtViewWidget::toViewX(), QtView::toViewX(), toViewX(), EpsView::toViewX(), QtViewWidget::toViewY(), QtView::toViewY(), toViewY(), EpsView::toViewY(), QtViewImp::userToDrawColor(), userToDrawColor(), EpsView::userToDrawColor(), QtViewImp::userToDrawX(), userToDrawX(), EpsView::userToDrawX(), QtViewImp::userToDrawY(), userToDrawY(), EpsView::userToDrawY(), and QtView::~QtView().

hippodraw::TextTTF* OpenGLView::m_TTF [private]
 

Definition at line 99 of file OpenGLView.h.

Referenced by draw_Text(), OpenGLView(), and ~OpenGLView().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3