Skip to content

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

C

Add Vector Guided Drawing Auto-Inbetween option (#2931)

manongjohn40a40ea47c32
diff --git a/toonz/sources/include/tools/cursors.h b/toonz/sources/include/tools/cursors.h
index 7947a7ec3..b1569977d 100644
--- a/toonz/sources/include/tools/cursors.h
+++ b/toonz/sources/include/tools/cursors.h
@@ -97,6 +97,8 @@ enum {
Ex_RGB = 0x80000,
Ex_HV = 0x100000,
Ex_Precise = 0x200000,
+ Ex_Prev = 0x400000,
+ Ex_Next = 0x800000,
// This section is for cursors that have fixed text that needs to
// be handled separately when flipping for left-handed cursors.
@@ -108,7 +110,9 @@ enum {
PickerCursorLine = PickerCursorLineBase | Ex_StyleLine,
PickerCursorArea = PickerCursorAreaBase | Ex_StyleArea,
PickerRGB = PickerRGBBase | Ex_RGB,
- ScaleHVCursor = ScaleHVCursorBase | Ex_HV
+ ScaleHVCursor = ScaleHVCursorBase | Ex_HV,
+ PickPrevCursor = PointingHandCursor | Ex_Prev,
+ PickNextCursor = PointingHandCursor | Ex_Next
};
} // namespace ToolCursor
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index 36cdb4573..17ab3c0fc 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -8,6 +8,7 @@
#include "toonz/txsheet.h"
#include "toonz/imagepainter.h"
#include "toonz/tapplication.h"
+#include "tools/cursors.h"
// TnzCore includes
#include "tcommon.h"
@@ -517,6 +518,9 @@ transformation.
return m_selectedFrames;
}
+ void tweenSelectedGuideStrokes();
+ void tweenGuideStrokeToSelected();
+
public:
static std::vector<int> m_cellsData; //!< \deprecated brutto brutto. fix
//! quick & dirty del baco #6213 (undo
@@ -569,6 +573,10 @@ protected:
ImagePainter::VisualSettings
m_visualSettings; //!< Settings used by the Viewer to draw scene contents
+ int guidedStrokePickMode = 0;
+ int m_guidedFrontStroke = -1;
+ int m_guidedBackStroke = -1;
+
public:
Viewer() {}
virtual ~Viewer() {}
@@ -654,6 +662,33 @@ public:
virtual void bindFBO() {}
virtual void releaseFBO() {}
+
+ int getGuidedStrokePickerMode() { return guidedStrokePickMode; }
+ void setGuidedStrokePickerMode(int mode) { guidedStrokePickMode = mode; }
+
+ int getGuidedStrokePickerCursor() {
+ if (guidedStrokePickMode < 0)
+ return ToolCursor::PickPrevCursor;
+ else if (guidedStrokePickMode > 0)
+ return ToolCursor::PickNextCursor;
+ else
+ return ToolCursor::PointingHandCursor;
+ }
+
+ int getGuidedFrontStroke() { return m_guidedFrontStroke; }
+ void setGuidedFrontStroke(int strokeIdx) {
+ m_guidedFrontStroke = strokeIdx;
+ invalidateAll();
+ }
+
+ int getGuidedBackStroke() { return m_guidedBackStroke; }
+ void setGuidedBackStroke(int strokeIdx) {
+ m_guidedBackStroke = strokeIdx;
+ invalidateAll();
+ }
+
+ void getGuidedFrameIdx(int *backIdx, int *frontIdx);
+ void doPickGuideStroke(const TPointD &pos);
};
#endif
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index 7cfe94b3b..1b50eebef 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -451,6 +451,8 @@ public:
QString getShortcutPreset() { return getStringValue(shortcutPreset); }
// Viewer context menu
int getGuidedDrawing() { return getIntValue(guidedDrawingType); }
+ bool getGuidedAutoInbetween() { return getBoolValue(guidedAutoInbetween); }
+ int getGuidedInterpolation() { return getIntValue(guidedInterpolationType); }
#if defined(MACOSX) && defined(__LP64__)
int getShmMax() const {
return getIntValue(shmmax);
diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h
index 320a36d69..c25b69e03 100644
--- a/toonz/sources/include/toonz/preferencesitemids.h
+++ b/toonz/sources/include/toonz/preferencesitemids.h
@@ -173,6 +173,8 @@ enum PreferencesItemId {
shortcutPreset,
// Viewer context menu
guidedDrawingType,
+ guidedAutoInbetween,
+ guidedInterpolationType,
// OSX shared memory settings
shmmax,
shmseg,
diff --git a/toonz/sources/include/toonz/stage.h b/toonz/sources/include/toonz/stage.h
index 39abc4e0f..95c68008f 100644
--- a/toonz/sources/include/toonz/stage.h
+++ b/toonz/sources/include/toonz/stage.h
@@ -66,13 +66,15 @@ DVAPI void visit(Visitor &visitor, ToonzScene *scene, TXsheet *xsh, int row);
DVAPI void visit(Visitor &visitor, TXshSimpleLevel *level, const TFrameId &fid,
const OnionSkinMask &osm, bool isPlaying,
- int isGuidedDrawingEnabled = 0);
+ int isGuidedDrawingEnabled = 0, int guidedBackStroke = -1,
+ int guidedFrontStroke = -1);
//-----------------------------------------------------------------------------
DVAPI void visit(Visitor &visitor, TXshLevel *level, const TFrameId &fid,
const OnionSkinMask &osm, bool isPlaying,
- double isGuidedDrawingEnabled = 0.0);
+ double isGuidedDrawingEnabled = 0.0, int guidedBackStroke = -1,
+ int guidedFrontStroke = -1);
//-----------------------------------------------------------------------------
} // namespace Stage
diff --git a/toonz/sources/include/toonz/stageplayer.h b/toonz/sources/include/toonz/stageplayer.h
index d1aa92669..4c9fae120 100644
--- a/toonz/sources/include/toonz/stageplayer.h
+++ b/toonz/sources/include/toonz/stageplayer.h
@@ -86,6 +86,8 @@ public:
bool m_isEditingLevel;
bool m_isVisibleinOSM; // Whether the current frame is in the onion skin
int m_isGuidedDrawingEnabled = 0;
+ int m_guidedFrontStroke = -1;
+ int m_guidedBackStroke = -1;
TXshSimpleLevel *m_sl; //!< (not owned) The player's simple level
TFrameId m_fid; //!< The player's frame in m_sl
TFrameId
@@ -104,6 +106,7 @@ public:
static double m_onionSkinFrontSize;
static double m_onionSkinBackSize;
+ static double m_firstFrontOnionSkin;
static double m_firstBackOnionSkin;
static double m_lastBackVisibleSkin;
diff --git a/toonz/sources/include/toonz/stagevisitor.h b/toonz/sources/include/toonz/stagevisitor.h
index 6d134e554..98935d329 100644
--- a/toonz/sources/include/toonz/stagevisitor.h
+++ b/toonz/sources/include/toonz/stagevisitor.h
@@ -133,6 +133,8 @@ struct DVAPI VisitArgs {
bool m_checkPreviewVisibility;
bool m_rasterizePli;
int m_isGuidedDrawingEnabled;
+ int m_guidedFrontStroke;
+ int m_guidedBackStroke;
public:
VisitArgs()
@@ -147,6 +149,8 @@ public:
, m_onlyVisible(false)
, m_checkPreviewVisibility(false)
, m_isGuidedDrawingEnabled(0)
+ , m_guidedFrontStroke(-1)
+ , m_guidedBackStroke(-1)
, m_rasterizePli(false) {}
};
diff --git a/toonz/sources/tnztools/Resources/ex_next.png b/toonz/sources/tnztools/Resources/ex_next.png
new file mode 100644
index 000000000..933cdd622
Binary files /dev/null and b/toonz/sources/tnztools/Resources/ex_next.png differ
diff --git a/toonz/sources/tnztools/Resources/ex_next_left.png b/toonz/sources/tnztools/Resources/ex_next_left.png
new file mode 100644
index 000000000..933cdd622
Binary files /dev/null and b/toonz/sources/tnztools/Resources/ex_next_left.png differ
diff --git a/toonz/sources/tnztools/Resources/ex_prev.png b/toonz/sources/tnztools/Resources/ex_prev.png
new file mode 100644
index 000000000..5cfb85eb6
Binary files /dev/null and b/toonz/sources/tnztools/Resources/ex_prev.png differ
diff --git a/toonz/sources/tnztools/Resources/ex_prev_left.png b/toonz/sources/tnztools/Resources/ex_prev_left.png
new file mode 100644
index 000000000..5cfb85eb6
Binary files /dev/null and b/toonz/sources/tnztools/Resources/ex_prev_left.png differ
diff --git a/toonz/sources/tnztools/bendertool.cpp b/toonz/sources/tnztools/bendertool.cpp
index 8d6796668..5293679da 100644
--- a/toonz/sources/tnztools/bendertool.cpp
+++ b/toonz/sources/tnztools/bendertool.cpp
@@ -188,7 +188,11 @@ public:
m_hitStrokeCorners.clear();
}
- int getCursorId() const override { return m_cursor; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursor;
+ }
} BenderTool;
//-----------------------------------------------------------------------------
@@ -407,6 +411,11 @@ void BenderTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
//-----------------------------------------------------------------------------
void BenderTool::leftButtonDown(const TPointD &p, const TMouseEvent &) {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(p);
+ return;
+ }
+
m_active = false;
TVectorImageP vi = TImageP(getImage(true));
if (!vi) return;
diff --git a/toonz/sources/tnztools/controlpointeditortool.cpp b/toonz/sources/tnztools/controlpointeditortool.cpp
index 2f6131bb2..12a04ee88 100644
--- a/toonz/sources/tnztools/controlpointeditortool.cpp
+++ b/toonz/sources/tnztools/controlpointeditortool.cpp
@@ -428,6 +428,11 @@ void ControlPointEditorTool::mouseMove(const TPointD &pos,
void ControlPointEditorTool::leftButtonDown(const TPointD &pos,
const TMouseEvent &e) {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
m_pos = pos;
double pix = getPixelSize() * 2.0f;
double maxDist = 5 * pix;
@@ -883,6 +888,9 @@ void ControlPointEditorTool::onImageChanged() {
//---------------------------------------------------------------------------
int ControlPointEditorTool::getCursorId() const {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+
switch (m_cursorType) {
case NORMAL:
return ToolCursor::SplineEditorCursor;
diff --git a/toonz/sources/tnztools/cursormanager.cpp b/toonz/sources/tnztools/cursormanager.cpp
index 0381006c7..24531fabc 100644
--- a/toonz/sources/tnztools/cursormanager.cpp
+++ b/toonz/sources/tnztools/cursormanager.cpp
@@ -92,6 +92,8 @@ const struct {
{ToolCursor::FillCursorL, "karasu", 7, 25, true},
{ToolCursor::RulerModifyCursor, "ruler_modify", 7, 7, true},
{ToolCursor::RulerNewCursor, "ruler_new", 7, 7, true},
+ {ToolCursor::PickPrevCursor, "", 13, 4, false},
+ {ToolCursor::PickNextCursor, "", 13, 4, false},
{0, 0, 0, 0, false}};
struct CursorData {
@@ -115,6 +117,8 @@ const struct {
{ToolCursor::Ex_RGB, "ex_rgb"},
{ToolCursor::Ex_HV, "ex_hv"},
{ToolCursor::Ex_Precise, "ex_precise"},
+ {ToolCursor::Ex_Prev, "ex_prev"},
+ {ToolCursor::Ex_Next, "ex_next"},
{0, 0}};
}; // namespace
diff --git a/toonz/sources/tnztools/cuttertool.cpp b/toonz/sources/tnztools/cuttertool.cpp
index 677324f1e..0aaf25b9b 100644
--- a/toonz/sources/tnztools/cuttertool.cpp
+++ b/toonz/sources/tnztools/cuttertool.cpp
@@ -195,6 +195,11 @@ public:
}
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
TVectorImageP vi = TImageP(getImage(true));
if (!vi) return;
QMutexLocker sl(vi->getMutex());
@@ -314,7 +319,11 @@ public:
m_cursorId = ToolCursor::CURSOR_NO;
}
- int getCursorId() const override { return m_cursorId; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
} cutterTool;
diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cpp
index 7d3f5f792..1ae4d3509 100644
--- a/toonz/sources/tnztools/geometrictool.cpp
+++ b/toonz/sources/tnztools/geometrictool.cpp
@@ -2,6 +2,7 @@
#include "toonz/tpalettehandle.h"
#include "tools/toolhandle.h"
+#include "tools/toolcommandids.h"
#include "toonz/tobjecthandle.h"
#include "toonz/txsheethandle.h"
#include "toonz/txshlevelhandle.h"
@@ -28,6 +29,7 @@
#include "toonz/trasterimageutils.h"
#include "toonz/preferences.h"
#include "historytypes.h"
+#include "toonzvectorbrushtool.h"
// For Qt translation support
#include <QCoreApplication>
@@ -850,6 +852,11 @@ public:
}
void leftButtonDown(const TPointD &p, const TMouseEvent &e) override {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(p);
+ return;
+ }
+
/* m_active = getApplication()->getCurrentObject()->isSpline() ||
(bool) getImage(true);*/
if (!getApplication()->getCurrentObject()->isSpline())
@@ -953,7 +960,11 @@ public:
if (m_primitive) m_primitive->draw();
}
- int getCursorId() const override { return ToolCursor::PenCursor; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return ToolCursor::PenCursor;
+ }
int getColorClass() const { return 1; }
@@ -1106,11 +1117,29 @@ public:
new std::vector<TFilledRegionInf>;
ImageUtils::getFillingInformationOverlappingArea(vi, *fillInformation,
stroke->getBBox());
- vi->addStroke(stroke);
- TUndoManager::manager()->add(new UndoPencil(
- vi->getStroke(vi->getStrokeCount() - 1), fillInformation, sl, id,
- m_isFrameCreated, m_isLevelCreated, m_param.m_autogroup.getValue(),
- m_param.m_autofill.getValue()));
+
+ bool strokeAdded = false;
+ if ((Preferences::instance()->getGuidedDrawing() == 1 ||
+ Preferences::instance()->getGuidedDrawing() == 2) &&
+ Preferences::instance()->getGuidedAutoInbetween()) {
+ TTool *tool =
+ TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
+ ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
+ if (vbTool) {
+ vbTool->setViewer(m_viewer);
+ strokeAdded = vbTool->doGuidedAutoInbetween(
+ id, vi, stroke, false, m_param.m_autogroup.getValue(),
+ m_param.m_autofill.getValue(), true);
+ }
+ }
+
+ if (!strokeAdded) {
+ vi->addStroke(stroke);
+ TUndoManager::manager()->add(new UndoPencil(
+ vi->getStroke(vi->getStrokeCount() - 1), fillInformation, sl, id,
+ m_isFrameCreated, m_isLevelCreated, m_param.m_autogroup.getValue(),
+ m_param.m_autofill.getValue()));
+ }
}
if (m_param.m_autogroup.getValue() && stroke->isSelfLoop()) {
int index = vi->getStrokeCount() - 1;
@@ -2066,7 +2095,7 @@ TStroke *EllipsePrimitive::makeStroke() const {
return 0;
return makeEllipticStroke(
- getThickness(),
+ getThickness(),
TPointD(0.5 * (m_selectingRect.x0 + m_selectingRect.x1),
0.5 * (m_selectingRect.y0 + m_selectingRect.y1)),
fabs(0.5 * (m_selectingRect.x1 - m_selectingRect.x0)),
diff --git a/toonz/sources/tnztools/irontool.cpp b/toonz/sources/tnztools/irontool.cpp
index fe6572611..a52b1f588 100644
--- a/toonz/sources/tnztools/irontool.cpp
+++ b/toonz/sources/tnztools/irontool.cpp
@@ -87,6 +87,11 @@ public:
}
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
if (m_active) return;
assert(m_undo == 0);
m_active = false;
@@ -505,7 +510,11 @@ Altrimenti non si fa altro che aumentarli i punti di controllo
void onLeave() override { m_draw = false; }
- int getCursorId() const override { return m_cursorId; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
void onEnter() override {
m_draw = true;
if ((TVectorImageP)getImage(false))
diff --git a/toonz/sources/tnztools/magnettool.cpp b/toonz/sources/tnztools/magnettool.cpp
index f6438f204..7dede52da 100644
--- a/toonz/sources/tnztools/magnettool.cpp
+++ b/toonz/sources/tnztools/magnettool.cpp
@@ -165,6 +165,11 @@ public:
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override {
TPointD p(pos);
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(p);
+ return;
+ }
+
m_oldPos = pos;
m_pointAtMouseDown = p;
@@ -438,7 +443,11 @@ lefrightButtonDown(p);
TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
- int getCursorId() const override { return m_cursorId; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
bool onPropertyChanged(std::string propertyName) override {
if (propertyName == m_toolSize.getName()) {
diff --git a/toonz/sources/tnztools/pinchtool.cpp b/toonz/sources/tnztools/pinchtool.cpp
index 445c6337f..55b5d53cc 100644
--- a/toonz/sources/tnztools/pinchtool.cpp
+++ b/toonz/sources/tnztools/pinchtool.cpp
@@ -177,6 +177,9 @@ void PinchTool::updateStrokeStatus(TStroke *stroke, double w) {
//-----------------------------------------------------------------------------
int PinchTool::updateCursor() const {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+
if (!(TVectorImageP)getImage(false)) return ToolCursor::CURSOR_NO;
return m_deformation->getCursorId();
@@ -185,6 +188,11 @@ int PinchTool::updateCursor() const {
//---------------------------------------------------------------------------
void PinchTool::leftButtonDown(const TPointD &pos, const TMouseEvent &event) {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
m_curr = m_down = pos;
if (!m_active && !m_selector.isSelected()) {
diff --git a/toonz/sources/tnztools/pumptool.cpp b/toonz/sources/tnztools/pumptool.cpp
index f6f8fa826..5c2de435e 100644
--- a/toonz/sources/tnztools/pumptool.cpp
+++ b/toonz/sources/tnztools/pumptool.cpp
@@ -115,7 +115,11 @@ public:
void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
bool moveCursor(const TPointD &pos);
- int getCursorId() const override { return m_cursorId; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
void invalidateCursorArea();
void onDeactivate() override;
@@ -258,6 +262,11 @@ void PumpTool::draw() {
//----------------------------------------------------------------------
void PumpTool::leftButtonDown(const TPointD &pos, const TMouseEvent &) {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
if (m_active || !m_enabled) return;
assert(m_undo == 0);
diff --git a/toonz/sources/tnztools/tnztools.qrc b/toonz/sources/tnztools/tnztools.qrc
index 8d1634799..7370ccc49 100644
--- a/toonz/sources/tnztools/tnztools.qrc
+++ b/toonz/sources/tnztools/tnztools.qrc
@@ -83,5 +83,9 @@
<file>Resources/brush_large.png</file>
<file>Resources/brush_crosshair.png</file>
<file>Resources/tracker.png</file>
+ <file>Resources/ex_prev.png</file>
+ <file>Resources/ex_prev_left.png</file>
+ <file>Resources/ex_next.png</file>
+ <file>Resources/ex_next_left.png</file>
</qresource>
</RCC>
\ No newline at end of file
diff --git a/toonz/sources/tnztools/tool.cpp b/toonz/sources/tnztools/tool.cpp
index 461ceb33d..410a2822e 100644
--- a/toonz/sources/tnztools/tool.cpp
+++ b/toonz/sources/tnztools/tool.cpp
@@ -32,6 +32,7 @@
#include "toonz/tstageobjecttree.h"
#include "toonz/dpiscale.h"
#include "toonz/palettecontroller.h"
+#include "toonz/tonionskinmaskhandle.h"
// TnzCore includes
#include "tvectorimage.h"
@@ -40,6 +41,10 @@
#include "tcolorstyles.h"
#include "ttoonzimage.h"
#include "trasterimage.h"
+#include "strokeselection.h"
+#include "tundo.h"
+
+#include "toonzvectorbrushtool.h"
//*****************************************************************************************
// Local namespace
@@ -1023,3 +1028,346 @@ void TTool::setSelectedFrames(const std::set<TFrameId> &selectedFrames) {
m_selectedFrames = selectedFrames;
onSelectedFramesChanged();
}
+
+//-------------------------------------------------------------------------------------------------------------
+
+void TTool::Viewer::getGuidedFrameIdx(int *backIdx, int *frontIdx) {
+ OnionSkinMask osMask =
+ m_application->getCurrentOnionSkin()->getOnionSkinMask();
+
+ if (!osMask.isEnabled() || osMask.isEmpty()) return;
+
+ TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+
+ int cidx = currentFrame->getFrameIndex();
+ int mosBack = 0;
+ int mosFront = 0;
+ int mosCount = osMask.getMosCount();
+ int fosBack = -1;
+ int fosFront = -1;
+ int fosCount = osMask.getFosCount();
+
+ // Find onion-skinned drawing that is being used for guided auto inbetween
+ if (Preferences::instance()->getGuidedDrawing() == 1) {
+ // Get closest moving unionskin
+ for (int i = 0; i < mosCount; i++) {
+ int cmos = osMask.getMos(i);
+ if (cmos == 0) continue; // skip current
+ if (cmos < 0 && (!mosBack || cmos > mosBack)) mosBack = cmos;
+ if (cmos > 0 && (!mosFront || cmos < mosFront)) mosFront = cmos;
+ }
+ if (mosBack) *backIdx = mosBack + cidx;
+ if (mosFront) *frontIdx = mosFront + cidx;
+
+ // Get closest fixed onionskin
+ for (int i = 0; i < fosCount; i++) {
+ int cfos = osMask.getFos(i);
+ if (cfos == cidx) continue; // skip current
+ if (cfos < cidx && (fosBack == -1 || cfos > fosBack)) fosBack = cfos;
+ if (cfos > cidx && (fosFront == -1 || cfos < fosFront)) fosFront = cfos;
+ }
+
+ if (*backIdx == -1)
+ *backIdx = fosBack;
+ else if (fosBack != -1)
+ *backIdx = std::max(*backIdx, fosBack);
+ if (*frontIdx == -1)
+ *frontIdx = fosFront;
+ else if (fosFront != -1)
+ *frontIdx = std::min(*frontIdx, fosFront);
+ } else if (Preferences::instance()->getGuidedDrawing() ==
+ 2) { // Furthest drawing
+ // Get moving unionskin
+ for (int i = 0; i < mosCount; i++) {
+ int cmos = osMask.getMos(i);
+ if (cmos == 0) continue; // skip current
+ if (cmos < 0 && (!mosBack || cmos < mosBack)) mosBack = cmos;
+ if (cmos > 0 && (!mosFront || cmos > mosFront)) mosFront = cmos;
+ }
+ if (mosBack) *backIdx = mosBack + cidx;
+ if (mosFront) *frontIdx = mosFront + cidx;
+
+ // Get fixed onionskin
+ for (int i = 0; i < fosCount; i++) {
+ int cfos = osMask.getFos(i);
+ if (cfos == cidx) continue; // skip current
+ if (cfos < cidx && (fosBack == -1 || cfos < fosBack)) fosBack = cfos;
+ if (cfos > cidx && (fosFront == -1 || cfos > fosFront)) fosFront = cfos;
+ }
+
+ if (*backIdx == -1)
+ *backIdx = fosBack;
+ else if (fosBack != -1)
+ *backIdx = std::min(*backIdx, fosBack);
+ if (*frontIdx == -1)
+ *frontIdx = fosFront;
+ else if (fosFront != -1)
+ *frontIdx = std::max(*frontIdx, fosFront);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------
+
+void TTool::Viewer::doPickGuideStroke(const TPointD &pos) {
+ int pickerMode = getGuidedStrokePickerMode();
+
+ if (!pickerMode) return;
+
+ if (pickerMode >= -2 && pickerMode <= 2) setGuidedStrokePickerMode(0);
+
+ int osBack = -1;
+ int osFront = -1;
+ int os = -1;
+
+ getGuidedFrameIdx(&osBack, &osFront);
+
+ if (pickerMode < 0) // Previous Frame
+ os = osBack;
+ else if (pickerMode > 0) // Next Frame
+ os = osFront;
+
+ TFrameId fid;
+ TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ TXshSimpleLevel *sl =
+ getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel();
+ if (!sl) return;
+
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = getApplication()->getCurrentXsheet()->getXsheet();
+ int col = getApplication()->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(os, col);
+ if (!cell.isEmpty()) fid = cell.getFrameId();
+ }
+ } else
+ fid = sl->getFrameId(os);
+
+ if (fid.isEmptyFrame()) return;
+
+ TVectorImageP fvi = sl->getFrame(fid, false);
+ if (!fvi) return;
+
+ UINT index;
+ double t, dist2 = 0;
+ double pixelSize = getPixelSize();
+ TAffine aff = getViewMatrix();
+ double maxDist = 5 * pixelSize;
+ double maxDist2 = maxDist * maxDist;
+ double checkDist = maxDist2 * 4;
+ TStroke *strokeRef;
+ if (fvi->getNearestStroke(pos, t, index, dist2)) {
+ strokeRef = fvi->getStroke(index);
+ TThickPoint cursor = strokeRef->getThickPoint(t);
+ double len = cursor.thick * pixelSize * sqrt(aff.det());
+ checkDist = std::max(checkDist, (len * len));
+ }
+
+ if (dist2 >= checkDist)
+ index = -1;
+ else {
+ if (pickerMode < 0) // Previous Frame
+ setGuidedBackStroke(index);
+ else if (pickerMode > 0) // Next Frame
+ setGuidedFrontStroke(index);
+ }
+
+ if (pickerMode <= -2) {
+ if (index != -1) setGuidedStrokePickerMode(pickerMode * -1);
+ } else if (pickerMode >= 2) {
+ if (pickerMode >= 3 && index != -1) {
+ TTool *tool = TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
+ ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
+ if (vbTool) {
+ vbTool->setViewer(this);
+ vbTool->doGuidedAutoInbetween(fid, fvi, strokeRef, false, false, false,
+ false);
+ }
+
+ setGuidedStrokePickerMode(pickerMode * -1);
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------
+
+void TTool::tweenSelectedGuideStrokes() {
+ if (!getViewer() || !m_application) return;
+
+ TXshSimpleLevel *sl =
+ m_application->getCurrentLevel()->getLevel()->getSimpleLevel();
+ if (!sl) return;
+
+ int backIdx = -1, frontIdx = -1;
+
+ getViewer()->getGuidedFrameIdx(&backIdx, &frontIdx);
+
+ if (backIdx == -1 || frontIdx == -1) return;
+
+ TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ int row = currentFrame->getFrameIndex();
+ TFrameId bFid, cFid, fFid;
+
+ cFid = getCurrentFid();
+ if (cFid.isEmptyFrame()) return;
+
+ TVectorImageP cvi = sl->getFrame(cFid, false);
+ if (!cvi) return;
+
+ int cStrokeCount = cvi->getStrokeCount();
+
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
+ int col = m_application->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(backIdx, col);
+ if (!cell.isEmpty()) bFid = cell.getFrameId();
+ cell = xsh->getCell(frontIdx, col);
+ if (!cell.isEmpty()) fFid = cell.getFrameId();
+ }
+ } else {
+ bFid = sl->getFrameId(backIdx);
+ fFid = sl->getFrameId(frontIdx);
+ }
+ if (bFid.isEmptyFrame() || fFid.isEmptyFrame()) return;
+
+ TVectorImageP bvi = sl->getFrame(bFid, false);
+ TVectorImageP fvi = sl->getFrame(fFid, false);
+
+ if (!bvi || !fvi) return;
+
+ int bStrokeCount = bvi->getStrokeCount();
+ int fStrokeCount = fvi->getStrokeCount();
+
+ if (!bStrokeCount || !fStrokeCount) return;
+
+ int bStrokeIdx = getViewer()->getGuidedBackStroke() != -1
+ ? getViewer()->getGuidedBackStroke()
+ : cStrokeCount;
+ int fStrokeIdx = getViewer()->getGuidedFrontStroke() != -1
+ ? getViewer()->getGuidedFrontStroke()
+ : cStrokeCount;
+
+ if (bStrokeIdx >= bStrokeCount || fStrokeIdx >= fStrokeCount) return;
+
+ TStroke *bStroke = bvi->getStroke(bStrokeIdx);
+ TStroke *fStroke = fvi->getStroke(fStrokeIdx);
+
+ if (!bStroke || !fStroke) return;
+
+ TTool *tool = TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
+ ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
+ if (vbTool) {
+ vbTool->setViewer(m_viewer);
+ vbTool->doFrameRangeStrokes(
+ bFid, bStroke, fFid, fStroke,
+ Preferences::instance()->getGuidedInterpolation(), false, false, false,
+ false, false, true);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------
+
+void TTool::tweenGuideStrokeToSelected() {
+ if (!getViewer() || !m_application) return;
+
+ TXshSimpleLevel *sl =
+ m_application->getCurrentLevel()->getLevel()->getSimpleLevel();
+ if (!sl) return;
+
+ int backIdx = -1, frontIdx = -1;
+
+ getViewer()->getGuidedFrameIdx(&backIdx, &frontIdx);
+
+ TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ int row = currentFrame->getFrameIndex();
+ TFrameId bFid, cFid, fFid;
+ TVectorImageP bvi, cvi, fvi;
+
+ cFid = getCurrentFid();
+ if (cFid.isEmptyFrame()) return;
+
+ cvi = sl->getFrame(cFid, false);
+ if (!cvi) return;
+
+ int cStrokeCount = cvi->getStrokeCount();
+ if (!cStrokeCount) return;
+
+ StrokeSelection *strokeSelection =
+ dynamic_cast<StrokeSelection *>(getSelection());
+ if (!strokeSelection || strokeSelection->isEmpty()) return;
+ const std::set<int> &selectedStrokeIdxs = strokeSelection->getSelection();
+ const std::set<int>::iterator it = selectedStrokeIdxs.begin();
+ int cStrokeIdx = *it;
+
+ TStroke *cStroke = cvi->getStroke(cStrokeIdx);
+ if (!cStroke) return;
+
+ if (backIdx != -1) {
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
+ int col = m_application->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(backIdx, col);
+ if (!cell.isEmpty()) bFid = cell.getFrameId();
+ }
+ } else
+ bFid = sl->getFrameId(backIdx);
+
+ if (!bFid.isEmptyFrame()) bvi = sl->getFrame(bFid, false);
+ }
+
+ if (frontIdx != -1) {
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
+ int col = m_application->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(frontIdx, col);
+ if (!cell.isEmpty()) fFid = cell.getFrameId();
+ }
+ } else
+ fFid = sl->getFrameId(frontIdx);
+
+ if (!fFid.isEmptyFrame()) fvi = sl->getFrame(fFid, false);
+ }
+
+ if (!bvi && !fvi) return;
+
+ int bStrokeCount = bvi ? bvi->getStrokeCount() : 0;
+ int fStrokeCount = fvi ? fvi->getStrokeCount() : 0;
+
+ if (!bStrokeCount && !fStrokeCount) return;
+
+ int bStrokeIdx = getViewer()->getGuidedBackStroke() != -1
+ ? getViewer()->getGuidedBackStroke()
+ : cStrokeCount;
+ int fStrokeIdx = getViewer()->getGuidedFrontStroke() != -1
+ ? getViewer()->getGuidedFrontStroke()
+ : cStrokeCount;
+
+ if ((bStrokeCount && bStrokeIdx >= bStrokeCount) ||
+ (fStrokeCount && fStrokeIdx >= fStrokeCount))
+ return;
+
+ TStroke *bStroke = bvi ? bvi->getStroke(bStrokeIdx) : 0;
+ TStroke *fStroke = fvi ? fvi->getStroke(fStrokeIdx) : 0;
+
+ if (!bStroke && !fStroke) return;
+
+ TTool *tool = TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
+ ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
+ if (vbTool) {
+ vbTool->setViewer(m_viewer);
+ TUndoManager::manager()->beginBlock();
+ if (bStroke)
+ vbTool->doFrameRangeStrokes(
+ bFid, bStroke, cFid, cStroke,
+ Preferences::instance()->getGuidedInterpolation(), false, false,
+ false, false, false, false);
+ if (fStroke)
+ vbTool->doFrameRangeStrokes(
+ cFid, cStroke, fFid, fStroke,
+ Preferences::instance()->getGuidedInterpolation(), false, false,
+ false, false, false, false);
+ TUndoManager::manager()->endBlock();
+ }
+}
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.cpp b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
index 8347fa91c..7d2c85f31 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
@@ -28,6 +28,7 @@
#include "toonz/palettecontroller.h"
#include "toonz/stage2.h"
#include "toonz/preferences.h"
+#include "toonz/tonionskinmaskhandle.h"
// TnzCore includes
#include "tstream.h"
@@ -335,8 +336,9 @@ static void findMaxCurvPoints(TStroke *stroke, const float &angoloLim,
}
static void addStroke(TTool::Application *application, const TVectorImageP &vi,
- TStroke *stroke, bool breakAngles, bool frameCreated,
- bool levelCreated, TXshSimpleLevel *sLevel = NULL,
+ TStroke *stroke, bool breakAngles, bool autoGroup,
+ bool autoFill, bool frameCreated, bool levelCreated,
+ TXshSimpleLevel *sLevel = NULL,
TFrameId fid = TFrameId::NO_FRAME) {
QMutexLocker lock(vi->getMutex());
@@ -380,7 +382,8 @@ static void addStroke(TTool::Application *application, const TVectorImageP &vi,
TStroke *str = new TStroke(*strokes[i]);
vi->addStroke(str);
TUndoManager::manager()->add(new UndoPencil(str, fillInformation, sl, id,
- frameCreated, levelCreated));
+ frameCreated, levelCreated,
+ autoGroup, autoFill));
}
TUndoManager::manager()->endBlock();
} else {
@@ -391,7 +394,24 @@ static void addStroke(TTool::Application *application, const TVectorImageP &vi,
TStroke *str = new TStroke(*stroke);
vi->addStroke(str);
TUndoManager::manager()->add(new UndoPencil(str, fillInformation, sl, id,
- frameCreated, levelCreated));
+ frameCreated, levelCreated,
+ autoGroup, autoFill));
+ }
+
+ if (autoGroup && stroke->isSelfLoop()) {
+ int index = vi->getStrokeCount() - 1;
+ vi->group(index, 1);
+ if (autoFill) {
+ // to avoid filling other strokes, I enter into the new stroke group
+ int currentGroup = vi->exitGroup();
+ vi->enterGroup(index);
+ vi->selectFill(stroke->getBBox().enlarge(1, 1), 0, stroke->getStyle(),
+ false, true, false);
+ if (currentGroup != -1)
+ vi->enterGroup(currentGroup);
+ else
+ vi->exitGroup();
+ }
}
// Update regions. It will call roundStroke() in
@@ -423,12 +443,13 @@ namespace {
//-------------------------------------------------------------------
void addStrokeToImage(TTool::Application *application, const TVectorImageP &vi,
- TStroke *stroke, bool breakAngles, bool frameCreated,
- bool levelCreated, TXshSimpleLevel *sLevel = NULL,
+ TStroke *stroke, bool breakAngles, bool autoGroup,
+ bool autoFill, bool frameCreated, bool levelCreated,
+ TXshSimpleLevel *sLevel = NULL,
TFrameId id = TFrameId::NO_FRAME) {
QMutexLocker lock(vi->getMutex());
- addStroke(application, vi.getPointer(), stroke, breakAngles, frameCreated,
- levelCreated, sLevel, id);
+ addStroke(application, vi.getPointer(), stroke, breakAngles, autoGroup,
+ autoFill, frameCreated, levelCreated, sLevel, id);
// la notifica viene gia fatta da addStroke!
// getApplication()->getCurrentTool()->getTool()->notifyImageChanged();
}
@@ -630,6 +651,8 @@ void ToonzVectorBrushTool::onDeactivate() {
//--------------------------------------------------------------------------------------------------
bool ToonzVectorBrushTool::preLeftButtonDown() {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) return false;
+
touchImage();
if (m_isFrameCreated) {
// When the xsheet frame is selected, whole viewer will be updated from
@@ -647,6 +670,11 @@ void ToonzVectorBrushTool::leftButtonDown(const TPointD &pos,
TTool::Application *app = TTool::getApplication();
if (!app) return;
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
int col = app->getCurrentColumn()->getColumnIndex();
m_isPath = app->getCurrentObject()->isSpline();
m_enabled = col >= 0 || m_isPath || app->getCurrentFrame()->isEditingLevel();
@@ -912,9 +940,10 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
curCol = application->getCurrentColumn()->getColumnIndex();
curFrame = application->getCurrentFrame()->getFrame();
}
- bool success =
- doFrameRangeStrokes(m_firstFrameId, m_firstStroke, getFrameId(),
- stroke, m_firstFrameRange);
+ bool success = doFrameRangeStrokes(
+ m_firstFrameId, m_firstStroke, getFrameId(), stroke,
+ m_frameRange.getIndex(), m_breakAngles.getValue(), false, false,
+ m_firstFrameRange);
if (e.isCtrlPressed()) {
if (application) {
if (m_firstFrameId > currentId) {
@@ -950,9 +979,29 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
stroke->setSelfLoop(true);
m_snapSelf = false;
}
- addStrokeToImage(getApplication(), vi, stroke, m_breakAngles.getValue(),
- m_isFrameCreated, m_isLevelCreated);
+
+ bool strokeAdded = false;
+
+ if ((Preferences::instance()->getGuidedDrawing() == 1 ||
+ Preferences::instance()->getGuidedDrawing() == 2) &&
+ Preferences::instance()->getGuidedAutoInbetween()) {
+ int fidx = getApplication()->getCurrentFrame()->getFrameIndex();
+ TFrameId fId = getFrameId();
+
+ strokeAdded = doGuidedAutoInbetween(
+ fId, vi, stroke, m_breakAngles.getValue(), false, false, true);
+
+ if (getApplication()->getCurrentFrame()->isEditingScene())
+ getApplication()->getCurrentFrame()->setFrame(fidx);
+ else
+ getApplication()->getCurrentFrame()->setFid(fId);
+ }
+
+ if (!strokeAdded)
+ addStrokeToImage(getApplication(), vi, stroke, m_breakAngles.getValue(),
+ false, false, m_isFrameCreated, m_isLevelCreated);
TRectD bbox = stroke->getBBox().enlarge(2) + m_track.getModifiedRegion();
+
invalidate(); // should use bbox?
}
assert(stroke);
@@ -971,11 +1020,11 @@ bool ToonzVectorBrushTool::keyDown(QKeyEvent *event) {
//--------------------------------------------------------------------------------------------------
-bool ToonzVectorBrushTool::doFrameRangeStrokes(TFrameId firstFrameId,
- TStroke *firstStroke,
- TFrameId lastFrameId,
- TStroke *lastStroke,
- bool drawFirstStroke) {
+bool ToonzVectorBrushTool::doFrameRangeStrokes(
+ TFrameId firstFrameId, TStroke *firstStroke, TFrameId lastFrameId,
+ TStroke *lastStroke, int interpolationType, bool breakAngles,
+ bool autoGroup, bool autoFill, bool drawFirstStroke, bool drawLastStroke,
+ bool withUndo) {
TXshSimpleLevel *sl =
TTool::getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel();
TStroke *first = new TStroke();
@@ -1009,7 +1058,11 @@ bool ToonzVectorBrushTool::doFrameRangeStrokes(TFrameId firstFrameId,
int m = fids.size();
assert(m > 0);
- TUndoManager::manager()->beginBlock();
+ if (withUndo) TUndoManager::manager()->beginBlock();
+ int row = getApplication()->getCurrentFrame()->isEditingScene()
+ ? getApplication()->getCurrentFrame()->getFrameIndex()
+ : -1;
+ TFrameId cFid = getApplication()->getCurrentFrame()->getFid();
for (int i = 0; i < m; ++i) {
TFrameId fid = fids[i];
assert(firstFrameId <= fid && fid <= lastFrameId);
@@ -1017,7 +1070,7 @@ bool ToonzVectorBrushTool::doFrameRangeStrokes(TFrameId firstFrameId,
// This is an attempt to divide the tween evenly
double t = m > 1 ? (double)i / (double)(m - 1) : 0.5;
double s = t;
- switch (m_frameRange.getIndex()) {
+ switch (interpolationType) {
case 1: // LINEAR_WSTR
break;
case 2: // EASEIN_WSTR
@@ -1032,41 +1085,129 @@ bool ToonzVectorBrushTool::doFrameRangeStrokes(TFrameId firstFrameId,
}
TTool::Application *app = TTool::getApplication();
- if (app) {
- if (app->getCurrentFrame()->isEditingScene())
- app->getCurrentFrame()->setFrame(fid.getNumber() - 1);
- else
- app->getCurrentFrame()->setFid(fid);
- }
+ if (app) app->getCurrentFrame()->setFid(fid);
TVectorImageP img = sl->getFrame(fid, true);
if (t == 0) {
if (!swapped && !drawFirstStroke) {
} else
addStrokeToImage(getApplication(), img, firstImage->getStroke(0),
- m_breakAngles.getValue(), m_isFrameCreated,
+ breakAngles, autoGroup, autoFill, m_isFrameCreated,
m_isLevelCreated, sl, fid);
} else if (t == 1) {
if (swapped && !drawFirstStroke) {
- } else
+ } else if (drawLastStroke)
addStrokeToImage(getApplication(), img, lastImage->getStroke(0),
- m_breakAngles.getValue(), m_isFrameCreated,
+ breakAngles, autoGroup, autoFill, m_isFrameCreated,
m_isLevelCreated, sl, fid);
} else {
assert(firstImage->getStrokeCount() == 1);
assert(lastImage->getStrokeCount() == 1);
TVectorImageP vi = TInbetween(firstImage, lastImage).tween(s);
assert(vi->getStrokeCount() == 1);
- addStrokeToImage(getApplication(), img, vi->getStroke(0),
- m_breakAngles.getValue(), m_isFrameCreated,
- m_isLevelCreated, sl, fid);
+ addStrokeToImage(getApplication(), img, vi->getStroke(0), breakAngles,
+ autoGroup, autoFill, m_isFrameCreated, m_isLevelCreated,
+ sl, fid);
}
}
- TUndoManager::manager()->endBlock();
+ if (row != -1)
+ getApplication()->getCurrentFrame()->setFrame(row);
+ else
+ getApplication()->getCurrentFrame()->setFid(cFid);
+
+ if (withUndo) TUndoManager::manager()->endBlock();
notifyImageChanged();
return true;
}
+//--------------------------------------------------------------------------------------------------
+bool ToonzVectorBrushTool::doGuidedAutoInbetween(
+ TFrameId cFid, const TVectorImageP &cvi, TStroke *cStroke, bool breakAngles,
+ bool autoGroup, bool autoFill, bool drawStroke) {
+ TApplication *app = TTool::getApplication();
+
+ if (cFid.isEmptyFrame() || cFid.isNoFrame() || !cvi || !cStroke) return false;
+
+ TXshSimpleLevel *sl = app->getCurrentLevel()->getLevel()->getSimpleLevel();
+ if (!sl) return false;
+
+ int osBack = -1;
+ int osFront = -1;
+
+ getViewer()->getGuidedFrameIdx(&osBack, &osFront);
+
+ TFrameHandle *currentFrame = getApplication()->getCurrentFrame();
+ bool resultBack = false;
+ bool resultFront = false;
+ TFrameId oFid;
+ int cStrokeIdx = cvi->getStrokeCount();
+ int cStrokeCount = cStrokeIdx + 1;
+
+ TUndoManager::manager()->beginBlock();
+ if (osBack != -1) {
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
+ int col = app->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(osBack, col);
+ if (!cell.isEmpty()) oFid = cell.getFrameId();
+ }
+ } else
+ oFid = sl->getFrameId(osBack);
+
+ TVectorImageP fvi = sl->getFrame(oFid, false);
+ int fStrokeCount = fvi ? fvi->getStrokeCount() : 0;
+
+ int strokeIdx = getViewer()->getGuidedBackStroke() != -1
+ ? getViewer()->getGuidedBackStroke()
+ : cStrokeIdx;
+
+ if (!oFid.isEmptyFrame() && oFid != cFid && fvi && fStrokeCount &&
+ strokeIdx < fStrokeCount) {
+ TStroke *fStroke = fvi->getStroke(strokeIdx);
+
+ resultBack = doFrameRangeStrokes(
+ oFid, fStroke, cFid, cStroke,
+ Preferences::instance()->getGuidedInterpolation(), breakAngles,
+ autoGroup, autoFill, false, drawStroke, false);
+ }
+ }
+
+ if (osFront != -1) {
+ bool drawFirstStroke = (osBack != -1 && resultBack) ? false : true;
+
+ if (currentFrame->isEditingScene()) {
+ TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
+ int col = app->getCurrentColumn()->getColumnIndex();
+ if (xsh && col >= 0) {
+ TXshCell cell = xsh->getCell(osFront, col);
+ if (!cell.isEmpty()) oFid = cell.getFrameId();
+ }
+ } else
+ oFid = sl->getFrameId(osFront);
+
+ TVectorImageP fvi = sl->getFrame(oFid, false);
+ int fStrokeCount = fvi ? fvi->getStrokeCount() : 0;
+
+ int strokeIdx = getViewer()->getGuidedFrontStroke() != -1
+ ? getViewer()->getGuidedFrontStroke()
+ : cStrokeIdx;
+
+ if (!oFid.isEmptyFrame() && oFid != cFid && fvi && fStrokeCount &&
+ strokeIdx < fStrokeCount) {
+ TStroke *fStroke = fvi->getStroke(strokeIdx);
+
+ resultFront = doFrameRangeStrokes(
+ cFid, cStroke, oFid, fStroke,
+ Preferences::instance()->getGuidedInterpolation(), breakAngles,
+ autoGroup, autoFill, drawFirstStroke, false, false);
+ }
+ }
+ TUndoManager::manager()->endBlock();
+
+ return resultBack || resultFront;
+}
+
//--------------------------------------------------------------------------------------------------
void ToonzVectorBrushTool::addTrackPoint(const TThickPoint &point,
@@ -1375,6 +1516,9 @@ void ToonzVectorBrushTool::draw() {
// If toggled off, don't draw brush outline
if (!Preferences::instance()->isCursorOutlineEnabled()) return;
+ // Don't draw brush outline if picking guiding stroke
+ if (getViewer()->getGuidedStrokePickerMode()) return;
+
// Draw the brush outline - change color when the Ink / Paint check is
// activated
if ((ToonzCheck::instance()->getChecks() & ToonzCheck::eInk) ||
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.h b/toonz/sources/tnztools/toonzvectorbrushtool.h
index ea531828f..9b36af738 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.h
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.h
@@ -107,7 +107,11 @@ public:
void onEnter() override;
void onLeave() override;
- int getCursorId() const override { return ToolCursor::PenCursor; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return ToolCursor::PenCursor;
+ }
TPropertyGroup *getProperties(int targetType) override;
bool onPropertyChanged(std::string propertyName) override;
@@ -128,9 +132,16 @@ public:
void flushTrackPoint();
bool doFrameRangeStrokes(TFrameId firstFrameId, TStroke *firstStroke,
TFrameId lastFrameId, TStroke *lastStroke,
- bool drawFirstStroke = true);
+ int interpolationType, bool breakAngles,
+ bool autoGroup = false, bool autoFill = false,
+ bool drawFirstStroke = true,
+ bool drawLastStroke = true, bool withUndo = true);
void checkGuideSnapping(bool beforeMousePress, bool invertCheck);
void checkStrokeSnapping(bool beforeMousePress, bool invertCheck);
+ bool doGuidedAutoInbetween(TFrameId cFid, const TVectorImageP &cvi,
+ TStroke *cStroke, bool breakAngles,
+ bool autoGroup = false, bool autoFill = false,
+ bool drawStroke = true);
protected:
TPropertyGroup m_prop[2];
diff --git a/toonz/sources/tnztools/typetool.cpp b/toonz/sources/tnztools/typetool.cpp
index bfeafc7e1..ff198d60d 100644
--- a/toonz/sources/tnztools/typetool.cpp
+++ b/toonz/sources/tnztools/typetool.cpp
@@ -388,7 +388,11 @@ public:
void onDeactivate() override;
void onImageChanged() override;
- int getCursorId() const override { return m_cursorId; }
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
bool onPropertyChanged(std::string propertyName) override;
@@ -1200,6 +1204,11 @@ void TypeTool::mouseMove(const TPointD &pos, const TMouseEvent &) {
void TypeTool::leftButtonDown(const TPointD &pos, const TMouseEvent &) {
TSelection::setCurrent(0);
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
if (!m_validFonts) return;
TImageP img;
diff --git a/toonz/sources/tnztools/vectorselectiontool.cpp b/toonz/sources/tnztools/vectorselectiontool.cpp
index f542077ea..114d7a78e 100644
--- a/toonz/sources/tnztools/vectorselectiontool.cpp
+++ b/toonz/sources/tnztools/vectorselectiontool.cpp
@@ -1617,6 +1617,18 @@ void VectorSelectionTool::leftButtonDrag(const TPointD &pos,
//-----------------------------------------------------------------------------
+void VectorSelectionTool::leftButtonDown(const TPointD &pos,
+ const TMouseEvent &e) {
+ if (getViewer() && getViewer()->getGuidedStrokePickerMode()) {
+ getViewer()->doPickGuideStroke(pos);
+ return;
+ }
+
+ SelectionTool::leftButtonDown(pos, e);
+}
+
+//-----------------------------------------------------------------------------
+
void VectorSelectionTool::leftButtonUp(const TPointD &pos,
const TMouseEvent &e) {
m_leftButtonMousePressed = false;
diff --git a/toonz/sources/tnztools/vectorselectiontool.h b/toonz/sources/tnztools/vectorselectiontool.h
index b9f874cdb..29df53b15 100644
--- a/toonz/sources/tnztools/vectorselectiontool.h
+++ b/toonz/sources/tnztools/vectorselectiontool.h
@@ -8,6 +8,7 @@
// TnzTools includes
#include "tools/strokeselection.h"
#include "tools/levelselection.h"
+#include "tools/cursors.h"
// TnzCore includes
#include "tstroke.h"
@@ -318,6 +319,7 @@ protected:
void onDeactivate() override;
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
+ void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
void leftButtonDoubleClick(const TPointD &, const TMouseEvent &e) override;
void addContextMenuItems(QMenu *menu) override;
@@ -330,6 +332,12 @@ protected:
bool onPropertyChanged(std::string propertyName) override;
void onImageChanged() override;
+ int getCursorId() const override {
+ if (m_viewer && m_viewer->getGuidedStrokePickerMode())
+ return m_viewer->getGuidedStrokePickerCursor();
+ return m_cursorId;
+ }
+
private:
class AttachedLevelSelection final : public LevelSelection {
StrokeSelection &m_strokeSelection; //!< Selection of strokes to be seen at
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index f2756bfa9..733e8bdcb 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -2160,6 +2160,20 @@ void MainWindow::defineActions() {
CommandManager::instance()->setToggleTexts(V_ShowHideFullScreen,
tr("Full Screen Mode"),
tr("Exit Full Screen Mode"));
+ createRightClickMenuAction(MI_SelectNextGuideStroke,
+ tr("Select Next Frame Guide Stroke"), "");
+ createRightClickMenuAction(MI_SelectPrevGuideStroke,
+ tr("Select Previous Frame Guide Stroke"), "");
+ createRightClickMenuAction(MI_SelectBothGuideStrokes,
+ tr("Select Prev && Next Frame Guide Strokes"), "");
+ createRightClickMenuAction(MI_SelectGuideStrokeReset,
+ tr("Reset Guide Stroke Selections"), "");
+ createRightClickMenuAction(MI_TweenGuideStrokes,
+ tr("Tween Selected Guide Strokes"), "");
+ createRightClickMenuAction(MI_TweenGuideStrokeToSelected,
+ tr("Tween Guide Strokes to Selected"), "");
+ createRightClickMenuAction(MI_SelectGuidesAndTweenMode,
+ tr("Select Guide Strokes && Tween Mode"), "");
// Following actions are for adding "Visualization" menu items to the command
// bar. They are separated from the original actions in order to avoid
diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h
index 382250be6..d6cb12113 100644
--- a/toonz/sources/toonz/menubarcommandids.h
+++ b/toonz/sources/toonz/menubarcommandids.h
@@ -363,4 +363,13 @@
#define MI_OpenOnlineManual "MI_OpenOnlineManual"
#define MI_ClearCacheFolder "MI_ClearCacheFolder"
+
+#define MI_SelectNextGuideStroke "MI_SelectNextGuideStroke"
+#define MI_SelectPrevGuideStroke "MI_SelectPrevGuideStroke"
+#define MI_SelectGuideStrokeReset "MI_SelectGuideStrokeReset"
+#define MI_TweenGuideStrokes "MI_TweenGuideStrokes"
+#define MI_TweenGuideStrokeToSelected "MI_TweenGuideStrokeToSelected"
+#define MI_SelectBothGuideStrokes "MI_SelectBothGuideStrokes"
+#define MI_SelectGuidesAndTweenMode "MI_SelectGuidesAndTweenMode"
+
#endif
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index d01d00285..909206fba 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -530,6 +530,141 @@ public:
}
} positionResetCommand;
+class TSelectGuideStrokeNextCommand final : public MenuItemHandler {
+public:
+ TSelectGuideStrokeNextCommand() : MenuItemHandler(MI_SelectNextGuideStroke) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->getViewer()->setGuidedStrokePickerMode(1);
+ }
+} selectGuideStrokeNextCommand;
+
+class TSelectGuideStrokePrevCommand final : public MenuItemHandler {
+public:
+ TSelectGuideStrokePrevCommand() : MenuItemHandler(MI_SelectPrevGuideStroke) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->getViewer()->setGuidedStrokePickerMode(-1);
+ }
+} selectGuideStrokePrevCommand;
+
+class TSelectBothGuideStrokesCommand final : public MenuItemHandler {
+public:
+ TSelectBothGuideStrokesCommand()
+ : MenuItemHandler(MI_SelectBothGuideStrokes) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->getViewer()->setGuidedStrokePickerMode(-2);
+ }
+} selectBothGuideStrokesCommand;
+
+class TSelectGuideStrokeResetCommand final : public MenuItemHandler {
+public:
+ TSelectGuideStrokeResetCommand()
+ : MenuItemHandler(MI_SelectGuideStrokeReset) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->getViewer()->setGuidedStrokePickerMode(0);
+ tool->getViewer()->setGuidedBackStroke(-1);
+ tool->getViewer()->setGuidedFrontStroke(-1);
+ tool->getViewer()->invalidateAll();
+ }
+} selectGuideStrokeResetCommand;
+
+class TTweenGuideStrokesCommand final : public MenuItemHandler {
+public:
+ TTweenGuideStrokesCommand() : MenuItemHandler(MI_TweenGuideStrokes) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->tweenSelectedGuideStrokes();
+ }
+} tweenGuideStrokesCommand;
+
+class TTweenGuideStrokeToSelectedCommand final : public MenuItemHandler {
+public:
+ TTweenGuideStrokeToSelectedCommand()
+ : MenuItemHandler(MI_TweenGuideStrokeToSelected) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->tweenGuideStrokeToSelected();
+ }
+} tweenGuideStrokeToSelectedCommand;
+
+class TSelectGuidesAndTweenCommand final : public MenuItemHandler {
+public:
+ TSelectGuidesAndTweenCommand()
+ : MenuItemHandler(MI_SelectGuidesAndTweenMode) {}
+ void execute() override {
+ TVectorImageP vi = (TVectorImageP)TTool::getImage(false);
+ if (!vi) return;
+
+ Preferences *pref = Preferences::instance();
+ if (!pref->isOnionSkinEnabled() ||
+ (pref->getGuidedDrawing() != 1 && pref->getGuidedDrawing() != 2))
+ return;
+
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return;
+
+ tool->getViewer()->setGuidedStrokePickerMode(-3);
+ }
+} selectGuidesAndTweenCommand;
+
//=============================================================================
// SceneViewer
//-----------------------------------------------------------------------------
@@ -1662,7 +1797,10 @@ void SceneViewer::drawScene() {
TXshSimpleLevel::m_fillFullColorRaster = false;
// Guided Drawing Check
- int useGuidedDrawing = Preferences::instance()->getGuidedDrawing();
+ int useGuidedDrawing = Preferences::instance()->getGuidedDrawing();
+ TTool *tool = app->getCurrentTool()->getTool();
+ int guidedFrontStroke = tool ? tool->getViewer()->getGuidedFrontStroke() : -1;
+ int guidedBackStroke = tool ? tool->getViewer()->getGuidedBackStroke() : -1;
m_minZ = 0;
if (is3DView()) {
@@ -1693,6 +1831,8 @@ void SceneViewer::drawScene() {
->getCell(app->getCurrentFrame()->getFrame(), args.m_col)
.getFrameId();
args.m_isGuidedDrawingEnabled = useGuidedDrawing;
+ args.m_guidedFrontStroke = guidedFrontStroke;
+ args.m_guidedBackStroke = guidedBackStroke;
// args.m_currentFrameId = app->getCurrentFrame()->getFid();
Stage::visit(painter, args);
@@ -1726,7 +1866,8 @@ void SceneViewer::drawScene() {
Stage::visit(painter, app->getCurrentLevel()->getLevel(),
app->getCurrentFrame()->getFid(),
app->getCurrentOnionSkin()->getOnionSkinMask(),
- frameHandle->isPlaying(), useGuidedDrawing);
+ frameHandle->isPlaying(), useGuidedDrawing, guidedBackStroke,
+ guidedFrontStroke);
} else {
std::pair<TXsheet *, int> xr;
int xsheetLevel = 0;
@@ -1751,6 +1892,9 @@ void SceneViewer::drawScene() {
->getCell(app->getCurrentFrame()->getFrame(), args.m_col)
.getFrameId();
args.m_isGuidedDrawingEnabled = useGuidedDrawing;
+ args.m_guidedFrontStroke = guidedFrontStroke;
+ args.m_guidedBackStroke = guidedBackStroke;
+
Stage::visit(painter, args);
}
diff --git a/toonz/sources/toonz/sceneviewercontextmenu.cpp b/toonz/sources/toonz/sceneviewercontextmenu.cpp
index 97b3f47d4..e276dbde6 100644
--- a/toonz/sources/toonz/sceneviewercontextmenu.cpp
+++ b/toonz/sources/toonz/sceneviewercontextmenu.cpp
@@ -155,7 +155,65 @@ SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent)
action->setCheckable(true);
action->setChecked(guidedDrawingStatus == 3);
ret = ret && parent->connect(action, SIGNAL(triggered()), this,
- SLOT(setGuidedDrawingAll()));
+ SLOT(setGuidedDrawingAll()));
+ guidedDrawingMenu->addSeparator();
+ bool enableOption = guidedDrawingStatus == 1 || guidedDrawingStatus == 2;
+ action = guidedDrawingMenu->addAction(tr("Auto Inbetween"));
+ action->setCheckable(true);
+ action->setChecked(Preferences::instance()->getGuidedAutoInbetween());
+ action->setEnabled(enableOption);
+ ret = ret && parent->connect(action, SIGNAL(triggered()), this,
+ SLOT(setGuidedAutoInbetween()));
+ guidedDrawingMenu->addSeparator();
+ int guidedInterpolation = Preferences::instance()->getGuidedInterpolation();
+ action = guidedDrawingMenu->addAction(tr("Linear Interpolation"));
+ action->setCheckable(true);
+ action->setChecked(guidedInterpolation == 1);
+ action->setEnabled(enableOption);
+ ret = ret && parent->connect(action, SIGNAL(triggered()), this,
+ SLOT(setGuidedInterpolationLinear()));
+ action = guidedDrawingMenu->addAction(tr("Ease In Interpolation"));
+ action->setCheckable(true);
+ action->setChecked(guidedInterpolation == 2);
+ action->setEnabled(enableOption);
+ ret = ret && parent->connect(action, SIGNAL(triggered()), this,
+ SLOT(setGuidedInterpolationEaseIn()));
+ action = guidedDrawingMenu->addAction(tr("Ease Out Interpolation"));
+ action->setCheckable(true);
+ action->setChecked(guidedInterpolation == 3);
+ action->setEnabled(enableOption);
+ ret = ret && parent->connect(action, SIGNAL(triggered()), this,
+ SLOT(setGuidedInterpolationEaseOut()));
+ action = guidedDrawingMenu->addAction(tr("Ease In/Out Interpolation"));
+ action->setCheckable(true);
+ action->setChecked(guidedInterpolation == 4);
+ action->setEnabled(enableOption);
+ ret = ret && parent->connect(action, SIGNAL(triggered()), this,
+ SLOT(setGuidedInterpolationEaseInOut()));
+ guidedDrawingMenu->addSeparator();
+ action = CommandManager::instance()->getAction(MI_SelectPrevGuideStroke);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+ action = CommandManager::instance()->getAction(MI_SelectNextGuideStroke);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+ action = CommandManager::instance()->getAction(MI_SelectBothGuideStrokes);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+ action = CommandManager::instance()->getAction(MI_SelectGuideStrokeReset);
+ action->setEnabled(true);
+ guidedDrawingMenu->addAction(action);
+ guidedDrawingMenu->addSeparator();
+ action = CommandManager::instance()->getAction(MI_TweenGuideStrokes);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+ action = CommandManager::instance()->getAction(MI_TweenGuideStrokeToSelected);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+ action = CommandManager::instance()->getAction(MI_SelectGuidesAndTweenMode);
+ action->setEnabled(enableOption);
+ guidedDrawingMenu->addAction(action);
+
// Zero Thick
if (!parent->isPreviewEnabled())
ZeroThickToggleGui::addZeroThickCommand(this);
@@ -385,6 +443,32 @@ void SceneViewerContextMenu::setGuidedDrawingAll() {
Preferences::instance()->setValue(guidedDrawingType, 3);
}
+//-----------------------------------------------------------------------------
+void SceneViewerContextMenu::setGuidedAutoInbetween() {
+ Preferences::instance()->setValue(
+ guidedAutoInbetween, !Preferences::instance()->getGuidedAutoInbetween());
+}
+
+//-----------------------------------------------------------------------------
+void SceneViewerContextMenu::setGuidedInterpolationLinear() {
+ Preferences::instance()->setValue(guidedInterpolationType, 1);
+}
+
+//-----------------------------------------------------------------------------
+void SceneViewerContextMenu::setGuidedInterpolationEaseIn() {
+ Preferences::instance()->setValue(guidedInterpolationType, 2);
+}
+
+//-----------------------------------------------------------------------------
+void SceneViewerContextMenu::setGuidedInterpolationEaseOut() {
+ Preferences::instance()->setValue(guidedInterpolationType, 3);
+}
+
+//-----------------------------------------------------------------------------
+void SceneViewerContextMenu::setGuidedInterpolationEaseInOut() {
+ Preferences::instance()->setValue(guidedInterpolationType, 4);
+}
+
//-----------------------------------------------------------------------------
void SceneViewerContextMenu::savePreviewedFrames() {
@@ -393,6 +477,7 @@ void SceneViewerContextMenu::savePreviewedFrames() {
->saveRenderedFrames();
}
+//-----------------------------------------------------------------------------
class ZeroThickToggle : public MenuItemHandler {
public:
ZeroThickToggle() : MenuItemHandler(MI_ZeroThick) {}
diff --git a/toonz/sources/toonz/sceneviewercontextmenu.h b/toonz/sources/toonz/sceneviewercontextmenu.h
index 41d998558..68be12764 100644
--- a/toonz/sources/toonz/sceneviewercontextmenu.h
+++ b/toonz/sources/toonz/sceneviewercontextmenu.h
@@ -35,6 +35,11 @@ public slots:
void setGuidedDrawingClosest();
void setGuidedDrawingFarthest();
void setGuidedDrawingAll();
+ void setGuidedAutoInbetween();
+ void setGuidedInterpolationLinear();
+ void setGuidedInterpolationEaseIn();
+ void setGuidedInterpolationEaseOut();
+ void setGuidedInterpolationEaseInOut();
void onShowHide();
void onSetCurrent();
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 61e944294..add268068 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -1634,7 +1634,10 @@ void SceneViewer::onToolSwitched() {
invalidateToolStatus();
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
- if (tool) tool->updateMatrix();
+ if (tool) {
+ tool->updateMatrix();
+ if (tool->getViewer()) tool->getViewer()->setGuidedStrokePickerMode(0);
+ }
onLevelChanged();
update();
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 2e004d5cc..8dd2af3ad 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -575,6 +575,10 @@ void Preferences::definePreferenceItems() {
define(shortcutPreset, "shortcutPreset", QMetaType::QString, "defopentoonz");
// Viewer context menu
define(guidedDrawingType, "guidedDrawingType", QMetaType::Int, 0); // Off
+ define(guidedAutoInbetween, "guidedAutoInbetween", QMetaType::Bool,
+ false); // Off
+ define(guidedInterpolationType, "guidedInterpolationType", QMetaType::Int,
+ 1); // Linear
#if defined(MACOSX) && defined(__LP64__)
// OSX shared memory settings
define(shmmax, "shmmax", QMetaType::Int, -1);
diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp
index 622bb341c..e42ade2be 100644
--- a/toonz/sources/toonzlib/stage.cpp
+++ b/toonz/sources/toonzlib/stage.cpp
@@ -77,7 +77,7 @@ void updateOnionSkinSize(const PlayerSet &players) {
assert(Player::m_onionSkinFrontSize == 0 && Player::m_onionSkinBackSize == 0);
int i;
int maxOnionSkinFrontValue = 0, maxOnionSkinBackValue = 0,
- firstBackOnionSkin = 0, lastBackVisibleSkin = 0;
+ firstFrontOnionSkin = 0, firstBackOnionSkin = 0, lastBackVisibleSkin = 0;
for (i = 0; i < (int)players.size(); i++) {
Player player = players[i];
if (player.m_onionSkinDistance == c_noOnionSkin) continue;
@@ -87,6 +87,12 @@ void updateOnionSkinSize(const PlayerSet &players) {
if (player.m_onionSkinDistance < 0 &&
maxOnionSkinBackValue > player.m_onionSkinDistance)
maxOnionSkinBackValue = player.m_onionSkinDistance;
+ if (firstFrontOnionSkin == 0 && player.m_onionSkinDistance > 0)
+ firstFrontOnionSkin = player.m_onionSkinDistance;
+ else if (player.m_onionSkinDistance > 0 &&
+ firstFrontOnionSkin > player.m_onionSkinDistance)
+ firstFrontOnionSkin = player.m_onionSkinDistance;
+
if (firstBackOnionSkin == 0 && player.m_onionSkinDistance < 0)
firstBackOnionSkin = player.m_onionSkinDistance;
else if (player.m_onionSkinDistance < 0 &&
@@ -99,6 +105,7 @@ void updateOnionSkinSize(const PlayerSet &players) {
}
Player::m_onionSkinFrontSize = maxOnionSkinFrontValue;
Player::m_onionSkinBackSize = maxOnionSkinBackValue;
+ Player::m_firstFrontOnionSkin = firstFrontOnionSkin;
Player::m_firstBackOnionSkin = firstBackOnionSkin;
Player::m_lastBackVisibleSkin = lastBackVisibleSkin;
}
@@ -199,6 +206,8 @@ public:
// for guided drawing
TFrameId m_currentFrameId;
int m_isGuidedDrawingEnabled;
+ int m_guidedFrontStroke = -1;
+ int m_guidedBackStroke = -1;
std::vector<TXshColumn *> m_ancestors;
const ImagePainter::VisualSettings *m_vs;
@@ -378,6 +387,8 @@ void StageBuilder::addCell(PlayerSet &players, ToonzScene *scene, TXsheet *xsh,
player.m_frame = row;
player.m_currentFrameId = m_currentFrameId;
player.m_isGuidedDrawingEnabled = m_isGuidedDrawingEnabled;
+ player.m_guidedFrontStroke = m_guidedFrontStroke;
+ player.m_guidedBackStroke = m_guidedBackStroke;
player.m_dpiAff = sl ? getDpiAffine(sl, cell.m_frameId) : TAffine();
player.m_onionSkinDistance = m_onionSkinDistance;
player.m_isCurrentColumn = (m_currentColumnIndex == col);
@@ -675,6 +686,8 @@ void StageBuilder::addSimpleLevelFrame(PlayerSet &players,
player.m_isEditingLevel = true;
player.m_currentFrameId = m_currentFrameId;
player.m_isGuidedDrawingEnabled = m_isGuidedDrawingEnabled;
+ player.m_guidedFrontStroke = m_guidedFrontStroke;
+ player.m_guidedBackStroke = m_guidedBackStroke;
player.m_isVisibleinOSM = ghostRow >= 0;
player.m_onionSkinDistance = m_onionSkinDistance;
player.m_dpiAff = getDpiAffine(level, ghostFid);
@@ -753,6 +766,8 @@ void StageBuilder::addSimpleLevelFrame(PlayerSet &players,
player.m_isEditingLevel = true;
player.m_currentFrameId = m_currentFrameId;
player.m_isGuidedDrawingEnabled = m_isGuidedDrawingEnabled;
+ player.m_guidedFrontStroke = m_guidedFrontStroke;
+ player.m_guidedBackStroke = m_guidedBackStroke;
player.m_isVisibleinOSM = rows[i] >= 0;
#ifdef NUOVO_ONION
player.m_onionSkinDistance = rows[i] - row;
@@ -842,8 +857,11 @@ void Stage::visit(Visitor &visitor, const VisitArgs &args) {
sb.m_onionSkinMask = *osm;
sb.m_currentFrameId = args.m_currentFrameId;
sb.m_isGuidedDrawingEnabled = args.m_isGuidedDrawingEnabled;
+ sb.m_guidedFrontStroke = args.m_guidedFrontStroke;
+ sb.m_guidedBackStroke = args.m_guidedBackStroke;
Player::m_onionSkinFrontSize = 0;
Player::m_onionSkinBackSize = 0;
+ Player::m_firstFrontOnionSkin = 0;
Player::m_firstBackOnionSkin = 0;
Player::m_lastBackVisibleSkin = 0;
Player::m_isShiftAndTraceEnabled = osm->isShiftTraceEnabled();
@@ -876,14 +894,18 @@ void Stage::visit(Visitor &visitor, ToonzScene *scene, TXsheet *xsh, int row) {
*/
void Stage::visit(Visitor &visitor, TXshSimpleLevel *level, const TFrameId &fid,
const OnionSkinMask &osm, bool isPlaying,
- int isGuidedDrawingEnabled) {
+ int isGuidedDrawingEnabled, int guidedBackStroke,
+ int guidedFrontStroke) {
StageBuilder sb;
sb.m_vs = &visitor.m_vs;
sb.m_onionSkinMask = osm;
sb.m_currentFrameId = fid;
sb.m_isGuidedDrawingEnabled = isGuidedDrawingEnabled;
+ sb.m_guidedFrontStroke = guidedFrontStroke;
+ sb.m_guidedBackStroke = guidedBackStroke;
Player::m_onionSkinFrontSize = 0;
Player::m_onionSkinBackSize = 0;
+ Player::m_firstFrontOnionSkin = 0;
Player::m_firstBackOnionSkin = 0;
Player::m_lastBackVisibleSkin = 0;
Player::m_isShiftAndTraceEnabled = osm.isShiftTraceEnabled();
@@ -896,8 +918,9 @@ void Stage::visit(Visitor &visitor, TXshSimpleLevel *level, const TFrameId &fid,
void Stage::visit(Visitor &visitor, TXshLevel *level, const TFrameId &fid,
const OnionSkinMask &osm, bool isPlaying,
- double isGuidedDrawingEnabled) {
+ double isGuidedDrawingEnabled, int guidedBackStroke,
+ int guidedFrontStroke) {
if (level && level->getSimpleLevel())
visit(visitor, level->getSimpleLevel(), fid, osm, isPlaying,
- (int)isGuidedDrawingEnabled);
+ (int)isGuidedDrawingEnabled, guidedBackStroke, guidedFrontStroke);
}
diff --git a/toonz/sources/toonzlib/stageplayer.cpp b/toonz/sources/toonzlib/stageplayer.cpp
index 2f7ff4eee..fa8071373 100644
--- a/toonz/sources/toonzlib/stageplayer.cpp
+++ b/toonz/sources/toonzlib/stageplayer.cpp
@@ -21,6 +21,7 @@ using namespace Stage;
double Player::m_onionSkinFrontSize = 0;
double Player::m_onionSkinBackSize = 0;
+double Player::m_firstFrontOnionSkin = 0;
double Player::m_firstBackOnionSkin = 0;
double Player::m_lastBackVisibleSkin = 0;
bool Player::m_isShiftAndTraceEnabled = false;
diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp
index 5018bc02a..e4711cb3a 100644
--- a/toonz/sources/toonzlib/stagevisitor.cpp
+++ b/toonz/sources/toonzlib/stagevisitor.cpp
@@ -869,13 +869,15 @@ void RasterPainter::onVectorImage(TVectorImage *vi,
rd.m_show0ThickStrokes = prefs.getShow0ThickLines();
rd.m_regionAntialias = prefs.getRegionAntialias();
rd.m_animatedGuidedDrawing = prefs.getAnimatedGuidedDrawing();
- if (player.m_onionSkinDistance < 0 &&
+ if (player.m_onionSkinDistance != 0 &&
(player.m_isCurrentColumn || player.m_isCurrentXsheetLevel)) {
if (player.m_isGuidedDrawingEnabled == 3 // show guides on all
|| (player.m_isGuidedDrawingEnabled == 1 && // show guides on closest
- player.m_onionSkinDistance == player.m_firstBackOnionSkin) ||
+ (player.m_onionSkinDistance == player.m_firstBackOnionSkin ||
+ player.m_onionSkinDistance == player.m_firstFrontOnionSkin)) ||
(player.m_isGuidedDrawingEnabled == 2 && // show guides on farthest
- player.m_onionSkinDistance == player.m_onionSkinBackSize) ||
+ (player.m_onionSkinDistance == player.m_onionSkinBackSize ||
+ player.m_onionSkinDistance == player.m_onionSkinFrontSize)) ||
(player.m_isEditingLevel && // fix for level editing mode sending extra
// players
player.m_isGuidedDrawingEnabled == 2 &&
@@ -889,7 +891,16 @@ void RasterPainter::onVectorImage(TVectorImage *vi,
TImageP image = sl->getFrame(player.m_currentFrameId, false);
TVectorImageP vecImage = image;
if (vecImage) currentStrokeCount = vecImage->getStrokeCount();
- if (currentStrokeCount < totalStrokes)
+ if (currentStrokeCount < 0) currentStrokeCount = 0;
+ if (player.m_guidedFrontStroke != -1 &&
+ (player.m_onionSkinDistance == player.m_onionSkinFrontSize ||
+ player.m_onionSkinDistance == player.m_firstFrontOnionSkin))
+ rd.m_indexToHighlight = player.m_guidedFrontStroke;
+ else if (player.m_guidedBackStroke != -1 &&
+ (player.m_onionSkinDistance == player.m_onionSkinBackSize ||
+ player.m_onionSkinDistance == player.m_firstBackOnionSkin))
+ rd.m_indexToHighlight = player.m_guidedBackStroke;
+ else if (currentStrokeCount < totalStrokes)
rd.m_indexToHighlight = currentStrokeCount;
double guidedM[4] = {1.0, 1.0, 1.0, 1.0}, guidedC[4];