|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#define NOMINMAX
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/OverallDesigner.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "ext/StrokeParametricDeformer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/StrokeDeformation.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/SmoothDeformation.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/CornerDeformation.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/StraightCornerDeformation.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/Selector.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ext/ContextStatus.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcurves.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <tstroke.h></tstroke.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <tgl.h></tgl.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <tgeometry.h></tgeometry.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <drawutil.h></drawutil.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <sstream></sstream>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#undef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#define RESTORE_DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
//*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
void extglDrawText(const TPointD &p,
|
|
Toshihiro Shimizu |
890ddd |
const std::string &s,
|
|
Toshihiro Shimizu |
890ddd |
void *character = GLUT_BITMAP_TIMES_ROMAN_10)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(p.x, p.y, 0);
|
|
Toshihiro Shimizu |
890ddd |
if (character <= GLUT_STROKE_MONO_ROMAN) {
|
|
Toshihiro Shimizu |
890ddd |
double factor = 0.07;
|
|
Toshihiro Shimizu |
890ddd |
glScaled(factor, factor, factor);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)s.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
glutStrokeCharacter(character, s[i]);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)s.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
glutBitmapCharacter(character, s[i]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawSign(const TPointD &p,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &v,
|
|
Toshihiro Shimizu |
890ddd |
double size)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (size == 0.0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
size = fabs(size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD v90 = rotate90(v);
|
|
Toshihiro Shimizu |
890ddd |
TPointD v270 = rotate270(v);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(p.x, p.y);
|
|
Toshihiro Shimizu |
890ddd |
v90 = normalize(v90);
|
|
Toshihiro Shimizu |
890ddd |
v90 = v90 * size;
|
|
Toshihiro Shimizu |
890ddd |
v90 = p + v90;
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(v90.x, v90.y);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(p.x, p.y);
|
|
Toshihiro Shimizu |
890ddd |
v270 = normalize(v270);
|
|
Toshihiro Shimizu |
890ddd |
v270 = v270 * size;
|
|
Toshihiro Shimizu |
890ddd |
v270 = p + v270;
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(v270.x, v270.y);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawCross(const TPointD &p,
|
|
Toshihiro Shimizu |
890ddd |
double size)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
v1 = TPointD(1, 1);
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
v2 = TPointD(1, -1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
drawSign(p, v1, size);
|
|
Toshihiro Shimizu |
890ddd |
drawSign(p, v2, size);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/**
|
|
Toshihiro Shimizu |
890ddd |
* Try to verify if it is possible to call
|
|
Toshihiro Shimizu |
890ddd |
* some method of this stroke.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
bool isValid(const TStroke *s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!s)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
const int
|
|
Toshihiro Shimizu |
890ddd |
cpCount = s->getControlPointCount();
|
|
Toshihiro Shimizu |
890ddd |
int
|
|
Toshihiro Shimizu |
890ddd |
i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < cpCount;
|
|
Toshihiro Shimizu |
890ddd |
++i)
|
|
Toshihiro Shimizu |
890ddd |
s->getControlPoint(i);
|
|
Toshihiro Shimizu |
890ddd |
const int
|
|
Toshihiro Shimizu |
890ddd |
chunkCount = s->getChunkCount();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < chunkCount;
|
|
Toshihiro Shimizu |
890ddd |
++i)
|
|
Toshihiro Shimizu |
890ddd |
s->getChunk(i);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void showCP(const TStroke *s,
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!s)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// show control points
|
|
Toshihiro Shimizu |
890ddd |
const int
|
|
Toshihiro Shimizu |
890ddd |
countCP = s->getControlPointCount();
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint
|
|
Toshihiro Shimizu |
890ddd |
p1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < countCP;
|
|
Toshihiro Shimizu |
890ddd |
++i) {
|
|
Toshihiro Shimizu |
890ddd |
p1 = s->getControlPoint(i);
|
|
Toshihiro Shimizu |
890ddd |
if (i & 1)
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 1.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
drawCross(convert(p1),
|
|
Toshihiro Shimizu |
890ddd |
p1.thick * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(convert(p1),
|
|
Toshihiro Shimizu |
890ddd |
p1.thick * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawStrokeCenterLine(const TStroke *stroke,
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
const ToonzExt::Interval &vals)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
from = vals.first,
|
|
Toshihiro Shimizu |
890ddd |
to = vals.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!stroke ||
|
|
Toshihiro Shimizu |
890ddd |
pixelSize < 0.0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
from = std::max(std::min(from, 1.0), 0.0);
|
|
Toshihiro Shimizu |
890ddd |
to = std::max(std::min(to, 1.0), 0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (from < to) {
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*stroke,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
from,
|
|
Toshihiro Shimizu |
890ddd |
to);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*stroke,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
from,
|
|
Toshihiro Shimizu |
890ddd |
1.0);
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*stroke,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
0.0,
|
|
Toshihiro Shimizu |
890ddd |
to);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tglDrawDisk(stroke->getPoint(from),
|
|
Toshihiro Shimizu |
890ddd |
5.0 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawDisk(stroke->getPoint(to),
|
|
Toshihiro Shimizu |
890ddd |
5.0 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawDisk(stroke->getPoint(0.0),
|
|
Toshihiro Shimizu |
890ddd |
9.0 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void showCorners(const TStroke *s,
|
|
Toshihiro Shimizu |
890ddd |
int cornerSize,
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!s)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TPointD
|
|
Toshihiro Shimizu |
890ddd |
offset(20, 20);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// show corners
|
|
Toshihiro Shimizu |
890ddd |
vector<double></double>
|
|
Toshihiro Shimizu |
890ddd |
corners;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::cornersDetector(s,
|
|
Toshihiro Shimizu |
890ddd |
cornerSize,
|
|
Toshihiro Shimizu |
890ddd |
corners);
|
|
Toshihiro Shimizu |
890ddd |
if (corners.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int
|
|
Toshihiro Shimizu |
890ddd |
i,
|
|
Toshihiro Shimizu |
890ddd |
size = corners.size();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.8, 1.0, 0.3);
|
|
Toshihiro Shimizu |
890ddd |
// find interval with corner like extremes
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < size;
|
|
Toshihiro Shimizu |
890ddd |
++i) {
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
tmp = corners[i];
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
pnt = s->getPoint(tmp);
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
large = 5.0;
|
|
Toshihiro Shimizu |
890ddd |
drawCross(pnt,
|
|
Toshihiro Shimizu |
890ddd |
large * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.7, 0.7, 0.7);
|
|
Toshihiro Shimizu |
890ddd |
std::ostringstream oss;
|
|
Toshihiro Shimizu |
890ddd |
oss << "[" << tmp << "]";
|
|
Toshihiro Shimizu |
890ddd |
extglDrawText(TPointD(pnt.x, pnt.y) + offset, oss.str());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
corners.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::straightCornersDetector(s,
|
|
Toshihiro Shimizu |
890ddd |
corners);
|
|
Toshihiro Shimizu |
890ddd |
if (corners.empty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
size = corners.size();
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.8, 1.0, 0.3);
|
|
Toshihiro Shimizu |
890ddd |
// find interval with corner like extremes
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < size;
|
|
Toshihiro Shimizu |
890ddd |
++i) {
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
tmp = corners[i];
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
pnt = s->getPoint(tmp);
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
large = 5.0;
|
|
Toshihiro Shimizu |
890ddd |
drawCross(pnt,
|
|
Toshihiro Shimizu |
890ddd |
large * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.7, 0.2, 0.2);
|
|
Toshihiro Shimizu |
890ddd |
std::ostringstream oss;
|
|
Toshihiro Shimizu |
890ddd |
oss << "[" << tmp << "]";
|
|
Toshihiro Shimizu |
890ddd |
extglDrawText(TPointD(pnt.x, pnt.y) - offset, oss.str());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::OverallDesigner::OverallDesigner(int x,
|
|
Toshihiro Shimizu |
890ddd |
int y)
|
|
Toshihiro Shimizu |
890ddd |
: x_(x), y_(y)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
pixelSize_ = sqrt(this->getPixelSize2());
|
|
Toshihiro Shimizu |
890ddd |
scale_ = pixelSize_ != 0.0 ? pixelSize_ : 1.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::OverallDesigner::~OverallDesigner()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::draw(ToonzExt::SmoothDeformation *sd)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->setPosition();
|
|
Toshihiro Shimizu |
890ddd |
TCubic c;
|
|
Toshihiro Shimizu |
890ddd |
c.setP0(TPointD(0.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP1(TPointD(4.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP2(TPointD(12.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP3(TPointD(16.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 1.0);
|
|
Toshihiro Shimizu |
890ddd |
tglDraw(c, 100, GL_LINE);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::draw(ToonzExt::CornerDeformation *sd)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->setPosition();
|
|
Toshihiro Shimizu |
890ddd |
TCubic c;
|
|
Toshihiro Shimizu |
890ddd |
c.setP0(TPointD(0.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP1(TPointD(0.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP2(TPointD(6.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP3(TPointD(12.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 1.0);
|
|
Toshihiro Shimizu |
890ddd |
tglDraw(c, 100, GL_LINE);
|
|
Toshihiro Shimizu |
890ddd |
c.setP0(TPointD(12.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP1(TPointD(6.0, 8.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP2(TPointD(6.0, 4.0));
|
|
Toshihiro Shimizu |
890ddd |
c.setP3(TPointD(12.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
tglDraw(c, 100, GL_LINE);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::draw(ToonzExt::StraightCornerDeformation *sd)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->setPosition();
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.0, 1.0, 1.0);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(TPointD(0.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(TPointD(8.0, 12.0));
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(TPointD(16.0, 0.0));
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::draw(ToonzExt::StrokeDeformation *sd)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (sd) {
|
|
Toshihiro Shimizu |
890ddd |
const TStroke *
|
|
Toshihiro Shimizu |
890ddd |
s;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//glColor3d(1.0,0.0,1.0);
|
|
Toshihiro Shimizu |
890ddd |
s = sd->getCopiedStroke();
|
|
Toshihiro Shimizu |
890ddd |
if (s) {
|
|
Toshihiro Shimizu |
890ddd |
const ContextStatus *
|
|
Toshihiro Shimizu |
890ddd |
status = sd->getStatus();
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
w = 0.0,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize = 1.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (status) {
|
|
Toshihiro Shimizu |
890ddd |
w = status->w_;
|
|
Toshihiro Shimizu |
890ddd |
pixelSize = status->pixelSize_ < 0 ? 1.0 : status->pixelSize_;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
drawCross(s->getPoint(0),
|
|
Toshihiro Shimizu |
890ddd |
2 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(s->getPoint(w), 8 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
drawCross(s->getPoint(w), 8 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::Interval
|
|
Toshihiro Shimizu |
890ddd |
ex = sd->getExtremes();
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterLine(s,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize_,
|
|
Toshihiro Shimizu |
890ddd |
ex);
|
|
Toshihiro Shimizu |
890ddd |
if (status) {
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 0);
|
|
Toshihiro Shimizu |
890ddd |
showCorners(s,
|
|
Toshihiro Shimizu |
890ddd |
status->cornerSize_,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 0);
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
offset = normalize(TPointD(1.0, 1.0)) * 20.0;
|
|
Toshihiro Shimizu |
890ddd |
std::ostringstream oss;
|
|
Toshihiro Shimizu |
890ddd |
oss << "(" << this->x_
|
|
Toshihiro Shimizu |
890ddd |
<< "," << this->y_
|
|
Toshihiro Shimizu |
890ddd |
<< ")\n{" << w
|
|
Toshihiro Shimizu |
890ddd |
<< ",{" << sd->getExtremes().first
|
|
Toshihiro Shimizu |
890ddd |
<< "," << sd->getExtremes().second
|
|
Toshihiro Shimizu |
890ddd |
<< "}}";
|
|
Toshihiro Shimizu |
890ddd |
extglDrawText(TPointD(x_, y_) + offset, oss.str());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.5, 1.0, 0.5);
|
|
Toshihiro Shimizu |
890ddd |
showCP(s,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0,1.0,0.0);
|
|
Toshihiro Shimizu |
890ddd |
s = sd->getStroke();
|
|
Toshihiro Shimizu |
890ddd |
if(s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
drawCross( s->getPoint(0),
|
|
Toshihiro Shimizu |
890ddd |
4);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterLine(s,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize_,
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::Interval(0,1));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
s = sd->getTransformedStroke();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
if (s) {
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
isValid(s);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*s,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize_);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const TStroke
|
|
Toshihiro Shimizu |
890ddd |
*c = sd->getCopiedStroke(),
|
|
Toshihiro Shimizu |
890ddd |
*s = sd->getStroke();
|
|
Toshihiro Shimizu |
890ddd |
if (c && s) {
|
|
Toshihiro Shimizu |
890ddd |
//glColor3d(1,1,0);
|
|
Toshihiro Shimizu |
890ddd |
//tglDrawDisk(s->getPoint(0.0),
|
|
Toshihiro Shimizu |
890ddd |
// 5*pixelSize_);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int count = std::min(c->getControlPointCount(),
|
|
Toshihiro Shimizu |
890ddd |
s->getControlPointCount());
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
i < count;
|
|
Toshihiro Shimizu |
890ddd |
++i) {
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint
|
|
Toshihiro Shimizu |
890ddd |
ccp = c->getControlPoint(i);
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint
|
|
Toshihiro Shimizu |
890ddd |
scp = s->getControlPoint(i);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::setPosition()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD
|
|
Toshihiro Shimizu |
890ddd |
offset(1, -1);
|
|
Toshihiro Shimizu |
890ddd |
offset = normalize(offset) * (20.0 * scale_);
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(x_ + offset.x,
|
|
Toshihiro Shimizu |
890ddd |
y_ + offset.y,
|
|
Toshihiro Shimizu |
890ddd |
0.0);
|
|
Toshihiro Shimizu |
890ddd |
glScalef(scale_,
|
|
Toshihiro Shimizu |
890ddd |
scale_,
|
|
Toshihiro Shimizu |
890ddd |
scale_);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzExt::OverallDesigner::draw(ToonzExt::Selector *selector)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!selector)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TStroke *
|
|
Toshihiro Shimizu |
890ddd |
ref = selector->getStroke();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!ref)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double
|
|
Toshihiro Shimizu |
890ddd |
length_at_w = ref->getLength(selector->getW()),
|
|
Toshihiro Shimizu |
890ddd |
emi_selector_length = selector->getLength() * 0.5,
|
|
Toshihiro Shimizu |
890ddd |
stroke_length = ref->getLength();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzExt::Interval
|
|
Toshihiro Shimizu |
890ddd |
interval;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (ref->isSelfLoop()) {
|
|
Toshihiro Shimizu |
890ddd |
interval.first = length_at_w - emi_selector_length;
|
|
Toshihiro Shimizu |
890ddd |
if (interval.first < 0.0)
|
|
Toshihiro Shimizu |
890ddd |
interval.first = stroke_length + interval.first;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
interval.first = ref->getParameterAtLength(interval.first);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
interval.second = length_at_w + emi_selector_length;
|
|
Toshihiro Shimizu |
890ddd |
if (interval.second > stroke_length)
|
|
Toshihiro Shimizu |
890ddd |
interval.second = interval.second - stroke_length;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
interval.second = ref->getParameterAtLength(interval.second);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
interval.first = ref->getParameterAtLength(std::max(0.0, length_at_w - emi_selector_length));
|
|
Toshihiro Shimizu |
890ddd |
interval.second = ref->getParameterAtLength(std::min(stroke_length, length_at_w + emi_selector_length));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
float
|
|
Toshihiro Shimizu |
890ddd |
prev_line_width = 1.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glGetFloatv(GL_LINE_WIDTH,
|
|
Toshihiro Shimizu |
890ddd |
&prev_line_width);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineWidth(2.0);
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterLine(ref,
|
|
Toshihiro Shimizu |
890ddd |
pixelSize_,
|
|
Toshihiro Shimizu |
890ddd |
interval);
|
|
Toshihiro Shimizu |
890ddd |
glLineWidth(prev_line_width);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
// End Of File
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
#ifdef RESTORE_DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#undef RESTORE_DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#define _DEBUG 1
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
//*/
|