2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define _STLP_DEBUG 1
|
|
|
|
#endif
|
|
|
|
#include "ext/StraightCornerDeformation.h"
|
|
|
|
#include "ext/StrokeDeformation.h"
|
|
|
|
#include "ext/LinearPotential.h"
|
|
|
|
//#include "ext/StrokeParametricDeformer.h"
|
2016-09-06 01:20:21 +12:00
|
|
|
//#include "ext/NotSymmetricBezierPotential.h"
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "ext/ContextStatus.h"
|
|
|
|
#include "ext/Designer.h"
|
|
|
|
//#include "ext/TriParam.h"
|
|
|
|
#include "ext/ExtUtil.h"
|
|
|
|
|
|
|
|
#include "DeformationSelector.h"
|
|
|
|
|
|
|
|
//#include <tcurves.h>
|
|
|
|
//#include <tstrokeutil.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <tstroke.h>
|
|
|
|
|
|
|
|
using namespace ToonzExt;
|
|
|
|
|
|
|
|
REGISTER(StraightCornerDeformation, 3);
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
StraightCornerDeformation::StraightCornerDeformation() {
|
|
|
|
setPotential(new LinearPotential);
|
|
|
|
shortcutKey_ = ContextStatus::CTRL;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
StraightCornerDeformation::~StraightCornerDeformation() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool StraightCornerDeformation::findExtremes_(const ContextStatus *status,
|
2016-06-15 18:43:10 +12:00
|
|
|
Interval &ret) {
|
|
|
|
bool found = ToonzExt::findNearestStraightCorners(
|
|
|
|
status->stroke2change_, status->w_, ret, &this->getStraightsList());
|
|
|
|
// it is not a forced solution
|
|
|
|
if ((status->key_event_ != shortcutKey_) && found)
|
|
|
|
return found;
|
|
|
|
else {
|
|
|
|
// it is forced then probably i want to find
|
|
|
|
found = ToonzExt::findNearestSpireCorners(
|
|
|
|
status->stroke2change_, status->w_, ret, status->cornerSize_,
|
|
|
|
&this->getSpiresList());
|
|
|
|
}
|
|
|
|
return found;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void StraightCornerDeformation::draw(Designer *designer) {
|
|
|
|
StrokeDeformationImpl::draw(0);
|
|
|
|
designer->draw(this);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool StraightCornerDeformation::check_(const ContextStatus *status) {
|
|
|
|
assert(status && "Not status available");
|
|
|
|
|
|
|
|
TStroke *s = status->stroke2change_;
|
|
|
|
double w = status->w_;
|
|
|
|
|
|
|
|
// check extremes in another way.
|
2020-04-12 17:19:20 +12:00
|
|
|
if ((!s->isSelfLoop() && areAlmostEqual(w, 0.0)) || areAlmostEqual(w, 1.0)) {
|
2016-06-15 18:43:10 +12:00
|
|
|
return isAStraightCorner(s, w, &this->getStraightsList());
|
|
|
|
}
|
|
|
|
|
|
|
|
ToonzExt::Interval ret;
|
|
|
|
if (ToonzExt::findNearestStraightCorners(status->stroke2change_, status->w_,
|
|
|
|
ret, &this->getStraightsList()) &&
|
|
|
|
isAStraightCorner(s, w, &this->getStraightsList())) {
|
|
|
|
if (ret.first > ret.second) {
|
|
|
|
assert(s->isSelfLoop());
|
|
|
|
if ((ret.first < w && w <= 1.0) || (0.0 <= w && w < ret.second))
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (ret.first < w && w < ret.second) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
double StraightCornerDeformation::findActionLength() {
|
|
|
|
return stroke2manipulate_->getLength();
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
StraightCornerDeformation *StraightCornerDeformation::instance() {
|
|
|
|
static StraightCornerDeformation singleton;
|
|
|
|
return &singleton;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// End Of File
|
|
|
|
//-----------------------------------------------------------------------------
|