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

EpsView Class Reference

#include <EpsView.h>

Inheritance diagram for EpsView:

Inheritance graph
[legend]
Collaboration diagram for EpsView:

Collaboration graph
[legend]
List of all members.

Detailed Description

The class of views for Encapsulated Postscript generation.

Author:
Sanket Biren Malde <sanket@stanford.edu>

Definition at line 27 of file EpsView.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 > &color, 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 size)
 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 size)
 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, const FontBase *font)
 Draws a text string at a point in the view's coordinate system.
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 size)
 Draws multiple line segments.
virtual void drawViewLines (const std::vector< double > &x, const std::vector< double > &y, hippodraw::Line::Style style, bool color, float size)
 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.
 EpsView (const std::string file, double x, double y, double w, double h)
 Creates an EpsView attached to file with a bounding rectangle.
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 aspect)
 This method does nothing as the generated EPS file should draw like it appears on the canvas.
virtual void setDrawRect (float x, float y, float w, float h)
 Sets the drawing Rectangle in the devices coordinate system.
virtual void setPlotter (PlotterBase *plotter)
 Sets the PlotterBase object to plotter.
float toViewX (double datX) const
float toViewY (double datY) const
float toX (double x) const
float toY (double y) const
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 ~EpsView ()

Protected Attributes

PlotterBasem_plotter
 The plotter object used by this view.

Private Member Functions

virtual void draw_Text (const std::string &s, float x, float y, float fontsize, float angle, char xp, char yp, const FontBase *)
 EpsView (const EpsView &)
void initPlot (const std::string &filename, double x, double y, double w, double h)
 Initializes data for the EPS file generation.

Private Attributes

HippoRectangle m_boundingRect
HippoRectangle m_draw_rect
std::ofstream m_outfile


Constructor & Destructor Documentation

EpsView::EpsView const EpsView  )  [private]
 

EpsView::EpsView const std::string  file,
double  x,
double  y,
double  w,
double  h
 

Creates an EpsView attached to file with a bounding rectangle.

Definition at line 38 of file EpsView.cxx.

References initPlot().

EpsView::~EpsView  )  [virtual]
 

Definition at line 45 of file EpsView.cxx.

References m_outfile.


Member Function Documentation

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

Bug:
Text size doesn't come out the same as on screen.

Definition at line 667 of file EpsView.cxx.

References m_outfile, and num_util::size().

Referenced by drawText(), and drawUserText().

void EpsView::drawColorLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const std::vector< Color > &  color,
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 152 of file EpsView.cxx.

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

void EpsView::drawLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const Color color,
float  size
[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 101 of file EpsView.cxx.

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

void EpsView::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 638 of file EpsView.cxx.

References HippoRectangle::getX(), HippoRectangle::getY(), m_boundingRect, m_draw_rect, m_outfile, and toY().

void EpsView::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 525 of file EpsView.cxx.

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

void EpsView::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 417 of file EpsView.cxx.

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

void EpsView::drawPolyLine const std::vector< double > &  xpoints,
const std::vector< double > &  ypoints,
hippodraw::Line::Style  style,
const Color color,
float  size
[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 301 of file EpsView.cxx.

References hippodraw::Line::Dash, hippodraw::Line::DashDot, hippodraw::Line::DashDotDot, hippodraw::Line::Dot, Color::getBlue(), Color::getGreen(), Color::getRed(), hippodraw::FontWeight::Invisible, m_outfile, 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 EpsView::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 361 of file EpsView.cxx.

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

void EpsView::drawText const std::string s,
float  x,
float  y,
float  fontsize,
float  angle,
char  xp,
char  yp,
bool  resize,
const FontBase font
[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 725 of file EpsView.cxx.

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

void EpsView::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 654 of file EpsView.cxx.

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

void EpsView::drawViewLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
const Color color,
float  size
[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 251 of file EpsView.cxx.

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

void EpsView::drawViewLines const std::vector< double > &  x,
const std::vector< double > &  y,
hippodraw::Line::Style  style,
bool  color,
float  size
[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 206 of file EpsView.cxx.

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

void EpsView::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 389 of file EpsView.cxx.

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

void EpsView::endPlot  )  [virtual]
 

Finalizes a view when all drawing has been done.

Implements ViewBase.

Definition at line 96 of file EpsView.cxx.

References m_outfile.

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 EpsView::getDrawRect  )  const [virtual]
 

Returns the drawing Rectangle in the devices coordinate system.

Must be implemented in derived class.

Implements ViewBase.

Definition at line 756 of file EpsView.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 * ViewBase::getPlotter  )  const [inherited]
 

Returns the plotter used by this view.

Reimplemented in OpenGLView.

Definition at line 50 of file ViewBase.cxx.

References ViewBase::m_plotter.

Referenced by DisplayController::addTextViewToList(), ViewBaseXML::areDataSourcesSaved(), CutController::connectDataRep(), CanvasView::controlMousePressEvent(), ViewBaseXML::createChild(), CanvasView::fillPlotterList(), CutController::fillTupleCutList(), PyCanvas::findSelectedView(), PyCanvas::getDisplays(), OpenGLView::getPlotter(), CanvasView::getViewFor(), PlotTable::initialize(), DisplayController::removeTextObservers(), PyCanvas::saveAsImage(), CanvasView::saveSelectedAsEps(), CanvasView::setIntervalEnabled(), and CanvasView::viewShowPickTable().

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 EpsView::initPlot double  aspect  )  [virtual]
 

This method does nothing as the generated EPS file should draw like it appears on the canvas.

Implements ViewBase.

Definition at line 50 of file EpsView.cxx.

void EpsView::initPlot const std::string filename,
double  x,
double  y,
double  w,
double  h
[private]
 

Initializes data for the EPS file generation.

filename is the name of the file. The x, y, w, and h are the x, y, width and height of the bounding rectangle.

Definition at line 58 of file EpsView.cxx.

References m_outfile.

Referenced by EpsView().

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

Sets the drawing Rectangle in the devices coordinate system.

Implements ViewBase.

Definition at line 762 of file EpsView.cxx.

References m_draw_rect, and HippoRectangle::setRect().

void ViewBase::setPlotter PlotterBase plotter  )  [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 in OpenGLView, and QtViewWidget.

Definition at line 45 of file ViewBase.cxx.

References ViewBase::m_plotter.

Referenced by QtViewWidget::setPlotter(), and OpenGLView::setPlotter().

float EpsView::toViewX double  datX  )  const
 

Definition at line 767 of file EpsView.cxx.

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

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

float EpsView::toViewY double  datY  )  const
 

Definition at line 774 of file EpsView.cxx.

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

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

float EpsView::toX double  x  )  const
 

Definition at line 796 of file EpsView.cxx.

References HippoRectangle::getX(), m_boundingRect, and m_draw_rect.

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

float EpsView::toY double  y  )  const
 

Definition at line 803 of file EpsView.cxx.

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

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

void EpsView::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 736 of file EpsView.cxx.

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

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

Implements ViewBase.

Definition at line 750 of file EpsView.cxx.

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

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

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

Implements ViewBase.

Definition at line 740 of file EpsView.cxx.

References ViewBase::m_plotter.

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

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

Implements ViewBase.

Definition at line 745 of file EpsView.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 EpsView::m_boundingRect [private]
 

Definition at line 34 of file EpsView.h.

Referenced by drawMag(), toViewX(), toViewY(), toX(), and toY().

HippoRectangle EpsView::m_draw_rect [private]
 

Definition at line 36 of file EpsView.h.

Referenced by drawMag(), getDrawRect(), setDrawRect(), toViewX(), toViewY(), toX(), and toY().

std::ofstream EpsView::m_outfile [private]
 

Definition at line 32 of file EpsView.h.

Referenced by draw_Text(), drawColorLines(), drawLines(), drawMag(), drawPoints(), drawPolyLine(), drawSquare(), drawText(), drawUserText(), drawViewLines(), drawViewSquare(), endPlot(), initPlot(), and ~EpsView().

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


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