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