summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-08-15 13:30:17 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-08-15 13:40:28 +0300
commitaa1f1539b73edc06dafd9fd157070bbfaf2a2ef6 (patch)
treef7f96a73d7faa35824844a7187c226f7db59ea27 /src
parentcf0b67d06249ad2472e2a5ea4de0918079dff7eb (diff)
Moved functions from specific controllers to abstract controller
Change-Id: Ib610d313d0708d8bb894e99004ace1530a83d1f7 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavis3d/engine/abstract3dcontroller.cpp125
-rw-r--r--src/datavis3d/engine/abstract3dcontroller_p.h41
-rw-r--r--src/datavis3d/engine/abstract3drenderer.cpp20
-rw-r--r--src/datavis3d/engine/abstract3drenderer_p.h8
-rw-r--r--src/datavis3d/engine/bars3dcontroller.cpp143
-rw-r--r--src/datavis3d/engine/bars3dcontroller_p.h56
-rw-r--r--src/datavis3d/engine/bars3drenderer.cpp24
-rw-r--r--src/datavis3d/engine/bars3drenderer_p.h5
-rw-r--r--src/datavis3d/engine/scatter3dcontroller.cpp108
-rw-r--r--src/datavis3d/engine/scatter3dcontroller_p.h57
-rw-r--r--src/datavis3d/engine/scatter3drenderer.cpp27
-rw-r--r--src/datavis3d/engine/scatter3drenderer_p.h6
-rw-r--r--src/datavis3dqml2/declarativebars.cpp10
-rw-r--r--src/datavis3dqml2/declarativescatter.cpp10
14 files changed, 256 insertions, 384 deletions
diff --git a/src/datavis3d/engine/abstract3dcontroller.cpp b/src/datavis3d/engine/abstract3dcontroller.cpp
index 83d89051..3c34f797 100644
--- a/src/datavis3d/engine/abstract3dcontroller.cpp
+++ b/src/datavis3d/engine/abstract3dcontroller.cpp
@@ -31,8 +31,11 @@ Abstract3DController::Abstract3DController(QRect boundRect, QObject *parent) :
m_verticalRotation(15.0f),
m_theme(),
m_font(QFont(QStringLiteral("Arial"))),
+ m_selectionMode(QDataVis::ModeItem),
m_shadowQuality(QDataVis::ShadowLow),
m_labelTransparency(QDataVis::TransparencyFromTheme),
+ m_isBackgroundEnabled(true),
+ m_isGridEnabled(true),
m_cameraHelper(new CameraHelper()),
m_zoomLevel(100),
m_axisX(0),
@@ -94,47 +97,67 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.shadowQualityChanged = false;
}
+ if (m_changeTracker.selectionModeChanged) {
+ m_renderer->updateSelectionMode(m_selectionMode);
+ m_changeTracker.selectionModeChanged = false;
+ }
+
+ if (m_changeTracker.objFileChanged) {
+ m_renderer->updateMeshFileName(m_objFile);
+ m_changeTracker.objFileChanged = false;
+ }
+
+ if (m_changeTracker.gridEnabledChanged) {
+ m_renderer->updateGridEnabled(m_isGridEnabled);
+ m_changeTracker.gridEnabledChanged = false;
+ }
+
+ if (m_changeTracker.backgroundEnabledChanged) {
+ m_renderer->updateBackgroundEnabled(m_isBackgroundEnabled);
+ m_changeTracker.backgroundEnabledChanged = false;
+ }
+
if (m_changeTracker.axisXTypeChanged) {
- m_renderer->updateAxisType(QAbstractAxis::AxisOrientation::AxisOrientationX, m_axisX->type());
+ m_renderer->updateAxisType(QAbstractAxis::AxisOrientationX, m_axisX->type());
m_changeTracker.axisXTypeChanged = false;
}
if (m_changeTracker.axisYTypeChanged) {
- m_renderer->updateAxisType(QAbstractAxis::AxisOrientation::AxisOrientationY, m_axisY->type());
+ m_renderer->updateAxisType(QAbstractAxis::AxisOrientationY, m_axisY->type());
m_changeTracker.axisYTypeChanged = false;
}
if (m_changeTracker.axisZTypeChanged) {
- m_renderer->updateAxisType(QAbstractAxis::AxisOrientation::AxisOrientationZ, m_axisZ->type());
+ m_renderer->updateAxisType(QAbstractAxis::AxisOrientationZ, m_axisZ->type());
m_changeTracker.axisZTypeChanged = false;
}
if (m_changeTracker.axisXTitleChanged) {
- m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientation::AxisOrientationX, m_axisX->title());
+ m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientationX, m_axisX->title());
m_changeTracker.axisXTitleChanged = false;
}
if (m_changeTracker.axisYTitleChanged) {
- m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientation::AxisOrientationY, m_axisY->title());
+ m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientationY, m_axisY->title());
m_changeTracker.axisYTitleChanged = false;
}
if (m_changeTracker.axisZTitleChanged) {
- m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientation::AxisOrientationZ, m_axisZ->title());
+ m_renderer->updateAxisTitle(QAbstractAxis::AxisOrientationZ, m_axisZ->title());
m_changeTracker.axisZTitleChanged = false;
}
if (m_changeTracker.axisXLabelsChanged) {
- m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientation::AxisOrientationX, m_axisX->labels());
+ m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientationX, m_axisX->labels());
m_changeTracker.axisXLabelsChanged = false;
}
if (m_changeTracker.axisYLabelsChanged) {
- m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientation::AxisOrientationY, m_axisY->labels());
+ m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientationY, m_axisY->labels());
m_changeTracker.axisYLabelsChanged = false;
}
if (m_changeTracker.axisZLabelsChanged) {
- m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientation::AxisOrientationZ, m_axisZ->labels());
+ m_renderer->updateAxisLabels(QAbstractAxis::AxisOrientationZ, m_axisZ->labels());
m_changeTracker.axisZLabelsChanged = false;
}
@@ -142,7 +165,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisXRangeChanged = false;
if (m_axisX->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisX = static_cast<QValueAxis *>(m_axisX);
- m_renderer->updateAxisRange(QAbstractAxis::AxisOrientation::AxisOrientationX, valueAxisX->min(), valueAxisX->max());
+ m_renderer->updateAxisRange(QAbstractAxis::AxisOrientationX,
+ valueAxisX->min(), valueAxisX->max());
}
}
@@ -150,7 +174,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisYRangeChanged = false;
if (m_axisY->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisY = static_cast<QValueAxis *>(m_axisY);
- m_renderer->updateAxisRange(QAbstractAxis::AxisOrientation::AxisOrientationY, valueAxisY->min(), valueAxisY->max());
+ m_renderer->updateAxisRange(QAbstractAxis::AxisOrientationY,
+ valueAxisY->min(), valueAxisY->max());
}
}
@@ -158,7 +183,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisZRangeChanged = false;
if (m_axisZ->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisZ = static_cast<QValueAxis *>(m_axisZ);
- m_renderer->updateAxisRange(QAbstractAxis::AxisOrientation::AxisOrientationZ, valueAxisZ->min(), valueAxisZ->max());
+ m_renderer->updateAxisRange(QAbstractAxis::AxisOrientationZ,
+ valueAxisZ->min(), valueAxisZ->max());
}
}
@@ -166,7 +192,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisXSegmentCountChanged = false;
if (m_axisX->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisX = static_cast<QValueAxis *>(m_axisX);
- m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationX, valueAxisX->segmentCount());
+ m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientationX,
+ valueAxisX->segmentCount());
}
}
@@ -174,7 +201,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisYSegmentCountChanged = false;
if (m_axisY->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisY = static_cast<QValueAxis *>(m_axisY);
- m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationY, valueAxisY->segmentCount());
+ m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientationY,
+ valueAxisY->segmentCount());
}
}
@@ -182,7 +210,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisZSegmentCountChanged = false;
if (m_axisZ->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisZ = static_cast<QValueAxis *>(m_axisZ);
- m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationZ, valueAxisZ->segmentCount());
+ m_renderer->updateAxisSegmentCount(QAbstractAxis::AxisOrientationZ,
+ valueAxisZ->segmentCount());
}
}
@@ -190,7 +219,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisXSubSegmentCountChanged = false;
if (m_axisX->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisX = static_cast<QValueAxis *>(m_axisX);
- m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationX, valueAxisX->subSegmentCount());
+ m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientationX,
+ valueAxisX->subSegmentCount());
}
}
@@ -198,7 +228,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisYSubSegmentCountChanged = false;
if (m_axisY->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisY = static_cast<QValueAxis *>(m_axisY);
- m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationY, valueAxisY->subSegmentCount());
+ m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientationY,
+ valueAxisY->subSegmentCount());
}
}
@@ -206,7 +237,8 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisZSubSegmentCountChanged = false;
if (m_axisZ->type() & QAbstractAxis::AxisTypeValue) {
QValueAxis *valueAxisZ = static_cast<QValueAxis *>(m_axisZ);
- m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientation::AxisOrientationZ, valueAxisZ->subSegmentCount());
+ m_renderer->updateAxisSubSegmentCount(QAbstractAxis::AxisOrientationZ,
+ valueAxisZ->subSegmentCount());
}
}
}
@@ -408,6 +440,17 @@ QFont Abstract3DController::font()
return m_font;
}
+void Abstract3DController::setSelectionMode(QDataVis::SelectionMode mode)
+{
+ m_selectionMode = mode;
+ m_changeTracker.selectionModeChanged = true;
+ emit selectionModeChanged(m_selectionMode);
+}
+
+QDataVis::SelectionMode Abstract3DController::selectionMode()
+{
+ return m_selectionMode;
+}
void Abstract3DController::setShadowQuality(QDataVis::ShadowQuality quality)
{
@@ -422,7 +465,6 @@ QDataVis::ShadowQuality Abstract3DController::shadowQuality()
return m_shadowQuality;
}
-
void Abstract3DController::setLabelTransparency(QDataVis::LabelTransparency transparency)
{
m_labelTransparency = transparency;
@@ -436,6 +478,42 @@ QDataVis::LabelTransparency Abstract3DController::labelTransparency()
return m_labelTransparency;
}
+void Abstract3DController::setBackgroundEnabled(bool enable)
+{
+ m_isBackgroundEnabled = enable;
+ m_changeTracker.backgroundEnabledChanged = true;
+ emit backgroundEnabledChanged(m_isBackgroundEnabled);
+}
+
+bool Abstract3DController::backgroundEnabled()
+{
+ return m_isBackgroundEnabled;
+}
+
+void Abstract3DController::setGridEnabled(bool enable)
+{
+ m_isGridEnabled = enable;
+ m_changeTracker.gridEnabledChanged = true;
+ emit gridEnabledChanged(m_isGridEnabled);
+}
+
+bool Abstract3DController::gridEnabled()
+{
+ return m_isGridEnabled;
+}
+
+void Abstract3DController::setMeshFileName(const QString &fileName)
+{
+ m_objFile = fileName;
+ m_changeTracker.objFileChanged = true;
+ emit meshFileNameChanged(m_objFile);
+}
+
+QString Abstract3DController::meshFileName()
+{
+ return m_objFile;
+}
+
void Abstract3DController::handleAxisTitleChanged(const QString &title)
{
handleAxisTitleChangedBySender(sender(), title);
@@ -570,11 +648,11 @@ void Abstract3DController::setAxisHelper(QAbstractAxis::AxisOrientation orientat
this, &Abstract3DController::handleAxisLabelsChanged);
- if (orientation == QAbstractAxis::AxisOrientation::AxisOrientationX)
+ if (orientation == QAbstractAxis::AxisOrientationX)
m_changeTracker.axisXTypeChanged = true;
- else if (orientation == QAbstractAxis::AxisOrientation::AxisOrientationY)
+ else if (orientation == QAbstractAxis::AxisOrientationY)
m_changeTracker.axisYTypeChanged = true;
- else if (orientation == QAbstractAxis::AxisOrientation::AxisOrientationZ)
+ else if (orientation == QAbstractAxis::AxisOrientationZ)
m_changeTracker.axisZTypeChanged = true;
emit axisTypeChanged(orientation, axis->type());
@@ -604,7 +682,8 @@ void Abstract3DController::setAxisHelper(QAbstractAxis::AxisOrientation orientat
handleAxisSubSegmentCountChangedBySender(valueAxis, valueAxis->subSegmentCount());
emit axisSubSegmentCountChanged(orientation, valueAxis->subSegmentCount());
- handleAxisAutoAdjustRangeChangedInOrientation(valueAxis->orientation(), valueAxis->isAutoAdjustRange());
+ handleAxisAutoAdjustRangeChangedInOrientation(valueAxis->orientation(),
+ valueAxis->isAutoAdjustRange());
}
}
diff --git a/src/datavis3d/engine/abstract3dcontroller_p.h b/src/datavis3d/engine/abstract3dcontroller_p.h
index ed201c66..8f21c97f 100644
--- a/src/datavis3d/engine/abstract3dcontroller_p.h
+++ b/src/datavis3d/engine/abstract3dcontroller_p.h
@@ -52,6 +52,10 @@ struct Abstract3DChangeBitField {
bool boundingRectChanged : 1;
bool sizeChanged : 1;
bool shadowQualityChanged : 1;
+ bool selectionModeChanged : 1;
+ bool objFileChanged : 1;
+ bool gridEnabledChanged : 1;
+ bool backgroundEnabledChanged : 1;
bool axisXTypeChanged : 1;
bool axisYTypeChanged : 1;
bool axisZTypeChanged : 1;
@@ -80,6 +84,10 @@ struct Abstract3DChangeBitField {
boundingRectChanged(true),
sizeChanged(true),
shadowQualityChanged(true),
+ selectionModeChanged(true),
+ objFileChanged(true),
+ gridEnabledChanged(true),
+ backgroundEnabledChanged(true),
axisXTypeChanged(true),
axisYTypeChanged(true),
axisZTypeChanged(true),
@@ -107,6 +115,13 @@ class QT_DATAVIS3D_EXPORT Abstract3DController : public QObject
Q_OBJECT
public:
+ enum SelectionType {
+ SelectionNone = 0,
+ SelectionItem,
+ SelectionRow,
+ SelectionColumn
+ };
+
enum MouseState {
MouseNone = 0,
MouseOnScene,
@@ -123,8 +138,12 @@ private:
GLfloat m_verticalRotation;
Theme m_theme;
QFont m_font;
+ QDataVis::SelectionMode m_selectionMode;
QDataVis::ShadowQuality m_shadowQuality;
QDataVis::LabelTransparency m_labelTransparency;
+ bool m_isBackgroundEnabled;
+ bool m_isGridEnabled;
+ QString m_objFile;
protected:
CameraHelper *m_cameraHelper;
@@ -205,6 +224,9 @@ public:
virtual void setFont(const QFont &font);
virtual QFont font();
+ // Selection mode
+ virtual void setSelectionMode(QDataVis::SelectionMode mode);
+ virtual QDataVis::SelectionMode selectionMode();
// Adjust shadow quality
virtual void setShadowQuality(QDataVis::ShadowQuality quality);
@@ -214,6 +236,18 @@ public:
virtual void setLabelTransparency(QDataVis::LabelTransparency transparency);
virtual QDataVis::LabelTransparency labelTransparency();
+ // Enable or disable background mesh
+ virtual void setBackgroundEnabled(bool enable);
+ virtual bool backgroundEnabled();
+
+ // Enable or disable background grid
+ virtual void setGridEnabled(bool enable);
+ virtual bool gridEnabled();
+
+ // override bar type with own mesh
+ virtual void setMeshFileName(const QString &fileName);
+ virtual QString meshFileName();
+
virtual void handleAxisTitleChangedBySender(QObject *sender, const QString &title);
virtual void handleAxisLabelsChangedBySender(QObject *sender);
virtual void handleAxisRangeChangedBySender(QObject *sender, qreal min, qreal max);
@@ -244,9 +278,14 @@ signals:
void axisRangeChanged(QAbstractAxis::AxisOrientation orientation, qreal min, qreal max);
void axisSegmentCountChanged(QAbstractAxis::AxisOrientation orientation, int count);
void axisSubSegmentCountChanged(QAbstractAxis::AxisOrientation orientation, int count);
+ void selectionModeChanged(QDataVis::SelectionMode mode);
+ void backgroundEnabledChanged(bool enable);
+ void gridEnabledChanged(bool enable); // TODO: Should be handled via axes?
+ void meshFileNameChanged(QString fileName);
private:
- void setAxisHelper(QAbstractAxis::AxisOrientation orientation, QAbstractAxis *axis, QAbstractAxis **axisPtr);
+ void setAxisHelper(QAbstractAxis::AxisOrientation orientation, QAbstractAxis *axis,
+ QAbstractAxis **axisPtr);
};
QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/engine/abstract3drenderer.cpp b/src/datavis3d/engine/abstract3drenderer.cpp
index 2e5d89d4..ffd30990 100644
--- a/src/datavis3d/engine/abstract3drenderer.cpp
+++ b/src/datavis3d/engine/abstract3drenderer.cpp
@@ -115,6 +115,26 @@ void Abstract3DRenderer::updateLabelTransparency(QDataVis::LabelTransparency tra
m_drawer->setTransparency(transparency);
}
+void Abstract3DRenderer::updateMeshFileName(const QString &objFileName)
+{
+ m_cachedObjFile = objFileName;
+}
+
+void Abstract3DRenderer::updateSelectionMode(QDataVis::SelectionMode mode)
+{
+ m_cachedSelectionMode = mode;
+}
+
+void Abstract3DRenderer::updateGridEnabled(bool enable)
+{
+ m_cachedIsGridEnabled = enable;
+}
+
+void Abstract3DRenderer::updateBackgroundEnabled(bool enable)
+{
+ m_cachedIsBackgroundEnabled = enable;
+}
+
void Abstract3DRenderer::handleResize()
{
if (m_cachedBoundingRect.width() == 0 || m_cachedBoundingRect.height() == 0)
diff --git a/src/datavis3d/engine/abstract3drenderer_p.h b/src/datavis3d/engine/abstract3drenderer_p.h
index b19ef101..6464651d 100644
--- a/src/datavis3d/engine/abstract3drenderer_p.h
+++ b/src/datavis3d/engine/abstract3drenderer_p.h
@@ -53,6 +53,10 @@ protected:
Drawer *m_drawer;
GLfloat m_autoScaleAdjustment;
QString m_cachedItemLabelFormat;
+ QString m_cachedObjFile;
+ QDataVis::SelectionMode m_cachedSelectionMode;
+ bool m_cachedIsGridEnabled;
+ bool m_cachedIsBackgroundEnabled;
AxisRenderCache m_axisCacheX;
AxisRenderCache m_axisCacheY;
@@ -71,6 +75,10 @@ public:
virtual void updateTheme(Theme theme);
virtual void updateFont(const QFont &font);
virtual void updateLabelTransparency(QDataVis::LabelTransparency transparency);
+ virtual void updateSelectionMode(QDataVis::SelectionMode newMode);
+ virtual void updateGridEnabled(bool enable);
+ virtual void updateBackgroundEnabled(bool enable);
+ virtual void updateMeshFileName(const QString &objFileName);
virtual void handleShadowQualityChange();
diff --git a/src/datavis3d/engine/bars3dcontroller.cpp b/src/datavis3d/engine/bars3dcontroller.cpp
index 2a6a3a15..72a72ba6 100644
--- a/src/datavis3d/engine/bars3dcontroller.cpp
+++ b/src/datavis3d/engine/bars3dcontroller.cpp
@@ -19,7 +19,6 @@
#include "bars3dcontroller_p.h"
#include "bars3drenderer_p.h"
#include "camerahelper_p.h"
-#include "utils_p.h"
#include "qabstractaxis_p.h"
#include "qvalueaxis_p.h"
#include "qcategoryaxis.h"
@@ -27,8 +26,6 @@
#include <QMatrix4x4>
#include <QMouseEvent>
-#include <QThread>
-#include <QDebug>
#include <qmath.h>
QT_DATAVIS3D_BEGIN_NAMESPACE
@@ -39,14 +36,10 @@ Bars3dController::Bars3dController(QRect boundRect)
m_columnCount(0),
m_mouseState(MouseNone),
m_mousePos(QPoint(0, 0)),
- m_selectionMode(QDataVis::ModeItem),
m_isSlicingActivated(false),
m_isBarSpecRelative(true),
m_barThickness(QSizeF(0.75f, 0.75f)),
m_barSpacing(m_barThickness * 3.0f),
- m_objFile(QStringLiteral(":/defaultMeshes/bar")),
- m_isGridEnabled(true),
- m_isBackgroundEnabled(true),
m_renderer(0),
m_data(0)
{
@@ -55,6 +48,8 @@ Bars3dController::Bars3dController(QRect boundRect)
setAxisY(new QValueAxis());
setAxisZ(new QCategoryAxis());
+ setBarType(QDataVis::Bars, false); // default object type
+
setDataProxy(new QBarDataProxy);
}
@@ -81,11 +76,6 @@ void Bars3dController::synchDataToRenderer()
return;
// Notify changes to renderer
- if (m_changeTracker.selectionModeChanged) {
- m_renderer->updateSelectionMode(m_selectionMode);
- m_changeTracker.selectionModeChanged = false;
- }
-
if (m_changeTracker.slicingActiveChanged) {
m_renderer->updateSlicingActive(m_isSlicingActivated);
m_changeTracker.slicingActiveChanged = false;
@@ -101,21 +91,6 @@ void Bars3dController::synchDataToRenderer()
m_changeTracker.barSpecsChanged = false;
}
- if (m_changeTracker.objFileChanged) {
- m_renderer->updateMeshFileName(m_objFile);
- m_changeTracker.objFileChanged = false;
- }
-
- if (m_changeTracker.gridEnabledChanged) {
- m_renderer->updateGridEnabled(m_isGridEnabled);
- m_changeTracker.gridEnabledChanged = false;
- }
-
- if (m_changeTracker.backgroundEnabledChanged) {
- m_renderer->updateBackgroundEnabled(m_isBackgroundEnabled);
- m_changeTracker.backgroundEnabledChanged = false;
- }
-
if (m_changeTracker.zoomLevelChanged) {
m_renderer->updateZoomLevel(m_zoomLevel);
m_changeTracker.zoomLevelChanged = false;
@@ -127,7 +102,8 @@ void Bars3dController::synchDataToRenderer()
}
}
-QMatrix4x4 Bars3dController::calculateViewMatrix(int zoom, int viewPortWidth, int viewPortHeight, bool showUnder)
+QMatrix4x4 Bars3dController::calculateViewMatrix(int zoom, int viewPortWidth,
+ int viewPortHeight, bool showUnder)
{
return m_cameraHelper->calculateViewMatrix(m_mousePos,
zoom,
@@ -201,8 +177,8 @@ void Bars3dController::mousePressEvent(QMouseEvent *event, const QPoint &mousePo
QRect mainViewPort = m_renderer->mainViewPort();
if (Qt::LeftButton == event->button()) {
if (m_isSlicingActivated) {
- if (event->pos().x() <= mainViewPort.width()
- && event->pos().y() <= mainViewPort.height()) {
+ if (mousePos.x() <= mainViewPort.width()
+ && mousePos.y() <= mainViewPort.height()) {
m_mouseState = Bars3dController::MouseOnOverview;
//qDebug() << "Mouse pressed on overview";
} else {
@@ -216,7 +192,7 @@ void Bars3dController::mousePressEvent(QMouseEvent *event, const QPoint &mousePo
m_mouseState = Bars3dController::MouseRotating;
#endif
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = event->pos();
+ m_mousePos = mousePos;
//qDebug() << "Mouse pressed on scene";
}
} else if (Qt::MiddleButton == event->button()) {
@@ -230,7 +206,7 @@ void Bars3dController::mousePressEvent(QMouseEvent *event, const QPoint &mousePo
m_mouseState = Bars3dController::MouseOnScene;
#endif
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = mousePos; //event->pos();
+ m_mousePos = mousePos;
}
m_cameraHelper->updateMousePos(m_mousePos);
}
@@ -240,8 +216,8 @@ void Bars3dController::mouseReleaseEvent(QMouseEvent *event, const QPoint &mouse
Q_UNUSED(event);
if (Bars3dController::MouseRotating == m_mouseState) {
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = mousePos; //event->pos();
- m_cameraHelper->updateMousePos(mousePos); //event->pos());
+ m_mousePos = mousePos;
+ m_cameraHelper->updateMousePos(mousePos);
}
m_mouseState = Bars3dController::MouseNone;
}
@@ -250,7 +226,7 @@ void Bars3dController::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos
{
Q_UNUSED(event);
if (Bars3dController::MouseRotating == m_mouseState)
- m_mousePos = mousePos; //event->pos();
+ m_mousePos = mousePos;
}
void Bars3dController::wheelEvent(QWheelEvent *event)
@@ -279,12 +255,18 @@ void Bars3dController::setDataProxy(QBarDataProxy *proxy)
delete m_data;
m_data = proxy;
- QObject::connect(m_data, &QBarDataProxy::arrayReset, this, &Bars3dController::handleArrayReset);
- QObject::connect(m_data, &QBarDataProxy::rowsAdded, this, &Bars3dController::handleRowsAdded);
- QObject::connect(m_data, &QBarDataProxy::rowsChanged, this, &Bars3dController::handleRowsChanged);
- QObject::connect(m_data, &QBarDataProxy::rowsRemoved, this, &Bars3dController::handleRowsRemoved);
- QObject::connect(m_data, &QBarDataProxy::rowsInserted, this, &Bars3dController::handleRowsInserted);
- QObject::connect(m_data, &QBarDataProxy::itemChanged, this, &Bars3dController::handleItemChanged);
+ QObject::connect(m_data, &QBarDataProxy::arrayReset, this,
+ &Bars3dController::handleArrayReset);
+ QObject::connect(m_data, &QBarDataProxy::rowsAdded, this,
+ &Bars3dController::handleRowsAdded);
+ QObject::connect(m_data, &QBarDataProxy::rowsChanged, this,
+ &Bars3dController::handleRowsChanged);
+ QObject::connect(m_data, &QBarDataProxy::rowsRemoved, this,
+ &Bars3dController::handleRowsRemoved);
+ QObject::connect(m_data, &QBarDataProxy::rowsInserted, this,
+ &Bars3dController::handleRowsInserted);
+ QObject::connect(m_data, &QBarDataProxy::itemChanged, this,
+ &Bars3dController::handleItemChanged);
adjustValueAxisRange();
m_isDataDirty = true;
@@ -389,51 +371,36 @@ bool Bars3dController::isBarSpecRelative()
return m_isBarSpecRelative;
}
-QString Bars3dController::objFile()
-{
- return m_objFile;
-}
-
void Bars3dController::setBarType(QDataVis::MeshStyle style, bool smooth)
{
+ QString objFile;
if (style == QDataVis::Bars) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/barSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/barSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/bar");
+ objFile = QStringLiteral(":/defaultMeshes/bar");
} else if (style == QDataVis::Pyramids) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/pyramidSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/pyramidSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/pyramid");
+ objFile = QStringLiteral(":/defaultMeshes/pyramid");
} else if (style == QDataVis::Cones) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/coneSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/coneSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/cone");
+ objFile = QStringLiteral(":/defaultMeshes/cone");
} else if (style == QDataVis::Cylinders) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/cylinderSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/cylinderSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/cylinder");
+ objFile = QStringLiteral(":/defaultMeshes/cylinder");
} else if (style == QDataVis::BevelBars) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/bevelbarSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/bevelbarSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/bevelbar");
+ objFile = QStringLiteral(":/defaultMeshes/bevelbar");
}
-
-
- m_changeTracker.objFileChanged = true;
- emit objFileChanged(m_objFile);
-}
-
-void Bars3dController::setMeshFileName(const QString &objFileName)
-{
- m_objFile = objFileName;
-
- m_changeTracker.objFileChanged = true;
- emit objFileChanged(m_objFile);
+ Abstract3DController::setMeshFileName(objFile);
}
// TODO: This sets data window. Needs more parameters, now assumes window always starts at 0,0.
@@ -451,15 +418,11 @@ void Bars3dController::setupSampleSpace(int rowCount, int columnCount)
emit sampleSpaceChanged(rowCount, columnCount);
}
-
void Bars3dController::setSelectionMode(QDataVis::SelectionMode mode)
{
- m_selectionMode = mode;
// Disable zoom if selection mode changes
setSlicingActive(false);
-
- m_changeTracker.selectionModeChanged = true;
- emit selectionModeChanged(m_selectionMode);
+ Abstract3DController::setSelectionMode(mode);
}
QPoint Bars3dController::mousePosition()
@@ -467,37 +430,6 @@ QPoint Bars3dController::mousePosition()
return m_mousePos;
}
-QDataVis::SelectionMode Bars3dController::selectionMode()
-{
- return m_selectionMode;
-}
-
-void Bars3dController::setGridEnabled(bool enable)
-{
- m_isGridEnabled = enable;
-
- m_changeTracker.gridEnabledChanged = true;
- emit gridEnabledChanged(m_isGridEnabled);
-}
-
-bool Bars3dController::gridEnabled()
-{
- return m_isGridEnabled;
-}
-
-void Bars3dController::setBackgroundEnabled(bool enable)
-{
- m_isBackgroundEnabled = enable;
-
- m_changeTracker.backgroundEnabledChanged = true;
- emit backgroundEnabledChanged(m_isBackgroundEnabled);
-}
-
-bool Bars3dController::backgroundEnabled()
-{
- return m_isBackgroundEnabled;
-}
-
int Bars3dController::columnCount()
{
return m_columnCount;
@@ -512,7 +444,8 @@ void Bars3dController::adjustValueAxisRange()
{
QValueAxis *valueAxis = static_cast<QValueAxis *>(m_axisY);
if (valueAxis && valueAxis->isAutoAdjustRange() && m_data) {
- QPair<GLfloat, GLfloat> limits = m_data->dptr()->limitValues(0, m_rowCount, 0, m_columnCount);
+ QPair<GLfloat, GLfloat> limits = m_data->dptr()->limitValues(0, m_rowCount,
+ 0, m_columnCount);
if (limits.first < 0) {
// TODO: Currently we only support symmetric y-axis for bar chart if there are negative values
qreal maxAbs = qMax(qFabs(limits.first), qFabs(limits.second));
diff --git a/src/datavis3d/engine/bars3dcontroller_p.h b/src/datavis3d/engine/bars3dcontroller_p.h
index 4f6523f0..5950d8cb 100644
--- a/src/datavis3d/engine/bars3dcontroller_p.h
+++ b/src/datavis3d/engine/bars3dcontroller_p.h
@@ -29,42 +29,26 @@
#ifndef Q3DBARSCONTROLLER_p_H
#define Q3DBARSCONTROLLER_p_H
-#include <QtCore/QSize>
-#include <QtCore/QObject>
-#include <QWindow>
-
-#include "abstract3dcontroller_p.h"
#include "datavis3dglobal_p.h"
+#include "abstract3dcontroller_p.h"
//#define DISPLAY_RENDER_SPEED
-class QPoint;
-class QSizeF;
-
QT_DATAVIS3D_BEGIN_NAMESPACE
class Bars3dRenderer;
-class LabelItem;
class QBarDataProxy;
struct Bars3DChangeBitField {
- bool selectionModeChanged : 1;
bool slicingActiveChanged : 1;
bool sampleSpaceChanged : 1;
bool barSpecsChanged : 1;
- bool objFileChanged : 1;
- bool gridEnabledChanged : 1;
- bool backgroundEnabledChanged : 1;
bool zoomLevelChanged : 1;
Bars3DChangeBitField() :
- selectionModeChanged(true),
slicingActiveChanged(true),
sampleSpaceChanged(true),
barSpecsChanged(true),
- objFileChanged(true),
- gridEnabledChanged(true),
- backgroundEnabledChanged(true),
zoomLevelChanged(true)
{
}
@@ -74,14 +58,6 @@ class QT_DATAVIS3D_EXPORT Bars3dController : public Abstract3DController
{
Q_OBJECT
-public:
- enum SelectionType {
- SelectionNone = 0,
- SelectionBar,
- SelectionRow,
- SelectionColumn
- };
-
private:
@@ -94,18 +70,14 @@ private:
// Interaction
MouseState m_mouseState;
QPoint m_mousePos;
- QDataVis::SelectionMode m_selectionMode;
bool m_isSlicingActivated;
+ // Look'n'feel
bool m_isBarSpecRelative;
QSizeF m_barThickness;
QSizeF m_barSpacing;
- // Look'n'Feel
- QString m_objFile;
- bool m_isGridEnabled;
- bool m_isBackgroundEnabled;
-
+ // Rendering
Bars3dRenderer *m_renderer;
QBarDataProxy *m_data;
@@ -139,28 +111,12 @@ public:
// bar type; bars (=cubes), pyramids, cones, cylinders, etc.
void setBarType(QDataVis::MeshStyle style, bool smooth = false);
- QString objFile();
-
- // override bar type with own mesh
- void setMeshFileName(const QString &objFileName);
// how many samples per row and column, and names for axes
void setupSampleSpace(int samplesRow, int samplesColumn);
- // TODO: light placement API
-
// Change selection mode; single bar, bar and row, bar and column, or all
void setSelectionMode(QDataVis::SelectionMode mode);
- QDataVis::SelectionMode selectionMode();
-
-
- // Enable or disable background grid
- void setGridEnabled(bool enable);
- bool gridEnabled();
-
- // Enable or disable background mesh
- void setBackgroundEnabled(bool enable);
- bool backgroundEnabled();
#if defined(Q_OS_ANDROID)
void mouseDoubleClickEvent(QMouseEvent *event);
@@ -186,21 +142,15 @@ public slots:
signals:
- void selectionModeChanged(QDataVis::SelectionMode mode);
void slicingActiveChanged(bool isSlicing);
void sampleSpaceChanged(int samplesRow, int samplesColumn);
void barSpecsChanged(QSizeF thickness, QSizeF spacing, bool relative);
- void objFileChanged(QString fileName);
- void gridEnabledChanged(bool enable); // TODO should be handled via axis
- void backgroundEnabledChanged(bool enable);
private:
void adjustValueAxisRange();
Q_DISABLE_COPY(Bars3dController)
- friend class DeclarativeBars;
- friend class DeclarativeBarsRenderer;
};
diff --git a/src/datavis3d/engine/bars3drenderer.cpp b/src/datavis3d/engine/bars3drenderer.cpp
index 0240d31a..fee2b883 100644
--- a/src/datavis3d/engine/bars3drenderer.cpp
+++ b/src/datavis3d/engine/bars3drenderer.cpp
@@ -801,7 +801,7 @@ void Bars3dRenderer::drawScene(CameraHelper *camera,
Bars3dController::SelectionType selectionType = isSelected(row, bar);
switch (selectionType) {
- case Bars3dController::SelectionBar: {
+ case Bars3dController::SelectionItem: {
barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor);
lightStrength = m_cachedTheme.m_highlightLightStrength;
// Insert data to QDataItem. We have no ownership, don't delete the previous one
@@ -1492,7 +1492,7 @@ void Bars3dRenderer::updateBarSpecs(QSizeF thickness, QSizeF spacing, bool relat
void Bars3dRenderer::updateMeshFileName(const QString &objFileName)
{
- m_cachedObjFile = objFileName;
+ Abstract3DRenderer::updateMeshFileName(objFileName);
loadBarMesh();
}
@@ -1545,10 +1545,9 @@ void Bars3dRenderer::updateSampleSpace(int rowCount, int columnCount)
calculateSceneScalingFactors();
}
-
void Bars3dRenderer::updateSelectionMode(QDataVis::SelectionMode mode)
{
- m_cachedSelectionMode = mode;
+ Abstract3DRenderer::updateSelectionMode(mode);
// Create zoom selection if there isn't one
if (mode >= QDataVis::ModeZoomRow && !m_sliceSelection) {
@@ -1560,20 +1559,11 @@ void Bars3dRenderer::updateSelectionMode(QDataVis::SelectionMode mode)
}
}
-
-
-
-void Bars3dRenderer::updateGridEnabled(bool enable)
-{
- m_cachedIsGridEnabled = enable;
-}
-
void Bars3dRenderer::updateBackgroundEnabled(bool enable)
{
- if (m_cachedIsBackgroundEnabled != enable) {
- m_cachedIsBackgroundEnabled = enable;
- // Load changed bar type
- loadBarMesh();
+ if (enable != m_cachedIsBackgroundEnabled) {
+ Abstract3DRenderer::updateBackgroundEnabled(enable);
+ loadBarMesh(); // Load changed bar type
}
}
@@ -1727,7 +1717,7 @@ Bars3dController::SelectionType Bars3dRenderer::isSelected(GLint row, GLint bar)
// prevSel = selection;
//}
if (current == m_selection) {
- isSelectedType = Bars3dController::SelectionBar;
+ isSelectedType = Bars3dController::SelectionItem;
}
else if (current.y() == m_selection.y() && (m_cachedSelectionMode == QDataVis::ModeItemAndColumn
|| m_cachedSelectionMode == QDataVis::ModeItemRowAndColumn
diff --git a/src/datavis3d/engine/bars3drenderer_p.h b/src/datavis3d/engine/bars3drenderer_p.h
index 221b3f74..cfcdad50 100644
--- a/src/datavis3d/engine/bars3drenderer_p.h
+++ b/src/datavis3d/engine/bars3drenderer_p.h
@@ -74,14 +74,10 @@ private:
// Cached state based on emitted signals from the controller
QSizeF m_cachedBarThickness;
QSizeF m_cachedBarSpacing;
- QString m_cachedObjFile;
bool m_cachedIsSlicingActivated;
- QDataVis::SelectionMode m_cachedSelectionMode;
int m_cachedZoomLevel;
int m_cachedRowCount;
int m_cachedColumnCount;
- bool m_cachedIsGridEnabled;
- bool m_cachedIsBackgroundEnabled;
// Internal state
BarRenderItem *m_selectedBar; // points to renderitem array
@@ -154,7 +150,6 @@ public slots:
void updateSlicingActive(bool isSlicing);
void updateSampleSpace(int rowCount, int columnCount);
void updateZoomLevel(int newZoomLevel);
- void updateGridEnabled(bool enable);
void updateBackgroundEnabled(bool enable);
void updateMeshFileName(const QString &objFileName);
diff --git a/src/datavis3d/engine/scatter3dcontroller.cpp b/src/datavis3d/engine/scatter3dcontroller.cpp
index 21490971..74bcc38a 100644
--- a/src/datavis3d/engine/scatter3dcontroller.cpp
+++ b/src/datavis3d/engine/scatter3dcontroller.cpp
@@ -19,15 +19,12 @@
#include "scatter3dcontroller_p.h"
#include "scatter3drenderer_p.h"
#include "camerahelper_p.h"
-#include "utils_p.h"
#include "qabstractaxis_p.h"
#include "qvalueaxis_p.h"
#include "qscatterdataproxy_p.h"
#include <QMatrix4x4>
#include <QMouseEvent>
-#include <QThread>
-#include <QDebug>
#include <qmath.h>
QT_DATAVIS3D_BEGIN_NAMESPACE
@@ -36,11 +33,7 @@ Scatter3DController::Scatter3DController(QRect boundRect)
: Abstract3DController(boundRect),
m_mouseState(MouseNone),
m_mousePos(QPoint(0, 0)),
- m_selectionMode(QDataVis::ModeItem),
m_isSlicingActivated(false),
- m_objFile(QStringLiteral(":/defaultMeshes/sphere")),
- m_isGridEnabled(true),
- m_isBackgroundEnabled(true),
m_renderer(0),
m_data(0)
{
@@ -49,6 +42,8 @@ Scatter3DController::Scatter3DController(QRect boundRect)
setAxisY(new QValueAxis());
setAxisZ(new QValueAxis());
+ setObjectType(QDataVis::Spheres, false); // default object type
+
setDataProxy(new QScatterDataProxy);
}
@@ -75,31 +70,11 @@ void Scatter3DController::synchDataToRenderer()
return;
// Notify changes to renderer
- if (m_changeTracker.selectionModeChanged) {
- m_renderer->updateSelectionMode(m_selectionMode);
- m_changeTracker.selectionModeChanged = false;
- }
-
if (m_changeTracker.slicingActiveChanged) {
// TODO: Add notification.
m_changeTracker.slicingActiveChanged = false;
}
- if (m_changeTracker.objFileChanged) {
- m_renderer->updateMeshFileName(m_objFile);
- m_changeTracker.objFileChanged = false;
- }
-
- if (m_changeTracker.gridEnabledChanged) {
- m_renderer->updateGridEnabled(m_isGridEnabled);
- m_changeTracker.gridEnabledChanged = false;
- }
-
- if (m_changeTracker.backgroundEnabledChanged) {
- m_renderer->updateBackgroundEnabled(m_isBackgroundEnabled);
- m_changeTracker.backgroundEnabledChanged = false;
- }
-
if (m_changeTracker.zoomLevelChanged) {
m_renderer->updateZoomLevel(m_zoomLevel);
m_changeTracker.zoomLevelChanged = false;
@@ -185,8 +160,8 @@ void Scatter3DController::mousePressEvent(QMouseEvent *event, const QPoint &mous
QRect mainViewPort = m_renderer->mainViewPort();
if (Qt::LeftButton == event->button()) {
if (m_isSlicingActivated) {
- if (event->pos().x() <= mainViewPort.width()
- && event->pos().y() <= mainViewPort.height()) {
+ if (mousePos.x() <= mainViewPort.width()
+ && mousePos.y() <= mainViewPort.height()) {
m_mouseState = Scatter3DController::MouseOnOverview;
//qDebug() << "Mouse pressed on overview";
} else {
@@ -200,7 +175,7 @@ void Scatter3DController::mousePressEvent(QMouseEvent *event, const QPoint &mous
m_mouseState = Scatter3DController::MouseRotating;
#endif
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = event->pos();
+ m_mousePos = mousePos;
//qDebug() << "Mouse pressed on scene";
}
} else if (Qt::MiddleButton == event->button()) {
@@ -213,7 +188,7 @@ void Scatter3DController::mousePressEvent(QMouseEvent *event, const QPoint &mous
m_mouseState = Scatter3DController::MouseOnScene;
#endif
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = mousePos; //event->pos();
+ m_mousePos = mousePos;
}
m_cameraHelper->updateMousePos(m_mousePos);
}
@@ -223,8 +198,8 @@ void Scatter3DController::mouseReleaseEvent(QMouseEvent *event, const QPoint &mo
Q_UNUSED(event);
if (Scatter3DController::MouseRotating == m_mouseState) {
// update mouse positions to prevent jumping when releasing or repressing a button
- m_mousePos = mousePos; //event->pos();
- m_cameraHelper->updateMousePos(mousePos); //event->pos());
+ m_mousePos = mousePos;
+ m_cameraHelper->updateMousePos(mousePos);
}
m_mouseState = Scatter3DController::MouseNone;
}
@@ -233,7 +208,7 @@ void Scatter3DController::mouseMoveEvent(QMouseEvent *event, const QPoint &mouse
{
Q_UNUSED(event);
if (Scatter3DController::MouseRotating == m_mouseState)
- m_mousePos = mousePos; //event->pos();
+ m_mousePos = mousePos;
}
void Scatter3DController::wheelEvent(QWheelEvent *event)
@@ -321,42 +296,29 @@ void Scatter3DController::handleItemsInserted(int startIndex, int count)
m_isDataDirty = true;
}
-void Scatter3DController::handleAxisAutoAdjustRangeChangedInOrientation(QAbstractAxis::AxisOrientation orientation, bool autoAdjust)
+void Scatter3DController::handleAxisAutoAdjustRangeChangedInOrientation(
+ QAbstractAxis::AxisOrientation orientation, bool autoAdjust)
{
Q_UNUSED(orientation)
Q_UNUSED(autoAdjust)
adjustValueAxisRange();
}
-QString Scatter3DController::objFile()
-{
- return m_objFile;
-}
-
void Scatter3DController::setObjectType(QDataVis::MeshStyle style, bool smooth)
{
+ QString objFile;
if (style == QDataVis::Spheres) {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/sphereSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/sphereSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/sphere");
+ objFile = QStringLiteral(":/defaultMeshes/sphere");
} else {
if (smooth)
- m_objFile = QStringLiteral(":/defaultMeshes/dotSmooth");
+ objFile = QStringLiteral(":/defaultMeshes/dotSmooth");
else
- m_objFile = QStringLiteral(":/defaultMeshes/dot");
+ objFile = QStringLiteral(":/defaultMeshes/dot");
}
-
- m_changeTracker.objFileChanged = true;
- emit objFileChanged(m_objFile);
-}
-
-void Scatter3DController::setMeshFileName(const QString &objFileName)
-{
- m_objFile = objFileName;
-
- m_changeTracker.objFileChanged = true;
- emit objFileChanged(m_objFile);
+ Abstract3DController::setMeshFileName(objFile);
}
void Scatter3DController::setSelectionMode(QDataVis::SelectionMode mode)
@@ -365,12 +327,9 @@ void Scatter3DController::setSelectionMode(QDataVis::SelectionMode mode)
qWarning("Unsupported selection mode.");
return;
}
- m_selectionMode = mode;
// Disable zoom if selection mode changes
setSlicingActive(false);
-
- m_changeTracker.selectionModeChanged = true;
- emit selectionModeChanged(m_selectionMode);
+ Abstract3DController::setSelectionMode(mode);
}
QPoint Scatter3DController::mousePosition()
@@ -378,37 +337,6 @@ QPoint Scatter3DController::mousePosition()
return m_mousePos;
}
-QDataVis::SelectionMode Scatter3DController::selectionMode()
-{
- return m_selectionMode;
-}
-
-void Scatter3DController::setGridEnabled(bool enable)
-{
- m_isGridEnabled = enable;
-
- m_changeTracker.gridEnabledChanged = true;
- emit gridEnabledChanged(m_isGridEnabled);
-}
-
-bool Scatter3DController::gridEnabled()
-{
- return m_isGridEnabled;
-}
-
-void Scatter3DController::setBackgroundEnabled(bool enable)
-{
- m_isBackgroundEnabled = enable;
-
- m_changeTracker.backgroundEnabledChanged = true;
- emit backgroundEnabledChanged(m_isBackgroundEnabled);
-}
-
-bool Scatter3DController::backgroundEnabled()
-{
- return m_isBackgroundEnabled;
-}
-
void Scatter3DController::adjustValueAxisRange()
{
if (m_data) {
diff --git a/src/datavis3d/engine/scatter3dcontroller_p.h b/src/datavis3d/engine/scatter3dcontroller_p.h
index f9d4c284..67f32278 100644
--- a/src/datavis3d/engine/scatter3dcontroller_p.h
+++ b/src/datavis3d/engine/scatter3dcontroller_p.h
@@ -29,39 +29,22 @@
#ifndef Q3DSCATTERCONTROLLER_p_H
#define Q3DSCATTERCONTROLLER_p_H
-#include <QtCore/QSize>
-#include <QtCore/QObject>
-#include <QWindow>
-
-#include "abstract3dcontroller_p.h"
#include "datavis3dglobal_p.h"
+#include "abstract3dcontroller_p.h"
//#define DISPLAY_RENDER_SPEED
-class QFont;
-class QPoint;
-class QSizeF;
-
QT_DATAVIS3D_BEGIN_NAMESPACE
class Scatter3DRenderer;
-class LabelItem;
class QScatterDataProxy;
struct Scatter3DChangeBitField {
- bool selectionModeChanged : 1;
bool slicingActiveChanged : 1;
- bool objFileChanged : 1;
- bool gridEnabledChanged : 1;
- bool backgroundEnabledChanged : 1;
bool zoomLevelChanged : 1;
Scatter3DChangeBitField() :
- selectionModeChanged(true),
slicingActiveChanged(true),
- objFileChanged(true),
- gridEnabledChanged(true),
- backgroundEnabledChanged(true),
zoomLevelChanged(true)
{
}
@@ -71,28 +54,15 @@ class QT_DATAVIS3D_EXPORT Scatter3DController : public Abstract3DController
{
Q_OBJECT
-public:
- enum SelectionType {
- SelectionNone = 0,
- SelectionBar,
- SelectionRow,
- SelectionColumn
- };
-
private:
Scatter3DChangeBitField m_changeTracker;
// Interaction
MouseState m_mouseState;
QPoint m_mousePos;
- QDataVis::SelectionMode m_selectionMode;
bool m_isSlicingActivated;
- // Look'n'Feel
- QString m_objFile;
- bool m_isGridEnabled;
- bool m_isBackgroundEnabled;
-
+ // Rendering
Scatter3DRenderer *m_renderer;
QScatterDataProxy *m_data;
@@ -111,24 +81,11 @@ public:
QMatrix4x4 calculateViewMatrix(int zoom, int viewPortWidth, int viewPortHeight,
bool showUnder = false);
- // bar type; bars (=cubes), pyramids, cones, cylinders, etc.
+ // Object type
void setObjectType(QDataVis::MeshStyle style, bool smooth = false);
- QString objFile();
-
- // override bar type with own mesh
- void setMeshFileName(const QString &objFileName);
- // Change selection mode; single bar, bar and row, bar and column, or all
+ // Change selection mode
void setSelectionMode(QDataVis::SelectionMode mode);
- QDataVis::SelectionMode selectionMode();
-
- // Enable or disable background grid
- void setGridEnabled(bool enable);
- bool gridEnabled();
-
- // Enable or disable background mesh
- void setBackgroundEnabled(bool enable);
- bool backgroundEnabled();
#if defined(Q_OS_ANDROID)
void mouseDoubleClickEvent(QMouseEvent *event);
@@ -154,14 +111,8 @@ public slots:
void handleItemsRemoved(int startIndex, int count);
void handleItemsInserted(int startIndex, int count);
-
signals:
- void selectionModeChanged(QDataVis::SelectionMode mode);
void slicingActiveChanged(bool isSlicing);
- void objFileChanged(QString fileName);
- void fontChanged(QFont font);
- void gridEnabledChanged(bool enable);
- void backgroundEnabledChanged(bool enable);
private:
void adjustValueAxisRange();
diff --git a/src/datavis3d/engine/scatter3drenderer.cpp b/src/datavis3d/engine/scatter3drenderer.cpp
index 78639d06..8e5fe28e 100644
--- a/src/datavis3d/engine/scatter3drenderer.cpp
+++ b/src/datavis3d/engine/scatter3drenderer.cpp
@@ -610,7 +610,7 @@ void Scatter3DRenderer::drawScene(CameraHelper *camera,
if (m_cachedSelectionMode > QDataVis::ModeNone) {
Scatter3DController::SelectionType selectionType = isSelected(bar, m_selection);
switch (selectionType) {
- case Scatter3DController::SelectionBar: {
+ case Scatter3DController::SelectionItem: {
barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor);
lightStrength = m_cachedTheme.m_highlightLightStrength;
// Insert data to ScatterRenderItem. We have no ownership, don't delete the previous one
@@ -1360,30 +1360,15 @@ void Scatter3DRenderer::handleResize()
void Scatter3DRenderer::updateMeshFileName(const QString &objFileName)
{
- //qDebug() << __FUNCTION__;
- m_cachedObjFile = objFileName;
+ Abstract3DRenderer::updateMeshFileName(objFileName);
loadBarMesh();
}
-void Scatter3DRenderer::updateSelectionMode(QDataVis::SelectionMode mode)
-{
- //qDebug() << __FUNCTION__;
- m_cachedSelectionMode = mode;
-}
-
-void Scatter3DRenderer::updateGridEnabled(bool enable)
-{
- //qDebug() << __FUNCTION__;
- m_cachedIsGridEnabled = enable;
-}
-
void Scatter3DRenderer::updateBackgroundEnabled(bool enable)
{
- //qDebug() << __FUNCTION__;
- if (m_cachedIsBackgroundEnabled != enable) {
- m_cachedIsBackgroundEnabled = enable;
- // Load changed bar type
- loadBarMesh();
+ if (enable != m_cachedIsBackgroundEnabled) {
+ Abstract3DRenderer::updateBackgroundEnabled(enable);
+ loadBarMesh(); // Load changed bar type
}
}
@@ -1552,7 +1537,7 @@ Scatter3DController::SelectionType Scatter3DRenderer::isSelected(GLint bar,
//}
if (current == selection)
- isSelectedType = Scatter3DController::SelectionBar;
+ isSelectedType = Scatter3DController::SelectionItem;
return isSelectedType;
}
diff --git a/src/datavis3d/engine/scatter3drenderer_p.h b/src/datavis3d/engine/scatter3drenderer_p.h
index 048764da..4eea41a9 100644
--- a/src/datavis3d/engine/scatter3drenderer_p.h
+++ b/src/datavis3d/engine/scatter3drenderer_p.h
@@ -74,11 +74,7 @@ private:
QMutex m_mutex;
// Cached state based on emitted signals from the controller
- QString m_cachedObjFile;
- QDataVis::SelectionMode m_cachedSelectionMode;
int m_cachedZoomLevel;
- bool m_cachedIsGridEnabled;
- bool m_cachedIsBackgroundEnabled;
// Internal state
ScatterRenderItem *m_selectedItem; // points to renderitem array
@@ -135,9 +131,7 @@ public:
QRect mainViewPort();
public slots:
- void updateSelectionMode(QDataVis::SelectionMode newMode);
void updateZoomLevel(int newZoomLevel);
- void updateGridEnabled(bool enable);
void updateBackgroundEnabled(bool enable);
void updateMeshFileName(const QString &objFileName);
diff --git a/src/datavis3dqml2/declarativebars.cpp b/src/datavis3dqml2/declarativebars.cpp
index 938575f5..565e71b7 100644
--- a/src/datavis3dqml2/declarativebars.cpp
+++ b/src/datavis3dqml2/declarativebars.cpp
@@ -168,14 +168,14 @@ bool DeclarativeBars::isBarSpacingRelative()
void DeclarativeBars::setBarType(QDataVis::MeshStyle style)
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
bool smooth = objFile.endsWith(smoothString);
m_shared->setBarType(style, smooth);
}
QDataVis::MeshStyle DeclarativeBars::barType()
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
if (objFile.contains("/sphere"))
return QDataVis::Spheres;
else
@@ -184,7 +184,7 @@ QDataVis::MeshStyle DeclarativeBars::barType()
void DeclarativeBars::setBarSmooth(bool smooth)
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
if (objFile.endsWith(smoothString)) {
if (smooth)
return; // Already smooth; do nothing
@@ -201,7 +201,7 @@ void DeclarativeBars::setBarSmooth(bool smooth)
bool DeclarativeBars::barSmooth()
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
return objFile.endsWith(smoothString);
}
@@ -212,7 +212,7 @@ void DeclarativeBars::setMeshFileName(const QString &objFileName)
QString DeclarativeBars::meshFileName()
{
- return m_shared->objFile();
+ return m_shared->meshFileName();
}
void DeclarativeBars::setCameraPreset(QDataVis::CameraPreset preset)
diff --git a/src/datavis3dqml2/declarativescatter.cpp b/src/datavis3dqml2/declarativescatter.cpp
index e880e553..6005ff99 100644
--- a/src/datavis3dqml2/declarativescatter.cpp
+++ b/src/datavis3dqml2/declarativescatter.cpp
@@ -122,14 +122,14 @@ QItemModelScatterDataMapping *DeclarativeScatter::mapping() const
void DeclarativeScatter::setObjectType(QDataVis::MeshStyle style)
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
bool smooth = objFile.endsWith(smoothString);
m_shared->setObjectType(style, smooth);
}
QDataVis::MeshStyle DeclarativeScatter::objectType()
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
if (objFile.contains("/sphere"))
return QDataVis::Spheres;
else
@@ -138,7 +138,7 @@ QDataVis::MeshStyle DeclarativeScatter::objectType()
void DeclarativeScatter::setObjectSmooth(bool smooth)
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
if (objFile.endsWith(smoothString)) {
if (smooth)
return; // Already smooth; do nothing
@@ -155,7 +155,7 @@ void DeclarativeScatter::setObjectSmooth(bool smooth)
bool DeclarativeScatter::objectSmooth()
{
- QString objFile = m_shared->objFile();
+ QString objFile = m_shared->meshFileName();
return objFile.endsWith(smoothString);
}
@@ -166,7 +166,7 @@ void DeclarativeScatter::setMeshFileName(const QString &objFileName)
QString DeclarativeScatter::meshFileName()
{
- return m_shared->objFile();
+ return m_shared->meshFileName();
}
void DeclarativeScatter::setCameraPreset(QDataVis::CameraPreset preset)