LegendWidget Class Reference

`#include <LegendWidget.h>`

Inheritance diagram for LegendWidget:

## Signals

void | enableEditor ()
Signals inherited from FrameWidget
void | changedCoordinates (const QRectF &)
void | showDialog ()
void | showMenu ()

## Public Member Functions

int | angle ()
void | clone (LegendWidget *t)
QFont | font ()
bool | hasTeXOutput ()
bool | isAutoUpdateEnabled ()
| LegendWidget (Graph *)
void | print (QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt])
QString | saveToString ()
void | setAngle (int angle)
void | setAutoUpdate (bool on=true)
void | setFont (const QFont &font)
void | setTeXOutput (bool on=true)
void | setText (const QString &s)
void | setTextColor (const QColor &c)
void | showTextEditor ()
QString | text ()
QColor | textColor ()
QSize | textSize (QPainter *p, const QwtText &text)
| ~LegendWidget ()
Public Member Functions inherited from FrameWidget
int | angle ()
AttachPolicy | attachPolicy ()
QColor | backgroundColor ()
double | bottom ()
QRectF | boundingRect () const
| Return bounding rectangle in plot coordinates. More...
QBrush | brush ()
QColor | frameColor ()
Qt::PenStyle | frameLineStyle ()
QPen | framePen ()
int | frameStyle ()
| FrameWidget (Graph *)
double | frameWidth ()
bool | isOnTop ()
void | mousePressEvent (QMouseEvent *)
void | move (const QPoint &pos)
Graph * | plot ()
void | resetCoordinates ()
void | resetOrigin ()
double | right ()
void | setAngle (int ang)
void | setAttachPolicy (AttachPolicy attachTo)
void | setBackgroundColor (const QColor &c)
void | setBrush (const QBrush &b)
void | setCoordinates (double left, double top, double right, double bottom)
| Set position (xValue() and yValue()), right and bottom values giving everything in plot coordinates. More...
void | setFrameColor (const QColor &c)
void | setFrameLineStyle (const Qt::PenStyle &s)
void | setFramePen (const QPen &p)
void | setFrameStyle (int style)
void | setFrameWidth (double w)
void | setOnTop (bool on=true)
void | setOrigin (int x, int y)
| Sets the position of the top left corner in paint coordinates. More...
void | setOriginCoord (double x, double y)
| Sets the position of the top left corner in axis coordinates. More...
void | setRect (int x, int y, int w, int h)
| Set geometry, giving everything in paint coordinates. More...
void | setSize (int w, int h)
| Set size in paint coordinates (pixels). More...
void | setSize (const QSize &newSize)
| Set size in paint coordinates. More...
void | showContextMenu ()
void | showPropertiesDialog ()
virtual void | updateCoordinates ()
double | xValue ()
| Returns the x axis coordiante of the top left corner. More...
double | yValue ()
| Returns the y axis coordiante of the top left corner. More...

## Static Public Member Functions

static void | restore (Graph *g, const QStringList &lst)
Static Public Member Functions inherited from FrameWidget
static double | heightIn (QWidget *w, Unit unit)
static void | setRect (QWidget *, double x, double y, double w, double h, Unit unit=Pixel)
| Set geometry of a widget in arbitrary units. More...
static double | widthIn (QWidget *w, Unit unit)
static double | xIn (QWidget *w, Unit unit)
static double | yIn (QWidget *w, Unit unit)

## Private Member Functions

void | drawSymbol (PlotCurve *c, int point, QPainter *p, int x, int y, int l)
void | drawText (QPainter *, const QRect &, QwtArray< long >, int)
void | drawVector (PlotCurve *c, QPainter *p, int x, int y, int l)
PlotCurve * | getCurve (const QString &s, int &point)
QwtArray< long > | itemsHeight (QPainter *p, int symbolLineLength, int frameWidth, int &width, int &height, int &textWidth, int &textHeight)
virtual void | paintEvent (QPaintEvent *e)
QString | parse (const QString &str)
int | symbolsMaxWidth ()

## Private Attributes

int | d_angle
| Rotation angle. More...
bool | d_auto_update
| Flag telling if the legend should be updated each time a curve is added/removed from the parent plot. More...
bool | d_tex_output
| Flag telling if the legend contains TeX commands that mustn't be escaped when exporting to .tex. More...
QwtText * | d_text
| Pointer to the QwtText object. More...
int | h_space
| Distance between symbols and legend text. More...
int | left_margin
| Distance between frame and content. More...
int | line_length
| Length of the symbol line. More...
int | top_margin

## Additional Inherited Members

Public Types inherited from FrameWidget
enum | AttachPolicy { Page, Scales }
| The attach to policy. More...
enum | FrameStyle { None = 0, Line = 1, Shadow = 2 }
| The kinds of frame a FrameWidget can draw around. More...
enum | Unit { Inch, Millimeter, Centimeter, Point, Pixel, Scale }
| Length units. More...
Protected Member Functions inherited from FrameWidget
double | calculateBottomValue ()
| Returns the y axis coordinate of the bottom right corner based on the pixel value. More...
double | calculateRightValue ()
| Returns the x axis coordinate of the bottom right corner based on the pixel value. More...
double | calculateXValue ()
| Returns the x axis coordinate of the top left corner based on the pixel value. More...
double | calculateYValue ()
| Returns the y axis coordinate of the top left corner based on the pixel value. More...
void | contextMenuEvent (QContextMenuEvent *)
virtual void | drawFrame (QPainter *p, const QRect &rect)
Protected Attributes inherited from FrameWidget
int | d_angle
| Rotation angle: not implemented yet. More...
AttachPolicy | d_attach_policy
| The attach to policy. More...
QBrush | d_brush
| Background brush. More...
int | d_frame
| Frame type. More...
QPen | d_frame_pen
| Pen used to draw the frame. More...
bool | d_on_top
Graph * | d_plot
| Parent plot. More...
int | d_shadow_width
| Frame width in pixels. More...
double | d_x
| X axis coordinate of the top left corner. More...
double | d_x_right
| The right side position in scale coordinates. More...
double | d_y
| Y axis coordinate of the top left corner. More...
double | d_y_bottom
| The bottom side position in scale coordinates. More...

## Constructor & Destructor Documentation

## LegendWidget()

LegendWidget::LegendWidget | ( | Graph * | plot | ) |

References d_text, enableEditor(), and FrameWidget::move().

Referenced by restore().

## ~LegendWidget()

LegendWidget::~LegendWidget | ( |  | ) |

References d_text.

## Member Function Documentation

## angle()

int LegendWidget::angle | ( |  | ) |

inline

References d_angle, setAngle(), text(), and textSize().

Referenced by clone(), itemsHeight(), PieLabel::restore(), PieLabel::saveToString(), setAngle(), and EnrichmentDialog::setWidget().

## clone()

void LegendWidget::clone | ( | LegendWidget * | t | ) |

References angle(), FrameWidget::attachPolicy(), FrameWidget::backgroundColor(), d_angle, d_auto_update, FrameWidget::d_frame, d_tex_output, font(), FrameWidget::framePen(), FrameWidget::frameStyle(), hasTeXOutput(), isAutoUpdateEnabled(), FrameWidget::setAttachPolicy(), FrameWidget::setBackgroundColor(), setFont(), FrameWidget::setFramePen(), FrameWidget::setOriginCoord(), setText(), setTextColor(), text(), textColor(), FrameWidget::xValue(), and FrameWidget::yValue().

Referenced by PieCurve::addLabel(), and Graph::addText().

## drawSymbol()

void LegendWidget::drawSymbol | ( | PlotCurve * | c,
|  | int | point,
|  | QPainter * | p,
|  | int | x,
|  | int | y,
|  | int | l
| ) |  |

private

References Graph::Box, PieCurve::color(), drawVector(), Graph::Histogram, Graph::HorizontalBars, PieCurve::pattern(), Graph::Pie, PlotCurve::type(), Graph::VectXYAM, Graph::VectXYXY, and Graph::VerticalBars.

Referenced by drawText(), and setTeXOutput().

## drawText()

void LegendWidget::drawText | ( | QPainter * | p,
|  | const QRect & | rect,
|  | QwtArray< long > | height,
|  | int | symbolLineLength
| ) |  |

private

References Graph::antialiasing(), Graph::curve(), d_angle, FrameWidget::d_frame_pen, FrameWidget::d_plot, d_text, drawSymbol(), getCurve(), h_space, left_margin, M_PI, parse(), text(), and textSize().

Referenced by paintEvent(), print(), and setTeXOutput().

## drawVector()

void LegendWidget::drawVector | ( | PlotCurve * | c,
|  | QPainter * | p,
|  | int | x,
|  | int | y,
|  | int | l
| ) |  |

private

References Graph::antialiasing(), VectorCurve::color(), FrameWidget::d_plot, VectorCurve::filledArrowHead(), VectorCurve::headAngle(), VectorCurve::headLength(), and VectorCurve::vectorPen().

Referenced by drawSymbol(), and setTeXOutput().

## enableEditor

void LegendWidget::enableEditor | ( |  | ) |

signal

Referenced by LegendWidget(), and showTextEditor().

## font()

QFont LegendWidget::font | ( |  | ) |

inline

References d_text, print(), restore(), saveToString(), setFont(), and showTextEditor().

Referenced by clone(), SelectionMoveResizer::operateOnTargets(), Graph::print(), PieLabel::saveToString(), Graph::scaleFonts(), and EnrichmentDialog::setWidget().

## getCurve()

PlotCurve * LegendWidget::getCurve | ( | const QString & | s,
|  | int & | point
| ) |  |

private

References Graph::curve(), FrameWidget::d_plot, MultiLayer::layer(), and Graph::multiLayer().

Referenced by drawText(), itemsHeight(), parse(), setTeXOutput(), and symbolsMaxWidth().

## hasTeXOutput()

bool LegendWidget::hasTeXOutput | ( |  | ) |

inline

References d_tex_output.

Referenced by clone(), and EnrichmentDialog::setWidget().

## isAutoUpdateEnabled()

bool LegendWidget::isAutoUpdateEnabled | ( |  | ) |

inline

References d_auto_update.

Referenced by CurvesDialog::addCurves(), Graph::addLegendItem(), clone(), Graph::legend(), Graph::modifyFunctionCurve(), Graph::plotBox(), Graph::removeLegendItem(), EnrichmentDialog::setWidget(), and Filter::showLegend().

## itemsHeight()

QwtArray< long > LegendWidget::itemsHeight | ( | QPainter * | p,
|  | int | symbolLineLength,
|  | int | frameWidth,
|  | int & | width,
|  | int & | height,
|  | int & | textWidth,
|  | int & | textHeight
| ) |  |

private

References angle(), d_angle, FrameWidget::d_frame, FrameWidget::d_shadow_width, d_text, FrameWidget::frameWidth(), getCurve(), h_space, left_margin, M_PI, parse(), FrameWidget::plot(), FrameWidget::Shadow, text(), textSize(), and top_margin.

Referenced by paintEvent(), print(), and setTeXOutput().

## paintEvent()

void LegendWidget::paintEvent | ( | QPaintEvent * | e | ) |

private virtual

Reimplemented from FrameWidget.

References FrameWidget::d_frame_pen, FrameWidget::drawFrame(), drawText(), itemsHeight(), line_length, and symbolsMaxWidth().

Referenced by setTeXOutput().

## parse()

QString LegendWidget::parse | ( | const QString & | str | ) |

private

References MdiSubWindow::applicationWindow(), Table::colIndex(), Table::colLabel(), Table::comment(), FrameWidget::d_plot, d_tex_output, Graph::Function, getCurve(), Graph::Histogram, Graph::multiLayer(), MdiSubWindow::name(), FrameWidget::plot(), Table::table(), ApplicationWindow::table(), Table::text(), PlotCurve::type(), and MdiSubWindow::windowLabel().

Referenced by drawText(), itemsHeight(), and setTeXOutput().

## print()

void LegendWidget::print | ( | QPainter * | p,
|  | const QwtScaleMap | map[QwtPlot::axisCnt]
| ) |  |

virtual

Reimplemented from FrameWidget.

References FrameWidget::calculateXValue(), FrameWidget::calculateYValue(), FrameWidget::d_frame_pen, FrameWidget::drawFrame(), drawText(), h_space, itemsHeight(), left_margin, line_length, FrameWidget::plot(), symbolsMaxWidth(), and top_margin.

Referenced by font().

## restore()

void LegendWidget::restore | ( | Graph * | g,
|  | const QStringList & | lst
| ) |  |

static

References Graph::add(), FrameWidget::backgroundColor(), LegendWidget(), PenStyleBox::penStyle(), setAngle(), FrameWidget::setAttachPolicy(), setAutoUpdate(), FrameWidget::setBackgroundColor(), setFont(), FrameWidget::setFrameColor(), FrameWidget::setFrameLineStyle(), FrameWidget::setFrameStyle(), FrameWidget::setFrameWidth(), FrameWidget::setOnTop(), FrameWidget::setOriginCoord(), setTeXOutput(), setText(), and setTextColor().

Referenced by font(), and ApplicationWindow::openGraph().

## saveToString()

QString LegendWidget::saveToString | ( |  | ) |

virtual

Reimplemented from FrameWidget.

Reimplemented in PieLabel.

References FrameWidget::backgroundColor(), d_angle, d_auto_update, d_tex_output, d_text, and FrameWidget::saveToString().

Referenced by font(), and PieLabel::saveToString().

## setAngle()

void LegendWidget::setAngle | ( | int | angle | ) |

References angle(), and d_angle.

Referenced by AddWidgetTool::addText(), angle(), Graph::insertText(), restore(), PieLabel::restore(), and EnrichmentDialog::setTextFormatTo().

## setAutoUpdate()

void LegendWidget::setAutoUpdate | ( | bool | on = `true` | ) |

inline

References d_auto_update.

Referenced by CurvesDialog::addCurves(), Graph::addTimeStamp(), Graph::insertLegend(), Graph::newLegend(), restore(), and EnrichmentDialog::setTextFormatTo().

## setFont()

void LegendWidget::setFont | ( | const QFont & | font | ) |

References d_text.

Referenced by AddWidgetTool::addText(), clone(), font(), Graph::insertText(), Graph::newLegend(), SelectionMoveResizer::operateOnTargets(), Graph::print(), restore(), PieLabel::restore(), Graph::scaleFonts(), Graph::setCurrentFont(), MultiLayer::setFonts(), and EnrichmentDialog::setTextFormatTo().

## setTeXOutput()

void LegendWidget::setTeXOutput | ( | bool | on = `true` | ) |

inline

References d_tex_output, drawSymbol(), drawText(), drawVector(), FrameWidget::frameWidth(), getCurve(), itemsHeight(), paintEvent(), parse(), and symbolsMaxWidth().

Referenced by restore(), and EnrichmentDialog::setTextFormatTo().

## setText()

void LegendWidget::setText | ( | const QString & | s | ) |

References d_text.

Referenced by CurvesDialog::addCurves(), Graph::addLegendItem(), AddWidgetTool::addText(), EnrichmentDialog::apply(), PieCurve::clearLabels(), clone(), PieLabel::closeEvent(), PieCurve::drawDisk(), PieCurve::drawSlices(), PieCurve::initLabels(), Graph::insertText(), Graph::modifyFunctionCurve(), Graph::newLegend(), Graph::plotBox(), Graph::removeLegendItem(), restore(), PieLabel::restore(), Graph::setLegend(), Filter::showLegend(), and text().

## setTextColor()

void LegendWidget::setTextColor | ( | const QColor & | c | ) |

References d_text.

Referenced by AddWidgetTool::addText(), clone(), Graph::insertText(), Graph::newLegend(), restore(), PieLabel::restore(), Graph::setCurrentColor(), EnrichmentDialog::setTextFormatTo(), and textColor().

## showTextEditor()

void LegendWidget::showTextEditor | ( |  | ) |

References MdiSubWindow::applicationWindow(), ApplicationWindow::d_in_place_editing, FrameWidget::d_plot, Graph::deselect(), enableEditor(), Graph::multiLayer(), and FrameWidget::showDialog().

Referenced by font(), and SelectionMoveResizer::mouseDoubleClickEvent().

## symbolsMaxWidth()

int LegendWidget::symbolsMaxWidth | ( |  | ) |

private

References Graph::Box, Graph::curveCount(), FrameWidget::d_plot, d_text, getCurve(), Graph::Histogram, Graph::HorizontalBars, line_length, Graph::Pie, text(), PlotCurve::type(), and Graph::VerticalBars.

Referenced by paintEvent(), print(), and setTeXOutput().

## text()

QString LegendWidget::text | ( |  | ) |

inline

References d_text, and setText().

Referenced by CurvesDialog::addCurves(), PieCurve::addLabel(), Graph::addLegendItem(), angle(), clone(), PieLabel::customText(), drawText(), itemsHeight(), Graph::modifyFunctionCurve(), SelectionMoveResizer::operateOnTargets(), Graph::removeLegendItem(), PieLabel::restore(), PieLabel::saveToString(), EnrichmentDialog::setWidget(), Filter::showLegend(), symbolsMaxWidth(), and TextEditor::TextEditor().

## textColor()

QColor LegendWidget::textColor | ( |  | ) |

inline

References d_text, and setTextColor().

Referenced by clone(), PieLabel::restore(), PieLabel::saveToString(), and EnrichmentDialog::setWidget().

## textSize()

QSize LegendWidget::textSize | ( | QPainter * | p,
|  | const QwtText & | text
| ) |  |

References FrameWidget::boundingRect().

Referenced by angle(), drawText(), and itemsHeight().

## Member Data Documentation

## d_angle

int LegendWidget::d_angle

private

Rotation angle.

Referenced by angle(), clone(), drawText(), itemsHeight(), saveToString(), and setAngle().

## d_auto_update

bool LegendWidget::d_auto_update

private

Flag telling if the legend should be updated each time a curve is added/removed from the parent plot.

Referenced by clone(), isAutoUpdateEnabled(), saveToString(), and setAutoUpdate().

## d_tex_output

bool LegendWidget::d_tex_output

private

Flag telling if the legend contains TeX commands that mustn't be escaped when exporting to .tex.

Referenced by clone(), hasTeXOutput(), parse(), saveToString(), and setTeXOutput().

## d_text

QwtText* LegendWidget::d_text

private

Pointer to the QwtText object.

Referenced by drawText(), font(), itemsHeight(), LegendWidget(), saveToString(), setFont(), setText(), setTextColor(), symbolsMaxWidth(), text(), textColor(), and ~LegendWidget().

## h_space

int LegendWidget::h_space

private

Distance between symbols and legend text.

Referenced by drawText(), itemsHeight(), and print().

## left_margin

int LegendWidget::left_margin

private

Distance between frame and content.

Referenced by drawText(), itemsHeight(), and print().

## line_length

int LegendWidget::line_length

private

Length of the symbol line.

Referenced by paintEvent(), print(), and symbolsMaxWidth().

## top_margin

int LegendWidget::top_margin

private

Referenced by itemsHeight(), and print().

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

- qtiplot/src/plot2D/LegendWidget.h
- qtiplot/src/plot2D/LegendWidget.cpp