Merge pull request #862 from shun-iwasawa/color_locator
Locator sub-window for showing close-up image at mouse position
This commit is contained in:
commit
cb372ada0e
15 changed files with 209 additions and 14 deletions
|
@ -214,7 +214,8 @@ public:
|
|||
eFilledRaster = 0x4000000, // Used only in LineTest
|
||||
eDefineLoadBox = 0x8000000,
|
||||
eUseLoadBox = 0x10000000,
|
||||
eEnd = 0x20000000
|
||||
eLocator = 0x20000000,
|
||||
eEnd = 0x40000000
|
||||
};
|
||||
|
||||
static const UINT cFullConsole = eEnd - 1;
|
||||
|
|
|
@ -141,6 +141,7 @@ set(MOC_HEADERS
|
|||
historypane.h
|
||||
cleanupsettingspane.h
|
||||
penciltestpopup.h
|
||||
locatorpopup.h
|
||||
# Tracker file
|
||||
dummyprocessor.h
|
||||
metnum.h
|
||||
|
@ -300,6 +301,7 @@ set(SOURCES
|
|||
historypane.cpp
|
||||
cleanupsettingspane.cpp
|
||||
penciltestpopup.cpp
|
||||
locatorpopup.cpp
|
||||
# Tracker file
|
||||
dummyprocessor.cpp
|
||||
metnum.cpp
|
||||
|
|
BIN
toonz/sources/toonz/Resources/locator.png
Normal file
BIN
toonz/sources/toonz/Resources/locator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
toonz/sources/toonz/Resources/locator_click.png
Normal file
BIN
toonz/sources/toonz/Resources/locator_click.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
toonz/sources/toonz/Resources/locator_over.png
Normal file
BIN
toonz/sources/toonz/Resources/locator_over.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -85,7 +85,7 @@ ColorModelViewer::ColorModelViewer(QWidget *parent)
|
|||
FlipConsole::eCompare | FlipConsole::eCustomize |
|
||||
FlipConsole::eSave | FlipConsole::eFilledRaster |
|
||||
FlipConsole::eDefineLoadBox | FlipConsole::eUseLoadBox |
|
||||
FlipConsole::eDefineSubCamera)),
|
||||
FlipConsole::eDefineSubCamera | FlipConsole::eLocator)),
|
||||
eDontKeepFilesOpened, true)
|
||||
, m_mode(0)
|
||||
, m_currentRefImgPath(TFilePath()) {
|
||||
|
|
|
@ -179,7 +179,8 @@ public:
|
|||
FlipBook(QWidget *parent = 0, QString viewerTitle = QString(),
|
||||
UINT flipConsoleButtonMask = FlipConsole::cFullConsole &
|
||||
(~(FlipConsole::eFilledRaster |
|
||||
FlipConsole::eDefineSubCamera)),
|
||||
FlipConsole::eDefineSubCamera |
|
||||
FlipConsole::eLocator)),
|
||||
UCHAR flags = 0, bool isColorModel = false);
|
||||
~FlipBook();
|
||||
void setLevel(const TFilePath &path, TPalette *palette = 0, int from = -1,
|
||||
|
|
117
toonz/sources/toonz/locatorpopup.cpp
Normal file
117
toonz/sources/toonz/locatorpopup.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
#include "locatorpopup.h"
|
||||
|
||||
// TnzLib includes
|
||||
#include "toonz/txshlevelhandle.h"
|
||||
#include "toonz/tframehandle.h"
|
||||
#include "toonz/preferences.h"
|
||||
#include "toonz/stage2.h"
|
||||
|
||||
// Tnz6 includes
|
||||
#include "tapp.h"
|
||||
#include "sceneviewer.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
LocatorPopup::LocatorPopup(QWidget *parent)
|
||||
: QDialog(parent), m_initialZoom(true) {
|
||||
m_viewer = new SceneViewer(NULL);
|
||||
m_viewer->setParent(parent);
|
||||
m_viewer->setIsLocator();
|
||||
|
||||
//---- layout
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->addWidget(m_viewer, 1);
|
||||
setLayout(mainLayout);
|
||||
|
||||
bool ret = true;
|
||||
// When zoom changed, change window title.
|
||||
ret = connect(m_viewer, SIGNAL(onZoomChanged()), SLOT(changeWindowTitle()));
|
||||
ret = ret &&
|
||||
connect(m_viewer, SIGNAL(previewToggled()), SLOT(changeWindowTitle()));
|
||||
assert(ret);
|
||||
|
||||
resize(400, 400);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LocatorPopup::onChangeViewAff(const TPointD &pos) {
|
||||
TAffine curAff = m_viewer->getSceneMatrix();
|
||||
TAffine newAff(curAff.a11, 0, -pos.x * curAff.a11, 0, curAff.a22,
|
||||
-pos.y * curAff.a22);
|
||||
m_viewer->setViewMatrix(newAff, 0);
|
||||
m_viewer->setViewMatrix(newAff, 1);
|
||||
m_viewer->update();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LocatorPopup::showEvent(QShowEvent *) {
|
||||
// zoom the locator for the first time
|
||||
if (m_initialZoom) {
|
||||
for (int z = 0; z < 4; z++) m_viewer->zoomQt(true, false);
|
||||
m_initialZoom = false;
|
||||
}
|
||||
|
||||
TApp *app = TApp::instance();
|
||||
TFrameHandle *frameHandle = app->getCurrentFrame();
|
||||
TXshLevelHandle *levelHandle = app->getCurrentLevel();
|
||||
|
||||
bool ret = true;
|
||||
ret = ret && connect(frameHandle, SIGNAL(frameSwitched()), this,
|
||||
SLOT(changeWindowTitle()));
|
||||
ret = ret && connect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this,
|
||||
SLOT(changeWindowTitle()));
|
||||
assert(ret);
|
||||
|
||||
changeWindowTitle();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LocatorPopup::hideEvent(QHideEvent *) {
|
||||
TApp *app = TApp::instance();
|
||||
disconnect(app->getCurrentLevel());
|
||||
disconnect(app->getCurrentFrame());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LocatorPopup::changeWindowTitle() {
|
||||
TApp *app = TApp::instance();
|
||||
// put the titlebar texts in this string
|
||||
QString name = tr("Locator");
|
||||
|
||||
bool showZoomFactor = false;
|
||||
|
||||
// if the frame type is "scene editing"
|
||||
if (app->getCurrentFrame()->isEditingScene()) {
|
||||
if (m_viewer->isPreviewEnabled()) showZoomFactor = true;
|
||||
|
||||
// If the current level exists and some option is set in the preference,
|
||||
// set the zoom value to the current level's dpi
|
||||
else if (Preferences::instance()
|
||||
->isActualPixelViewOnSceneEditingModeEnabled() &&
|
||||
app->getCurrentLevel()->getSimpleLevel() &&
|
||||
!CleanupPreviewCheck::instance()
|
||||
->isEnabled() // cleanup preview must be OFF
|
||||
&&
|
||||
!CameraTestCheck::instance()
|
||||
->isEnabled()) // camera test mode must be OFF neither
|
||||
showZoomFactor = true;
|
||||
}
|
||||
// if the frame type is "level editing"
|
||||
else {
|
||||
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
||||
if (level) showZoomFactor = true;
|
||||
}
|
||||
|
||||
if (showZoomFactor) {
|
||||
name = name + " Zoom : " +
|
||||
QString::number((int)(100.0 * sqrt(m_viewer->getViewMatrix().det()) *
|
||||
m_viewer->getDpiFactor())) +
|
||||
"%";
|
||||
}
|
||||
setWindowTitle(name);
|
||||
}
|
34
toonz/sources/toonz/locatorpopup.h
Normal file
34
toonz/sources/toonz/locatorpopup.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef LOCATORPOPUP_H
|
||||
#define LOCATORPOPUP_H
|
||||
|
||||
#include "tgeometry.h"
|
||||
#include <QDialog>
|
||||
|
||||
class SceneViewer;
|
||||
|
||||
//=============================================================================
|
||||
// LoactorPopup
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class LocatorPopup : public QDialog {
|
||||
Q_OBJECT
|
||||
SceneViewer* m_viewer;
|
||||
bool m_initialZoom;
|
||||
|
||||
public:
|
||||
LocatorPopup(QWidget* parent = 0);
|
||||
SceneViewer* viewer() { return m_viewer; }
|
||||
|
||||
void onChangeViewAff(const TPointD& curPos);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*);
|
||||
void hideEvent(QHideEvent*);
|
||||
|
||||
protected slots:
|
||||
void changeWindowTitle();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -124,7 +124,7 @@ MagpieFileImportPopup::MagpieFileImportPopup()
|
|||
FlipConsole::eRed | FlipConsole::eGreen | FlipConsole::eBlue |
|
||||
FlipConsole::eMatte | FlipConsole::eDefineSubCamera |
|
||||
FlipConsole::eDefineLoadBox | FlipConsole::eUseLoadBox |
|
||||
FlipConsole::eFilledRaster));
|
||||
FlipConsole::eFilledRaster | FlipConsole::eLocator));
|
||||
m_flipbook = new FlipBook(this, tr("Import Magpie File"), buttonMask);
|
||||
m_flipbook->setFixedHeight(250);
|
||||
frameLayout->addWidget(m_flipbook);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "viewerdraw.h"
|
||||
#include "menubarcommandids.h"
|
||||
#include "ruler.h"
|
||||
#include "locatorpopup.h"
|
||||
|
||||
// TnzTools includes
|
||||
#include "tools/cursors.h"
|
||||
|
@ -501,9 +502,9 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
|
|||
, m_sideRasterPos()
|
||||
, m_topRasterPos()
|
||||
, m_toolDisableReason("")
|
||||
, m_editPreviewSubCamera(false) {
|
||||
assert(parent);
|
||||
|
||||
, m_editPreviewSubCamera(false)
|
||||
, m_locator(NULL)
|
||||
, m_isLocator(false) {
|
||||
m_visualSettings.m_sceneProperties =
|
||||
TApp::instance()->getCurrentScene()->getScene()->getProperties();
|
||||
// Enables multiple key input.
|
||||
|
@ -880,6 +881,9 @@ void SceneViewer::hideEvent(QHideEvent *) {
|
|||
|
||||
ToolHandle *toolHandle = app->getCurrentTool();
|
||||
if (toolHandle) toolHandle->disconnect(this);
|
||||
|
||||
// hide locator
|
||||
if (m_locator && m_locator->isVisible()) m_locator->hide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -967,7 +971,7 @@ void SceneViewer::drawBuildVars() {
|
|||
}
|
||||
|
||||
TTool *tool = app->getCurrentTool()->getTool();
|
||||
if (tool) tool->setViewer(this);
|
||||
if (tool && !m_isLocator) tool->setViewer(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1100,7 +1104,7 @@ void SceneViewer::drawCameraStand() {
|
|||
// Show white background when level editing mode.
|
||||
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
||||
if (m_drawEditingLevel && tool && tool->isEnabled()) {
|
||||
tool->setViewer(this);
|
||||
if (!m_isLocator) tool->setViewer(this);
|
||||
glPushMatrix();
|
||||
if (m_referenceMode == CAMERA3D_REFERENCE) {
|
||||
mult3DMatrix();
|
||||
|
@ -1358,6 +1362,13 @@ void SceneViewer::drawOverlay() {
|
|||
// use
|
||||
// another glContext
|
||||
if (tool->getName() == "T_RGBPicker") tool->onImageChanged();
|
||||
|
||||
// draw cross at the center of the locator window
|
||||
if (m_isLocator) {
|
||||
glColor3d(1.0, 0.0, 0.0);
|
||||
tglDrawSegment(TPointD(-4, 0), TPointD(5, 0));
|
||||
tglDrawSegment(TPointD(0, -4), TPointD(0, 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
class Ruler;
|
||||
class QMenu;
|
||||
class SceneViewer;
|
||||
class LocatorPopup;
|
||||
|
||||
namespace ImageUtils {
|
||||
class FullScreenWidget;
|
||||
|
@ -135,6 +136,9 @@ class SceneViewer final : public QGLWidget,
|
|||
TOP_3D,
|
||||
} m_current3DDevice;
|
||||
|
||||
LocatorPopup *m_locator;
|
||||
bool m_isLocator;
|
||||
|
||||
// iwsw commented out temporarily
|
||||
// Ghibli3DLutUtil * m_ghibli3DLutUtil;
|
||||
public:
|
||||
|
@ -230,6 +234,8 @@ public:
|
|||
|
||||
void setFocus(Qt::FocusReason reason) { QWidget::setFocus(reason); };
|
||||
|
||||
void setIsLocator() { m_isLocator = true; }
|
||||
|
||||
public:
|
||||
// SceneViewer's gadget public functions
|
||||
TPointD winToWorld(const QPoint &pos) const;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "onionskinmaskgui.h"
|
||||
#include "ruler.h"
|
||||
#include "comboviewerpane.h"
|
||||
#include "locatorpopup.h"
|
||||
|
||||
// TnzTools includes
|
||||
#include "tools/cursors.h"
|
||||
|
@ -180,6 +181,14 @@ void SceneViewer::onButtonPressed(FlipConsole::EGadget button) {
|
|||
m_editPreviewSubCamera = !m_editPreviewSubCamera;
|
||||
update();
|
||||
break;
|
||||
|
||||
// open locator. Create one for the first time
|
||||
case FlipConsole::eLocator:
|
||||
if (!m_locator) m_locator = new LocatorPopup(this);
|
||||
m_locator->show();
|
||||
m_locator->raise();
|
||||
m_locator->activateWindow();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +356,12 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
|
|||
TMouseEvent toonzEvent;
|
||||
initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
|
||||
false);
|
||||
TPointD pos = tool->getMatrix().inv() * winToWorld(curPos);
|
||||
TPointD worldPos = winToWorld(curPos);
|
||||
TPointD pos = tool->getMatrix().inv() * worldPos;
|
||||
|
||||
if (m_locator) {
|
||||
m_locator->onChangeViewAff(worldPos);
|
||||
}
|
||||
|
||||
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
|
||||
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
|
||||
|
@ -375,6 +389,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
|
|||
// panning
|
||||
panQt(curPos - m_pos);
|
||||
m_pos = curPos;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -973,6 +988,7 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
|
|||
#endif
|
||||
|
||||
if (m_freezedStatus != NO_FREEZED) return;
|
||||
if (m_isLocator) return;
|
||||
|
||||
TPoint winPos(e->pos().x(), height() - e->pos().y());
|
||||
std::vector<int> columnIndices;
|
||||
|
|
|
@ -443,5 +443,8 @@
|
|||
<file>Resources/finger_rollover.svg</file>
|
||||
<file>Resources/ruler.svg</file>
|
||||
<file>Resources/ruler_rollover.svg</file>
|
||||
<file>Resources/locator.png</file>
|
||||
<file>Resources/locator_click.png</file>
|
||||
<file>Resources/locator_over.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1234,16 +1234,19 @@ void FlipConsole::createPlayToolBar(bool withCustomWidget) {
|
|||
if (m_gadgetsMask & eRed || m_gadgetsMask & eGRed)
|
||||
m_colorFilterSep = m_playToolBar->addSeparator();
|
||||
|
||||
// Sound & Histogram
|
||||
if (m_gadgetsMask & eSound || m_gadgetsMask & eHisto) {
|
||||
// Sound & Histogram & Locator
|
||||
if (m_gadgetsMask & eSound || m_gadgetsMask & eHisto ||
|
||||
m_gadgetsMask & eLocator) {
|
||||
if (m_gadgetsMask & eSound) {
|
||||
createButton(eSound, "sound", tr("&Soundtrack "), true);
|
||||
m_soundSep = m_playToolBar->addSeparator();
|
||||
}
|
||||
if (m_gadgetsMask & eHisto) {
|
||||
if (m_gadgetsMask & eHisto)
|
||||
createButton(eHisto, "histograms", tr("&Histogram"), false);
|
||||
if (m_gadgetsMask & eLocator)
|
||||
createButton(eLocator, "locator", tr("&Locator"), false);
|
||||
if (m_gadgetsMask & eHisto || m_gadgetsMask & eLocator)
|
||||
m_histoSep = m_playToolBar->addSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gadgetsMask & eFilledRaster) {
|
||||
|
@ -1572,6 +1575,7 @@ void FlipConsole::doButtonPressed(UINT button) {
|
|||
case eHisto:
|
||||
case eSaveImg:
|
||||
case eSave:
|
||||
case eLocator:
|
||||
// nothing to do
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue