Skip to content

Commit

Permalink
Merge pull request #3073 from manongjohn/fix_guided_drawing_issues
Browse files Browse the repository at this point in the history
Fix guided drawing issues
  • Loading branch information
RodneyBaker committed Jan 29, 2020
2 parents 431a98c + 2e916a6 commit a2795f2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 44 deletions.
23 changes: 10 additions & 13 deletions toonz/sources/tnztools/geometrictool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,12 @@ class GeometricTool final : public TTool {
ImageUtils::getFillingInformationOverlappingArea(vi, *fillInformation,
stroke->getBBox());

bool strokeAdded = false;
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 ((Preferences::instance()->getGuidedDrawingType() == 1 ||
Preferences::instance()->getGuidedDrawingType() == 2) &&
Preferences::instance()->getGuidedAutoInbetween()) {
Expand All @@ -1127,19 +1132,11 @@ class GeometricTool final : public TTool {
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);
vbTool->doGuidedAutoInbetween(id, vi, stroke, false,
m_param.m_autogroup.getValue(),
m_param.m_autofill.getValue(), false);
}
}

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;
Expand Down Expand Up @@ -2095,7 +2092,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)),
Expand Down
6 changes: 6 additions & 0 deletions toonz/sources/tnztools/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,8 @@ void TTool::tweenSelectedGuideStrokes() {
TTool *tool = TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
if (vbTool) {
m_isFrameCreated = false;
m_isLevelCreated = false;
vbTool->setViewer(m_viewer);
vbTool->doFrameRangeStrokes(
bFid, bStroke, fFid, fStroke,
Expand Down Expand Up @@ -1394,6 +1396,8 @@ void TTool::tweenGuideStrokeToSelected() {
TTool *tool = TTool::getTool(T_Brush, TTool::ToolTargetType::VectorImage);
ToonzVectorBrushTool *vbTool = (ToonzVectorBrushTool *)tool;
if (vbTool) {
m_isFrameCreated = false;
m_isLevelCreated = false;
vbTool->setViewer(m_viewer);
TUndoManager::manager()->beginBlock();
if (bStroke)
Expand Down Expand Up @@ -1473,5 +1477,7 @@ void TTool::flipGuideStrokeDirection(int mode) {
if (!stroke) return;

stroke->changeDirection();
sl->setDirtyFlag(true);
getViewer()->invalidateAll();
m_application->getCurrentLevel()->notifyLevelChange();
}
29 changes: 16 additions & 13 deletions toonz/sources/tnztools/toonzvectorbrushtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,29 +980,26 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
m_snapSelf = false;
}

bool strokeAdded = false;
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?

if ((Preferences::instance()->getGuidedDrawingType() == 1 ||
Preferences::instance()->getGuidedDrawingType() == 2) &&
Preferences::instance()->getGuidedAutoInbetween()) {
int fidx = getApplication()->getCurrentFrame()->getFrameIndex();
TFrameId fId = getFrameId();

strokeAdded = doGuidedAutoInbetween(
fId, vi, stroke, m_breakAngles.getValue(), false, false, true);
doGuidedAutoInbetween(fId, vi, stroke, m_breakAngles.getValue(), false,
false, false);

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);
m_track.clear();
Expand Down Expand Up @@ -1141,7 +1138,7 @@ bool ToonzVectorBrushTool::doGuidedAutoInbetween(
bool resultFront = false;
TFrameId oFid;
int cStrokeIdx = cvi->getStrokeCount();
int cStrokeCount = cStrokeIdx + 1;
if (!drawStroke) cStrokeIdx--;

TUndoManager::manager()->beginBlock();
if (osBack != -1) {
Expand All @@ -1166,10 +1163,13 @@ bool ToonzVectorBrushTool::doGuidedAutoInbetween(
strokeIdx < fStrokeCount) {
TStroke *fStroke = fvi->getStroke(strokeIdx);

resultBack = doFrameRangeStrokes(
bool frameCreated = m_isFrameCreated;
m_isFrameCreated = false;
resultBack = doFrameRangeStrokes(
oFid, fStroke, cFid, cStroke,
Preferences::instance()->getGuidedInterpolation(), breakAngles,
autoGroup, autoFill, false, drawStroke, false);
m_isFrameCreated = frameCreated;
}
}

Expand Down Expand Up @@ -1197,10 +1197,13 @@ bool ToonzVectorBrushTool::doGuidedAutoInbetween(
strokeIdx < fStrokeCount) {
TStroke *fStroke = fvi->getStroke(strokeIdx);

resultFront = doFrameRangeStrokes(
bool frameCreated = m_isFrameCreated;
m_isFrameCreated = false;
resultFront = doFrameRangeStrokes(
cFid, cStroke, oFid, fStroke,
Preferences::instance()->getGuidedInterpolation(), breakAngles,
autoGroup, autoFill, drawFirstStroke, false, false);
m_isFrameCreated = frameCreated;
}
}
TUndoManager::manager()->endBlock();
Expand Down
36 changes: 18 additions & 18 deletions toonz/sources/toonz/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,24 +2209,24 @@ void MainWindow::defineActions() {
CommandManager::instance()->setToggleTexts(V_ShowHideFullScreen,
tr("Full Screen Mode"),
tr("Exit Full Screen Mode"));
createMiscAction(MI_SelectNextGuideStroke,
tr("Select Next Frame Guide Stroke"), "");
createMiscAction(MI_SelectPrevGuideStroke,
tr("Select Previous Frame Guide Stroke"), "");
createMiscAction(MI_SelectBothGuideStrokes,
tr("Select Prev && Next Frame Guide Strokes"), "");
createMiscAction(MI_SelectGuideStrokeReset,
tr("Reset Guide Stroke Selections"), "");
createMiscAction(MI_TweenGuideStrokes,
tr("Tween Selected Guide Strokes"), "");
createMiscAction(MI_TweenGuideStrokeToSelected,
tr("Tween Guide Strokes to Selected"), "");
createMiscAction(MI_SelectGuidesAndTweenMode,
tr("Select Guide Strokes && Tween Mode"), "");
createMiscAction(MI_FlipNextGuideStroke,
tr("Flip Next Guide Stroke Direction"), "");
createMiscAction(MI_FlipPrevGuideStroke,
tr("Flip Previous Guide Stroke Direction"), "");
createToolOptionsAction(MI_SelectNextGuideStroke,
tr("Select Next Frame Guide Stroke"), "");
createToolOptionsAction(MI_SelectPrevGuideStroke,
tr("Select Previous Frame Guide Stroke"), "");
createToolOptionsAction(MI_SelectBothGuideStrokes,
tr("Select Prev && Next Frame Guide Strokes"), "");
createToolOptionsAction(MI_SelectGuideStrokeReset,
tr("Reset Guide Stroke Selections"), "");
createToolOptionsAction(MI_TweenGuideStrokes,
tr("Tween Selected Guide Strokes"), "");
createToolOptionsAction(MI_TweenGuideStrokeToSelected,
tr("Tween Guide Strokes to Selected"), "");
createToolOptionsAction(MI_SelectGuidesAndTweenMode,
tr("Select Guide Strokes && Tween Mode"), "");
createToolOptionsAction(MI_FlipNextGuideStroke,
tr("Flip Next Guide Stroke Direction"), "");
createToolOptionsAction(MI_FlipPrevGuideStroke,
tr("Flip Previous Guide Stroke Direction"), "");

// Following actions are for adding "Visualization" menu items to the command
// bar. They are separated from the original actions in order to avoid
Expand Down

0 comments on commit a2795f2

Please sign in to comment.