Skip to content

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

C

#assistants: TToolViewer

Ivan Mahonin1c557b22a47f
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index 4aed87ac7..b6aff1bf5 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -58,6 +58,8 @@ class TFxHandle;
class ToolOptionsBox;
+class TToolViewer;
+
class QMenu;
class QKeyEvent;
@@ -353,11 +355,11 @@ public:
createOptionsBox(); //!< Factory function returning a newly created
//! GUI options box to be displayed for the tool
- void setViewer(Viewer *viewer) {
+ void setViewer(TToolViewer *viewer) {
m_viewer = viewer;
onSetViewer();
}
- Viewer *getViewer() const { return m_viewer; }
+ TToolViewer *getViewer() const { return m_viewer; }
double getPixelSize() const;
@@ -552,7 +554,7 @@ public:
protected:
std::string m_name; //!< The tool's name.
- Viewer *m_viewer; //!< Tool's current viewer.
+ TToolViewer *m_viewer; //!< Tool's current viewer.
TAffine m_matrix; //!< World-to-window reference change affine.
int m_targetType; //!< The tool's image type target.
@@ -576,17 +578,17 @@ protected:
};
//*****************************************************************************************
-// TTool::Viewer declaration
+// TToolViewer declaration
//*****************************************************************************************
/*!
- \brief The TTool::Viewer class is the abstract base class that provides an
+ \brief The TToolViewer class is the abstract base class that provides an
interface for
TTool viewer widgets (it is required that such widgets support
OpenGL).
*/
-class TTool::Viewer {
+class TToolViewer {
protected:
ImagePainter::VisualSettings
m_visualSettings; //!< Settings used by the Viewer to draw scene contents
@@ -597,8 +599,8 @@ protected:
QWidget *m_viewerWidget = nullptr;
public:
- Viewer(QWidget *widget) : m_viewerWidget(widget) {}
- virtual ~Viewer() {}
+ TToolViewer(QWidget *widget) : m_viewerWidget(widget) {}
+ virtual ~TToolViewer() {}
const ImagePainter::VisualSettings &visualSettings() const {
return m_visualSettings;
diff --git a/toonz/sources/tnztools/edittool.cpp b/toonz/sources/tnztools/edittool.cpp
index 6940b9c6b..29cb43f84 100644
--- a/toonz/sources/tnztools/edittool.cpp
+++ b/toonz/sources/tnztools/edittool.cpp
@@ -596,11 +596,11 @@ public:
class DragZTool final : public DragChannelTool {
TPointD m_lastPos;
- TTool::Viewer *m_viewer;
+ TToolViewer *m_viewer;
double m_dz;
public:
- DragZTool(TTool::Viewer *viewer, bool globalKeyframesEnabled)
+ DragZTool(TToolViewer *viewer, bool globalKeyframesEnabled)
: DragChannelTool(TStageObject::T_Z, globalKeyframesEnabled)
, m_viewer(viewer) {}
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index 2b6d78f53..649dddffe 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -1259,7 +1259,7 @@ int AreaFillTool::pick(const TImageP &image, const TPointD &pos,
TVectorImageP vi = image;
if (!ti && !vi) return 0;
- TTool::Viewer *viewer = m_parent->getViewer();
+ TToolViewer *viewer = m_parent->getViewer();
StylePicker picker(viewer->viewerWidget(), image);
double scale2 = 1.0;
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index 823b0cf78..de714cefa 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -357,7 +357,7 @@ void FullColorBrushTool::inputLeftButtonDown(
TPointD previousBrushPos = m_brushPos;
m_brushPos = m_mousePos = pos;
m_mousePressed = true;
- Viewer *viewer = getViewer();
+ TToolViewer *viewer = getViewer();
if (!viewer) return;
TRasterImageP ri = (TRasterImageP)getImage(true);
diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cpp
index ea8a594dd..9849b29e5 100644
--- a/toonz/sources/tnztools/geometrictool.cpp
+++ b/toonz/sources/tnztools/geometrictool.cpp
@@ -1825,7 +1825,7 @@ TPointD Primitive::checkGuideSnapping(TPointD pos) {
if ((m_param->m_targetType & TTool::Vectors) && m_param->m_snap.getValue()) {
int vGuideCount = 0, hGuideCount = 0;
double guideDistance = sqrt(m_param->m_minDistance2);
- TTool::Viewer *viewer = m_tool->getViewer();
+ TToolViewer *viewer = m_tool->getViewer();
if (viewer) {
vGuideCount = viewer->getVGuideCount();
hGuideCount = viewer->getHGuideCount();
diff --git a/toonz/sources/tnztools/modifiers/modifierassistants.cpp b/toonz/sources/tnztools/modifiers/modifierassistants.cpp
index acd24da5a..0385fa3ce 100644
--- a/toonz/sources/tnztools/modifiers/modifierassistants.cpp
+++ b/toonz/sources/tnztools/modifiers/modifierassistants.cpp
@@ -107,21 +107,22 @@ TModifierAssistants::modifyTrack(
if ((int)modifier->guidelines.size() > 1 && modifier->savePoint.available()) {
// select guideline
bool longEnough = false;
- if (TInputManager *manager = getManager()) {
- if (TToolViewer *viewer = manager->getViewer()) {
- TAffine trackToScreen = manager->toolToWorld()
- * viewer->get3dViewMatrix().get2d().inv();
- TGuidelineP guideline = TGuideline::findBest(modifier->guidelines, track, trackToScreen, longEnough);
- if (guideline != modifier->guidelines.front())
- for(int i = 1; i < (int)modifier->guidelines.size(); ++i)
- if (modifier->guidelines[i] == guideline) {
- std::swap(modifier->guidelines[i], modifier->guidelines.front());
- start = 0;
- break;
- }
- }
+ if (TInputManager *manager = getManager())
+ if (TInputHandler *handler = manager->getHandler())
+ if (TTool *tool = handler->getTool())
+ if (TToolViewer *viewer = tool->getViewer()) {
+ TAffine trackToScreen = manager->toolToWorld()
+ * viewer->get3dViewMatrix().get2d().inv();
+ TGuidelineP guideline = TGuideline::findBest(modifier->guidelines, track, trackToScreen, longEnough);
+ if (guideline != modifier->guidelines.front())
+ for(int i = 1; i < (int)modifier->guidelines.size(); ++i)
+ if (modifier->guidelines[i] == guideline) {
+ std::swap(modifier->guidelines[i], modifier->guidelines.front());
+ start = 0;
+ break;
+ }
}
- modifier->savePoint.setLock(!longEnough);
+ if (longEnough) modifier->savePoint.unlock(); else modifier->savePoint.lock();
} else {
modifier->savePoint.reset();
}
diff --git a/toonz/sources/tnztools/plastictool.cpp b/toonz/sources/tnztools/plastictool.cpp
index be85dcacf..5255a1244 100644
--- a/toonz/sources/tnztools/plastictool.cpp
+++ b/toonz/sources/tnztools/plastictool.cpp
@@ -926,7 +926,7 @@ void PlasticTool::onChange() {
}
// Passing through Qt's event system to compress repaints in a single one
- TTool::Viewer *viewer = getViewer();
+ TToolViewer *viewer = getViewer();
if (viewer) // This goes through paintEvent(),
viewer->invalidateAll(); // \a unlike TTool::invalidate()
}
@@ -942,7 +942,7 @@ void PlasticTool::onChange(const TParamChange &pc) {
//------------------------------------------------------------------------
void PlasticTool::onSetViewer() {
- Viewer *viewer = getViewer();
+ TToolViewer *viewer = getViewer();
if (viewer) {
PlasticVisualSettings &pvs =
viewer->visualSettings().m_plasticVisualSettings;
@@ -997,7 +997,7 @@ void PlasticTool::onDeactivate() {
SIGNAL(xsheetSwitched()), this, SLOT(onXsheetChanged())),
assert(ret);
- Viewer *viewer = getViewer();
+ TToolViewer *viewer = getViewer();
if (viewer) {
viewer->visualSettings().m_plasticVisualSettings = PlasticVisualSettings();
// Only the mesh visibility is not reset in order to enable to keep the mesh
diff --git a/toonz/sources/tnztools/skeletonsubtools.cpp b/toonz/sources/tnztools/skeletonsubtools.cpp
index 58ea4aa91..26b474b70 100644
--- a/toonz/sources/tnztools/skeletonsubtools.cpp
+++ b/toonz/sources/tnztools/skeletonsubtools.cpp
@@ -254,7 +254,7 @@ void DragRotationTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
//
//------------------------------------------------------------
-ParentChangeTool::ParentChangeTool(SkeletonTool *tool, TTool::Viewer *viewer)
+ParentChangeTool::ParentChangeTool(SkeletonTool *tool, TToolViewer *viewer)
: DragTool(tool)
, m_viewer(viewer)
, m_index(-1)
@@ -730,7 +730,7 @@ public:
//
//------------------------------------------------------------
-IKTool::IKTool(SkeletonTool *tool, TTool::Viewer *viewer, Skeleton *skeleton,
+IKTool::IKTool(SkeletonTool *tool, TToolViewer *viewer, Skeleton *skeleton,
int columnIndex)
: DragTool(tool)
, m_viewer(viewer)
diff --git a/toonz/sources/tnztools/skeletonsubtools.h b/toonz/sources/tnztools/skeletonsubtools.h
index f3eb6ac92..447213550 100644
--- a/toonz/sources/tnztools/skeletonsubtools.h
+++ b/toonz/sources/tnztools/skeletonsubtools.h
@@ -112,7 +112,7 @@ public:
//---------------------------------------------------------
class ParentChangeTool final : public DragTool {
- TTool::Viewer *m_viewer;
+ TToolViewer *m_viewer;
TPointD m_firstWinPos;
TPointD m_lastPos, m_lastPos2;
TPointD m_center;
@@ -142,7 +142,7 @@ class ParentChangeTool final : public DragTool {
double m_pixelSize;
public:
- ParentChangeTool(SkeletonTool *tool, TTool::Viewer *viewer);
+ ParentChangeTool(SkeletonTool *tool, TToolViewer *viewer);
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
@@ -156,7 +156,7 @@ public:
class IKToolUndo;
class IKTool final : public DragTool {
- TTool::Viewer *m_viewer;
+ TToolViewer *m_viewer;
TPointD m_pos;
Skeleton *m_skeleton;
int m_columnIndex;
@@ -192,7 +192,7 @@ class IKTool final : public DragTool {
bool isParentOf(int columnIndex, int childColumnIndex) const;
public:
- IKTool(SkeletonTool *tool, TTool::Viewer *viewer, Skeleton *skeleton,
+ IKTool(SkeletonTool *tool, TToolViewer *viewer, Skeleton *skeleton,
int columnIndex);
~IKTool();
diff --git a/toonz/sources/tnztools/tool.cpp b/toonz/sources/tnztools/tool.cpp
index 8c1ce1953..b97e9bdc7 100644
--- a/toonz/sources/tnztools/tool.cpp
+++ b/toonz/sources/tnztools/tool.cpp
@@ -1079,15 +1079,15 @@ void TTool::setSelectedFrames(const std::set<TFrameId> &selectedFrames) {
//-------------------------------------------------------------------------------------------------------------
-void TTool::Viewer::getGuidedFrameIdx(int *backIdx, int *frontIdx) {
+void TToolViewer::getGuidedFrameIdx(int *backIdx, int *frontIdx) {
if (!Preferences::instance()->isGuidedDrawingEnabled()) return;
OnionSkinMask osMask =
- m_application->getCurrentOnionSkin()->getOnionSkinMask();
+ TTool::getApplication()->getCurrentOnionSkin()->getOnionSkinMask();
if (!osMask.isEnabled() || osMask.isEmpty()) return;
- TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ TFrameHandle *currentFrame = TTool::getApplication()->getCurrentFrame();
int cidx = currentFrame->getFrameIndex();
int mosBack = 0;
@@ -1158,7 +1158,7 @@ void TTool::Viewer::getGuidedFrameIdx(int *backIdx, int *frontIdx) {
//-------------------------------------------------------------------------------------------------------------
-void TTool::Viewer::doPickGuideStroke(const TPointD &pos) {
+void TToolViewer::doPickGuideStroke(const TPointD &pos) {
int pickerMode = getGuidedStrokePickerMode();
if (!pickerMode) return;
@@ -1177,14 +1177,14 @@ void TTool::Viewer::doPickGuideStroke(const TPointD &pos) {
os = osFront;
TFrameId fid;
- TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ TFrameHandle *currentFrame = TTool::getApplication()->getCurrentFrame();
TXshSimpleLevel *sl =
- getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel();
+ TTool::getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel();
if (!sl) return;
if (currentFrame->isEditingScene()) {
- TXsheet *xsh = getApplication()->getCurrentXsheet()->getXsheet();
- int col = getApplication()->getCurrentColumn()->getColumnIndex();
+ TXsheet *xsh = TTool::getApplication()->getCurrentXsheet()->getXsheet();
+ int col = TTool::getApplication()->getCurrentColumn()->getColumnIndex();
if (xsh && col >= 0) {
TXshCell cell = xsh->getCell(os, col);
if (!cell.isEmpty()) fid = cell.getFrameId();
diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp
index 96775c93f..1af2ee973 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.cpp
+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp
@@ -1014,7 +1014,7 @@ void PegbarChannelField::onChange(TMeasuredValue *fld, bool addToUndo) {
after.setValue(v);
after.applyValues();
- TTool::Viewer *viewer = m_tool->getViewer();
+ TToolViewer *viewer = m_tool->getViewer();
if (viewer) m_tool->invalidate();
setCursorPosition(0);
diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cpp
index fa7457fd4..68877cf02 100644
--- a/toonz/sources/tnztools/toolutils.cpp
+++ b/toonz/sources/tnztools/toolutils.cpp
@@ -1506,7 +1506,7 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
const TPixel32 &color, TPoint delta,
double pixelSize, bool isPicking,
std::vector<TRectD> *otherBalloons) {
- TTool::Viewer *viewer =
+ TToolViewer *viewer =
TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
QString qText = QString::fromStdString(text);
@@ -1650,7 +1650,7 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
void ToolUtils::drawHook(const TPointD &pos, ToolUtils::HookType type,
bool highlighted, bool onionSkin) {
- TTool::Viewer *viewer =
+ TToolViewer *viewer =
TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
int r = 10, d = r + r;
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.cpp b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
index 806cdf3f5..a2e0d81b1 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
@@ -1451,7 +1451,7 @@ void ToonzVectorBrushTool::checkGuideSnapping(bool beforeMousePress,
// check guide snapping
int vGuideCount = 0, hGuideCount = 0;
double guideDistance = sqrt(m_minDistance2);
- TTool::Viewer *viewer = getViewer();
+ TToolViewer *viewer = getViewer();
if (viewer) {
vGuideCount = viewer->getVGuideCount();
hGuideCount = viewer->getHGuideCount();
diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cpp
index ad06f47d4..8c0b71e6b 100644
--- a/toonz/sources/toonz/columncommand.cpp
+++ b/toonz/sources/toonz/columncommand.cpp
@@ -1437,7 +1437,7 @@ public:
int cc = TApp::instance()->getCurrentColumn()->getColumnIndex();
bool sound_changed = false;
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
- TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr;
+ TToolViewer *viewer = tool ? tool->getViewer() : nullptr;
bool viewer_changed = false;
int startCol =
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index d22e441ed..fdf2e0868 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -755,7 +755,7 @@ public:
SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
: GLWidgetForHighDpi(parent)
- , TTool::Viewer(this)
+ , TToolViewer(this)
, m_pressure(0)
, m_lastMousePos(0, 0)
, m_mouseButton(Qt::NoButton)
diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h
index 09ac47088..bf1fbe699 100644
--- a/toonz/sources/toonz/sceneviewer.h
+++ b/toonz/sources/toonz/sceneviewer.h
@@ -64,7 +64,7 @@ public:
//-----------------------------------------------------------------------------
class SceneViewer final : public GLWidgetForHighDpi,
- public TTool::Viewer,
+ public TToolViewer,
public Previewer::Listener {
Q_OBJECT
@@ -363,10 +363,10 @@ protected:
// center: window coordinate, pixels, topleft origin
void zoomQt(const QPoint &center, double scaleFactor);
- // overridden from TTool::Viewer
+ // overridden from TToolViewer
void pan(const TPointD &delta) override { panQt(QPointF(delta.x, delta.y)); }
- // overridden from TTool::Viewer
+ // overridden from TToolViewer
void zoom(const TPointD &center, double factor) override;
void rotate(const TPointD &center, double angle) override;
void rotate3D(double dPhi, double dTheta) override;