summaryrefslogtreecommitdiffstats
path: root/tests/surfacetest/graphmodifier.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-09-25 15:04:44 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-09-26 10:06:52 +0300
commit0ab45b018fa98e9ef6cffd70178f208eb4f16550 (patch)
tree77d324f47ccb52cc543df9e8990153b82ead2688 /tests/surfacetest/graphmodifier.cpp
parent36bc54f5720bddb9899e64d665117ac1e1b5bc94 (diff)
Implement zooming to cursor
Zooming to cursor is now default operating mode of the default input handler. Task-number: QTRD-3263 Change-Id: I5699fc0ce7393059538972cd52f31f06d87e3d8d Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'tests/surfacetest/graphmodifier.cpp')
-rw-r--r--tests/surfacetest/graphmodifier.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/surfacetest/graphmodifier.cpp b/tests/surfacetest/graphmodifier.cpp
index a22ede2b..1a069cf4 100644
--- a/tests/surfacetest/graphmodifier.cpp
+++ b/tests/surfacetest/graphmodifier.cpp
@@ -21,18 +21,21 @@
#include <QtDataVisualization/QSurfaceDataProxy>
#include <QtDataVisualization/QSurface3DSeries>
#include <QtDataVisualization/Q3DTheme>
+#include <QtDataVisualization/Q3DInputHandler>
#include <qmath.h>
#include <QLinearGradient>
#include <QDebug>
#include <QComboBox>
-
+#ifndef QT_NO_CURSOR
+#include <QtGui/QCursor>
+#endif
using namespace QtDataVisualization;
//#define JITTER_PLANE
//#define WONKY_PLANE
-GraphModifier::GraphModifier(Q3DSurface *graph)
+GraphModifier::GraphModifier(Q3DSurface *graph, QWidget *parentWidget)
: m_graph(graph),
m_series1(new QSurface3DSeries),
m_series2(new QSurface3DSeries),
@@ -63,7 +66,8 @@ GraphModifier::GraphModifier(Q3DSurface *graph)
m_drawMode2(QSurface3DSeries::DrawSurfaceAndWireframe),
m_drawMode3(QSurface3DSeries::DrawSurfaceAndWireframe),
m_drawMode4(QSurface3DSeries::DrawSurfaceAndWireframe),
- m_offset(4.0f)
+ m_offset(4.0f),
+ m_parentWidget(parentWidget)
{
m_graph->setAxisX(new QValue3DAxis);
m_graph->axisX()->setTitle("X-Axis");
@@ -97,6 +101,8 @@ GraphModifier::GraphModifier(Q3DSurface *graph)
m_graph->axisY()->setRange(m_minY, m_minY + m_rangeY);
m_graph->axisZ()->setRange(m_minZ, m_minZ + m_rangeZ);
+ static_cast<Q3DInputHandler *>(m_graph->activeInputHandler())->setZoomAtTargetEnabled(true);
+
for (int i = 0; i < 4; i++) {
m_multiseries[i] = new QSurface3DSeries;
m_multiseries[i]->setName(QStringLiteral("Series %1").arg(i+1));
@@ -109,6 +115,7 @@ GraphModifier::GraphModifier(Q3DSurface *graph)
m_theSeries->setItemLabelFormat(QStringLiteral("@seriesName: (@xLabel, @zLabel): @yLabel"));
connect(&m_timer, &QTimer::timeout, this, &GraphModifier::timeout);
+ connect(&m_graphPositionQueryTimer, &QTimer::timeout, this, &GraphModifier::graphQueryTimeout);
connect(m_theSeries, &QSurface3DSeries::selectedPointChanged, this, &GraphModifier::selectedPointChanged);
QObject::connect(m_graph, &Q3DSurface::axisXChanged, this,
@@ -119,6 +126,8 @@ GraphModifier::GraphModifier(Q3DSurface *graph)
&GraphModifier::handleAxisZChanged);
QObject::connect(m_graph, &QAbstract3DGraph::currentFpsChanged, this,
&GraphModifier::handleFpsChange);
+
+ //m_graphPositionQueryTimer.start(100);
}
GraphModifier::~GraphModifier()
@@ -691,6 +700,16 @@ void GraphModifier::timeout()
m_theSeries->dataProxy()->resetArray(m_planeArray);
}
+void GraphModifier::graphQueryTimeout()
+{
+#ifndef QT_NO_CURSOR
+ m_graph->scene()->setGraphPositionQuery(m_parentWidget->mapFromGlobal(QCursor::pos()));
+ qDebug() << "pos: " << (m_parentWidget->mapFromGlobal(QCursor::pos()));
+#else
+ m_graph->scene()->setGraphPositionQuery(QPoint(100, 100));
+#endif
+}
+
void GraphModifier::handleAxisXChanged(QValue3DAxis *axis)
{
qDebug() << __FUNCTION__ << axis << axis->orientation() << (axis == m_graph->axisX());