SciDAVis  1.D4
Public Types | Public Member Functions | Protected Attributes | Private Member Functions
Legend Class Reference

A piece of text to be drawn on a Plot. More...

#include <Legend.h>

Inheritance diagram for Legend:
PlotEnrichement

List of all members.

Public Types

enum  FrameStyle { None = 0, Line = 1, Shadow = 2 }
 The kinds of frame a Legend can draw around the Text. More...

Public Member Functions

int angle ()
QColor backgroundColor ()
virtual QwtDoubleRect boundingRect () const
 Bounding rectangle in plot coordinates.
QFont font ()
int frameStyle ()
 Legend (Plot *)
QRect rect () const
 Bounding rectangle in paint coordinates.
void setAngle (int ang)
void setBackgroundColor (const QColor &c)
void setFont (const QFont &font)
void setFrameStyle (int style)
void setOrigin (const QPoint &p)
 Set QwtPlotMarker::value() in paint coordinates.
void setOriginCoord (double x, double y)
 Sets the position of the top left corner in axis coordinates.
void setText (const QString &s)
void setTextColor (const QColor &c)
QString text ()
QColor textColor ()
void updateOrigin ()
 Keep the markers on screen each time the scales are modified by adding/removing curves.
 ~Legend ()
- Public Member Functions inherited from PlotEnrichement
double bottom ()
QPoint origin () const
 Return position in paint coordinates.
 PlotEnrichement ()
double right ()
virtual void setBoundingRect (double left, double top, double right, double bottom)
 Set position (xValue() and yValue()), right and bottom values giving everything in plot coordinates.
virtual void setRect (int x, int y, int w, int h)
 Set value (position) and d_size, giving everything in paint coordinates.
void setSize (const QSize &size)
 Set d_size.
QSize size ()
 Return d_size.
virtual void updateBoundingRect ()

Protected Attributes

int d_angle
 Rotation angle: not implemented yet.
int d_frame
 Frame type.
Plotd_plot
 Parent plot.
QPoint d_pos
 TopLeft position in pixels.
int d_shadow_size_x
int d_shadow_size_y
QwtText * d_text
 Pointer to the QwtText object.
int hspace
 Distance between symbols and legend text.
int left_margin
 Distance between frame and content.
int top_margin

Private Member Functions

void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const
void drawFrame (QPainter *p, int type, const QRect &rect) const
void drawLegends (QPainter *p, const QRect &rect, QwtArray< long > height, int symbolLineLength) const
void drawSymbols (QPainter *p, const QRect &rect, QwtArray< long > height, int symbolLineLength) const
void drawVector (QPainter *p, int x, int y, int l, int curveIndex) const
QwtArray< long > itemsHeight (int y, int symbolLineLength, int &width, int &height) const
QString parse (const QString &str) const
int symbolsMaxLineLength () const

Detailed Description

A piece of text to be drawn on a Plot.

Contrary to its name, Legend is not just used for the plot legend, but for any kind of text; particularly also for the "Add Text" tool. Accordingly, it is also referred to as "TextMarker" by other classes.

Future Plans

Rename to TextMarker (or maybe TextEnrichment; see documentation of ImageMarker for details).

See also:
ImageMarker, ArrowMarker

Member Enumeration Documentation

The kinds of frame a Legend can draw around the Text.

Enumerator:
None 
Line 
Shadow 

Constructor & Destructor Documentation

Legend::Legend ( Plot plot)
Legend::~Legend ( )

References d_text.


Member Function Documentation

int Legend::angle ( )
inline
QColor Legend::backgroundColor ( )
inline
QwtDoubleRect Legend::boundingRect ( ) const
virtual

Bounding rectangle in plot coordinates.

Reimplemented from PlotEnrichement.

References PlotEnrichement::bottom(), d_plot, rect(), and PlotEnrichement::right().

void Legend::draw ( QPainter *  p,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRect &  r 
) const
private
void Legend::drawFrame ( QPainter *  p,
int  type,
const QRect &  rect 
) const
private

References d_shadow_size_x, d_shadow_size_y, d_text, Line, None, and Shadow.

Referenced by draw().

void Legend::drawLegends ( QPainter *  p,
const QRect &  rect,
QwtArray< long >  height,
int  symbolLineLength 
) const
private

References d_text, hspace, left_margin, parse(), PlotEnrichement::size(), and text().

Referenced by draw().

void Legend::drawSymbols ( QPainter *  p,
const QRect &  rect,
QwtArray< long >  height,
int  symbolLineLength 
) const
private
void Legend::drawVector ( QPainter *  p,
int  x,
int  y,
int  l,
int  curveIndex 
) const
private
QFont Legend::font ( )
inline
int Legend::frameStyle ( )
inline
QwtArray< long > Legend::itemsHeight ( int  y,
int  symbolLineLength,
int &  width,
int &  height 
) const
private
QString Legend::parse ( const QString &  str) const
private

References Graph::curve(), and d_plot.

Referenced by drawLegends(), and itemsHeight().

QRect Legend::rect ( ) const
virtual
void Legend::setAngle ( int  ang)
inline
void Legend::setBackgroundColor ( const QColor &  c)
void Legend::setFont ( const QFont &  font)
void Legend::setFrameStyle ( int  style)
void Legend::setOrigin ( const QPoint &  p)
void Legend::setOriginCoord ( double  x,
double  y 
)

Sets the position of the top left corner in axis coordinates.

References d_plot, and d_pos.

Referenced by Graph::insertTextMarker().

void Legend::setText ( const QString &  s)
void Legend::setTextColor ( const QColor &  c)
int Legend::symbolsMaxLineLength ( ) const
private

References Plot::curve(), Plot::curveKeys(), d_plot, d_text, and text().

Referenced by draw(), and rect().

QString Legend::text ( )
inline
QColor Legend::textColor ( )
inline
void Legend::updateOrigin ( )

Keep the markers on screen each time the scales are modified by adding/removing curves.

References d_plot, and d_pos.

Referenced by Graph::updateMarkersBoundingRect().


Member Data Documentation

int Legend::d_angle
protected

Rotation angle: not implemented yet.

Referenced by angle(), and setAngle().

int Legend::d_frame
protected

Frame type.

Referenced by draw(), frameStyle(), and setFrameStyle().

Plot* Legend::d_plot
protected
QPoint Legend::d_pos
protected

TopLeft position in pixels.

Reimplemented from PlotEnrichement.

Referenced by setOrigin(), setOriginCoord(), and updateOrigin().

int Legend::d_shadow_size_x
protected

Referenced by drawFrame(), and Legend().

int Legend::d_shadow_size_y
protected

Referenced by drawFrame(), and Legend().

QwtText* Legend::d_text
protected
int Legend::hspace
protected

Distance between symbols and legend text.

Referenced by drawLegends(), itemsHeight(), and Legend().

int Legend::left_margin
protected

Distance between frame and content.

Referenced by drawLegends(), drawSymbols(), itemsHeight(), and Legend().

int Legend::top_margin
protected

Referenced by itemsHeight(), and Legend().


The documentation for this class was generated from the following files: