LibEngsas
Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
EChartLine Class Reference

A EWidget to display line chartsThe title of the whole chart can be set by setTitle(). Afterwards set the title of the x- (setXTitle()) and y-axis (setYTitle()). Now configure the x- and y-axis with setXTicks() and setYTicks(). The chart is configured now and you can add lines with addDataSet(). Make sure, that the values are added in the order of x- and y-ticks. If x-ticks and y-ticks are not numeric, x- and y-values can only contain exactly the values from x-ticks and y-ticks. More...

#include <echartline.h>

+ Inheritance diagram for EChartLine:
+ Collaboration diagram for EChartLine:

Public Member Functions

 EChartLine (QWidget *parent=NULL)
void setYTitle (QString yTitle)
QString yTitle () const
void setXTitle (QString xTitle)
QString xTitle () const
void setXTicksAngle (int angle)
int xTicksAngle () const
 Returns the angle of the x-ticks labels.
void setXTicks (const QList< QVariant > xTicks)
void setYTicks (const QList< QVariant > yTicks)
- Public Member Functions inherited from EChartBase
 EChartBase (QWidget *parent=NULL)
void setChartTitle (QString chartTitle)
QString chartTitle () const
void setNumberPrecision (int precision)
int numberPrecision () const
void setNumberFormat (char format)
char numberFormat () const
void addDataSet (EChartValues dataSet, const QString label, QColor color=QColor())
 Adds a new line to the graph.
bool removeDataSet (const QString label)
void setTitleFont (QFont font)
QFont titleFont () const
void setLabelFont (QFont font)
QFont labelFont () const
EActionexportAction () const
- Public Member Functions inherited from EWidget
 EWidget (QWidget *parent=0, Qt::WindowFlags flags=0)
virtual ~EWidget ()
void setWindowTitle (const QString &title)
void connectByPass (QObject *object)
 Connects all standard signals.

Protected Member Functions

void drawChart (QPainter *painter, QRect viewPort)
 Function to draw the chart.
void mouseMoveEvent (QMouseEvent *event)
 Used to display the measurements.
- Protected Member Functions inherited from EChartBase
void paintEvent (QPaintEvent *event)
- Protected Member Functions inherited from EWidget
void addManagedDockWidget (QDockWidget *widget, const Qt::DockWidgetArea &area, QString actionLabel=QString(), QString actionParent=QString())
 Adds an dock widget via addNewDockWidget() and adds widget to the list of managed dock widgets.

Properties

QString xTitle
QString yTitle
int xTicksAngle
- Properties inherited from EChartBase
QString chartTitle
int numberPrecision
char numberFormat
QFont titleFont
QFont labelFont

Private Member Functions

float linearInterpolation (const float dy, const float x1, const float x0, const float y0, const float x) const

Private Attributes

QString myXTitle
QString myYTitle
QList< QVariant > xTicks
QList< QVariant > yTicks
bool xNumeric
bool yNumeric
QMap< QString, QList< QPointF > > linesDrawn
QPoint origin
QPoint currentPosition
qreal currentXValue
qreal currentYValue
int myXTicksAngle

Additional Inherited Members

- Public Slots inherited from EChartBase
void exportChart ()
void exportChart (QPainter *painter, QRect boundingRect)
void clear ()
- Signals inherited from EWidget
void error (const QString &message)
void warning (const QString &message)
void information (const QString &message)
void reloadEnableActions ()
 Request reloading of enabled actions in EMainWindow.
void addMenu (QMenu *newMenu, const QString &parent, QString before=QString())
void addAction (QAction *newAction, const QString &parent, QString before=QString())
void addToolBar (QToolBar *newToolBar, Qt::ToolBarArea area=Qt::TopToolBarArea)
void addNewDockWidget (QDockWidget *widget, const Qt::DockWidgetArea &area)
 To add managed dock widgets, use addManagedDockWidget() instead.
void setCentralWidget (QWidget *centralWidget)
void showSettings ()
void showHelp (const QString &page)
void showStatusWidget (QWidget *widget)
void reloadSettingsRequest ()
 Indicates, that a reload of the settings is needed.
void doReloadSettings ()
 Emitted to bring the reload request back to the farest child.
- Protected Slots inherited from EChartBase
virtual void contextMenu (QPoint pos) const
 This slot is called, if the context menu of this chart should be shown.
- Protected Attributes inherited from EChartBase
int marginHorizontal
int marginVertical
QRect viewPort
QStringList colorNames
QList< void(*)(QPainter *, QPoint)> markers
QMap< QString, EChartValuesdataSets
QMap< QString, QColor > dataSetsColors
QMap< QString, void(*)(QPainter
*, QPoint)> 
dataSetsMarkers

Detailed Description

A EWidget to display line charts

The title of the whole chart can be set by setTitle(). Afterwards set the title of the x- (setXTitle()) and y-axis (setYTitle()). Now configure the x- and y-axis with setXTicks() and setYTicks(). The chart is configured now and you can add lines with addDataSet(). Make sure, that the values are added in the order of x- and y-ticks. If x-ticks and y-ticks are not numeric, x- and y-values can only contain exactly the values from x-ticks and y-ticks.

If chart is numeric (x-ticks and y-ticks contains only numeric values) the precision and the format of the displayed numbers can be configured with setNumberPrecision() and setNumberFormat(). Per default the format is 'f' and the precision 2 (e. g. 123.45).

Todo:

calculate the linesDrawn only if line is added, the x- or y-ticks are changed or the widget size is changed.

Provide context menu to export chart values and chart as image

Constructor & Destructor Documentation

EChartLine::EChartLine ( QWidget *  parent = NULL)

+ Here is the call graph for this function:

Member Function Documentation

void EChartLine::drawChart ( QPainter *  painter,
QRect  viewPort 
)
protectedvirtual

Function to draw the chart.

It is called by the overladed paintEvent() function and also used to export the chart into an image.

Note
Make sure to restore the painter afterwards!

Implements EChartBase.

+ Here is the call graph for this function:

float EChartLine::linearInterpolation ( const float  dy,
const float  x1,
const float  x0,
const float  y0,
const float  x 
) const
private

+ Here is the caller graph for this function:

void EChartLine::mouseMoveEvent ( QMouseEvent *  event)
protected

Used to display the measurements.

+ Here is the call graph for this function:

void EChartLine::setXTicks ( const QList< QVariant >  xTicks)
void EChartLine::setXTicksAngle ( int  angle)

+ Here is the caller graph for this function:

void EChartLine::setXTitle ( QString  xTitle)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EChartLine::setYTicks ( const QList< QVariant >  yTicks)
void EChartLine::setYTitle ( QString  yTitle)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int EChartLine::xTicksAngle ( ) const

Returns the angle of the x-ticks labels.

0degree is horizontal and than it turns clockwise (e. g. vertical from top to bottom is equal to 90degree). Default is 0 and maximum is 360degree.

See Also
setXTicksAngle()

+ Here is the caller graph for this function:

QString EChartLine::xTitle ( ) const
inline

+ Here is the caller graph for this function:

QString EChartLine::yTitle ( ) const
inline

+ Here is the caller graph for this function:

Member Data Documentation

QPoint EChartLine::currentPosition
private
qreal EChartLine::currentXValue
private
qreal EChartLine::currentYValue
private
QMap<QString, QList<QPointF> > EChartLine::linesDrawn
private

The points currently used to draw the lines

int EChartLine::myXTicksAngle
private
QString EChartLine::myXTitle
private
QString EChartLine::myYTitle
private
QPoint EChartLine::origin
private
bool EChartLine::xNumeric
private
QList<QVariant> EChartLine::xTicks
private
bool EChartLine::yNumeric
private
QList<QVariant> EChartLine::yTicks
private

Property Documentation

int EChartLine::xTicksAngle
readwrite
QString EChartLine::xTitle
readwrite
QString EChartLine::yTitle
readwrite

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