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,92 +3196,102 @@ 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();
stroke = pegbar->getSpline()->getStroke();
if (!isMotionPathViewer) {
stroke = pegbar->getSpline()->getStroke();
if (!stroke) return;
if (!stroke) return;
int frame = TApp::instance()->getCurrentFrame()->getFrame();
int frame = TApp::instance()->getCurrentFrame()->getFrame();
TAffine aff;
double objZ = 0, objNoScaleZ = 0;
if (objId != TStageObjectId::NoneId) {
aff = xsh->getParentPlacement(objId, frame);
objZ = xsh->getZ(objId, frame);
objNoScaleZ = xsh->getStageObject(objId)->getGlobalNoScaleZ();
}
TAffine aff;
double objZ = 0, objNoScaleZ = 0;
if (objId != TStageObjectId::NoneId) {
aff = xsh->getParentPlacement(objId, frame);
objZ = xsh->getZ(objId, frame);
objNoScaleZ = xsh->getStageObject(objId)->getGlobalNoScaleZ();
}
glPushMatrix();
if (camera3d) {
tglMultMatrix(aff);
aff = TAffine();
glTranslated(0, 0, objZ);
} else {
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
double camZ = xsh->getZ(cameraId, frame);
TAffine camAff = xsh->getPlacement(cameraId, frame);
TAffine tmp;
TStageObject::perspective(tmp, camAff, camZ, aff, objZ, objNoScaleZ);
aff = viewMatrix * tmp;
}
if (TApp::instance()->getCurrentObject()->isSpline()) {
glColor3d(1.0, 0.5, 0);
glLineStipple(1, 0x18FF);
} else {
glLineStipple(1, 0xCCCC);
glColor3d(1, 0, 1);
}
glEnable(GL_LINE_STIPPLE);
tglMultMatrix(aff);
double pixelSize = std::max(0.1, pixelsize);
double strokeLength = stroke->getLength();
int n = (int)(5 + (strokeLength / pixelSize) * 0.1);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < n; i++)
tglVertex(stroke->getPoint((double)i / (double)(n - 1)));
glEnd();
glDisable(GL_LINE_STIPPLE);
int cpCount = stroke->getControlPointCount();
for (int i = 0; i * 4 < cpCount; i++) {
double t = stroke->getParameterAtControlPoint(i * 4);
TPointD pos = stroke->getPoint(t);
tglDrawText(pos, QString::number(i).toStdString().c_str());
}
{
TAffine parentAff = xsh->getParentPlacement(objId, frame);
TAffine aff = xsh->getPlacement(objId, frame);
TPointD center = Stage::inch * xsh->getCenter(objId, frame);
glPushMatrix();
tglMultMatrix(parentAff.inv() * TTranslation(aff * center));
center = TPointD();
if (camera3d) {
tglMultMatrix(aff);
aff = TAffine();
glTranslated(0, 0, objZ);
} else {
TStageObjectId cameraId =
xsh->getStageObjectTree()->getCurrentCameraId();
double camZ = xsh->getZ(cameraId, frame);
TAffine camAff = xsh->getPlacement(cameraId, frame);
TAffine tmp;
TStageObject::perspective(tmp, camAff, camZ, aff, objZ, objNoScaleZ);
aff = viewMatrix * tmp;
}
// draw center
// tglDrawDisk(center,pixelSize*5);
tglDrawDisk(center, sqrt(tglGetPixelSize2()) * 5);
if (TApp::instance()->getCurrentObject()->isSpline()) {
glColor3d(1.0, 0.5, 0);
glLineStipple(1, 0x18FF);
} else {
glLineStipple(1, 0xCCCC);
glColor3d(1, 0, 1);
}
glEnable(GL_LINE_STIPPLE);
tglMultMatrix(aff);
double pixelSize = std::max(0.1, pixelsize);
double strokeLength = stroke->getLength();
int n = (int)(5 + (strokeLength / pixelSize) * 0.1);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < n; i++)
tglVertex(stroke->getPoint((double)i / (double)(n - 1)));
glEnd();
glDisable(GL_LINE_STIPPLE);
int cpCount = stroke->getControlPointCount();
for (int i = 0; i * 4 < cpCount; i++) {
double t = stroke->getParameterAtControlPoint(i * 4);
TPointD pos = stroke->getPoint(t);
tglDrawText(pos, QString::number(i).toStdString().c_str());
}
{
TAffine parentAff = xsh->getParentPlacement(objId, frame);
TAffine aff = xsh->getPlacement(objId, frame);
TPointD center = Stage::inch * xsh->getCenter(objId, frame);
glPushMatrix();
tglMultMatrix(parentAff.inv() * TTranslation(aff * center));
center = TPointD();
// draw center
// tglDrawDisk(center,pixelSize*5);
tglDrawDisk(center, sqrt(tglGetPixelSize2()) * 5);
glPopMatrix();
}
glPopMatrix();
}
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,7 +77,16 @@ void StatusBar::updateInfoText() {
TApp* app = TApp::instance();
ToolHandle* toolHandle = app->getCurrentTool();
TTool* tool = toolHandle->getTool();
std::string name = tool->getName();
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,19 +141,20 @@ 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 +
"Shift - Straight Lines" + 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 +
"Hold Cmd + Shift - Toggle Snapping"});
"Cmd - Straight Lines Snapped to Angles" + 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 +
"Hold Ctrl + Shift - Toggle Snapping"});
"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",
"Brush Tool: Draws in the work area freehand" + spacer +
@ -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 +
"Shift - Straight Lines" + 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 - Straight Lines Snapped to Angles" + spacer +
"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(