Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DFTFringe.pro
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ SOURCES += SingleApplication/singleapplication.cpp \
astigpolargraph.cpp \
astigscatterplot.cpp \
astigstatsdlg.cpp \
autoinvertdlg.cpp \
autoinvertdlg.cpp \
averagewavefrontfilesdlg.cpp \
batchigramwizard.cpp \
bathastigdlg.cpp \
Expand All @@ -171,6 +171,7 @@ SOURCES += SingleApplication/singleapplication.cpp \
contourview.cpp \
counterrotationdlg.cpp \
cpoint.cpp \
custom3dinputhandler.cpp \
defocusdlg.cpp \
dftarea.cpp \
dftcolormap.cpp \
Expand Down Expand Up @@ -293,6 +294,7 @@ HEADERS += bezier/bezier.h \
contourview.h \
counterrotationdlg.h \
cpoint.h \
custom3dinputhandler.h \
defocusdlg.h \
dftarea.h \
dftcolormap.h \
Expand Down
4 changes: 3 additions & 1 deletion DFTFringe_Dale.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SOURCES += main.cpp \
astigpolargraph.cpp \
autoinvertdlg.cpp \
cpoint.cpp \
custom3dinputhandler.cpp \
defocusdlg.cpp \
edgeplot.cpp \
hotkeysdlg.cpp \
Expand Down Expand Up @@ -153,6 +154,7 @@ HEADERS += mainwindow.h \
astigpolargraph.h \
autoinvertdlg.h \
cpoint.h \
custom3dinputhandler.h \
defocusdlg.h \
edgeplot.h \
IgramArea.h \
Expand Down Expand Up @@ -411,7 +413,7 @@ RC_FILE = DFTFringe.rc
QMAKE_CXXFLAGS += -std=c++11

# The application version
VERSION = Dale7.3.2
VERSION = 3Dmouse_08/24/26

# Define the preprocessor macro to get the application version in our application.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
Expand Down
2 changes: 2 additions & 0 deletions DFTFringe_QT5.pro
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ SOURCES += SingleApplication/singleapplication.cpp \
contourview.cpp \
counterrotationdlg.cpp \
cpoint.cpp \
custom3dinputhandler.cpp \
defocusdlg.cpp \
dftarea.cpp \
dftcolormap.cpp \
Expand Down Expand Up @@ -297,6 +298,7 @@ HEADERS += bezier/bezier.h \
contourview.h \
counterrotationdlg.h \
cpoint.h \
custom3dinputhandler.h \
defocusdlg.h \
dftarea.h \
dftcolormap.h \
Expand Down
110 changes: 110 additions & 0 deletions custom3dinputhandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "custom3dinputhandler.h"
#include <QtMath>
Custom3DInputHandler::Custom3DInputHandler(QAbstract3DGraph *graph)
: Q3DInputHandler(graph), m_isRightDragging(false), m_graphRef(graph) {
setZoomAtTargetEnabled(true);
}

void Custom3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos) {
if (event->button() == Qt::RightButton) {
m_isRightDragging = true;
m_lastMousePos = event->pos();
event->accept();
return; // Consume event so base handler doesn't interfere
}

// Map Left-Click to Right-Click for standard rotation in base handler
Qt::MouseButton mappedButton = (event->button() == Qt::LeftButton) ? Qt::RightButton : event->button();
Qt::MouseButtons mappedButtons = event->buttons();
if (mappedButtons & Qt::LeftButton) {
mappedButtons = (mappedButtons & ~Qt::LeftButton) | Qt::RightButton;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent customEvent(event->type(), event->position(), event->globalPosition(),
mappedButton, mappedButtons, event->modifiers());
#else
QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:23:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   23 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:23:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   23 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:23:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   23 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:23:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   23 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

mappedButton, mappedButtons, event->modifiers());
#endif
Q3DInputHandler::mousePressEvent(&customEvent, mousePos);
Q3DInputHandler::mousePressEvent(&customEvent, mousePos);
}

void Custom3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos) {
if (event->button() == Qt::RightButton) {
m_isRightDragging = false;
event->accept();
return;
}

Qt::MouseButton mappedButton = (event->button() == Qt::LeftButton) ? Qt::RightButton : event->button();
Qt::MouseButtons mappedButtons = event->buttons();
if (mappedButtons & Qt::LeftButton) {
mappedButtons = (mappedButtons & ~Qt::LeftButton) | Qt::RightButton;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent customEvent(event->type(), event->position(), event->globalPosition(),
mappedButton, mappedButtons, event->modifiers());
#else
QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:41:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   41 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:41:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   41 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:41:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   41 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:41:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   41 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

mappedButton, mappedButtons, event->modifiers());
#endif
Q3DInputHandler::mousePressEvent(&customEvent, mousePos);
Q3DInputHandler::mouseReleaseEvent(&customEvent, mousePos);
}



void Custom3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) {
if (m_isRightDragging && m_graphRef) {
QPoint delta = event->pos() - m_lastMousePos;
m_lastMousePos = event->pos();

// Adjust camera target to pan the view
Q3DCamera *camera = m_graphRef->scene()->activeCamera();
if (camera) {
QVector3D target = camera->target();
float panScale = 0.003f;

// Extract both rotations in radians
float xRotRad = qDegreesToRadians(camera->xRotation()); // Yaw (horizontal orbit)
float yRotRad = qDegreesToRadians(camera->yRotation()); // Pitch (vertical tilt)

float cosX = qCos(xRotRad);
float sinX = qSin(xRotRad);
float cosY = qCos(yRotRad);
float sinY = qSin(yRotRad);

// Invert Y delta (flipped back so dragging down moves the scene down)
float invertedDeltaY = -delta.y();

float dx = (-delta.x() * cosX - invertedDeltaY * sinX * cosY) * panScale;
float dy = (invertedDeltaY * sinY) * panScale;
float dz = (delta.x() * sinX - invertedDeltaY * cosX * cosY) * panScale;

target.setX(target.x() + dx);
target.setY(target.y() + dy);
target.setZ(target.z() + dz);

camera->setTarget(target);
}
event->accept();
return;
}

Qt::MouseButtons mappedButtons = event->buttons();
if (mappedButtons & Qt::LeftButton) {
mappedButtons = (mappedButtons & ~Qt::LeftButton) | Qt::RightButton;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent customEvent(event->type(), event->position(), event->globalPosition(),
event->button(), mappedButtons, event->modifiers());
#else
QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:70:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   70 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:70:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   70 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

custom3dinputhandler.cpp:90:51: warning: [clang-diagnostic-deprecated-declarations]

'localPos' is deprecated: Use position()

   90 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                   ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:226:5: note: 'localPos' has been explicitly marked deprecated here
  226 |     QT_DEPRECATED_VERSION_X_6_0("Use position()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

clang-tidy diagnostic

custom3dinputhandler.cpp:90:70: warning: [clang-diagnostic-deprecated-declarations]

'globalPos' is deprecated: Use globalPosition()

   90 |     QMouseEvent customEvent(event->type(), event->localPos(), event->globalPos(),
      |                                                                      ^
/usr/include/x86_64-linux-gnu/qt6/QtGui/qevent.h:215:5: note: 'globalPos' has been explicitly marked deprecated here
  215 |     QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
      |     ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:326:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_0'
  326 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text)
      |                                            ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:238:33: note: expanded from macro 'QT_DEPRECATED_X'
  238 | #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
      |                                 ^
/usr/include/x86_64-linux-gnu/qt6/QtCore/qcompilerdetection.h:956:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  956 | #  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
      |                                    ^

event->button(), mappedButtons, event->modifiers());
#endif
Q3DInputHandler::mouseMoveEvent(&customEvent, mousePos);
}
30 changes: 30 additions & 0 deletions custom3dinputhandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CUSTOM3DINPUTHANDLER_H
#define CUSTOM3DINPUTHANDLER_H

#include <QtDataVisualization/Q3DInputHandler>
#include <QtDataVisualization/QAbstract3DGraph>
#include <QtDataVisualization/Q3DCamera>
#include <QMouseEvent>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
//keep compatiblity with Qt5
using namespace QtDataVisualization;
Comment thread
atsju marked this conversation as resolved.
#endif

class Custom3DInputHandler : public Q3DInputHandler {
Q_OBJECT
public:
Custom3DInputHandler(QAbstract3DGraph *graph = nullptr);

protected:
void mousePressEvent(QMouseEvent *event, const QPoint &mousePos) override;
void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos) override;
void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) override;

private:
bool m_isRightDragging;
QPoint m_lastMousePos;
QAbstract3DGraph *m_graphRef;
};

#endif // CUSTOM3DINPUTHANDLER_H
10 changes: 8 additions & 2 deletions surfacegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@
#include <QLabel>
#include <QSettings>
#include <QDebug>

#include "custom3dinputhandler.h"
int sampleCountX = 50;
int sampleCountZ = 50;

const float sampleMin = -8.0f;
const float sampleMax = 8.0f;
#include <QOpenGLFunctions>




SurfaceGraph::SurfaceGraph(Q3DSurface *surface)
: m_graph(surface),m_axisMaxSliderXValue(100),m_axisMinSliderXValue(0), m_wf(0), m_colorRange(.56)
{
m_xGridMin = 0;
// Replace default input handler with your custom one
Custom3DInputHandler *customInputHandler = new Custom3DInputHandler(m_graph);
m_graph->setActiveInputHandler(customInputHandler);
m_graph->setAxisX(new QValue3DAxis);
m_graph->setAxisY(new QValue3DAxis);
m_graph->setAxisZ(new QValue3DAxis);
Expand Down Expand Up @@ -478,7 +485,6 @@ QSize SurfaceGraph::Size(){
QImage SurfaceGraph::render(int width, int height){
QSize orgsize = m_graph->size();
if (orgsize.width() < width){
qDebug() << "m_graph size" << orgsize << width << height;
m_graph->resize(width, height);
}
QImage result = m_graph->renderToImage(0, QSize(width,height));
Expand Down
Loading