qchartaxis.cpp
377 lines
| 6.6 KiB
| text/x-c
|
CppLexer
/ src / qchartaxis.cpp
|
r72 | #include "qchartaxis.h" | ||
|
r85 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
|
r331 | /*! | ||
\class QChartAxis | ||||
\brief The QChartAxis class is used for manipulating chart's axis | ||||
and for adding optional axes to the chart. | ||||
\mainclass | ||||
There is only one x Axis, however there can be multiple y axes. | ||||
Each chart series can be bound to exactly one Y axis and the share common X axis. | ||||
Axis can be setup to show axis line with ticks, gird lines and shades. | ||||
*/ | ||||
|
r333 | /*! | ||
\fn bool QChartAxis::isAxisVisible() const | ||||
\brief Returns if axis is visible | ||||
\sa setAxisVisible() | ||||
*/ | ||||
|
r331 | /*! | ||
\fn QPen QChartAxis::axisPen() const | ||||
\brief Returns pen used to draw axis and ticks. | ||||
\sa setAxisPen() | ||||
*/ | ||||
|
r333 | |||
/*! | ||||
\fn bool QChartAxis::isGridVisible() const | ||||
\brief Returns if grid is visible | ||||
\sa setGridVisible() | ||||
*/ | ||||
|
r331 | /*! | ||
\fn QPen QChartAxis::gridPen() const | ||||
\brief Returns pen used to draw grid. | ||||
\sa setGridPen() | ||||
*/ | ||||
|
r333 | /*! | ||
|
r365 | \fn bool QChartAxis::labelsVisible() const | ||
|
r333 | \brief Returns if grid is visible | ||
\sa setLabelsVisible() | ||||
*/ | ||||
|
r331 | /*! | ||
\fn QPen QChartAxis::labelsPen() const | ||||
|
r333 | \brief Returns the pen used to labels. | ||
|
r331 | \sa setLabelsPen() | ||
*/ | ||||
/*! | ||||
\fn QBrush QChartAxis::labelsBrush() const | ||||
|
r333 | \brief Returns brush used to draw labels. | ||
|
r331 | \sa setLabelsBrush() | ||
*/ | ||||
/*! | ||||
\fn QFont QChartAxis::labelsFont() const | ||||
|
r333 | \brief Returns font used to draw labels. | ||
|
r331 | \sa setLabelsFont() | ||
*/ | ||||
/*! | ||||
\fn QFont QChartAxis::labelsAngle() const | ||||
|
r333 | \brief Returns angle used to draw labels. | ||
|
r331 | \sa setLabelsAngle() | ||
*/ | ||||
|
r333 | /*! | ||
|
r365 | \fn bool QChartAxis::shadesVisible() const | ||
|
r333 | \brief Returns if shades are visible. | ||
\sa setShadesVisible() | ||||
*/ | ||||
/*! | ||||
\fn qreal QChartAxis::shadesOpacity() const | ||||
\brief Returns opacity of shades. | ||||
*/ | ||||
|
r331 | /*! | ||
\fn QPen QChartAxis::shadesPen() const | ||||
|
r333 | \brief Returns pen used to draw shades. | ||
|
r331 | \sa setShadesPen() | ||
*/ | ||||
/*! | ||||
\fn QBrush QChartAxis::shadesBrush() const | ||||
|
r333 | \brief Returns brush used to draw shades. | ||
|
r331 | \sa setShadesBrush() | ||
*/ | ||||
|
r333 | /*! | ||
\fn qreal QChartAxis::min() const | ||||
\brief Returns minimum value on the axis. | ||||
\sa setMin() | ||||
*/ | ||||
/*! | ||||
\fn qreal QChartAxis::max() const | ||||
\brief Returns maximim value on the axis. | ||||
\sa setMax() | ||||
*/ | ||||
/*! | ||||
\fn void QChartAxis::minChanged(qreal min) | ||||
\brief Axis emits signal when \a min of axis has changed. | ||||
*/ | ||||
/*! | ||||
\fn void QChartAxis::maxChanged(qreal max) | ||||
\brief Axis emits signal when \a max of axis has changed. | ||||
*/ | ||||
/*! | ||||
\fn int QChartAxis::ticksCount() const | ||||
\brief Return number of ticks on the axis | ||||
\sa setTicksCount() | ||||
*/ | ||||
|
r331 | /*! | ||
\fn void QChartAxis::update(QChartAxis*) | ||||
\brief \internal | ||||
*/ | ||||
/*! | ||||
\fn void QChartAxis::ticksChanged(QChartAxis*) | ||||
\brief \internal | ||||
*/ | ||||
|
r400 | /*! | ||
\fn void QChartAxis::rangeChanged(QChartAxis*) | ||||
\brief \internal | ||||
*/ | ||||
/*! | ||||
\fn void QChartAxis::updateRange(qreal min, qreal max) | ||||
\brief \internal \a min \a max | ||||
*/ | ||||
|
r331 | /*! | ||
Constructs new axis object which is a child of \a parent. Ownership is taken by | ||||
QChatView or QChart when axis added. | ||||
*/ | ||||
|
r223 | QChartAxis::QChartAxis(QObject* parent):QObject(parent), | ||
|
r85 | m_axisVisible(true), | ||
|
r176 | m_gridVisible(true), | ||
|
r85 | m_labelsVisible(true), | ||
|
r223 | m_labelsAngle(0), | ||
|
r188 | m_shadesVisible(true), | ||
|
r223 | m_shadesOpacity(1.0), | ||
m_min(0), | ||||
m_max(0), | ||||
|
r241 | m_ticksCount(5) | ||
|
r72 | { | ||
} | ||||
|
r331 | /*! | ||
Destructor of the axis object. When axis is added to chart, chart object takes ownership. | ||||
*/ | ||||
|
r72 | QChartAxis::~QChartAxis() | ||
{ | ||||
} | ||||
|
r331 | /*! | ||
Sets \a pen used to draw axis line and ticks. | ||||
*/ | ||||
|
r140 | void QChartAxis::setAxisPen(const QPen& pen) | ||
{ | ||||
|
r176 | m_axisPen=pen; | ||
|
r223 | emit update(this); | ||
|
r140 | } | ||
|
r331 | /*! | ||
Sets if axis and ticks are \a visible. | ||||
*/ | ||||
|
r85 | void QChartAxis::setAxisVisible(bool visible) | ||
{ | ||||
m_axisVisible=visible; | ||||
|
r223 | emit update(this); | ||
|
r85 | } | ||
|
r331 | /*! | ||
Sets if grid is \a visible. | ||||
*/ | ||||
|
r85 | void QChartAxis::setGridVisible(bool visible) | ||
{ | ||||
|
r176 | m_gridVisible=visible; | ||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a pen used to draw grid. | ||||
*/ | ||||
|
r176 | void QChartAxis::setGridPen(const QPen& pen) | ||
{ | ||||
m_gridPen=pen; | ||||
|
r223 | emit update(this); | ||
|
r85 | } | ||
|
r331 | /*! | ||
Sets if axis' labels are \a visible. | ||||
*/ | ||||
|
r85 | void QChartAxis::setLabelsVisible(bool visible) | ||
{ | ||||
m_labelsVisible=visible; | ||||
|
r223 | emit update(this); | ||
|
r85 | } | ||
|
r331 | /*! | ||
Sets \a pen used to draw labels. | ||||
*/ | ||||
|
r176 | void QChartAxis::setLabelsPen(const QPen& pen) | ||
{ | ||||
m_labelsPen=pen; | ||||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a brush used to draw labels. | ||||
*/ | ||||
|
r176 | void QChartAxis::setLabelsBrush(const QBrush& brush) | ||
{ | ||||
m_labelsBrush=brush; | ||||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a font used to draw labels. | ||||
*/ | ||||
|
r176 | void QChartAxis::setLabelsFont(const QFont& font) | ||
{ | ||||
m_labelsFont=font; | ||||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a angle for all the labels on given axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::setLabelsAngle(int angle) | ||
|
r176 | { | ||
|
r223 | m_labelsAngle=angle; | ||
emit update(this); | ||||
|
r176 | } | ||
|
r331 | /*! | ||
Sets if shades are \a visible. | ||||
*/ | ||||
|
r176 | void QChartAxis::setShadesVisible(bool visible) | ||
{ | ||||
m_shadesVisible=visible; | ||||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a pen used to draw shades. | ||||
*/ | ||||
|
r176 | void QChartAxis::setShadesPen(const QPen& pen) | ||
{ | ||||
m_shadesPen=pen; | ||||
|
r223 | emit update(this); | ||
|
r176 | } | ||
|
r331 | /*! | ||
Sets \a brush used to draw shades. | ||||
*/ | ||||
|
r176 | void QChartAxis::setShadesBrush(const QBrush& brush) | ||
|
r85 | { | ||
|
r176 | m_shadesBrush=brush; | ||
|
r223 | emit update(this); | ||
|
r85 | } | ||
|
r331 | /*! | ||
Sets \a opacity of the shades. | ||||
*/ | ||||
|
r188 | void QChartAxis::setShadesOpacity(qreal opacity) | ||
{ | ||||
m_shadesOpacity=opacity; | ||||
|
r223 | emit update(this); | ||
|
r188 | } | ||
|
r85 | |||
|
r331 | /*! | ||
|
r400 | Sets \a min value on the axis. | ||
|
r331 | */ | ||
|
r223 | void QChartAxis::setMin(qreal min) | ||
{ | ||||
|
r400 | if(m_min!=min) { | ||
m_min=min; | ||||
emit rangeChanged(this); | ||||
} | ||||
|
r223 | } | ||
|
r331 | /*! | ||
|
r400 | Sets \a max value on the axis. | ||
|
r331 | */ | ||
|
r223 | void QChartAxis::setMax(qreal max) | ||
{ | ||||
|
r400 | if(m_max!=max) { | ||
m_max=max; | ||||
emit rangeChanged(this); | ||||
} | ||||
|
r223 | } | ||
|
r331 | /*! | ||
Sets range from \a min to \a max on the axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::setRange(qreal min, qreal max) | ||
{ | ||||
|
r400 | setMin(min); | ||
setMax(max); | ||||
} | ||||
void QChartAxis::updateRange(qreal min, qreal max) | ||||
{ | ||||
if(m_max!=max){ | ||||
emit maxChanged(max); | ||||
} | ||||
if(m_min!=min){ | ||||
emit minChanged(min); | ||||
} | ||||
m_max=max; | ||||
m_min=min; | ||||
|
r223 | } | ||
|
r331 | /*! | ||
Sets \a count for ticks on the axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::setTicksCount(int count) | ||
{ | ||||
m_ticksCount=count; | ||||
emit ticksChanged(this); | ||||
} | ||||
|
r331 | /*! | ||
TODO: refactor me. Sets string \a label for \a value on the axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::addAxisTickLabel(qreal value,const QString& label) | ||
{ | ||||
m_ticks.insert(value,label); | ||||
emit ticksChanged(this); | ||||
} | ||||
|
r331 | /*! | ||
TODO: refactor me. Removes label for \a value on the axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::removeAxisTickLabel(qreal value) | ||
{ | ||||
m_ticks.remove(value); | ||||
emit ticksChanged(this); | ||||
} | ||||
|
r331 | /*! | ||
TODO: refactor me. Returns label for \a value on the axis. | ||||
*/ | ||||
|
r223 | QString QChartAxis::axisTickLabel(qreal value) const | ||
{ | ||||
return m_ticks.value(value); | ||||
} | ||||
|
r331 | /*! | ||
TODO: refactor me. Removes all the string labels for on the axis. | ||||
*/ | ||||
|
r223 | void QChartAxis::clearAxisTickLabels() | ||
{ | ||||
m_ticks.clear(); | ||||
emit ticksChanged(this); | ||||
} | ||||
#include "moc_qchartaxis.cpp" | ||||
|
r85 | QTCOMMERCIALCHART_END_NAMESPACE | ||