qt6 support
This commit is contained in:
@@ -77,7 +77,13 @@ void MouseController::mouseReleaseEvent(QMouseEvent * e) {
|
||||
}
|
||||
if (e->button() == Qt::RightButton) {
|
||||
if (view->renderer_.edit_mode && !view->scene()->selectedObjects().isEmpty())
|
||||
view->popupMenu(e->globalPos());
|
||||
view->popupMenu(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
((QMouseEvent*)e)->globalPos()
|
||||
#else
|
||||
((QMouseEvent*)e)->globalPosition().toPoint()
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,8 +137,8 @@ void MouseController::mouseMoveEvent(QMouseEvent * e) {
|
||||
foreach (int a, axis) {
|
||||
QVector3D axe_vector; axe_vector[a] = 1.;
|
||||
QMatrix4x4 axis_mat = view->camera()->fullViewMatrix() * rs.axis_mat;
|
||||
QVector3D center_screen = axis_mat * rs.selection_center;
|
||||
QVector3D axe_screen = ((axis_mat * (rs.selection_center + axe_vector)) - center_screen).normalized();
|
||||
QVector3D center_screen = axis_mat.map(rs.selection_center);
|
||||
QVector3D axe_screen = (axis_mat.map(rs.selection_center + axe_vector) - center_screen).normalized();
|
||||
QVector3D mouse_vector(cpos - lastPos);
|
||||
mouse_vector[1] *= -1.;
|
||||
if (cur_action == RendererService::haMove) {
|
||||
@@ -200,9 +206,14 @@ void MouseController::mouseMoveEvent(QMouseEvent * e) {
|
||||
}
|
||||
QRect g_rect(QPoint(), view->size());
|
||||
if (mouseRotate_) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
float dx = e->x() - lastPos.x();
|
||||
float dy = e->y() - lastPos.y();
|
||||
if (e->buttons().testFlag(Qt::MidButton)) {
|
||||
#else
|
||||
float dx = e->position().toPoint().x() - lastPos.x();
|
||||
float dy = e->position().toPoint().y() - lastPos.y();
|
||||
#endif
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON)) {
|
||||
if (cameraOrbit_) {
|
||||
view->camera()->orbitZ (dx / 4.f);
|
||||
view->camera()->orbitXY(dy / 4.f);
|
||||
@@ -257,8 +268,13 @@ void MouseController::mouseMoveEvent(QMouseEvent * e) {
|
||||
return;
|
||||
}
|
||||
lastPos = g_rect.center();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
int dx = e->x() - lastPos.x();
|
||||
int dy = e->y() - lastPos.y();
|
||||
#else
|
||||
int dx = e->position().toPoint().x() - lastPos.x();
|
||||
int dy = e->position().toPoint().y() - lastPos.y();
|
||||
#endif
|
||||
emit view->glMouseMoveEvent(new QMouseEvent(QEvent::MouseMove, QPoint(dx, dy), e->button(), e->buttons(), e->modifiers()));
|
||||
return;
|
||||
}
|
||||
@@ -268,8 +284,14 @@ void MouseController::mouseMoveEvent(QMouseEvent * e) {
|
||||
|
||||
void MouseController::wheelEvent(QWheelEvent * e) {
|
||||
if (mouseRotate_) {
|
||||
if (e->delta() > 0) view->camera()->flyCloser(0.1f);
|
||||
if (e->delta() < 0) view->camera()->flyFarer(0.1f);
|
||||
double ang =
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
e->delta();
|
||||
#else
|
||||
e->angleDelta().y();
|
||||
#endif
|
||||
if (ang > 0) view->camera()->flyCloser(0.1f);
|
||||
if (ang < 0) view->camera()->flyFarer(0.1f);
|
||||
emit view->cameraPosChanged(view->camera()->pos());
|
||||
}
|
||||
emit view->glWheelEvent(e);
|
||||
@@ -283,6 +305,6 @@ void MouseController::leaveEvent(QEvent * ) {
|
||||
|
||||
|
||||
void MouseController::mouseDoubleClickEvent(QMouseEvent * e) {
|
||||
if (e->buttons().testFlag(Qt::MidButton))
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON))
|
||||
emit view->doubleClick();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user