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

OpenGLWindow Class Reference

#include <OpenGLWindow.h>

Inheritance diagram for OpenGLWindow:

Inheritance graph
[legend]
Collaboration diagram for OpenGLWindow:

Collaboration graph
[legend]
List of all members.

Detailed Description

The window class using OpenGL.

Attention:
This class was contributed by its author as an experiment to evaluate the core library classes with OpenGL. 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 OpenGLWindow.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.
void flush ()
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.
 OpenGLWindow (Display *, Colormap, XVisualInfo *, GLXContext)
void resize (int, int)
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.
Window window () const
virtual ~OpenGLWindow ()

Protected Attributes

PlotterBasem_plotter
 The plotter object used by this view.

Private Member Functions

void paint ()

Private Attributes

Colormap m_colormap
GLXContext m_ctx
Display * m_display
int m_height
XVisualInfo * m_vinfo
int m_width
Window m_window


Constructor & Destructor Documentation

OpenGLWindow::OpenGLWindow Display *  ,
Colormap  ,
XVisualInfo *  ,
GLXContext 
 

Definition at line 22 of file OpenGLWindow.cxx.

References m_colormap, m_display, m_height, m_vinfo, m_width, and m_window.

OpenGLWindow::~OpenGLWindow  )  [virtual]
 

Definition at line 85 of file OpenGLWindow.cxx.


Member Function Documentation

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, inherited]
 

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, OpenGLView::toViewX(), and OpenGLView::toViewY().

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

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, OpenGLView::toViewX(), and OpenGLView::toViewY().

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

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 OpenGLView::draw_Text(), OpenGLView::toX(), and OpenGLView::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, inherited]
 

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, inherited]
 

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, OpenGLView::toViewX(), OpenGLView::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, inherited]
 

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, OpenGLView::toViewX(), and OpenGLView::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(), paint(), and QtViewWidget::paintEvent().

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

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 OpenGLView::toViewX(), and OpenGLView::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, inherited]
 

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 OpenGLView::draw_Text(), OpenGLView::toX(), and OpenGLView::toY().

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

Definition at line 555 of file OpenGLView.cxx.

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

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

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 OpenGLView::draw_Text(), OpenGLView::toViewX(), and OpenGLView::toViewY().

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

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, OpenGLView::toX(), and OpenGLView::toY().

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

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, OpenGLView::toX(), and OpenGLView::toY().

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

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 OpenGLView::toX(), and OpenGLView::toY().

void OpenGLView::endPlot  )  [virtual, inherited]
 

Finalizes a view when all drawing has been done.

Implements ViewBase.

Definition at line 71 of file OpenGLView.cxx.

void OpenGLWindow::flush  ) 
 

Definition at line 88 of file OpenGLWindow.cxx.

References m_display, and m_window.

Referenced by paint().

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, inherited]
 

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 OpenGLView::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 [inherited]
 

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, inherited]
 

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 OpenGLWindow::paint  )  [private]
 

Definition at line 110 of file OpenGLWindow.cxx.

References ViewBase::drawSelf(), flush(), m_height, m_width, and OpenGLView::setRect().

Referenced by resize().

void OpenGLWindow::resize int  ,
int 
 

Definition at line 99 of file OpenGLWindow.cxx.

References m_ctx, m_display, m_height, m_width, m_window, and paint().

Referenced by OpenGLApp::exec().

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

Sets the drawing Rectangle in the devices coordinate system.

Implements ViewBase.

Definition at line 602 of file OpenGLView.cxx.

void OpenGLView::setPlotter PlotterBase  )  [virtual, inherited]
 

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
[inherited]
 

Definition at line 49 of file OpenGLView.cxx.

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

Referenced by paint().

void OpenGLView::update const Observable  )  [virtual, inherited]
 

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, inherited]
 

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, inherited]
 

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, inherited]
 

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().

Window OpenGLWindow::window  )  const
 

Definition at line 94 of file OpenGLWindow.cxx.

References m_window.

Referenced by OpenGLApp::findView().


Member Data Documentation

Colormap OpenGLWindow::m_colormap [private]
 

Definition at line 34 of file OpenGLWindow.h.

Referenced by OpenGLWindow().

GLXContext OpenGLWindow::m_ctx [private]
 

Definition at line 36 of file OpenGLWindow.h.

Referenced by resize().

Display* OpenGLWindow::m_display [private]
 

Definition at line 33 of file OpenGLWindow.h.

Referenced by flush(), OpenGLWindow(), and resize().

int OpenGLWindow::m_height [private]
 

Definition at line 39 of file OpenGLWindow.h.

Referenced by OpenGLWindow(), paint(), and resize().

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(), OpenGLView::toViewX(), EpsView::toViewX(), QtViewWidget::toViewY(), QtView::toViewY(), OpenGLView::toViewY(), EpsView::toViewY(), QtViewImp::userToDrawColor(), OpenGLView::userToDrawColor(), EpsView::userToDrawColor(), QtViewImp::userToDrawX(), OpenGLView::userToDrawX(), EpsView::userToDrawX(), QtViewImp::userToDrawY(), OpenGLView::userToDrawY(), EpsView::userToDrawY(), and QtView::~QtView().

XVisualInfo* OpenGLWindow::m_vinfo [private]
 

Definition at line 35 of file OpenGLWindow.h.

Referenced by OpenGLWindow().

int OpenGLWindow::m_width [private]
 

Definition at line 38 of file OpenGLWindow.h.

Referenced by OpenGLWindow(), paint(), and resize().

Window OpenGLWindow::m_window [private]
 

Definition at line 37 of file OpenGLWindow.h.

Referenced by flush(), OpenGLWindow(), resize(), and window().


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