|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectid.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobject.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectspline.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clearImage(TVectorImage *img) {
|
|
Shinya Kitaoka |
120a6e |
while (img->getStrokeCount()) img->deleteStroke(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// obj -> image
|
|
Shinya Kitaoka |
120a6e |
void getSpline(TVectorImage *dstImg, TStageObjectId objId,
|
|
Shinya Kitaoka |
120a6e |
TStageObjectSpline *currentSpline) {
|
|
Shinya Kitaoka |
120a6e |
QMutexLocker lock(dstImg->getMutex());
|
|
Shinya Kitaoka |
120a6e |
clearImage(dstImg);
|
|
Shinya Kitaoka |
120a6e |
if (currentSpline)
|
|
Shinya Kitaoka |
120a6e |
dstImg->addStroke(new TStroke(*currentSpline->getStroke()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// image -> obj
|
|
Shinya Kitaoka |
120a6e |
void setSpline(TVectorImage *srcImg, TStageObjectId objId,
|
|
Shinya Kitaoka |
120a6e |
TStageObjectSpline *currentSpline) {
|
|
Shinya Kitaoka |
120a6e |
if (!currentSpline) return;
|
|
Shinya Kitaoka |
120a6e |
if (srcImg->getStrokeCount() == 0) {
|
|
Shinya Kitaoka |
120a6e |
double d = 30;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Shinya Kitaoka |
120a6e |
points.push_back(TPointD(-d, 0));
|
|
Shinya Kitaoka |
120a6e |
points.push_back(TPointD(0, 0));
|
|
Shinya Kitaoka |
120a6e |
points.push_back(TPointD(d, 0));
|
|
Shinya Kitaoka |
120a6e |
srcImg->addStroke(new TStroke(points), false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TStroke *stroke = srcImg->getStroke(0);
|
|
Shinya Kitaoka |
120a6e |
currentSpline->setStroke(new TStroke(*stroke));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TXshLevelHandle
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TObjectHandle::TObjectHandle()
|
|
Shinya Kitaoka |
120a6e |
: m_objectId(TStageObjectId::NoneId)
|
|
Shinya Kitaoka |
120a6e |
, m_isSpline(false)
|
|
Shinya Kitaoka |
120a6e |
, m_splineImage(0)
|
|
Shinya Kitaoka |
120a6e |
, m_currentSpline(0) {
|
|
Shinya Kitaoka |
120a6e |
m_splineImage = new TVectorImage();
|
|
Shinya Kitaoka |
120a6e |
m_splineImage->addRef();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle::~TObjectHandle() { m_splineImage->release(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId TObjectHandle::getObjectId() { return m_objectId; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TObjectHandle::setObjectId(TStageObjectId objectId) {
|
|
Shinya Kitaoka |
120a6e |
if (m_objectId != objectId) {
|
|
Shinya Kitaoka |
120a6e |
m_objectId = objectId;
|
|
Shinya Kitaoka |
120a6e |
m_isSpline = false;
|
|
Shinya Kitaoka |
120a6e |
clearImage(m_splineImage);
|
|
Shinya Kitaoka |
120a6e |
emit objectSwitched();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TObjectHandle::setIsSpline(bool isSpline) {
|
|
Shinya Kitaoka |
120a6e |
if (m_isSpline != isSpline) {
|
|
Shinya Kitaoka |
120a6e |
m_isSpline = isSpline;
|
|
Shinya Kitaoka |
120a6e |
emit objectSwitched();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TObjectHandle::commitSplineChanges() {
|
|
Shinya Kitaoka |
120a6e |
setSpline(m_splineImage, m_objectId, m_currentSpline);
|
|
Shinya Kitaoka |
120a6e |
emit splineChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TObjectHandle::setSplineObject(TStageObjectSpline *splineObject) {
|
|
Shinya Kitaoka |
120a6e |
m_currentSpline = splineObject;
|
|
Shinya Kitaoka |
120a6e |
if (m_isSpline && m_currentSpline)
|
|
Shinya Kitaoka |
120a6e |
getSpline(m_splineImage, m_objectId, m_currentSpline);
|
|
Toshihiro Shimizu |
890ddd |
}
|