Fix motion path issues (#505)

This commit is contained in:
Jeremy Bullock 2020-11-16 09:13:09 -07:00 committed by GitHub
parent b8cc17a0f0
commit 5ca6de7e04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 157 additions and 109 deletions

View file

@ -1285,14 +1285,16 @@ public:
bool isSpline = false;
if (TTool::getApplication()->getCurrentObject()->isSpline()) {
isSpline = true;
if (!ToolUtils::isJustCreatedSpline(vi.getPointer())) {
m_primitive->setIsPrompting(true);
QString question("Are you sure you want to replace the motion path?");
int ret =
DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"), 0);
m_primitive->setIsPrompting(false);
if (ret == 2 || ret == 0) return;
}
// if (!ToolUtils::isJustCreatedSpline(vi.getPointer())) {
// m_primitive->setIsPrompting(true);
// QString question("Are you sure you want to replace the motion
// path?");
// int ret =
// DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"),
// 0);
// m_primitive->setIsPrompting(false);
// if (ret == 2 || ret == 0) return;
//}
QMutexLocker lock(vi->getMutex());
TUndo *undo = new UndoPath(
getXsheet()->getStageObject(getObjectId())->getSpline());

View file

@ -1091,17 +1091,17 @@ void ToonzVectorBrushTool::leftButtonUp(const TPointD &pos,
~Cleanup() { m_this->m_track.clear(), m_this->invalidate(); }
} cleanup = {this};
if (!isJustCreatedSpline(vi.getPointer())) {
m_isPrompting = true;
// if (!isJustCreatedSpline(vi.getPointer())) {
// m_isPrompting = true;
QString question("Are you sure you want to replace the motion path?");
int ret =
DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"), 0);
// QString question("Are you sure you want to replace the motion path?");
// int ret =
// DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"), 0);
m_isPrompting = false;
// m_isPrompting = false;
if (ret == 2 || ret == 0) return;
}
// if (ret == 2 || ret == 0) return;
//}
QMutexLocker lock(vi->getMutex());

View file

@ -1621,8 +1621,28 @@ void SceneViewer::drawOverlay() {
glPopMatrix();
}
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
TStageObjectId objId = app->getCurrentObject()->getObjectId();
bool isMotionPath = false;
if (objId == xsh->getStageObjectTree()->getMotionPathViewerId() &&
app->getCurrentObject()->isSpline()) {
isMotionPath = true;
int x0, x1, y0, y1;
rect().getCoords(&x0, &y0, &x1, &y1);
x0 = (-(x1 / 2)) + 15;
y0 = ((y1 / 2)) - 25;
glPushMatrix();
glScaled(3, 3, 3);
glColor3d(1.0, 0.0, 0.0);
tglDrawText(TPointD(x0 / 3, y0 / 3),
tr("Motion Path Selected").toStdWString());
glPopMatrix();
}
// draw camera
if (viewCameraToggle.getStatus() && m_drawEditingLevel == false) {
if (!isMotionPath && viewCameraToggle.getStatus() &&
m_drawEditingLevel == false) {
unsigned long f = 0;
if (m_referenceMode == CAMERA_REFERENCE)
f |= ViewerDraw::CAMERA_REFERENCE;
@ -1661,6 +1681,7 @@ void SceneViewer::drawOverlay() {
rect().getCoords(&x0, &y0, &x1, &y1);
x0 = (-(x1 / 2)) + 15;
y0 = ((y1 / 2)) - 15;
glColor3d(1.0, 0.0, 0.0);
tglDrawDisk(TPointD(x0, y0), 10);
}
@ -3175,15 +3196,20 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
TStageObjectId objId = TApp::instance()->getCurrentObject()->getObjectId();
TStageObject *pegbar =
(objId != TStageObjectId::NoneId &&
objId != xsh->getStageObjectTree()->getMotionPathViewerId())
(objId != TStageObjectId::NoneId) //&&
// objId != xsh->getStageObjectTree()->getMotionPathViewerId())
? xsh->getStageObject(objId)
: 0;
bool isMotionPathViewer =
objId == xsh->getStageObjectTree()->getMotionPathViewerId() &&
TApp::instance()->getCurrentObject()->isSpline();
TStageObjectSpline *pegbarSpline = 0;
if (pegbar && pegbar->getSpline()) {
if (TApp::instance()->getCurrentObject()->isSpline() && pegbar &&
pegbar->getSpline()) {
const TStroke *stroke = 0;
pegbarSpline = pegbar->getSpline();
if (!isMotionPathViewer) {
stroke = pegbar->getSpline()->getStroke();
if (!stroke) return;
@ -3204,7 +3230,8 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
aff = TAffine();
glTranslated(0, 0, objZ);
} else {
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
TStageObjectId cameraId =
xsh->getStageObjectTree()->getCurrentCameraId();
double camZ = xsh->getZ(cameraId, frame);
TAffine camAff = xsh->getPlacement(cameraId, frame);
TAffine tmp;
@ -3256,11 +3283,15 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
glPopMatrix();
}
}
int splineCount = xsh->getStageObjectTree()->getSplineCount();
for (int i = 0; i < splineCount; i++) {
TStageObjectSpline *spline = xsh->getStageObjectTree()->getSpline(i);
if (!spline->getActive()) continue;
if (isMotionPathViewer && (pegbarSpline && pegbarSpline == spline))
int z;
else if (!spline->getActive())
continue;
const TStroke *stroke = 0;
int steps = 0;

View file

@ -12,9 +12,10 @@
#include "toonz/tcolumnhandle.h"
#include "toonz/txshlevel.h"
#include "toonz/txshleveltypes.h"
#include "toonz/tobjecthandle.h"
#include "toonzqt/tselectionhandle.h"
#include "toonzqt/selection.h"
#include "toonz/tstageobjecttree.h"
#include "tools/tool.h"
@ -37,6 +38,7 @@ StatusBar::StatusBar(QWidget* parent) : QStatusBar(parent) {
TApp* app = TApp::instance();
TFrameHandle* frameHandle = app->getCurrentFrame();
TXshLevelHandle* levelHandle = app->getCurrentLevel();
TObjectHandle* object = app->getCurrentObject();
bool ret = true;
@ -46,6 +48,8 @@ StatusBar::StatusBar(QWidget* parent) : QStatusBar(parent) {
SLOT(updateInfoText()));
ret = ret && connect(levelHandle, SIGNAL(xshLevelChanged()), this,
SLOT(updateInfoText()));
ret = ret &&
connect(object, SIGNAL(objectSwitched()), this, SLOT(updateInfoText()));
assert(ret);
@ -73,6 +77,15 @@ void StatusBar::updateInfoText() {
TApp* app = TApp::instance();
ToolHandle* toolHandle = app->getCurrentTool();
TTool* tool = toolHandle->getTool();
TObjectHandle* object = app->getCurrentObject();
TStageObjectTree* tree =
app->getCurrentXsheet()->getXsheet()->getStageObjectTree();
if (object->isSpline()) {
m_infoLabel->setText(
tr("Motion Path Selected: Click on a level or frame to leave motion "
"path editing."));
return;
}
std::string name = tool->getName();
tool->getToolType();
int target = tool->getTargetType();
@ -128,18 +141,19 @@ void StatusBar::makeMap() {
"Animate Tool: Modifies the position, rotation and size of "
"the current column"});
m_infoMap.insert({"T_Brush", "Brush Tool: Draws in the work area freehand"});
m_infoMap.insert({"T_BrushVector",
"Brush Tool: Draws in the work area freehand" + spacer +
m_infoMap.insert(
{"T_BrushVector", "Brush Tool: Draws in the work area freehand" + spacer +
"Shift - Straight Lines" + spacer +
#ifdef MACOSX
"Cmd - Straight Lines Snapped to Angles" + spacer +
"Cmd + Opt - Add / Remove Vanishing Point" + spacer +
"Opt - Draw to Vanishing Point" + spacer +
"Cmd + Opt - Add / Remove Vanishing Point" +
spacer + "Opt - Draw to Vanishing Point" + spacer +
"Hold Cmd + Shift - Toggle Snapping"});
#else
"Control - Straight Lines Snapped to Angles" + spacer +
"Ctrl + Alt - Add / Remove Vanishing Point" + spacer +
"Alt - Draw to Vanishing Point" + spacer +
"Control - Straight Lines Snapped to Angles" +
spacer +
"Ctrl + Alt - Add / Remove Vanishing Point" +
spacer + "Alt - Draw to Vanishing Point" + spacer +
"Hold Ctrl + Shift - Toggle Snapping"});
#endif
m_infoMap.insert({"T_BrushSmartRaster",
@ -154,25 +168,26 @@ void StatusBar::makeMap() {
"Ctrl + Alt - Add / Remove Vanishing Point" + spacer +
"Alt - Draw to Vanishing Point"});
#endif
m_infoMap.insert({"T_BrushRaster",
"Brush Tool: Draws in the work area freehand" + spacer +
m_infoMap.insert(
{"T_BrushRaster", "Brush Tool: Draws in the work area freehand" + spacer +
"Shift - Straight Lines" + spacer +
#ifdef MACOSX
"Cmd - Straight Lines Snapped to Angles" + spacer +
"Cmd + Opt - Add / Remove Vanishing Point" + spacer +
"Opt - Draw to Vanishing Point"});
"Cmd + Opt - Add / Remove Vanishing Point" +
spacer + "Opt - Draw to Vanishing Point"});
#else
"Control - Straight Lines Snapped to Angles" + spacer +
"Ctrl + Alt - Add / Remove Vanishing Point" + spacer +
"Alt - Draw to Vanishing Point"});
"Control - Straight Lines Snapped to Angles" +
spacer +
"Ctrl + Alt - Add / Remove Vanishing Point" +
spacer + "Alt - Draw to Vanishing Point"});
#endif
m_infoMap.insert({"T_Geometric", "Geometry Tool: Draws geometric shapes"});
m_infoMap.insert({ "T_GeometricVector", "Geometry Tool: Draws geometric shapes" +
spacer +
m_infoMap.insert(
{"T_GeometricVector", "Geometry Tool: Draws geometric shapes" + spacer +
#ifdef MACOSX
"Hold Cmd + Shift - Toggle Snapping" });
"Hold Cmd + Shift - Toggle Snapping"});
#else
"Hold Ctrl + Shift - Toggle Snapping" });
"Hold Ctrl + Shift - Toggle Snapping"});
#endif
m_infoMap.insert({"T_Type", "Type Tool: Adds text"});
m_infoMap.insert(