Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

locator popup

shun_iwasawadb5f54040cd9
diff --git a/toonz/sources/include/toonzqt/flipconsole.h b/toonz/sources/include/toonzqt/flipconsole.h
index f7d54e63c..5e7c32ae9 100644
--- a/toonz/sources/include/toonzqt/flipconsole.h
+++ b/toonz/sources/include/toonzqt/flipconsole.h
@@ -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;
diff --git a/toonz/sources/tnztools/brushtool.cpp b/toonz/sources/tnztools/brushtool.cpp
index 3272da2f5..84599e9a5 100644
--- a/toonz/sources/tnztools/brushtool.cpp
+++ b/toonz/sources/tnztools/brushtool.cpp
@@ -1688,6 +1688,8 @@ void BrushTool::draw() {
} else {
tglDrawCircle(m_brushPos, 0.5 * m_minThick);
tglDrawCircle(m_brushPos, 0.5 * m_maxThick);
+ std::cout << "BRUSH m_brushPos = " << m_brushPos.x << ", " << m_brushPos.y
+ << std::endl;
}
}
diff --git a/toonz/sources/tnztools/vectorerasertool.cpp b/toonz/sources/tnztools/vectorerasertool.cpp
index 18d75023a..a1c8c54d5 100644
--- a/toonz/sources/tnztools/vectorerasertool.cpp
+++ b/toonz/sources/tnztools/vectorerasertool.cpp
@@ -427,6 +427,8 @@ void EraserTool::draw() {
if (m_eraseType.getValue() == NORMAL_ERASE) {
tglColor(TPixel32(255, 0, 255));
tglDrawCircle(m_brushPos, m_pointSize);
+ std::cout << "ERASER m_brushPos = " << m_brushPos.x << ", "
+ << m_brushPos.y << std::endl;
}
if ((m_eraseType.getValue() == FREEHAND_ERASE ||
m_eraseType.getValue() == POLYLINE_ERASE) &&
diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt
index 41ff9b355..2f6670fd9 100644
--- a/toonz/sources/toonz/CMakeLists.txt
+++ b/toonz/sources/toonz/CMakeLists.txt
@@ -140,6 +140,7 @@ set(MOC_HEADERS
historypane.h
cleanupsettingspane.h
penciltestpopup.h
+ locatorpopup.h
# Tracker file
dummyprocessor.h
metnum.h
@@ -298,6 +299,7 @@ set(SOURCES
historypane.cpp
cleanupsettingspane.cpp
penciltestpopup.cpp
+ locatorpopup.cpp
# Tracker file
dummyprocessor.cpp
metnum.cpp
diff --git a/toonz/sources/toonz/Resources/locator.png b/toonz/sources/toonz/Resources/locator.png
new file mode 100644
index 000000000..439df6358
Binary files /dev/null and b/toonz/sources/toonz/Resources/locator.png differ
diff --git a/toonz/sources/toonz/Resources/locator_click.png b/toonz/sources/toonz/Resources/locator_click.png
new file mode 100644
index 000000000..80452210f
Binary files /dev/null and b/toonz/sources/toonz/Resources/locator_click.png differ
diff --git a/toonz/sources/toonz/Resources/locator_over.png b/toonz/sources/toonz/Resources/locator_over.png
new file mode 100644
index 000000000..80452210f
Binary files /dev/null and b/toonz/sources/toonz/Resources/locator_over.png differ
diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp
index 9ff95ab44..e4b0085c1 100644
--- a/toonz/sources/toonz/colormodelviewer.cpp
+++ b/toonz/sources/toonz/colormodelviewer.cpp
@@ -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()) {
diff --git a/toonz/sources/toonz/flipbook.h b/toonz/sources/toonz/flipbook.h
index a116f3c73..b9e13ee0c 100644
--- a/toonz/sources/toonz/flipbook.h
+++ b/toonz/sources/toonz/flipbook.h
@@ -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,
diff --git a/toonz/sources/toonz/locatorpopup.cpp b/toonz/sources/toonz/locatorpopup.cpp
new file mode 100644
index 000000000..048626e64
--- /dev/null
+++ b/toonz/sources/toonz/locatorpopup.cpp
@@ -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 TAffine &affine, 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);
+}
\ No newline at end of file
diff --git a/toonz/sources/toonz/locatorpopup.h b/toonz/sources/toonz/locatorpopup.h
new file mode 100644
index 000000000..7745e2acc
--- /dev/null
+++ b/toonz/sources/toonz/locatorpopup.h
@@ -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 TAffine& affine, const TPointD& curPos);
+
+protected:
+ void showEvent(QShowEvent*);
+ void hideEvent(QHideEvent*);
+
+protected slots:
+ void changeWindowTitle();
+};
+
+#endif
\ No newline at end of file
diff --git a/toonz/sources/toonz/magpiefileimportpopup.cpp b/toonz/sources/toonz/magpiefileimportpopup.cpp
index 5134d722b..72a90abcf 100644
--- a/toonz/sources/toonz/magpiefileimportpopup.cpp
+++ b/toonz/sources/toonz/magpiefileimportpopup.cpp
@@ -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);
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index d039b34c3..6873009cf 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -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);
}
//-----------------------------------------------------------------------------
@@ -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(-5, 0), TPointD(5, 0));
+ tglDrawSegment(TPointD(0, -5), TPointD(0, 5));
+ }
}
}
diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h
index 68ed8dedf..0941505b6 100644
--- a/toonz/sources/toonz/sceneviewer.h
+++ b/toonz/sources/toonz/sceneviewer.h
@@ -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;
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 17f3f3d46..8ca058589 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -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;
}
}
@@ -349,6 +358,10 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
false);
TPointD pos = tool->getMatrix().inv() * winToWorld(curPos);
+ if (m_locator) {
+ m_locator->onChangeViewAff(m_viewAff[m_viewMode], pos);
+ }
+
TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
pos.x /= m_dpiScale.x;
@@ -375,6 +388,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
// panning
panQt(curPos - m_pos);
m_pos = curPos;
+
return;
}
}
@@ -973,6 +987,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;
diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc
index 75aa7a16e..b279cd14c 100644
--- a/toonz/sources/toonz/toonz.qrc
+++ b/toonz/sources/toonz/toonz.qrc
@@ -442,5 +442,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>
diff --git a/toonz/sources/toonzqt/flipconsole.cpp b/toonz/sources/toonzqt/flipconsole.cpp
index 706bb6edc..1caa5ac0f 100644
--- a/toonz/sources/toonzqt/flipconsole.cpp
+++ b/toonz/sources/toonzqt/flipconsole.cpp
@@ -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;