Fix mouse handling for render model
Before we use a tricky way to share mouse event between model render widget and model edit widget, which forward the event from render widget to edit widget. This will cause some problem, such as the scroll bar of edit widget would not work when it covered by the render model. Now the mouse event is totally disabled in the render widget, and when there is a need we forward it from edit widget.master
parent
f2849a020f
commit
71ccb2b71f
|
@ -261,7 +261,6 @@ void MaterialListWidget::reload()
|
|||
MaterialWidget *widget = new MaterialWidget(m_document, materialId);
|
||||
connect(widget, &MaterialWidget::modifyMaterial, this, &MaterialListWidget::modifyMaterial);
|
||||
connect(widget, &MaterialWidget::cornerButtonClicked, this, &MaterialListWidget::cornerButtonClicked);
|
||||
widget->previewWidget()->setGraphicsFunctions(this);
|
||||
setItemWidget(item, col, widget);
|
||||
widget->reload();
|
||||
widget->updateCheckedState(isMaterialSelected(materialId));
|
||||
|
@ -287,40 +286,6 @@ void MaterialListWidget::removeAllContent()
|
|||
clear();
|
||||
}
|
||||
|
||||
bool MaterialListWidget::mouseMove(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialListWidget::wheel(QWheelEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialListWidget::mouseRelease(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialListWidget::mousePress(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
showContextMenu(mapFromGlobal(event->globalPos()));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialListWidget::mouseDoubleClick(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialListWidget::keyPress(QKeyEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void MaterialListWidget::copy()
|
||||
{
|
||||
if (m_selectedMaterialIds.empty() && m_currentSelectedMaterialId.isNull())
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#define MATERIAL_LIST_WIDGET_H
|
||||
#include <QTreeWidget>
|
||||
#include <map>
|
||||
#include <QMouseEvent>
|
||||
#include "skeletondocument.h"
|
||||
#include "materialwidget.h"
|
||||
#include "skeletongraphicswidget.h"
|
||||
|
||||
class MaterialListWidget : public QTreeWidget, public SkeletonGraphicsFunctions
|
||||
class MaterialListWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -30,12 +30,6 @@ public slots:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
bool mouseMove(QMouseEvent *event) override;
|
||||
bool wheel(QWheelEvent *event) override;
|
||||
bool mouseRelease(QMouseEvent *event) override;
|
||||
bool mousePress(QMouseEvent *event) override;
|
||||
bool mouseDoubleClick(QMouseEvent *event) override;
|
||||
bool keyPress(QKeyEvent *event) override;
|
||||
private:
|
||||
int calculateColumnCount();
|
||||
void updateMaterialSelectState(QUuid materialId, bool selected);
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
#include <QGuiApplication>
|
||||
#include <math.h>
|
||||
#include "modelwidget.h"
|
||||
#include "ds3file.h"
|
||||
#include "skeletongraphicswidget.h"
|
||||
#include "modelwidget.h"
|
||||
#include "dust3dutil.h"
|
||||
|
||||
// Modifed from http://doc.qt.io/qt-5/qtopengl-hellogl2-glwidget-cpp.html
|
||||
|
||||
|
@ -19,10 +17,11 @@ ModelWidget::ModelWidget(QWidget *parent) :
|
|||
m_zRot(0),
|
||||
m_program(nullptr),
|
||||
m_moveStarted(false),
|
||||
m_graphicsFunctions(NULL),
|
||||
m_moveEnabled(true),
|
||||
m_zoomEnabled(true)
|
||||
{
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
// --transparent causes the clear color to be transparent. Therefore, on systems that
|
||||
// support it, the widget will become transparent apart from the logo.
|
||||
if (m_transparent) {
|
||||
|
@ -37,7 +36,6 @@ ModelWidget::ModelWidget(QWidget *parent) :
|
|||
fmt.setSamples(4);
|
||||
setFormat(fmt);
|
||||
}
|
||||
setMouseTracking(true);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
|
@ -56,11 +54,6 @@ int ModelWidget::zRot()
|
|||
return m_zRot;
|
||||
}
|
||||
|
||||
void ModelWidget::setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions)
|
||||
{
|
||||
m_graphicsFunctions = graphicsFunctions;
|
||||
}
|
||||
|
||||
ModelWidget::~ModelWidget()
|
||||
{
|
||||
cleanup();
|
||||
|
@ -187,71 +180,56 @@ void ModelWidget::toggleWireframe()
|
|||
update();
|
||||
}
|
||||
|
||||
void ModelWidget::mousePressEvent(QMouseEvent *event)
|
||||
bool ModelWidget::inputMousePressEventFromOtherWidget(QMouseEvent *event)
|
||||
{
|
||||
bool shouldStartMove = false;
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier) &&
|
||||
!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
|
||||
shouldStartMove = true;
|
||||
shouldStartMove = m_moveEnabled;
|
||||
}
|
||||
} else if (event->button() == Qt::MidButton) {
|
||||
shouldStartMove = m_moveEnabled;
|
||||
}
|
||||
if (shouldStartMove) {
|
||||
m_lastPos = event->pos();
|
||||
m_lastPos = convertInputPosFromOtherWidget(event);
|
||||
if (!m_moveStarted) {
|
||||
m_moveStartPos = mapToParent(event->pos());
|
||||
m_moveStartPos = mapToParent(convertInputPosFromOtherWidget(event));
|
||||
m_moveStartGeometry = geometry();
|
||||
m_moveStarted = true;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (!m_moveStarted && m_graphicsFunctions && m_graphicsFunctions->mousePress(event))
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModelWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
bool ModelWidget::inputMouseReleaseEventFromOtherWidget(QMouseEvent *event)
|
||||
{
|
||||
QOpenGLWidget::mouseReleaseEvent(event);
|
||||
if (m_graphicsFunctions)
|
||||
m_graphicsFunctions->mouseRelease(event);
|
||||
Q_UNUSED(event);
|
||||
if (m_moveStarted) {
|
||||
m_moveStarted = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModelWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
bool ModelWidget::inputMouseMoveEventFromOtherWidget(QMouseEvent *event)
|
||||
{
|
||||
QOpenGLWidget::mouseDoubleClickEvent(event);
|
||||
if (m_graphicsFunctions)
|
||||
m_graphicsFunctions->mouseDoubleClick(event);
|
||||
}
|
||||
if (!m_moveStarted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModelWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QOpenGLWidget::keyPressEvent(event);
|
||||
if (m_graphicsFunctions)
|
||||
m_graphicsFunctions->keyPress(event);
|
||||
}
|
||||
|
||||
void ModelWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
QOpenGLWidget::mouseMoveEvent(event);
|
||||
if (!m_moveStarted && m_graphicsFunctions && m_graphicsFunctions->mouseMove(event))
|
||||
return;
|
||||
|
||||
int dx = event->x() - m_lastPos.x();
|
||||
int dy = event->y() - m_lastPos.y();
|
||||
QPoint pos = convertInputPosFromOtherWidget(event);
|
||||
int dx = pos.x() - m_lastPos.x();
|
||||
int dy = pos.y() - m_lastPos.y();
|
||||
|
||||
if ((event->buttons() & Qt::MidButton) ||
|
||||
(m_moveStarted && (event->buttons() & Qt::LeftButton))) {
|
||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
if (m_moveStarted) {
|
||||
QRect rect = m_moveStartGeometry;
|
||||
QPoint pos = mapToParent(event->pos());
|
||||
rect.translate(pos.x() - m_moveStartPos.x(), pos.y() - m_moveStartPos.y());
|
||||
QPoint posInParent = mapToParent(pos);
|
||||
rect.translate(posInParent.x() - m_moveStartPos.x(), posInParent.y() - m_moveStartPos.y());
|
||||
setGeometry(rect);
|
||||
}
|
||||
} else {
|
||||
|
@ -259,24 +237,29 @@ void ModelWidget::mouseMoveEvent(QMouseEvent *event)
|
|||
setYRotation(m_yRot + 8 * dx);
|
||||
}
|
||||
}
|
||||
m_lastPos = event->pos();
|
||||
m_lastPos = pos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelWidget::zoom(float delta)
|
||||
QPoint ModelWidget::convertInputPosFromOtherWidget(QMouseEvent *event)
|
||||
{
|
||||
QMargins margins(delta, delta, delta, delta);
|
||||
setGeometry(geometry().marginsAdded(margins));
|
||||
return mapFromGlobal(event->globalPos());
|
||||
}
|
||||
|
||||
void ModelWidget::wheelEvent(QWheelEvent *event)
|
||||
bool ModelWidget::inputWheelEventFromOtherWidget(QWheelEvent *event)
|
||||
{
|
||||
QOpenGLWidget::wheelEvent(event);
|
||||
if (!m_moveStarted && m_graphicsFunctions && m_graphicsFunctions->wheel(event))
|
||||
return;
|
||||
//QPoint globalPos = event->globalPos();
|
||||
//QPoint zero;
|
||||
//QPoint leftTop = mapToGlobal(zero);
|
||||
//QRect globalRect(leftTop.x(), leftTop.y(), width(), height());
|
||||
//if (!globalRect.contains(globalPos))
|
||||
// return false;
|
||||
|
||||
if (m_moveStarted)
|
||||
return;
|
||||
return true;
|
||||
if (!m_zoomEnabled)
|
||||
return;
|
||||
return false;
|
||||
qreal delta = event->delta() / 10;
|
||||
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
if (delta > 0)
|
||||
|
@ -288,6 +271,13 @@ void ModelWidget::wheelEvent(QWheelEvent *event)
|
|||
delta = delta < 0 ? -1.0 : 1.0;
|
||||
}
|
||||
zoom(delta);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelWidget::zoom(float delta)
|
||||
{
|
||||
QMargins margins(delta, delta, delta, delta);
|
||||
setGeometry(geometry().marginsAdded(margins));
|
||||
}
|
||||
|
||||
void ModelWidget::updateMesh(MeshLoader *mesh)
|
||||
|
|
|
@ -32,6 +32,11 @@ public:
|
|||
void toggleWireframe();
|
||||
void enableMove(bool enabled);
|
||||
void enableZoom(bool enabled);
|
||||
bool inputMousePressEventFromOtherWidget(QMouseEvent *event);
|
||||
bool inputMouseMoveEventFromOtherWidget(QMouseEvent *event);
|
||||
bool inputWheelEventFromOtherWidget(QWheelEvent *event);
|
||||
bool inputMouseReleaseEventFromOtherWidget(QMouseEvent *event);
|
||||
QPoint convertInputPosFromOtherWidget(QMouseEvent *event);
|
||||
public slots:
|
||||
void setXRotation(int angle);
|
||||
void setYRotation(int angle);
|
||||
|
@ -46,12 +51,6 @@ protected:
|
|||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
void resizeGL(int width, int height) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
public:
|
||||
int xRot();
|
||||
int yRot();
|
||||
|
@ -62,7 +61,6 @@ private:
|
|||
int m_zRot;
|
||||
ModelShaderProgram *m_program;
|
||||
bool m_moveStarted;
|
||||
SkeletonGraphicsFunctions *m_graphicsFunctions;
|
||||
bool m_moveEnabled;
|
||||
bool m_zoomEnabled;
|
||||
private:
|
||||
|
|
|
@ -251,7 +251,6 @@ void MotionListWidget::reload()
|
|||
MotionWidget *widget = new MotionWidget(m_document, motionId);
|
||||
connect(widget, &MotionWidget::modifyMotion, this, &MotionListWidget::modifyMotion);
|
||||
connect(widget, &MotionWidget::cornerButtonClicked, this, &MotionListWidget::cornerButtonClicked);
|
||||
widget->previewWidget()->setGraphicsFunctions(this);
|
||||
setItemWidget(item, col, widget);
|
||||
widget->reload();
|
||||
widget->updateCheckedState(isMotionSelected(motionId));
|
||||
|
@ -277,40 +276,6 @@ void MotionListWidget::removeAllContent()
|
|||
clear();
|
||||
}
|
||||
|
||||
bool MotionListWidget::mouseMove(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MotionListWidget::wheel(QWheelEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MotionListWidget::mouseRelease(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MotionListWidget::mousePress(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
showContextMenu(mapFromGlobal(event->globalPos()));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MotionListWidget::mouseDoubleClick(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MotionListWidget::keyPress(QKeyEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void MotionListWidget::copy()
|
||||
{
|
||||
if (m_selectedMotionIds.empty() && m_currentSelectedMotionId.isNull())
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#define MOTION_LIST_WIDGET_H
|
||||
#include <QTreeWidget>
|
||||
#include <map>
|
||||
#include <QMouseEvent>
|
||||
#include "skeletondocument.h"
|
||||
#include "motionwidget.h"
|
||||
#include "skeletongraphicswidget.h"
|
||||
|
||||
class MotionListWidget : public QTreeWidget, public SkeletonGraphicsFunctions
|
||||
class MotionListWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -28,12 +28,6 @@ public slots:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
bool mouseMove(QMouseEvent *event) override;
|
||||
bool wheel(QWheelEvent *event) override;
|
||||
bool mouseRelease(QMouseEvent *event) override;
|
||||
bool mousePress(QMouseEvent *event) override;
|
||||
bool mouseDoubleClick(QMouseEvent *event) override;
|
||||
bool keyPress(QKeyEvent *event) override;
|
||||
private:
|
||||
int calculateColumnCount();
|
||||
void updateMotionSelectState(QUuid motionId, bool selected);
|
||||
|
|
|
@ -251,7 +251,6 @@ void PoseListWidget::reload()
|
|||
PoseWidget *widget = new PoseWidget(m_document, poseId);
|
||||
connect(widget, &PoseWidget::modifyPose, this, &PoseListWidget::modifyPose);
|
||||
connect(widget, &PoseWidget::cornerButtonClicked, this, &PoseListWidget::cornerButtonClicked);
|
||||
widget->previewWidget()->setGraphicsFunctions(this);
|
||||
setItemWidget(item, col, widget);
|
||||
widget->reload();
|
||||
widget->updateCheckedState(isPoseSelected(poseId));
|
||||
|
@ -277,40 +276,6 @@ void PoseListWidget::removeAllContent()
|
|||
clear();
|
||||
}
|
||||
|
||||
bool PoseListWidget::mouseMove(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PoseListWidget::wheel(QWheelEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PoseListWidget::mouseRelease(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PoseListWidget::mousePress(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
showContextMenu(mapFromGlobal(event->globalPos()));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PoseListWidget::mouseDoubleClick(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PoseListWidget::keyPress(QKeyEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void PoseListWidget::copy()
|
||||
{
|
||||
if (m_selectedPoseIds.empty() && m_currentSelectedPoseId.isNull())
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
#define POSE_LIST_WIDGET_H
|
||||
#include <QTreeWidget>
|
||||
#include <map>
|
||||
#include <QMouseEvent>
|
||||
#include "skeletondocument.h"
|
||||
#include "posewidget.h"
|
||||
#include "skeletongraphicswidget.h"
|
||||
|
||||
class PoseListWidget : public QTreeWidget, public SkeletonGraphicsFunctions
|
||||
class PoseListWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -28,12 +28,6 @@ public slots:
|
|||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
bool mouseMove(QMouseEvent *event) override;
|
||||
bool wheel(QWheelEvent *event) override;
|
||||
bool mouseRelease(QMouseEvent *event) override;
|
||||
bool mousePress(QMouseEvent *event) override;
|
||||
bool mouseDoubleClick(QMouseEvent *event) override;
|
||||
bool keyPress(QKeyEvent *event) override;
|
||||
private:
|
||||
int calculateColumnCount();
|
||||
void updatePoseSelectState(QUuid poseId, bool selected);
|
||||
|
|
|
@ -221,7 +221,8 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
|||
m_modelRenderWidget->setMinimumSize(SkeletonDocumentWindow::m_modelRenderWidgetInitialSize, SkeletonDocumentWindow::m_modelRenderWidgetInitialSize);
|
||||
m_modelRenderWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
m_modelRenderWidget->move(SkeletonDocumentWindow::m_modelRenderWidgetInitialX, SkeletonDocumentWindow::m_modelRenderWidgetInitialY);
|
||||
m_modelRenderWidget->setGraphicsFunctions(graphicsWidget);
|
||||
|
||||
m_graphicsWidget->setModelWidget(m_modelRenderWidget);
|
||||
|
||||
m_document->setSharedContextWidget(m_modelRenderWidget);
|
||||
|
||||
|
@ -230,7 +231,6 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
|||
QDockWidget *partTreeDocker = new QDockWidget(tr("Parts"), this);
|
||||
partTreeDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
||||
SkeletonPartTreeWidget *partTreeWidget = new SkeletonPartTreeWidget(m_document, partTreeDocker);
|
||||
partTreeWidget->setGraphicsFunctions(graphicsWidget);
|
||||
partTreeDocker->setWidget(partTreeWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, partTreeDocker);
|
||||
connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
|
||||
|
|
|
@ -41,7 +41,9 @@ SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document)
|
|||
m_checkedOriginItem(nullptr),
|
||||
m_ikMoveUpdateVersion(0),
|
||||
m_ikMover(nullptr),
|
||||
m_deferredRemoveTimer(nullptr)
|
||||
m_deferredRemoveTimer(nullptr),
|
||||
m_eventForwardingToModelWidget(false),
|
||||
m_modelWidget(nullptr)
|
||||
{
|
||||
setRenderHint(QPainter::Antialiasing, false);
|
||||
setBackgroundBrush(QBrush(QWidget::palette().color(QWidget::backgroundRole()), Qt::SolidPattern));
|
||||
|
@ -86,6 +88,11 @@ SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document)
|
|||
connect(this, &SkeletonGraphicsWidget::customContextMenuRequested, this, &SkeletonGraphicsWidget::showContextMenu);
|
||||
}
|
||||
|
||||
void SkeletonGraphicsWidget::setModelWidget(ModelWidget *modelWidget)
|
||||
{
|
||||
m_modelWidget = modelWidget;
|
||||
}
|
||||
|
||||
void SkeletonGraphicsWidget::enableBackgroundBlur()
|
||||
{
|
||||
m_backgroundItem->setOpacity(0.25);
|
||||
|
@ -564,27 +571,40 @@ void SkeletonGraphicsWidget::editModeChanged()
|
|||
|
||||
void SkeletonGraphicsWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_modelWidget && m_modelWidget->inputMouseMoveEventFromOtherWidget(event))
|
||||
return;
|
||||
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
mouseMove(event);
|
||||
}
|
||||
|
||||
void SkeletonGraphicsWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode ||
|
||||
SkeletonDocumentEditMode::ZoomOut == m_document->editMode ||
|
||||
SkeletonDocumentEditMode::Drag == m_document->editMode)
|
||||
QGraphicsView::wheelEvent(event);
|
||||
wheel(event);
|
||||
if (!wheel(event)) {
|
||||
if (m_modelWidget && m_modelWidget->inputWheelEventFromOtherWidget(event))
|
||||
return;
|
||||
}
|
||||
|
||||
//if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode ||
|
||||
// SkeletonDocumentEditMode::ZoomOut == m_document->editMode ||
|
||||
// SkeletonDocumentEditMode::Drag == m_document->editMode)
|
||||
// QGraphicsView::wheelEvent(event);
|
||||
}
|
||||
|
||||
void SkeletonGraphicsWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_modelWidget && m_modelWidget->inputMouseReleaseEventFromOtherWidget(event))
|
||||
return;
|
||||
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
mouseRelease(event);
|
||||
}
|
||||
|
||||
void SkeletonGraphicsWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_modelWidget && m_modelWidget->inputMousePressEventFromOtherWidget(event))
|
||||
return;
|
||||
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
m_mouseEventFromSelf = true;
|
||||
if (mousePress(event)) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "theme.h"
|
||||
#include "dust3dutil.h"
|
||||
#include "skeletonikmover.h"
|
||||
#include "modelwidget.h"
|
||||
|
||||
class SkeletonGraphicsOriginItem : public QGraphicsPolygonItem
|
||||
{
|
||||
|
@ -336,18 +337,7 @@ private:
|
|||
SkeletonProfile m_profile;
|
||||
};
|
||||
|
||||
class SkeletonGraphicsFunctions
|
||||
{
|
||||
public:
|
||||
virtual bool mouseMove(QMouseEvent *event) = 0;
|
||||
virtual bool wheel(QWheelEvent *event) = 0;
|
||||
virtual bool mouseRelease(QMouseEvent *event) = 0;
|
||||
virtual bool mousePress(QMouseEvent *event) = 0;
|
||||
virtual bool mouseDoubleClick(QMouseEvent *event) = 0;
|
||||
virtual bool keyPress(QKeyEvent *event) = 0;
|
||||
};
|
||||
|
||||
class SkeletonGraphicsWidget : public QGraphicsView, public SkeletonGraphicsFunctions
|
||||
class SkeletonGraphicsWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -411,6 +401,7 @@ public:
|
|||
bool hasEdgeSelection();
|
||||
bool hasNodeSelection();
|
||||
bool hasTwoDisconnectedNodesSelection();
|
||||
void setModelWidget(ModelWidget *modelWidget);
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
@ -522,6 +513,8 @@ private: //need initalize
|
|||
unsigned long long m_ikMoveUpdateVersion;
|
||||
SkeletonIkMover *m_ikMover;
|
||||
QTimer *m_deferredRemoveTimer;
|
||||
bool m_eventForwardingToModelWidget;
|
||||
ModelWidget *m_modelWidget;
|
||||
private:
|
||||
QVector3D m_ikMoveTarget;
|
||||
QUuid m_ikMoveEndEffectorId;
|
||||
|
|
|
@ -62,42 +62,6 @@ SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document,
|
|||
connect(this, &QTreeWidget::itemCollapsed, this, &SkeletonPartTreeWidget::groupCollapsed);
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::mouseMove(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::wheel(QWheelEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::mouseRelease(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::mousePress(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
showContextMenu(mapFromGlobal(event->globalPos()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::mouseDoubleClick(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::keyPress(QKeyEvent *event)
|
||||
{
|
||||
if (m_graphicsFunctions)
|
||||
return m_graphicsFunctions->keyPress(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void SkeletonPartTreeWidget::selectComponent(QUuid componentId, bool multiple)
|
||||
{
|
||||
if (multiple) {
|
||||
|
@ -703,7 +667,6 @@ void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTree
|
|||
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable));
|
||||
QUuid partId = component->linkToPartId;
|
||||
SkeletonPartWidget *widget = new SkeletonPartWidget(m_document, partId);
|
||||
widget->previewWidget()->setGraphicsFunctions(this);
|
||||
item->setSizeHint(0, SkeletonPartWidget::preferredSize());
|
||||
setItemWidget(item, 0, widget);
|
||||
widget->reload();
|
||||
|
@ -969,18 +932,6 @@ QSize SkeletonPartTreeWidget::sizeHint() const
|
|||
return QSize(size.width() * 1.35, size.height() * 5.5);
|
||||
}
|
||||
|
||||
void SkeletonPartTreeWidget::setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions)
|
||||
{
|
||||
m_graphicsFunctions = graphicsFunctions;
|
||||
}
|
||||
|
||||
void SkeletonPartTreeWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QTreeWidget::keyPressEvent(event);
|
||||
if (m_graphicsFunctions)
|
||||
m_graphicsFunctions->keyPress(event);
|
||||
}
|
||||
|
||||
bool SkeletonPartTreeWidget::isComponentSelected(QUuid componentId)
|
||||
{
|
||||
return (m_currentSelectedComponentId == componentId ||
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
#include <QUuid>
|
||||
#include <QMouseEvent>
|
||||
#include "skeletondocument.h"
|
||||
#include "skeletongraphicswidget.h"
|
||||
|
||||
class SkeletonPartTreeWidget : public QTreeWidget, public SkeletonGraphicsFunctions
|
||||
class SkeletonPartTreeWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
@ -44,7 +43,6 @@ signals:
|
|||
public:
|
||||
SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent);
|
||||
QTreeWidgetItem *findComponentItem(QUuid componentId);
|
||||
void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions);
|
||||
public slots:
|
||||
void componentNameChanged(QUuid componentId);
|
||||
void componentChildrenChanged(QUuid componentId);
|
||||
|
@ -71,15 +69,8 @@ public slots:
|
|||
void removeAllContent();
|
||||
void showContextMenu(const QPoint &pos);
|
||||
protected:
|
||||
virtual QSize sizeHint() const;
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
bool mouseMove(QMouseEvent *event);
|
||||
bool wheel(QWheelEvent *event);
|
||||
bool mouseRelease(QMouseEvent *event);
|
||||
bool mousePress(QMouseEvent *event);
|
||||
bool mouseDoubleClick(QMouseEvent *event);
|
||||
bool keyPress(QKeyEvent *event);
|
||||
QSize sizeHint() const override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
private:
|
||||
void addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem);
|
||||
void deleteItemChildren(QTreeWidgetItem *item);
|
||||
|
@ -91,7 +82,6 @@ private:
|
|||
const SkeletonDocument *m_document = nullptr;
|
||||
std::map<QUuid, QTreeWidgetItem *> m_partItemMap;
|
||||
std::map<QUuid, QTreeWidgetItem *> m_componentItemMap;
|
||||
SkeletonGraphicsFunctions *m_graphicsFunctions = nullptr;
|
||||
QFont m_normalFont;
|
||||
QFont m_selectedFont;
|
||||
QUuid m_currentSelectedComponentId;
|
||||
|
|
Loading…
Reference in New Issue