##// END OF EJS Templates
Adds loosenumber algorithm...
Adds loosenumber algorithm * adds loose numbers , natvie numbers * rewrites zoom handling * remove zoom stack since loose numbers takes control * adds number of fractional digits to show

File last commit:

r678:e39e59ad9161
r678:e39e59ad9161
Show More
qchartaxis.cpp
403 lines | 7.2 KiB | text/x-c | CppLexer
Michal Klocek
Adds qchartaxis stub
r72 #include "qchartaxis.h"
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor documentation...
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.
*/
Michal Klocek
Adds missing doc for qchartaxis
r333 /*!
\fn bool QChartAxis::isAxisVisible() const
\brief Returns if axis is visible
\sa setAxisVisible()
*/
Michal Klocek
Refactor documentation...
r331 /*!
\fn QPen QChartAxis::axisPen() const
\brief Returns pen used to draw axis and ticks.
\sa setAxisPen()
*/
Michal Klocek
Adds missing doc for qchartaxis
r333
/*!
Michal Klocek
Renames Grid to GridLine
r535 \fn bool QChartAxis::isGridLineVisible() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns if grid is visible
Michal Klocek
Renames Grid to GridLine
r535 \sa setGridLineVisible()
Michal Klocek
Adds missing doc for qchartaxis
r333 */
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Fixes shades counter
r551 \fn QPen QChartAxis::gridLinePen() const
Michal Klocek
Refactor documentation...
r331 \brief Returns pen used to draw grid.
Michal Klocek
Fixes shades counter
r551 \sa setGridLinePen()
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Adds missing doc for qchartaxis
r333 /*!
Michal Klocek
Fix labels, shades visible naming convention
r365 \fn bool QChartAxis::labelsVisible() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns if grid is visible
\sa setLabelsVisible()
*/
Michal Klocek
Refactor documentation...
r331 /*!
\fn QPen QChartAxis::labelsPen() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns the pen used to labels.
Michal Klocek
Refactor documentation...
r331 \sa setLabelsPen()
*/
/*!
\fn QBrush QChartAxis::labelsBrush() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns brush used to draw labels.
Michal Klocek
Refactor documentation...
r331 \sa setLabelsBrush()
*/
/*!
\fn QFont QChartAxis::labelsFont() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns font used to draw labels.
Michal Klocek
Refactor documentation...
r331 \sa setLabelsFont()
*/
/*!
\fn QFont QChartAxis::labelsAngle() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns angle used to draw labels.
Michal Klocek
Refactor documentation...
r331 \sa setLabelsAngle()
*/
Michal Klocek
Adds missing doc for qchartaxis
r333 /*!
Michal Klocek
Fix labels, shades visible naming convention
r365 \fn bool QChartAxis::shadesVisible() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns if shades are visible.
\sa setShadesVisible()
*/
/*!
\fn qreal QChartAxis::shadesOpacity() const
\brief Returns opacity of shades.
*/
Michal Klocek
Refactor documentation...
r331 /*!
\fn QPen QChartAxis::shadesPen() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns pen used to draw shades.
Michal Klocek
Refactor documentation...
r331 \sa setShadesPen()
*/
/*!
\fn QBrush QChartAxis::shadesBrush() const
Michal Klocek
Adds missing doc for qchartaxis
r333 \brief Returns brush used to draw shades.
Michal Klocek
Refactor documentation...
r331 \sa setShadesBrush()
*/
Michal Klocek
Adds missing doc for qchartaxis
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.
*/
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Refactor domain model...
r439 \fn void QChartAxis::rangeChanged(qreal min, qreal max)
\brief Axis emits signal when \a min or \a max of axis has changed.
Michal Klocek
Refactor documentation...
r331 */
/*!
Michal Klocek
Refactor domain model...
r439 \fn int QChartAxis::ticksCount() const
\brief Return number of ticks on the axis
\sa setTicksCount()
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Adds axis setRange implementation
r400 /*!
Michal Klocek
minor. qchartaxis docs
r441 \fn void QChartAxis::updated()
Michal Klocek
Adds axis setRange implementation
r400 \brief \internal
*/
/*!
Michal Klocek
Refactor domain model...
r439 \fn void QChartAxis::handleAxisRangeChanged(qreal min, qreal max)
Michal Klocek
Adds axis setRange implementation
r400 \brief \internal \a min \a max
*/
Michal Klocek
Refactor documentation...
r331 /*!
Constructs new axis object which is a child of \a parent. Ownership is taken by
QChatView or QChart when axis added.
*/
Michal Klocek
Refactors axis handling...
r223 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 m_axisVisible(true),
Michal Klocek
Renames Grid to GridLine
r535 m_gridLineVisible(true),
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 m_labelsVisible(true),
Michal Klocek
Refactors axis handling...
r223 m_labelsAngle(0),
Michal Klocek
Sets shades not visible by default
r552 m_shadesVisible(false),
Michal Klocek
Refactors axis handling...
r223 m_shadesOpacity(1.0),
m_min(0),
m_max(0),
Michal Klocek
Adds loosenumber algorithm...
r678 m_ticksCount(5),
m_selection(NativeLabelsSelection)
Michal Klocek
Adds qchartaxis stub
r72 {
}
Michal Klocek
Refactor documentation...
r331 /*!
Destructor of the axis object. When axis is added to chart, chart object takes ownership.
*/
Michal Klocek
Adds qchartaxis stub
r72 QChartAxis::~QChartAxis()
{
}
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a pen used to draw axis line and ticks.
*/
Michal Klocek
Adds refactored axis to presenter
r140 void QChartAxis::setAxisPen(const QPen& pen)
{
Michal Klocek
Refactor domain model...
r439 if (pen != m_axisPen) {
Michal Klocek
Adds more axis handling...
r176 m_axisPen=pen;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds refactored axis to presenter
r140 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets if axis and ticks are \a visible.
*/
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 void QChartAxis::setAxisVisible(bool visible)
{
Michal Klocek
Refactor domain model...
r439 if (m_axisVisible!=visible) {
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 m_axisVisible=visible;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Renames Grid to GridLine
r535 Sets if grid line is \a visible.
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Renames Grid to GridLine
r535 void QChartAxis::setGridLineVisible(bool visible)
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 {
Michal Klocek
Renames Grid to GridLine
r535 if (m_gridLineVisible!=visible) {
m_gridLineVisible=visible;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Renames Grid to GridLine
r535 Sets \a pen used to draw grid line.
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Renames Grid to GridLine
r535 void QChartAxis::setGridLinePen(const QPen& pen)
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Renames Grid to GridLine
r535 if (m_gridLinePen!=pen) {
m_gridLinePen=pen;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets if axis' labels are \a visible.
*/
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 void QChartAxis::setLabelsVisible(bool visible)
{
Michal Klocek
Refactor domain model...
r439 if(m_labelsVisible!=visible) {
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 m_labelsVisible=visible;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a pen used to draw labels.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setLabelsPen(const QPen& pen)
{
Michal Klocek
Refactor domain model...
r439 if(m_labelsPen!=pen) {
Michal Klocek
Adds more axis handling...
r176 m_labelsPen=pen;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a brush used to draw labels.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setLabelsBrush(const QBrush& brush)
{
Michal Klocek
Refactor domain model...
r439 if(m_labelsBrush!=brush) {
Michal Klocek
Adds more axis handling...
r176 m_labelsBrush=brush;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a font used to draw labels.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setLabelsFont(const QFont& font)
{
Michal Klocek
Refactor domain model...
r439 if(m_labelsFont!=font) {
Michal Klocek
Adds more axis handling...
r176 m_labelsFont=font;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a angle for all the labels on given axis.
*/
Michal Klocek
Refactors axis handling...
r223 void QChartAxis::setLabelsAngle(int angle)
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactor domain model...
r439 if(m_labelsAngle!=angle) {
Michal Klocek
Refactors axis handling...
r223 m_labelsAngle=angle;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets if shades are \a visible.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setShadesVisible(bool visible)
{
Michal Klocek
Refactor domain model...
r439 if(m_shadesVisible!=visible) {
Michal Klocek
Adds more axis handling...
r176 m_shadesVisible=visible;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a pen used to draw shades.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setShadesPen(const QPen& pen)
{
Michal Klocek
Refactor domain model...
r439 if(m_shadesPen!=pen) {
m_shadesPen=pen;
emit updated();
}
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a brush used to draw shades.
*/
Michal Klocek
Adds more axis handling...
r176 void QChartAxis::setShadesBrush(const QBrush& brush)
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 {
Michal Klocek
Refactor domain model...
r439 if(m_shadesBrush!=brush) {
Michal Klocek
Adds more axis handling...
r176 m_shadesBrush=brush;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a opacity of the shades.
*/
Michal Klocek
Adds opacity to shades
r188 void QChartAxis::setShadesOpacity(qreal opacity)
{
Michal Klocek
Refactor domain model...
r439 if(m_shadesOpacity!=opacity) {
Michal Klocek
Adds opacity to shades
r188 m_shadesOpacity=opacity;
Michal Klocek
Refactor domain model...
r439 emit updated();
}
Michal Klocek
Adds opacity to shades
r188 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Adds axis setRange implementation
r400 Sets \a min value on the axis.
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Refactors axis handling...
r223 void QChartAxis::setMin(qreal min)
{
Michal Klocek
Refactor domain model...
r439 setRange(min,m_max);
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Refactor documentation...
r331 /*!
Michal Klocek
Adds axis setRange implementation
r400 Sets \a max value on the axis.
Michal Klocek
Refactor documentation...
r331 */
Michal Klocek
Refactors axis handling...
r223 void QChartAxis::setMax(qreal max)
{
Michal Klocek
Refactor domain model...
r439 setRange(m_min,max);
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Refactor documentation...
r331 /*!
Sets range from \a min to \a max on the axis.
*/
Michal Klocek
Refactors axis handling...
r223 void QChartAxis::setRange(qreal min, qreal max)
{
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442
Michal Klocek
Refactor domain model...
r439 bool changed = false;
if(m_min!=min) {
m_min=min;
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442 changed=true;
Michal Klocek
Refactor domain model...
r439 emit minChanged(min);
}
Michal Klocek
Adds axis setRange implementation
r400
Michal Klocek
Refactor domain model...
r439 if(m_max!=max) {
m_max=max;
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442 changed=true;
Michal Klocek
Adds axis setRange implementation
r400 emit maxChanged(max);
}
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442 if(changed) {
Michal Klocek
Adds missing ticks hadnling
r554 emit rangeChanged(m_min,m_max);
Michal Klocek
Adds loosenumber algorithm...
r678 emit this->changed(m_min, m_max, m_ticksCount, m_selection);
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442 }
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Adds axis setRange implementation
r400
Michal Klocek
Refactor documentation...
r331 /*!
Sets \a count for ticks on the axis.
*/
Michal Klocek
Refactors axis handling...
r223 void QChartAxis::setTicksCount(int count)
{
Michal Klocek
Refactor domain model...
r439 if(m_ticksCount!=count) {
Michal Klocek
Adds scroll support...
r531 m_ticksCount=count;
Michal Klocek
Adds missing ticks hadnling
r554 emit ticksCountChanged(count);
Michal Klocek
Adds loosenumber algorithm...
r678 emit changed(m_min, m_max, m_ticksCount, m_selection);
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Adds axis show/hide to API
r534 /*!
Sets axis, shades, labels and grid lines to be visible.
*/
void QChartAxis::show()
{
m_axisVisible=true;
Michal Klocek
Renames Grid to GridLine
r535 m_gridLineVisible=true;
Michal Klocek
Adds axis show/hide to API
r534 m_labelsVisible=true;
m_shadesVisible=true;
emit updated();
}
/*!
Sets axis, shades, labels and grid lines to not be visible.
*/
void QChartAxis::hide()
{
m_axisVisible=false;
Michal Klocek
Renames Grid to GridLine
r535 m_gridLineVisible=false;
Michal Klocek
Adds axis show/hide to API
r534 m_labelsVisible=false;
m_shadesVisible=false;
emit updated();
}
Michal Klocek
Adds loosenumber algorithm...
r678 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count)
Michal Klocek
Adds missing ticks hadnling
r554 {
setRange(min,max);
Michal Klocek
Adds loosenumber algorithm...
r678 setTicksCount(count);
Michal Klocek
Adds missing ticks hadnling
r554 }
Michal Klocek
Adds loosenumber algorithm...
r678 void QChartAxis::setLabelsSelectionMode(LabelsSelection mode)
Michal Klocek
Adds missing ticks hadnling
r554 {
Michal Klocek
Adds loosenumber algorithm...
r678 if(m_selection!=mode){
m_selection=mode;
emit changed(m_min, m_max, m_ticksCount, m_selection);
}
Michal Klocek
Adds missing ticks hadnling
r554 }
Michal Klocek
Refactors axis handling...
r223 #include "moc_qchartaxis.cpp"
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 QTCOMMERCIALCHART_END_NAMESPACE