|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qtglobal></qtglobal>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "sceneviewercontextmenu.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Tnz6 includes
|
|
Toshihiro Shimizu |
890ddd |
#include "sceneviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "viewerpane.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tapp.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "iocommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "menubarcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "onionskinmaskgui.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ruler.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "comboviewerpane.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzTools includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursormanager.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcamera.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tonionskinmaskhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/dpiscale.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjecttree.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/selection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/imageutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "subcameramanager.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/keycodes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "timagecache.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qurl></qurl>
|
|
Toshihiro Shimizu |
890ddd |
#include <qapplication></qapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdebug></qdebug>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmimedata></qmimedata>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// definito - per ora - in tapp.cpp
|
|
Toshihiro Shimizu |
890ddd |
extern QString updateToolEnableStatus(TTool *tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ahime': baco di Qt. il tablet event non conosce i modificatori correnti
|
|
Toshihiro Shimizu |
890ddd |
int modifiers = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
|
|
Shinya Kitaoka |
120a6e |
int widgetHeight, double pressure, bool isTablet,
|
|
Shinya Kitaoka |
120a6e |
bool isClick) {
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pos =
|
|
Shinya Kitaoka |
120a6e |
TPoint(event->pos().x(), widgetHeight - 1 - event->pos().y());
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pressure = isTablet ? int(255 * pressure) : 255;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
|
Shinya Kitaoka |
120a6e |
event->modifiers() & Qt::AltModifier,
|
|
Shinya Kitaoka |
120a6e |
event->modifiers() & Qt::ControlModifier);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_leftButtonPressed = (event->buttons() & Qt::LeftButton) != 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void initToonzEvent(TMouseEvent &toonzEvent, QKeyEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pos = TPoint();
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pressure = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
|
Shinya Kitaoka |
120a6e |
event->modifiers() & Qt::AltModifier,
|
|
Shinya Kitaoka |
120a6e |
event->modifiers() & Qt::ControlModifier);
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_leftButtonPressed = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//====================================
|
|
Toshihiro Shimizu |
890ddd |
// SceneViewerShortcutReceiver
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class SceneViewerShortcutReceiver {
|
|
Shinya Kitaoka |
120a6e |
SceneViewer *m_viewer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SceneViewerShortcutReceiver(SceneViewer *viewer) : m_viewer(viewer) {}
|
|
Shinya Kitaoka |
120a6e |
~SceneViewerShortcutReceiver() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool exec(QKeyEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
CommandManager *cManager = CommandManager::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (event->key() == cManager->getKeyFromId(MI_RegeneratePreview)) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer->regeneratePreview();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (event->key() == cManager->getKeyFromId(MI_RegenerateFramePr)) {
|
|
Shinya Kitaoka |
120a6e |
m_viewer->regeneratePreviewFrame();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (event->key() == cManager->getKeyFromId(MI_SavePreviewedFrames)) {
|
|
Shinya Kitaoka |
120a6e |
Previewer::instance(m_viewer->getPreviewMode() ==
|
|
Shinya Kitaoka |
120a6e |
SceneViewer::SUBCAMERA_PREVIEW)
|
|
Shinya Kitaoka |
120a6e |
->saveRenderedFrames();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::onButtonPressed(FlipConsole::EGadget button) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
switch (button) {
|
|
Shinya Kitaoka |
120a6e |
case FlipConsole::eSaveImg: {
|
|
Shinya Kitaoka |
120a6e |
if (m_previewMode == NO_PREVIEW) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning(QObject::tr(
|
|
Shinya Kitaoka |
120a6e |
"It is not possible to save images in camera stand view."));
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
int row = app->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Previewer *previewer =
|
|
Shinya Kitaoka |
120a6e |
Previewer::instance(m_previewMode == SUBCAMERA_PREVIEW);
|
|
Shinya Kitaoka |
120a6e |
if (!previewer->isFrameReady(row)) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning(QObject::tr("The preview images are not ready yet."));
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterP ras =
|
|
Shinya Kitaoka |
120a6e |
previewer->getRaster(row, m_visualSettings.m_recomputeIfNeeded);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TImageCache::instance()->add(QString("TnzCompareImg"),
|
|
Shinya Kitaoka |
120a6e |
TRasterImageP(ras->clone()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case FlipConsole::eSave:
|
|
Shinya Kitaoka |
120a6e |
Previewer::instance(m_previewMode == SUBCAMERA_PREVIEW)
|
|
Shinya Kitaoka |
120a6e |
->saveRenderedFrames();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case FlipConsole::eHisto: {
|
|
Shinya Kitaoka |
120a6e |
QAction *action = CommandManager::instance()->getAction(MI_Histogram);
|
|
Shinya Kitaoka |
120a6e |
action->trigger();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case FlipConsole::eDefineSubCamera:
|
|
Shinya Kitaoka |
120a6e |
m_editPreviewSubCamera = !m_editPreviewSubCamera;
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::tabletEvent(QTabletEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = true;
|
|
Shinya Kitaoka |
120a6e |
m_pressure = e->pressure();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Management of the Eraser pointer
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
|
|
Shinya Kitaoka |
120a6e |
if (e->pointerType() == QTabletEvent::Eraser) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_eraserPointerOn) {
|
|
Shinya Kitaoka |
120a6e |
if (toolHandle->getTool()->getName() != T_Eraser) {
|
|
Shinya Kitaoka |
120a6e |
// Save the current tool
|
|
Shinya Kitaoka |
120a6e |
m_backupTool = QString::fromStdString(toolHandle->getTool()->getName());
|
|
Shinya Kitaoka |
120a6e |
// Switch to the Eraser tool
|
|
Shinya Kitaoka |
120a6e |
toolHandle->setTool(T_Eraser);
|
|
Shinya Kitaoka |
120a6e |
m_eraserPointerOn = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (m_eraserPointerOn) {
|
|
Shinya Kitaoka |
120a6e |
// Restore the previous tool
|
|
Shinya Kitaoka |
120a6e |
toolHandle->setTool(m_backupTool);
|
|
Shinya Kitaoka |
120a6e |
m_eraserPointerOn = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
e->ignore();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::leaveEvent(QEvent *) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_isMouseEntered) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_isMouseEntered = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (tool && tool->isEnabled()) tool->onLeave();
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::enterEvent(QEvent *) {
|
|
Shinya Kitaoka |
120a6e |
if (m_isMouseEntered) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_isMouseEntered = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
modifiers = 0;
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = app->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
|
Shinya Kitaoka |
120a6e |
if (level && level->getSimpleLevel())
|
|
Shinya Kitaoka |
120a6e |
m_dpiScale =
|
|
Shinya Kitaoka |
120a6e |
getCurrentDpiScale(level->getSimpleLevel(), tool->getCurrentFid());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_dpiScale = TPointD(1, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
invalidateToolStatus();
|
|
Shinya Kitaoka |
120a6e |
if (tool && tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
tool->updateMatrix();
|
|
Shinya Kitaoka |
120a6e |
tool->onEnter();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setFocus();
|
|
Shinya Kitaoka |
120a6e |
updateGL();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPoint curPos = event->pos();
|
|
Shinya Kitaoka |
120a6e |
bool cursorSet = false;
|
|
Shinya Kitaoka |
120a6e |
m_lastMousePos = curPos;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_editPreviewSubCamera) {
|
|
Shinya Kitaoka |
120a6e |
if (!PreviewSubCameraManager::instance()->mouseMoveEvent(this, event))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// if the "compare with snapshot" mode is activated, change the mouse cursor
|
|
Shinya Kitaoka |
120a6e |
// on the border handle
|
|
Shinya Kitaoka |
120a6e |
if (m_visualSettings.m_doCompare) {
|
|
Shinya Kitaoka |
120a6e |
if (abs(curPos.x() - width() * m_compareSettings.m_compareX) < 20) {
|
|
Shinya Kitaoka |
120a6e |
cursorSet = true;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(this, ToolCursor::ScaleHCursor);
|
|
Shinya Kitaoka |
120a6e |
} else if (abs((height() - curPos.y()) -
|
|
Shinya Kitaoka |
120a6e |
height() * m_compareSettings.m_compareY) < 20) {
|
|
Shinya Kitaoka |
120a6e |
cursorSet = true;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(this, ToolCursor::ScaleVCursor);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// control of the border handle when the "compare with snapshot" mode is
|
|
Shinya Kitaoka |
120a6e |
// activated
|
|
Shinya Kitaoka |
120a6e |
if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY) {
|
|
Shinya Kitaoka |
120a6e |
if (m_compareSettings.m_dragCompareX)
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareX +=
|
|
Shinya Kitaoka |
120a6e |
((double)(curPos.x() - m_pos.x())) / width();
|
|
Shinya Kitaoka |
120a6e |
else if (m_compareSettings.m_dragCompareY)
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareY -=
|
|
Shinya Kitaoka |
120a6e |
((double)(curPos.y() - m_pos.y())) / height();
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareX =
|
|
Shinya Kitaoka |
120a6e |
tcrop(m_compareSettings.m_compareX, 0.0, 1.0);
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareY =
|
|
Shinya Kitaoka |
120a6e |
tcrop(m_compareSettings.m_compareY, 0.0, 1.0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_pos = curPos;
|
|
Shinya Kitaoka |
120a6e |
} else if (m_mouseButton == Qt::NoButton || m_mouseButton == Qt::LeftButton) {
|
|
Shinya Kitaoka |
120a6e |
if (is3DView() && m_current3DDevice != NONE &&
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton == Qt::LeftButton)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
else if (is3DView() && m_mouseButton == Qt::NoButton) {
|
|
Shinya Kitaoka |
120a6e |
TRectD rect = TRectD(TPointD(m_topRasterPos.x, m_topRasterPos.y),
|
|
Shinya Kitaoka |
120a6e |
TDimensionD(20, 20));
|
|
Shinya Kitaoka |
120a6e |
if (rect.contains(TPointD(curPos.x(), curPos.y())))
|
|
Shinya Kitaoka |
120a6e |
m_current3DDevice = TOP_3D;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
rect = TRectD(TPointD(m_sideRasterPos.x, m_sideRasterPos.y),
|
|
Shinya Kitaoka |
120a6e |
TDimensionD(20, 20));
|
|
Shinya Kitaoka |
120a6e |
if (rect.contains(TPointD(curPos.x(), curPos.y()))) {
|
|
Shinya Kitaoka |
120a6e |
if (m_phi3D > 0)
|
|
Shinya Kitaoka |
120a6e |
m_current3DDevice = SIDE_RIGHT_3D;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_current3DDevice = SIDE_LEFT_3D;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_current3DDevice = NONE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_current3DDevice != NONE) {
|
|
Shinya Kitaoka |
120a6e |
cursorSet = true;
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(this, ToolCursor::CURSOR_ARROW);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// if the middle mouse button is pressed while dragging, then do panning
|
|
Shinya Kitaoka |
120a6e |
Qt::MouseButtons mousebuttons;
|
|
Shinya Kitaoka |
120a6e |
mousebuttons = event->buttons();
|
|
Shinya Kitaoka |
120a6e |
if (mousebuttons & Qt::MidButton) {
|
|
Shinya Kitaoka |
120a6e |
// panning
|
|
Shinya Kitaoka |
120a6e |
QPoint p = curPos - m_pos;
|
|
Shinya Kitaoka |
120a6e |
if (m_pos == QPoint(0, 0) && p.manhattanLength() > 300) return;
|
|
Shinya Kitaoka |
120a6e |
panQt(curPos - m_pos);
|
|
Shinya Kitaoka |
120a6e |
m_pos = curPos;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
|
|
Shinya Kitaoka |
120a6e |
false);
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(curPos);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// qDebug() << "mouseMoveEvent. " << (m_tabletEvent?"tablet":"mouse")
|
|
Shinya Kitaoka |
120a6e |
// << " pressure=" << m_pressure << " mouseButton=" << m_mouseButton
|
|
Shinya Kitaoka |
120a6e |
// << " buttonClicked=" << m_buttonClicked;
|
|
Shinya Kitaoka |
120a6e |
if ((m_tabletEvent && m_pressure > 0) || m_mouseButton == Qt::LeftButton) {
|
|
Shinya Kitaoka |
120a6e |
// sometimes the mousePressedEvent is postponed to a wrong mouse move
|
|
Shinya Kitaoka |
120a6e |
// event!
|
|
Shinya Kitaoka |
120a6e |
if (m_buttonClicked) tool->leftButtonDrag(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
} else if (m_pressure == 0) {
|
|
Shinya Kitaoka |
120a6e |
tool->mouseMove(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
// m_tabletEvent=false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (!cursorSet) setToolCursor(this, tool->getCursorId());
|
|
Shinya Kitaoka |
120a6e |
m_pos = curPos;
|
|
Shinya Kitaoka |
120a6e |
} else if (m_mouseButton == Qt::MidButton) {
|
|
Shinya Kitaoka |
120a6e |
if ((event->buttons() & Qt::MidButton) == 0)
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton = Qt::NoButton;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
// panning
|
|
Shinya Kitaoka |
120a6e |
panQt(curPos - m_pos);
|
|
Shinya Kitaoka |
120a6e |
m_pos = curPos;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
// evita i press ripetuti
|
|
Shinya Kitaoka |
120a6e |
if (m_buttonClicked) return;
|
|
Shinya Kitaoka |
120a6e |
m_buttonClicked = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton != Qt::NoButton) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_pos = event->pos();
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton = event->button();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// when using tablet, avoid unexpected drawing behavior occurs when
|
|
Shinya Kitaoka |
120a6e |
// middle-click
|
|
Shinya Kitaoka |
120a6e |
Qt::MouseButtons mousebuttons;
|
|
Shinya Kitaoka |
120a6e |
mousebuttons = event->buttons();
|
|
Shinya Kitaoka |
120a6e |
if (m_tabletEvent && m_mouseButton == Qt::MidButton &&
|
|
Shinya Kitaoka |
120a6e |
(mousebuttons | Qt::LeftButton))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (is3DView() && m_current3DDevice != NONE &&
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton == Qt::LeftButton)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
else if (m_mouseButton == Qt::LeftButton && m_editPreviewSubCamera) {
|
|
Shinya Kitaoka |
120a6e |
if (!PreviewSubCameraManager::instance()->mousePressEvent(this, event))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else if (m_mouseButton == Qt::LeftButton && m_visualSettings.m_doCompare) {
|
|
Shinya Kitaoka |
120a6e |
if (abs(m_pos.x() - width() * m_compareSettings.m_compareX) < 20) {
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareX = true;
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareY = false;
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareY = ImagePainter::DefaultCompareValue;
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else if (abs((height() - m_pos.y()) -
|
|
Shinya Kitaoka |
120a6e |
height() * m_compareSettings.m_compareY) < 20) {
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareY = true;
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareX = false;
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_compareX = ImagePainter::DefaultCompareValue;
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareX = m_compareSettings.m_dragCompareY =
|
|
Shinya Kitaoka |
120a6e |
false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton == Qt::LeftButton && tool->preLeftButtonDown()) {
|
|
Shinya Kitaoka |
120a6e |
tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
if (m_pressure > 0 && !m_tabletEvent) m_tabletEvent = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TApp::instance()->isPenCloseToTablet()) m_tabletEvent = true;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true);
|
|
Shinya Kitaoka |
120a6e |
// if(!m_tabletEvent) qDebug() << "-----------------MOUSE PRESS 'PURO'.
|
|
Shinya Kitaoka |
120a6e |
// POSSIBILE EMBOLO";
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(m_pos);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton == Qt::LeftButton) {
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentTool()->setToolBusy(true);
|
|
Shinya Kitaoka |
120a6e |
tool->leftButtonDown(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton == Qt::RightButton) tool->rightButtonDown(pos, toonzEvent);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::mouseReleaseEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
// evita i release ripetuti
|
|
Shinya Kitaoka |
120a6e |
if (!m_buttonClicked) return;
|
|
Shinya Kitaoka |
120a6e |
m_buttonClicked = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_toolDisableReason.isEmpty() && m_mouseButton == Qt::LeftButton &&
|
|
Shinya Kitaoka |
120a6e |
!m_editPreviewSubCamera)
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning(m_toolDisableReason);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton != event->button()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_current3DDevice != NONE) {
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton = Qt::NoButton;
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
m_pressure = 0;
|
|
Shinya Kitaoka |
120a6e |
if (m_current3DDevice == SIDE_LEFT_3D)
|
|
Shinya Kitaoka |
120a6e |
set3DLeftSideView();
|
|
Shinya Kitaoka |
120a6e |
else if (m_current3DDevice == SIDE_RIGHT_3D)
|
|
Shinya Kitaoka |
120a6e |
set3DRightSideView();
|
|
Shinya Kitaoka |
120a6e |
else if (m_current3DDevice == TOP_3D)
|
|
Shinya Kitaoka |
120a6e |
set3DTopView();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton == Qt::LeftButton && m_editPreviewSubCamera) {
|
|
Shinya Kitaoka |
120a6e |
if (!PreviewSubCameraManager::instance()->mouseReleaseEvent(this, event))
|
|
Shinya Kitaoka |
120a6e |
goto quit;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY) {
|
|
Shinya Kitaoka |
120a6e |
m_compareSettings.m_dragCompareX = m_compareSettings.m_dragCompareY = false;
|
|
Shinya Kitaoka |
120a6e |
goto quit;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_pos = QPoint(0, 0);
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) goto quit;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
|
|
Shinya Kitaoka |
120a6e |
false);
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(event->pos());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_mouseButton == Qt::LeftButton) {
|
|
Shinya Kitaoka |
120a6e |
tool->leftButtonUp(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentTool()->setToolBusy(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
quit:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_mouseButton = Qt::NoButton;
|
|
Shinya Kitaoka |
120a6e |
m_tabletEvent = false;
|
|
Shinya Kitaoka |
120a6e |
m_pressure = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::wheelEvent(QWheelEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int delta = 0;
|
|
Shinya Kitaoka |
120a6e |
switch (event->source()) {
|
|
Shinya Kitaoka |
120a6e |
case Qt::MouseEventNotSynthesized: {
|
|
Shinya Kitaoka |
120a6e |
delta = event->angleDelta().y();
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case Qt::MouseEventSynthesizedBySystem: {
|
|
Shinya Kitaoka |
120a6e |
QPoint numPixels = event->pixelDelta();
|
|
Shinya Kitaoka |
120a6e |
QPoint numDegrees = event->angleDelta() / 8;
|
|
Shinya Kitaoka |
120a6e |
if (!numPixels.isNull()) {
|
|
Shinya Kitaoka |
120a6e |
delta = event->pixelDelta().y();
|
|
Shinya Kitaoka |
120a6e |
} else if (!numDegrees.isNull()) {
|
|
Shinya Kitaoka |
120a6e |
QPoint numSteps = numDegrees / 15;
|
|
Shinya Kitaoka |
120a6e |
delta = numSteps.y();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
default: // Qt::MouseEventSynthesizedByQt,
|
|
Shinya Kitaoka |
120a6e |
// Qt::MouseEventSynthesizedByApplication
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
std::cout << "not supported event: Qt::MouseEventSynthesizedByQt, "
|
|
Shinya Kitaoka |
120a6e |
"Qt::MouseEventSynthesizedByApplication"
|
|
Shinya Kitaoka |
120a6e |
<< std::endl;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // end switch
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (abs(delta) > 0) {
|
|
Shinya Kitaoka |
120a6e |
zoomQt(event->pos(), exp(0.001 * delta));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
event->accept();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool SceneViewer::event(QEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::KeyPress) {
|
|
Shinya Kitaoka |
120a6e |
if (!((QKeyEvent *)e)->isAutoRepeat()) {
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentTool()->storeTool();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (e->type() == QEvent::ShortcutOverride) {
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (tool && tool->isEnabled() && tool->getName() == T_Type &&
|
|
Shinya Kitaoka |
120a6e |
tool->isActive())
|
|
Shinya Kitaoka |
120a6e |
e->accept();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (e->type() == QEvent::KeyRelease) {
|
|
Shinya Kitaoka |
120a6e |
if (!((QKeyEvent *)e)->isAutoRepeat()) {
|
|
Shinya Kitaoka |
120a6e |
QWidget *focusWidget = QApplication::focusWidget();
|
|
Shinya Kitaoka |
120a6e |
if (focusWidget == 0 ||
|
|
Shinya Kitaoka |
120a6e |
QString(focusWidget->metaObject()->className()) == "SceneViewer")
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentTool()->restoreTool();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// discard too frequent move events
|
|
Shinya Kitaoka |
120a6e |
static QTime clock;
|
|
Shinya Kitaoka |
120a6e |
if (e->type() == QEvent::MouseButtonPress)
|
|
Shinya Kitaoka |
120a6e |
clock.start();
|
|
Shinya Kitaoka |
120a6e |
else if (e->type() == QEvent::MouseMove) {
|
|
Shinya Kitaoka |
120a6e |
if (clock.elapsed() < 10) {
|
|
Shinya Kitaoka |
120a6e |
e->accept();
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clock.start();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
switch(e->type())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
case QEvent::Enter:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "************************** Enter";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case QEvent::Leave:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "************************** Leave";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case QEvent::TabletPress:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "************************** TabletPress" << m_pressure;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case QEvent::TabletMove:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "************************** TabletMove";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case QEvent::TabletRelease:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "************************** TabletRelease";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case QEvent::MouseButtonPress:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "**************************MouseButtonPress" << m_pressure << " "
|
|
Shinya Kitaoka |
120a6e |
<< m_tabletEvent;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case QEvent::MouseMove:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "**************************MouseMove" << m_pressure;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case QEvent::MouseButtonRelease:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "**************************MouseButtonRelease";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case QEvent::MouseButtonDblClick:
|
|
Shinya Kitaoka |
120a6e |
qDebug() << "============================== MouseButtonDblClick";
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return QGLWidget::event(e);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
class ViewerZoomer : public ImageUtils::ShortcutZoomer {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ViewerZoomer(SceneViewer *parent) : ShortcutZoomer(parent) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool zoom(bool zoomin, bool resetZoom) override {
|
|
Shinya Kitaoka |
120a6e |
SceneViewer *sceneViewer = static_cast<sceneviewer *="">(getWidget());</sceneviewer>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
resetZoom ? sceneViewer->resetSceneViewer()
|
|
Shinya Kitaoka |
120a6e |
: sceneViewer->zoomQt(zoomin, resetZoom);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool fit() override {
|
|
Shinya Kitaoka |
120a6e |
static_cast<sceneviewer *="">(getWidget())->fitToCamera();</sceneviewer>
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool setActualPixelSize() override {
|
|
Shinya Kitaoka |
120a6e |
static_cast<sceneviewer *="">(getWidget())->setActualPixelSize();</sceneviewer>
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool toggleFullScreen(bool quit) override {
|
|
Shinya Kitaoka |
120a6e |
if (ImageUtils::FullScreenWidget *fsWidget =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<imageutils::fullscreenwidget *="">(</imageutils::fullscreenwidget>
|
|
Shinya Kitaoka |
120a6e |
getWidget()->parentWidget()))
|
|
Shinya Kitaoka |
120a6e |
return fsWidget->toggleFullScreen(quit);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool changeFrameSkippingHolds(QKeyEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if ((e->modifiers() & Qt::ShiftModifier) == 0 ||
|
|
Shinya Kitaoka |
120a6e |
e->key() != Qt::Key_Down && e->key() != Qt::Key_Up)
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = app->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
if (!fh->isEditingScene()) return false;
|
|
Shinya Kitaoka |
120a6e |
int row = fh->getFrame();
|
|
Shinya Kitaoka |
120a6e |
int col = app->getCurrentColumn()->getColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
TXshCell cell = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
if (e->key() == Qt::Key_Down) {
|
|
Shinya Kitaoka |
120a6e |
if (cell.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
int r0, r1;
|
|
Shinya Kitaoka |
120a6e |
if (xsh->getCellRange(col, r0, r1)) {
|
|
Shinya Kitaoka |
120a6e |
while (row <= r1 && xsh->getCell(row, col).isEmpty()) row++;
|
|
Shinya Kitaoka |
120a6e |
if (xsh->getCell(row, col).isEmpty()) return false;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
while (xsh->getCell(row, col) == cell) row++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Key_Up
|
|
Shinya Kitaoka |
120a6e |
while (row >= 0 && xsh->getCell(row, col) == cell) row--;
|
|
Shinya Kitaoka |
120a6e |
if (row < 0) return false;
|
|
Shinya Kitaoka |
120a6e |
cell = xsh->getCell(row, col);
|
|
Shinya Kitaoka |
120a6e |
while (row > 0 && xsh->getCell(row - 1, col) == cell) row--;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
fh->setFrame(row);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::keyPressEvent(QKeyEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int key = event->key();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (changeFrameSkippingHolds(event)) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if ((event->modifiers() & Qt::ShiftModifier) &&
|
|
Shinya Kitaoka |
120a6e |
(key == Qt::Key_Down || key == Qt::Key_Up)) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isTextToolActive = tool->getName() == T_Type && tool->isActive();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!isTextToolActive && ViewerZoomer(this).exec(event)) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!isTextToolActive && SceneViewerShortcutReceiver(this).exec(event))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (key == Qt::Key_Shift)
|
|
Shinya Kitaoka |
120a6e |
modifiers |= Qt::SHIFT;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Control)
|
|
Shinya Kitaoka |
120a6e |
modifiers |= Qt::CTRL;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Alt || key == Qt::Key_AltGr)
|
|
Shinya Kitaoka |
120a6e |
modifiers |= Qt::ALT;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||
|
|
Shinya Kitaoka |
120a6e |
key == Qt::Key_AltGr) {
|
|
Shinya Kitaoka |
120a6e |
// quando l'utente preme shift/ctrl ecc. alcuni tool (es. pinch) devono
|
|
Shinya Kitaoka |
120a6e |
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event);
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pos =
|
|
Shinya Kitaoka |
120a6e |
TPoint(m_lastMousePos.x(), height() - 1 - m_lastMousePos.y());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tool->mouseMove(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(this, tool->getCursorId());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool shiftButton = QApplication::keyboardModifiers() == Qt::ShiftModifier;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TUINT32 flags = 0;
|
|
Shinya Kitaoka |
120a6e |
TPoint pos;
|
|
Shinya Kitaoka |
120a6e |
if (key == Qt::Key_Shift)
|
|
Shinya Kitaoka |
120a6e |
flags = TwConsts::TK_ShiftPressed;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Control)
|
|
Shinya Kitaoka |
120a6e |
flags = TwConsts::TK_CtrlPressed;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Alt)
|
|
Shinya Kitaoka |
120a6e |
flags = TwConsts::TK_AltPressed;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_CapsLock)
|
|
Shinya Kitaoka |
120a6e |
flags = TwConsts::TK_CapsLock;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Backspace)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Backspace;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Return)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Return;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Left && !shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_LeftArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Right && !shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_RightArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Up && !shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_UpArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Down && !shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_DownArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Left && shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_ShiftLeftArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Right && shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_ShiftRightArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Up && shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_ShiftUpArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Down && shiftButton)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_ShiftDownArrow;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Home)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Home;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_End)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_End;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_PageUp)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_PageUp;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_PageDown)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_PageDown;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Insert)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Insert;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Delete)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Delete;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Escape)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_Esc;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F1)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F1;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F2)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F2;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F3)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F3;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F4)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F4;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F5)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F5;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F6)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F6;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F7)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F7;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F8)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F8;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F9)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F9;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F10)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F10;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F11)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F11;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_F12)
|
|
Shinya Kitaoka |
120a6e |
key = TwConsts::TK_F12;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Menu || key == Qt::Key_Meta)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret = false;
|
|
Shinya Kitaoka |
120a6e |
if (tool) // && m_toolEnabled)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QString text = event->text();
|
|
Shinya Kitaoka |
120a6e |
if ((event->modifiers() & Qt::ShiftModifier)) text.toUpper();
|
|
Shinya Kitaoka |
120a6e |
std::wstring unicodeChar = text.toStdWString();
|
|
Shinya Kitaoka |
120a6e |
ret = tool->keyDown(key, unicodeChar, flags, pos); // per il textTool
|
|
Shinya Kitaoka |
120a6e |
if (ret) {
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ret = tool->keyDown(key, flags, pos); // per gli altri tool
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (!ret) {
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *fh = TApp::instance()->getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (key == TwConsts::TK_UpArrow)
|
|
Shinya Kitaoka |
120a6e |
fh->prevFrame();
|
|
Shinya Kitaoka |
120a6e |
else if (key == TwConsts::TK_DownArrow)
|
|
Shinya Kitaoka |
120a6e |
fh->nextFrame();
|
|
Shinya Kitaoka |
120a6e |
else if (key == TwConsts::TK_Home)
|
|
Shinya Kitaoka |
120a6e |
fh->firstFrame();
|
|
Shinya Kitaoka |
120a6e |
else if (key == TwConsts::TK_End)
|
|
Shinya Kitaoka |
120a6e |
fh->lastFrame();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
// TODO: devo accettare l'evento?
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::keyReleaseEvent(QKeyEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
tool->setViewer(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int key = event->key();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||
|
|
Shinya Kitaoka |
120a6e |
key == Qt::Key_AltGr) {
|
|
Shinya Kitaoka |
120a6e |
if (key == Qt::Key_Shift)
|
|
Shinya Kitaoka |
120a6e |
modifiers &= ~Qt::ShiftModifier;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Control)
|
|
Shinya Kitaoka |
120a6e |
modifiers &= ~Qt::ControlModifier;
|
|
Shinya Kitaoka |
120a6e |
else if (key == Qt::Key_Alt || key == Qt::Key_AltGr)
|
|
Shinya Kitaoka |
120a6e |
modifiers &= ~Qt::AltModifier;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// quando l'utente preme shift/ctrl ecc. alcuni tool (es. pinch) devono
|
|
Shinya Kitaoka |
120a6e |
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event);
|
|
Shinya Kitaoka |
120a6e |
toonzEvent.m_pos =
|
|
Shinya Kitaoka |
120a6e |
TPoint(m_lastMousePos.x(), height() - 1 - m_lastMousePos.y());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tool->mouseMove(pos, toonzEvent);
|
|
Shinya Kitaoka |
120a6e |
setToolCursor(this, tool->getCursorId());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (tool->getName() == T_Type)
|
|
Shinya Kitaoka |
120a6e |
event->accept();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
event->ignore();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int frame = TApp::instance()->getCurrentFrame()->getFrame();
|
|
Shinya Kitaoka |
120a6e |
if (frame == -1) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (!tool || !tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
TMouseEvent toonzEvent;
|
|
Shinya Kitaoka |
120a6e |
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true);
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = tool->getMatrix().inv() * winToWorld(event->pos());
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
|
Shinya Kitaoka |
120a6e |
pos.x /= m_dpiScale.x;
|
|
Shinya Kitaoka |
120a6e |
pos.y /= m_dpiScale.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (event->button() == Qt::LeftButton)
|
|
Shinya Kitaoka |
120a6e |
tool->leftButtonDoubleClick(pos, toonzEvent);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace ImageUtils;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
|
|
Shinya Kitaoka |
9f5a1b |
#ifndef _WIN32
|
|
Shinya Kitaoka |
120a6e |
/* On windows the widget receive the release event before the menu
|
|
Shinya Kitaoka |
120a6e |
is shown, on linux and osx the release event is lost, never
|
|
Shinya Kitaoka |
120a6e |
received by the widget */
|
|
Shinya Kitaoka |
120a6e |
QMouseEvent fakeRelease(QEvent::MouseButtonRelease, e->pos(), Qt::RightButton,
|
|
Shinya Kitaoka |
120a6e |
Qt::NoButton, Qt::NoModifier);
|
|
xenogenesi |
456038 |
|
|
Shinya Kitaoka |
120a6e |
QApplication::instance()->sendEvent(this, &fakeRelease);
|
|
tomosu |
cb0b4d |
#endif
|
|
tomosu |
cb0b4d |
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint winPos(e->pos().x(), height() - e->pos().y());
|
|
Shinya Kitaoka |
120a6e |
std::vector<int> columnIndices;</int>
|
|
Shinya Kitaoka |
120a6e |
// enable to select all the columns regardless of the click position
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0;
|
|
Shinya Kitaoka |
120a6e |
i < TApp::instance()->getCurrentXsheet()->getXsheet()->getColumnCount();
|
|
Shinya Kitaoka |
120a6e |
i++)
|
|
Shinya Kitaoka |
120a6e |
columnIndices.push_back(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SceneViewerContextMenu *menu = new SceneViewerContextMenu(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
TPointD pos =
|
|
Shinya Kitaoka |
120a6e |
((tool) ? tool->getMatrix().inv() : TAffine()) * winToWorld(e->pos());
|
|
Shinya Kitaoka |
120a6e |
menu->addEnterGroupCommands(pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
menu->addLevelCommands(columnIndices);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ComboViewerPanel *cvp = qobject_cast<comboviewerpanel *="">(</comboviewerpanel>
|
|
Shinya Kitaoka |
120a6e |
parentWidget()->parentWidget()->parentWidget());
|
|
Shinya Kitaoka |
120a6e |
if (cvp) {
|
|
Shinya Kitaoka |
120a6e |
menu->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
cvp->addShowHideContextMenu(menu);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
menu->exec(e->globalPos());
|
|
Shinya Kitaoka |
120a6e |
delete menu;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::inputMethodEvent(QInputMethodEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (tool && tool->isEnabled()) {
|
|
Shinya Kitaoka |
120a6e |
tool->onInputText(e->preeditString().toStdWString(),
|
|
Shinya Kitaoka |
120a6e |
e->commitString().toStdWString(), e->replacementStart(),
|
|
Shinya Kitaoka |
120a6e |
e->replacementLength());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::dragEnterEvent(QDragEnterEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = event->mimeData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (acceptResourceOrFolderDrop(mimeData->urls()))
|
|
Shinya Kitaoka |
120a6e |
event->acceptProposedAction();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
event->ignore();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::dropEvent(QDropEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
if (m_freezedStatus != NO_FREEZED) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = e->mimeData();
|
|
Shinya Kitaoka |
120a6e |
if (mimeData->hasUrls()) {
|
|
Shinya Kitaoka |
120a6e |
IoCmd::LoadResourceArguments args;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
foreach (const QUrl &url, mimeData->urls()) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(url.toLocalFile().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
args.resourceDatas.push_back(fp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
IoCmd::loadResources(args);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
e->acceptProposedAction();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SceneViewer::onToolSwitched() {
|
|
Shinya Kitaoka |
120a6e |
m_forceGlFlush = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
invalidateToolStatus();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
|
Shinya Kitaoka |
120a6e |
if (tool) tool->updateMatrix();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
onLevelChanged();
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|