mirror of https://github.com/qt/qtdatavis3d.git
Add hasSeries method to Abstract3D graph
Added a hasSeries method to Abstract3Dgraph. The method can be used to check whether a series has already been added to the graph. In addition, modified cpp and qml autotests to test the added method. Fixes: QTBUG-96683 Change-Id: I91f70ca15b6c5fbaa7691cd17bbfc2ef460c3d37 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
5502d8116f
commit
333cf89735
|
@ -189,6 +189,12 @@
|
|||
* Clears selection from all attached series.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlmethod bool AbstractGraph3D::hasSeries(Abstract3DSeries series)
|
||||
* \since 6.3
|
||||
* Returns whether the \a series has already been added to the graph.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlmethod int AbstractGraph3D::addCustomItem(Custom3DItem item)
|
||||
*
|
||||
|
|
|
@ -164,11 +164,13 @@
|
|||
* generate the row or column labels on the axes in cases where the labels are not explicitly set
|
||||
* to the axes. If the newly added series has specified a selected bar, it will be highlighted and
|
||||
* any existing selection will be cleared. Only one added series can have an active selection.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlmethod void Bars3D::removeSeries(Bar3DSeries series)
|
||||
* Remove the \a series from the graph.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -179,4 +181,5 @@
|
|||
* \note When moving a series to a new \a index that is after its old index,
|
||||
* the new position in list is calculated as if the series was still in its old
|
||||
* index, so the final index is actually the \a index decremented by one.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
|
|
@ -97,9 +97,11 @@
|
|||
* Adds the \a series to the graph. A graph can contain multiple series, but has only one set of
|
||||
* axes. If the newly added series has specified a selected item, it will be highlighted and
|
||||
* any existing selection will be cleared. Only one added series can have an active selection.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlmethod void Scatter3D::removeSeries(Scatter3DSeries series)
|
||||
* Remove the \a series from the graph.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
|
|
@ -108,9 +108,11 @@
|
|||
/*!
|
||||
* \qmlmethod void Surface3D::addSeries(Surface3DSeries series)
|
||||
* Adds the \a series to the graph.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \qmlmethod void Surface3D::removeSeries(Surface3DSeries series)
|
||||
* Removes the \a series from the graph.
|
||||
* \sa AbstractGraph3D::hasSeries()
|
||||
*/
|
||||
|
|
|
@ -179,6 +179,11 @@ void Abstract3DController::removeSeries(QAbstract3DSeries *series)
|
|||
}
|
||||
}
|
||||
|
||||
bool Abstract3DController::hasSeries(QAbstract3DSeries *series)
|
||||
{
|
||||
return m_seriesList.contains(series);
|
||||
}
|
||||
|
||||
QList<QAbstract3DSeries *> Abstract3DController::seriesList()
|
||||
{
|
||||
return m_seriesList;
|
||||
|
|
|
@ -243,6 +243,7 @@ public:
|
|||
virtual void addSeries(QAbstract3DSeries *series);
|
||||
virtual void insertSeries(int index, QAbstract3DSeries *series);
|
||||
virtual void removeSeries(QAbstract3DSeries *series);
|
||||
virtual bool hasSeries(QAbstract3DSeries *series);
|
||||
QList<QAbstract3DSeries *> seriesList();
|
||||
|
||||
virtual void setAxisX(QAbstract3DAxis *axis);
|
||||
|
|
|
@ -157,7 +157,7 @@ QBar3DSeries *Q3DBars::primarySeries() const
|
|||
* to the axes. If the newly added series has specified a selected bar, it will be highlighted and
|
||||
* any existing selection will be cleared. Only one added series can have an active selection.
|
||||
*
|
||||
* \sa seriesList(), primarySeries
|
||||
* \sa seriesList(), primarySeries, QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DBars::addSeries(QBar3DSeries *series)
|
||||
{
|
||||
|
@ -166,6 +166,8 @@ void Q3DBars::addSeries(QBar3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Removes the \a series from the graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DBars::removeSeries(QBar3DSeries *series)
|
||||
{
|
||||
|
@ -180,7 +182,7 @@ void Q3DBars::removeSeries(QBar3DSeries *series)
|
|||
* the new position in list is calculated as if the series was still in its old
|
||||
* index, so the final index is actually the \a index decremented by one.
|
||||
*
|
||||
* \sa addSeries(), seriesList()
|
||||
* \sa addSeries(), seriesList(), QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DBars::insertSeries(int index, QBar3DSeries *series)
|
||||
{
|
||||
|
@ -189,6 +191,8 @@ void Q3DBars::insertSeries(int index, QBar3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Returns the list of series added to this graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
QList<QBar3DSeries *> Q3DBars::seriesList() const
|
||||
{
|
||||
|
|
|
@ -110,6 +110,8 @@ Q3DScatter::~Q3DScatter()
|
|||
* Adds the \a series to the graph. A graph can contain multiple series, but has only one set of
|
||||
* axes. If the newly added series has specified a selected item, it will be highlighted and
|
||||
* any existing selection will be cleared. Only one added series can have an active selection.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DScatter::addSeries(QScatter3DSeries *series)
|
||||
{
|
||||
|
@ -118,6 +120,8 @@ void Q3DScatter::addSeries(QScatter3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Removes the \a series from the graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DScatter::removeSeries(QScatter3DSeries *series)
|
||||
{
|
||||
|
@ -126,6 +130,8 @@ void Q3DScatter::removeSeries(QScatter3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Returns the list of series added to this graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
QList<QScatter3DSeries *> Q3DScatter::seriesList() const
|
||||
{
|
||||
|
|
|
@ -127,6 +127,8 @@ Q3DSurface::~Q3DSurface()
|
|||
* Adds the \a series to the graph. A graph can contain multiple series, but has only one set of
|
||||
* axes. If the newly added series has specified a selected item, it will be highlighted and
|
||||
* any existing selection will be cleared. Only one added series can have an active selection.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DSurface::addSeries(QSurface3DSeries *series)
|
||||
{
|
||||
|
@ -135,6 +137,8 @@ void Q3DSurface::addSeries(QSurface3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Removes the \a series from the graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
void Q3DSurface::removeSeries(QSurface3DSeries *series)
|
||||
{
|
||||
|
@ -143,6 +147,8 @@ void Q3DSurface::removeSeries(QSurface3DSeries *series)
|
|||
|
||||
/*!
|
||||
* Returns the list of series added to this graph.
|
||||
*
|
||||
* \sa QAbstract3DGraph::hasSeries()
|
||||
*/
|
||||
QList<QSurface3DSeries *> Q3DSurface::seriesList() const
|
||||
{
|
||||
|
|
|
@ -435,6 +435,16 @@ void QAbstract3DGraph::clearSelection()
|
|||
d_ptr->m_visualController->clearSelection();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns whether the \a series has already been added to the graph.
|
||||
*
|
||||
* \since 6.3
|
||||
*/
|
||||
bool QAbstract3DGraph::hasSeries(QAbstract3DSeries *series)
|
||||
{
|
||||
return d_ptr->m_visualController->hasSeries(series);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Adds a QCustom3DItem \a item to the graph. Graph takes ownership of the added item.
|
||||
*
|
||||
|
|
|
@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
|
|||
class QAbstract3DGraphPrivate;
|
||||
class QCustom3DItem;
|
||||
class QAbstract3DAxis;
|
||||
class QAbstract3DSeries;
|
||||
|
||||
class QT_DATAVISUALIZATION_EXPORT QAbstract3DGraph : public QWindow, protected QOpenGLFunctions
|
||||
{
|
||||
|
@ -141,6 +142,8 @@ public:
|
|||
|
||||
void clearSelection();
|
||||
|
||||
virtual bool hasSeries(QAbstract3DSeries *series);
|
||||
|
||||
int addCustomItem(QCustom3DItem *item);
|
||||
void removeCustomItems();
|
||||
void removeCustomItem(QCustom3DItem *item);
|
||||
|
|
|
@ -185,6 +185,11 @@ void AbstractDeclarative::clearSelection()
|
|||
m_controller->clearSelection();
|
||||
}
|
||||
|
||||
bool AbstractDeclarative::hasSeries(QAbstract3DSeries *series)
|
||||
{
|
||||
return m_controller->hasSeries(series);
|
||||
}
|
||||
|
||||
void AbstractDeclarative::setSelectionMode(SelectionFlags mode)
|
||||
{
|
||||
int intmode = int(mode);
|
||||
|
|
|
@ -168,6 +168,8 @@ public:
|
|||
|
||||
Q_INVOKABLE virtual void clearSelection();
|
||||
|
||||
Q_REVISION(6, 3) Q_INVOKABLE virtual bool hasSeries(QAbstract3DSeries *series);
|
||||
|
||||
Q_REVISION(1, 1) Q_INVOKABLE virtual int addCustomItem(QCustom3DItem *item);
|
||||
Q_REVISION(1, 1) Q_INVOKABLE virtual void removeCustomItems();
|
||||
Q_REVISION(1, 1) Q_INVOKABLE virtual void removeCustomItem(QCustom3DItem *item);
|
||||
|
|
|
@ -57,6 +57,7 @@ private slots:
|
|||
void selectSeries();
|
||||
void removeSeries();
|
||||
void removeMultipleSeries();
|
||||
void hasSeries();
|
||||
|
||||
// The following tests are not required for scatter or surface, as they are handled identically
|
||||
void addInputHandler();
|
||||
|
@ -300,6 +301,15 @@ void tst_bars::removeMultipleSeries()
|
|||
delete series3;
|
||||
}
|
||||
|
||||
void tst_bars::hasSeries()
|
||||
{
|
||||
QBar3DSeries *series1 = newSeries();
|
||||
m_graph->addSeries(series1);
|
||||
QCOMPARE(m_graph->hasSeries(series1), true);
|
||||
QBar3DSeries *series2 = newSeries();
|
||||
QCOMPARE(m_graph->hasSeries(series2), false);
|
||||
}
|
||||
|
||||
// The following tests are not required for scatter or surface, as they are handled identically
|
||||
void tst_bars::addInputHandler()
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ private slots:
|
|||
void selectSeries();
|
||||
void removeSeries();
|
||||
void removeMultipleSeries();
|
||||
void hasSeries();
|
||||
|
||||
private:
|
||||
Q3DScatter *m_graph;
|
||||
|
@ -253,5 +254,14 @@ void tst_scatter::removeMultipleSeries()
|
|||
delete series3;
|
||||
}
|
||||
|
||||
void tst_scatter::hasSeries()
|
||||
{
|
||||
QScatter3DSeries *series1 = newSeries();
|
||||
m_graph->addSeries(series1);
|
||||
QCOMPARE(m_graph->hasSeries(series1), true);
|
||||
QScatter3DSeries *series2 = newSeries();
|
||||
QCOMPARE(m_graph->hasSeries(series2), false);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_scatter)
|
||||
#include "tst_scatter.moc"
|
||||
|
|
|
@ -54,6 +54,7 @@ private slots:
|
|||
void selectSeries();
|
||||
void removeSeries();
|
||||
void removeMultipleSeries();
|
||||
void hasSeries();
|
||||
|
||||
private:
|
||||
Q3DSurface *m_graph;
|
||||
|
@ -263,5 +264,14 @@ void tst_surface::removeMultipleSeries()
|
|||
delete series3;
|
||||
}
|
||||
|
||||
void tst_surface::hasSeries()
|
||||
{
|
||||
QSurface3DSeries *series1 = newSeries();
|
||||
m_graph->addSeries(series1);
|
||||
QCOMPARE(m_graph->hasSeries(series1), true);
|
||||
QSurface3DSeries *series2 = newSeries();
|
||||
QCOMPARE(m_graph->hasSeries(series2), false);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_surface)
|
||||
#include "tst_surface.moc"
|
||||
|
|
|
@ -88,6 +88,14 @@ Item {
|
|||
bars3d.seriesList[0].selectedBar = Qt.point(0, 0)
|
||||
compare(bars3d.selectedSeries, series1)
|
||||
|
||||
waitForRendering(top)
|
||||
}
|
||||
|
||||
function test_6_has_series() {
|
||||
bars3d.seriesList = [series1]
|
||||
compare(bars3d.hasSeries(series1), true)
|
||||
compare(bars3d.hasSeries(series2), false)
|
||||
|
||||
waitForRendering(top)
|
||||
bars3d.destroy()
|
||||
waitForRendering(top)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtDataVisualization 1.2
|
||||
import QtDataVisualization
|
||||
import QtTest 1.0
|
||||
|
||||
Item {
|
||||
|
@ -67,5 +67,11 @@ Item {
|
|||
series.seriesList[0].selectedItem = 0
|
||||
compare(series.selectedSeries, series1)
|
||||
}
|
||||
|
||||
function test_5_has_series() {
|
||||
series.seriesList = [series1]
|
||||
compare(series.hasSeries(series1), true)
|
||||
compare(series.hasSeries(series2), false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtDataVisualization 1.2
|
||||
import QtDataVisualization
|
||||
import QtTest 1.0
|
||||
|
||||
Item {
|
||||
|
@ -67,5 +67,11 @@ Item {
|
|||
series.seriesList[0].selectedPoint = Qt.point(0, 0)
|
||||
compare(series.selectedSeries, series1)
|
||||
}
|
||||
|
||||
function test_5_has_series() {
|
||||
series.seriesList = [series1]
|
||||
compare(series.hasSeries(series1), true)
|
||||
compare(series.hasSeries(series2), false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue