From 3880b19e779569ff87dd5f6c1c77c32d63f40a3a 2013-06-12 11:22:09 From: Mika Salmela Date: 2013-06-12 11:22:09 Subject: [PATCH] Selectable outlines for box Change-Id: Ic31fa26f914baaa6c26f52c73ca4328ec7523581 Reviewed-by: Miikka Heikkinen --- diff --git a/plugins/declarative/declarativeboxplotseries.cpp b/plugins/declarative/declarativeboxplotseries.cpp index ffb4526..1b6a38c 100644 --- a/plugins/declarative/declarativeboxplotseries.cpp +++ b/plugins/declarative/declarativeboxplotseries.cpp @@ -25,6 +25,227 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \qmlclass BoxSet QBoxSet + + BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation + of range and three medians. There are two ways to give the values. The first one is with constructor + or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median, + upper quartile and upper extreme. The second method is to create an empty QBoxSet instance and give the values using + value specific methods. + \sa BoxPlotSeries +*/ +/*! + \qmlproperty string BoxSet::values + The values on the box-and-whiskers set. +*/ +/*! + \qmlproperty string BoxSet::label + Defines the label of the box-and-whiskers set. +*/ +/*! + \qmlproperty int BoxSet::count + The count of values on the box-and-whiskers set +*/ +/*! + \qmlmethod void BoxSet::at(int index) + Returns the value at \a index position. +*/ +/*! + \qmlmethod void BoxSet::append(qreal value) + Appends new value \a value to the end of set. +*/ +/*! + \qmlmethod void BoxSet::clear() + Sets all values on the set to 0. +*/ +/*! + \qmlmethod void BoxSet::setValue(int index, qreal value) + Sets a new \a value on the \a index position. +*/ +/*! + \qmlsignal BoxSet::onClicked() + This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item. +*/ +/*! + \qmlsignal BoxSet::onHovered(bool status) + The signal is emitted if mouse is hovered on top of box-and-whiskers item. + Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item. +*/ +/*! + \qmlsignal BoxSet::onPenChanged() + This signal is emitted when the pen of the box-and-whiskers item has changed. +*/ +/*! + \qmlsignal BoxSet::onBrushChanged() + This signal is emitted when the brush of the box-and-whiskers item has changed. +*/ +/*! + \qmlsignal BoxSet::onChangedValues() + This signal is emitted when multiple values have been changed on the box-and-whiskers item. +*/ +/*! + \qmlsignal BoxSet::onChangedValue(int index) + This signal is emitted values the value in the box-and-whiskers item has been modified. + Parameter \a index indicates the position of the modified value. +*/ +/*! + \qmlsignal BoxSet::onCleared() + This signal is emitted when all the values on the set are cleared to 0. +*/ + + +/*! + \qmlclass BoxPlotSeries QBoxPlotSeries + \inherits QAbstractSeries + + BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this class is to act as + a container for single box-and-whiskers items. Each item is drawn to own slot. If chart includes multiple instances of + BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. + + The following QML shows how to create a simple box-and-whiskers chart: + \code + import QtQuick 1.0 + import QtCommercial.Chart 1.3 + + ChartView { + title: "Box Plot series" + width: 400 + height: 300 + theme: ChartView.ChartThemeBrownSand + legend.alignment: Qt.AlignBottom + + BoxPlotSeries { + id: plotSeries + name: "Income" + BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } + BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } + BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } + BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } + BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } + } + } + \endcode + + \beginfloatleft + \image examples_qmlboxplot.png + \endfloat + \clearfloat +*/ +/*! + \qmlmethod BoxPlotSeries::append(string label, VariantList values) + Appends a new box-and-whiskers set with \a label and \a values to the series. + */ +/*! + \qmlmethod BoxPlotSeries::append(BoxSet box) + Appends the \a box to the series. +*/ +/*! + \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values) + Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. +*/ +/*! + \qmlmethod BoxPlotSeries::remove(QBoxSet boxset) + Removes the \a boxset from the series. +*/ +/*! + \qmlmethod BoxPlotSeries::clear() + Removes all boxsets from the series. Deletes removed sets. +*/ +/*! + \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); + Signal is emitted when the user clicks the \a boxset on the chart. +*/ +/*! + \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); + Signal is emitted when there is change in hover \a status over \a boxset. +*/ +/*! + \qmlsignal BoxPlotSeries::onCountChanged(); + Signal is emitted when there is change in count of box-and-whiskers items in the series. +*/ +/*! + \qmlsignal BoxPlotSeries::onBoxsetsAdded() + Signal is emitted when new box-and-whiskers sets are added to the series. + */ +/*! + \qmlsignal BoxPlotSeries::onBoxsetsRemoved() + Signal is emitted when new box-and-whiskers sets are removed from the series. + */ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisX + The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for + the series. + \sa axisXTop +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisY + The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for + the series. + \sa axisYRight +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisXTop + The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or + axisXTop, but not both. + \sa axisX +*/ +/*! + \qmlproperty AbstractAxis BoxPlotSeries::axisYRight + The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY + or axisYRight, but not both. + \sa axisY +*/ +/*! + \qmlproperty bool BoxPlotSeries::boxOutlineVisible + This property configures the visibility of the middle box outline. +*/ +/*! + \qmlproperty Pen BoxPlotSeries::pen + This property configures the pen of the box-and-whiskers items. +*/ +/*! + \qmlproperty Brush BoxPlotSeries::brush + This property configures the brush of the box-and-whiskers items. +*/ +/*! + \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged() + Signal is emitted when the middle box outline visibility is changed. + */ +/*! + \qmlsignal BoxPlotSeries::onPenChanged() + Signal is emitted when the pen for box-and-whiskers items has changed. +*/ +/*! + \qmlsignal BoxPlotSeries::onBrushChanged() + Signal is emitted when the brush for box-and-whiskers items has changed. +*/ +/*! + \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset) + Signal is emitted when the user clicks the \a boxset on the chart. +*/ +/*! + \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset) + Signal is emitted when there is change in hover \a status over \a boxset. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis) + Signal is emitted when there is change in X axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis) + Signal is emitted when there is change in Y axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis) + Signal is emitted when there is change in top X axis. +*/ +/*! + \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis) + Signal is emitted when there is change in Y right axis. +*/ + + DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent) : QBoxSet(label, parent) { diff --git a/src/boxplotchart/boxplotchartitem.cpp b/src/boxplotchart/boxplotchartitem.cpp index 31c8476..058a0b9 100644 --- a/src/boxplotchart/boxplotchartitem.cpp +++ b/src/boxplotchart/boxplotchartitem.cpp @@ -84,6 +84,7 @@ void BoxPlotChartItem::handleDataStructureChanged() // Set the decorative issues for the newly created box box->setBrush(m_series->brush()); box->setPen(m_series->pen()); + box->setBoxOutlined(m_series->boxOutlineVisible()); } updateBoxGeometry(box, s); @@ -101,6 +102,7 @@ void BoxPlotChartItem::handleUpdatedBars() foreach (BoxWhiskers *item, m_boxTable.values()) { item->setBrush(m_series->brush()); item->setPen(m_series->pen()); + item->setBoxOutlined(m_series->boxOutlineVisible()); } // Override with QBoxSet specific settings foreach (QBoxSet *set, m_boxTable.keys()) { diff --git a/src/boxplotchart/boxwhiskers.cpp b/src/boxplotchart/boxwhiskers.cpp index 50faf64..fe027e0 100644 --- a/src/boxplotchart/boxwhiskers.cpp +++ b/src/boxplotchart/boxwhiskers.cpp @@ -58,12 +58,22 @@ void BoxWhiskers::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void BoxWhiskers::setBrush(const QBrush &brush) { m_brush = brush; + m_outlinePen.setColor(m_brush.color()); update(); } void BoxWhiskers::setPen(const QPen &pen) { + qreal widthDiff = pen.widthF() - m_pen.widthF(); + m_boundingRect.adjust(-widthDiff, -widthDiff, widthDiff, widthDiff); + m_pen = pen; + m_medianPen = pen; + m_medianPen.setCapStyle(Qt::FlatCap); + m_outlinePen = pen; + m_outlinePen.setStyle(Qt::SolidLine); + m_outlinePen.setColor(m_brush.color()); + update(); } @@ -98,10 +108,17 @@ void BoxWhiskers::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio Q_UNUSED(option) Q_UNUSED(widget) - painter->setPen(m_pen); painter->setBrush(m_brush); painter->setClipRect(parentItem()->boundingRect()); + painter->setPen(m_pen); painter->drawPath(m_boxPath); + if (!m_boxOutlined) + painter->setPen(m_outlinePen); + painter->drawRect(m_middleBox); + painter->setPen(m_medianPen); + qreal halfLine = m_pen.widthF() / 2.0; + painter->drawLine(QLineF(m_geometryLeft - halfLine, m_geometryMedian, + m_geometryRight + halfLine, m_geometryMedian)); } void BoxWhiskers::updateGeometry(AbstractDomain *domain) @@ -121,12 +138,12 @@ void BoxWhiskers::updateGeometry(AbstractDomain *domain) QPointF geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_upperExtreme), m_validData); if (!m_validData) return; - qreal geometryLeft = geometryPoint.x(); + m_geometryLeft = geometryPoint.x(); qreal geometryUpperExtreme = geometryPoint.y(); geometryPoint = m_domain->calculateGeometryPoint(QPointF(left + barWidth, m_data.m_upperQuartile), m_validData); if (!m_validData) return; - qreal geometryRight = geometryPoint.x(); + m_geometryRight = geometryPoint.x(); qreal geometryUpperQuartile = geometryPoint.y(); geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_lowerQuartile), m_validData); if (!m_validData) @@ -139,33 +156,29 @@ void BoxWhiskers::updateGeometry(AbstractDomain *domain) geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_median), m_validData); if (!m_validData) return; - qreal geometryMedian = geometryPoint.y(); + m_geometryMedian = geometryPoint.y(); // Upper whisker - path.moveTo(geometryLeft, geometryUpperExtreme); - path.lineTo(geometryRight, geometryUpperExtreme); - path.moveTo((geometryLeft + geometryRight) / 2.0, geometryUpperExtreme); - path.lineTo((geometryLeft + geometryRight) / 2.0, geometryUpperQuartile); + path.moveTo(m_geometryLeft, geometryUpperExtreme); + path.lineTo(m_geometryRight, geometryUpperExtreme); + path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperExtreme); + path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperQuartile); // Middle Box - path.addRect(geometryLeft, geometryUpperQuartile, geometryRight - geometryLeft, geometryLowerQuartile - geometryUpperQuartile); - - // Median line - path.moveTo(geometryLeft, geometryMedian); - path.lineTo(geometryRight, geometryMedian); + m_middleBox.setCoords(m_geometryLeft, geometryUpperQuartile, m_geometryRight, geometryLowerQuartile); // Lower whisker - path.moveTo(geometryLeft, geometryLowerExtreme); - path.lineTo(geometryRight, geometryLowerExtreme); - path.moveTo((geometryLeft + geometryRight) / 2.0, geometryLowerQuartile); - path.lineTo((geometryLeft + geometryRight) / 2.0, geometryLowerExtreme); + path.moveTo(m_geometryLeft, geometryLowerExtreme); + path.lineTo(m_geometryRight, geometryLowerExtreme); + path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerQuartile); + path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerExtreme); path.closeSubpath(); m_boxPath = path; m_boundingRect = m_boxPath.boundingRect(); - qreal extra = (m_pen.width() / 2.0); + qreal extra = (m_pen.widthF() / 2.0); m_boundingRect.adjust(-extra, -extra, extra, extra); } diff --git a/src/boxplotchart/boxwhiskers_p.h b/src/boxplotchart/boxwhiskers_p.h index 17b32c6..44bd1eb 100644 --- a/src/boxplotchart/boxwhiskers_p.h +++ b/src/boxplotchart/boxwhiskers_p.h @@ -54,6 +54,7 @@ public: void setBrush(const QBrush &brush); void setPen(const QPen &pen); void setLayout(const BoxWhiskersData &data); + void setBoxOutlined(const bool outlined) { m_boxOutlined = outlined; } void mousePressEvent(QGraphicsSceneMouseEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event); @@ -83,8 +84,15 @@ private: bool m_validData; QBrush m_brush; QPen m_pen; + QPen m_medianPen; + QPen m_outlinePen; + bool m_boxOutlined; BoxWhiskersData m_data; QSizeF m_domainSize; + QRectF m_middleBox; + qreal m_geometryMedian; + qreal m_geometryLeft; + qreal m_geometryRight; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 547d086..e6c3761 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -48,115 +48,59 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \sa QBoxSet */ - -/*! - \qmlclass BoxPlotSeries QBoxPlotSeries - \inherits QAbstractSeries - - BoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as - a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of - BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. - - The following QML shows how to create a simple box-and-whiskers chart: - \code - import QtQuick 1.0 - import QtCommercial.Chart 1.1 - - ChartView { - title: "Box Plot series" - width: 400 - height: 300 - theme: ChartView.ChartThemeBrownSand - legend.alignment: Qt.AlignBottom - - BoxPlotSeries { - id: plotSeries - name: "Income" - BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } - BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } - BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } - BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } - BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } - } - } - \endcode - - \beginfloatleft - \image examples_qmlboxplot.png - \endfloat - \clearfloat -*/ - /*! \fn QBoxPlotSeries::boxsetsAdded(QList sets) \brief Signal is emitted when a new \a sets of box-and-whiskers data is added to the series. */ - /*! \fn QBoxPlotSeries::boxsetsRemoved(QList sets) \brief Signal is emitted when \a sets of box-and-whiskers data is removed from the series. */ - /*! \fn QBoxPlotSeries::clicked(QBoxSet *boxset) \brief Signal is emitted when the user clicks the \a boxset on the chart. */ - /*! \fn QBoxPlotSeries::hovered(bool status, QBoxSet *boxset) \brief Signal is emitted when there is change in hover \a status over \a boxset. */ - /*! \fn QBoxPlotSeries::countChanged() \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. */ /*! - \fn virtual SeriesType QBoxPlotSeries::type() const - \brief Returns type of series. - \sa QAbstractSeries, SeriesType + \property QBoxPlotSeries::boxOutlineVisible + \brief This property configures the visibility of the middle box outline. */ /*! - \qmlmethod BoxPlotSeries::append(const QString label, QVariantList values) - Appends a new box-and-whiskers set with \a label and \a values to the series. - */ -/*! - \qmlmethod BoxPlotSeries::append(BoxSet *box) - Appends the \a box to the series. + \property QBoxPlotSeries::pen + \brief This property configures the pen of the box-and-whiskers items. */ /*! - \qmlmethod BoxPlotSeries::insert(int index, const QString label, QVariantList values) - Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. + \property QBoxPlotSeries::brush + \brief This property configures the brush of the box-and-whiskers items. */ /*! - \qmlmethod BoxPlotSeries::remove(QBoxSet *boxset) - Removes the \a boxset from the series. + \fn void QBoxPlotSeries::boxOutlineVisibilityChanged() + Signal is emitted when the middle box outline visibility is changed. */ /*! - \qmlmethod BoxPlotSeries::clear() - Removes all boxsets from the series. Deletes removed sets. + \fn void QBoxPlotSeries::penChanged() + This signal is emitted when the pen of the box-and-whiskers has changed. + \sa brush */ - /*! - \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); - Signal is emitted when the user clicks the \a boxset on the chart. -*/ -/*! - \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); - Signal is emitted when there is change in hover \a status over \a boxset. + \fn void QBoxPlotSeries::brushChanged() + This signal is emitted when the brush of the box-and-whiskers has changed. + \sa brush */ + + /*! - \qmlsignal BoxPlotSeries::onCountChanged(); - Signal is emitted when there is change in count of box-and-whiskers items in the series. + \fn virtual SeriesType QBoxPlotSeries::type() const + \brief Returns type of series. + \sa QAbstractSeries, SeriesType */ -/*! - \qmlsignal BoxPlotSeries::onBoxsetsAdded() - Signal is emitted when new box-and-whiskers sets are added to the series. - */ -/*! - \qmlsignal BoxPlotSeries::boxsetsRemoved() - Signal is emitted when new box-and-whiskers sets are removed from the series. - */ /*! Constructs empty QBoxPlotSeries. @@ -314,9 +258,24 @@ QAbstractSeries::SeriesType QBoxPlotSeries::type() const return QAbstractSeries::SeriesTypeBoxPlot; } -/*! - Sets brush for the series. Box-and-whiskers items are drawn using \a brush -*/ +void QBoxPlotSeries::setBoxOutlineVisible(bool visible) +{ + Q_D(QBoxPlotSeries); + + if (d->m_boxOutlineVisible != visible) { + d->m_boxOutlineVisible = visible; + emit d->updated(); + emit boxOutlineVisibilityChanged(); + } +} + +bool QBoxPlotSeries::boxOutlineVisible() +{ + Q_D(QBoxPlotSeries); + + return d->m_boxOutlineVisible; +} + void QBoxPlotSeries::setBrush(const QBrush &brush) { Q_D(QBoxPlotSeries); @@ -324,12 +283,10 @@ void QBoxPlotSeries::setBrush(const QBrush &brush) if (d->m_brush != brush) { d->m_brush = brush; emit d->updated(); + emit brushChanged(); } } -/*! - Returns brush of the series. -*/ QBrush QBoxPlotSeries::brush() const { Q_D(const QBoxPlotSeries); @@ -337,9 +294,6 @@ QBrush QBoxPlotSeries::brush() const return d->m_brush; } -/*! - Sets pen for the series. Box-and-whiskers items are drawn using \a pen -*/ void QBoxPlotSeries::setPen(const QPen &pen) { Q_D(QBoxPlotSeries); @@ -347,12 +301,10 @@ void QBoxPlotSeries::setPen(const QPen &pen) if (d->m_pen != pen) { d->m_pen = pen; emit d->updated(); + emit penChanged(); } } -/*! - Returns the pen of this series. -*/ QPen QBoxPlotSeries::pen() const { Q_D(const QBoxPlotSeries); @@ -365,7 +317,8 @@ QPen QBoxPlotSeries::pen() const QBoxPlotSeriesPrivate::QBoxPlotSeriesPrivate(QBoxPlotSeries *q) : QAbstractSeriesPrivate(q), m_pen(QChartPrivate::defaultPen()), - m_brush(QChartPrivate::defaultBrush()) + m_brush(QChartPrivate::defaultBrush()), + m_boxOutlineVisible(true) { } diff --git a/src/boxplotchart/qboxplotseries.h b/src/boxplotchart/qboxplotseries.h index ae4930e..751462a 100644 --- a/src/boxplotchart/qboxplotseries.h +++ b/src/boxplotchart/qboxplotseries.h @@ -32,6 +32,9 @@ class QBoxPlotSeriesPrivate; class QTCOMMERCIALCHART_EXPORT QBoxPlotSeries : public QAbstractSeries { Q_OBJECT + Q_PROPERTY(bool boxOutlineVisible READ boxOutlineVisible WRITE setBoxOutlineVisible NOTIFY boxOutlineVisibilityChanged) + Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) public: explicit QBoxPlotSeries(QObject *parent = 0); ~QBoxPlotSeries(); @@ -47,6 +50,8 @@ public: QAbstractSeries::SeriesType type() const; + void setBoxOutlineVisible(bool visible); + bool boxOutlineVisible(); void setBrush(const QBrush &brush); QBrush brush() const; void setPen(const QPen &pen); @@ -56,6 +61,9 @@ Q_SIGNALS: void clicked(QBoxSet *boxset); void hovered(bool status, QBoxSet *boxset); void countChanged(); + void penChanged(); + void brushChanged(); + void boxOutlineVisibilityChanged(); void boxsetsAdded(QList sets); void boxsetsRemoved(QList sets); diff --git a/src/boxplotchart/qboxplotseries_p.h b/src/boxplotchart/qboxplotseries_p.h index 5395038..fc4dd0a 100644 --- a/src/boxplotchart/qboxplotseries_p.h +++ b/src/boxplotchart/qboxplotseries_p.h @@ -86,6 +86,7 @@ protected: QList m_boxSets; QPen m_pen; QBrush m_brush; + bool m_boxOutlineVisible; int m_index; BoxPlotAnimation *m_animation; diff --git a/src/boxplotchart/qboxset.cpp b/src/boxplotchart/qboxset.cpp index fc47b5b..a065800 100644 --- a/src/boxplotchart/qboxset.cpp +++ b/src/boxplotchart/qboxset.cpp @@ -39,16 +39,6 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \sa QBoxPlotSeries */ /*! - \qmlclass BoxSet QBoxSet - - BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation - of range and three medians. There are two ways to give the values. The first one is with constructor - or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median, - upper quartile and upper extre. The second method is to create an empty QBoxSet instance and give the values using - value specific methods. - \sa BoxPlotSeries -*/ -/*! \enum QBoxSet::ValuePositions \value LowerExtreme @@ -57,102 +47,49 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \value UpperQuartile \value UpperExtreme */ - -/*! - \qmlproperty string BoxSet::label - Defines the label of the boxSet. -*/ -/*! - \qmlproperty int BoxSet::count - The count of values on the box-and-whiskers set -*/ - /*! \property QBoxSet::pen \brief Defines the pen used by the box-and-whiskers set. */ - /*! \property QBoxSet::brush \brief Defines the brush used by the box-and-whiskers set. */ - -/*! - \qmlmethod void BoxSet::setValue(int index, qreal value) - Sets a new \a value on the \a index position. -*/ /*! \fn void QBoxSet::clicked() The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. */ /*! - \qmlsignal BoxSet::onClicked() - This signal is emitted when the user clicks with a mouse on top of box-and-whisker item. -*/ - -/*! \fn void QBoxSet::hovered(bool status) The signal is emitted if mouse is hovered on top of box-and-whisker item. Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. */ /*! - \qmlsignal BoxSet::onHovered(bool status) - - The signal is emitted if mouse is hovered on top of box-and-whisker item. - Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. -*/ - -/*! \fn void QBoxSet::penChanged() This signal is emitted when the pen of the box-and-whisker item has changed. \sa pen */ /*! - \qmlsignal BoxSet::onPenChanged() - This signal is emitted when the pen of the box-and-whisker item has changed. -*/ -/*! \fn void QBoxSet::brushChanged() This signal is emitted when the brush of the box-and-whisker item has changed. \sa brush */ /*! - \qmlsignal BoxSet::onBrushChanged() - This signal is emitted when the brush of the box-and-whisker item has changed. -*/ - -/*! \fn void QBoxSet::valuesChanged() This signal is emitted when multiple values have been changed on the box-and-whisker item. \sa append() */ /*! - \qmlsignal BoxSet::onChangedValues() - This signal is emitted when multiple values have been changed on the box-and-whisker item. -*/ - -/*! \fn void QBoxSet::valueChanged(int index) This signal is emitted values the value in the box-and-whisker item has been modified. Parameter \a index indicates the position of the modified value. \sa at() */ /*! - \qmlsignal BoxSet::onChangedValue(int index) - This signal is emitted values the value in the box-and-whisker item has been modified. - Parameter \a index indicates the position of the modified value. -*/ - -/*! \fn void QBoxSet::cleared() This signal is emitted when all the values on the set are cleared to 0. */ -/*! - \qmlsignal BoxSet::onCleared() - This signal is emitted when all the values on the set are cleared to 0. -*/ - /*! Constructs QBoxSet with optional \a label and parent of \a parent diff --git a/tests/boxplottester/mainwidget.cpp b/tests/boxplottester/mainwidget.cpp index 251f756..8dca595 100644 --- a/tests/boxplottester/mainwidget.cpp +++ b/tests/boxplottester/mainwidget.cpp @@ -193,6 +193,10 @@ void MainWidget::initCheckboxes(QGridLayout *grid) modelMapperCheckBox->setChecked(false); grid->addWidget(modelMapperCheckBox, m_rowPos++, 0); + m_boxOutlined = new QCheckBox("Box outlined"); + connect(m_boxOutlined, SIGNAL(toggled(bool)), this, SLOT(boxOutlineToggled(bool))); + m_boxOutlined->setChecked(true); + grid->addWidget(m_boxOutlined, m_rowPos++, 0); } void MainWidget::updateAxis(int categoryCount) @@ -244,6 +248,8 @@ void MainWidget::addSeries() connect(set1, SIGNAL(clicked()), this, SLOT(singleBoxClicked())); connect(set2, SIGNAL(hovered(bool)), this, SLOT(singleBoxHovered(bool))); + m_series[m_seriesCount]->setBoxOutlineVisible(m_boxOutlined->checkState()); + m_chart->addSeries(m_series[m_seriesCount]); updateAxis(m_series[0]->count()); @@ -383,6 +389,13 @@ void MainWidget::antialiasingToggled(bool enabled) m_chartView->setRenderHint(QPainter::Antialiasing, enabled); } +void MainWidget::boxOutlineToggled(bool visible) +{ + qDebug() << "BoxPlotTester::boxOutlineToggled toggled to " << visible; + for (int i = 0; i < m_seriesCount; i++) + m_series[i]->setBoxOutlineVisible(visible); +} + void MainWidget::modelMapperToggled(bool enabled) { if (enabled) { @@ -445,5 +458,4 @@ void MainWidget::changePen() qDebug() << "changePen() = " << m_penTool->pen(); for (int i = 0; i < m_seriesCount; i++) m_series[i]->setPen(m_penTool->pen()); - } diff --git a/tests/boxplottester/mainwidget.h b/tests/boxplottester/mainwidget.h index c6e293c..d1b7246 100644 --- a/tests/boxplottester/mainwidget.h +++ b/tests/boxplottester/mainwidget.h @@ -30,6 +30,7 @@ #include #include #include +#include class QGridLayout; @@ -68,6 +69,7 @@ private slots: void singleBoxHovered(bool state); void changePen(); void antialiasingToggled(bool); + void boxOutlineToggled(bool); private: QChart *m_chart; @@ -79,6 +81,7 @@ private: int m_rowPos; int m_seriesCount; QBoxPlotSeries *m_series[10]; + QCheckBox *m_boxOutlined; }; #endif // MAINWIDGET_H