|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tregion.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tregionprop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstrokeutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorrenderdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorfunctions.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsimplecolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tthreadmessage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstrokeprop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcurves.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstrokeoutline.h"
|
|
Jeremy Bullock |
1e17ed |
#include <qtime></qtime>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifndef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
#define CALLBACK
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef checkErrorsByGL
|
|
Shinya Kitaoka |
120a6e |
#define checkErrorsByGL \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
GLenum err = glGetError(); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_INVALID_ENUM); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_INVALID_VALUE); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_INVALID_OPERATION); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_STACK_OVERFLOW); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_STACK_UNDERFLOW); \
|
|
Shinya Kitaoka |
120a6e |
assert(err != GL_OUT_OF_MEMORY); \
|
|
Shinya Kitaoka |
120a6e |
assert(err == GL_NO_ERROR); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef checkErrorsByGL
|
|
Toshihiro Shimizu |
890ddd |
#define checkErrorsByGL
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace std;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
DV_EXPORT_API void mylog(std::string s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static TThread::Mutex mutex;
|
|
Toshihiro Shimizu |
890ddd |
QMutexLocker sl(mutex);
|
|
Toshihiro Shimizu |
890ddd |
std::ofstream os("C:\\gmt\\buttami\\bu.txt", std::ios::app);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
LARGE_INTEGER ticksPerSecond;
|
|
Shinya Kitaoka |
120a6e |
LARGE_INTEGER tick;
|
|
Shinya Kitaoka |
120a6e |
static LARGE_INTEGER firstTick;
|
|
Toshihiro Shimizu |
890ddd |
static bool firstTime = true;
|
|
Toshihiro Shimizu |
890ddd |
long dt = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QueryPerformanceFrequency(&ticksPerSecond);
|
|
Toshihiro Shimizu |
890ddd |
QueryPerformanceCounter(&tick);
|
|
Toshihiro Shimizu |
890ddd |
if(firstTime) {firstTick = tick;firstTime=false;}
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
dt =
|
|
Shinya Kitaoka |
120a6e |
(long)(1000000*(tick.QuadPart-firstTick.QuadPart)/ticksPerSecond.QuadPart);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os << dt << ":" << s << std::endl;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool checkQuadraticDistance(TStroke *stroke, bool checkThickness) {
|
|
Shinya Kitaoka |
120a6e |
UINT i, qCount = stroke->getChunkCount();
|
|
Shinya Kitaoka |
120a6e |
const TThickQuadratic *q;
|
|
Shinya Kitaoka |
120a6e |
TThickPoint p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// se i punti coincidono e' una stroke puntiforme ed e' ammessa
|
|
Shinya Kitaoka |
120a6e |
if (qCount == 1) return true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i != qCount; i++) {
|
|
Shinya Kitaoka |
120a6e |
q = stroke->getChunk(i);
|
|
Shinya Kitaoka |
120a6e |
p1 = q->getThickP0();
|
|
Shinya Kitaoka |
120a6e |
p2 = q->getThickP1();
|
|
Shinya Kitaoka |
120a6e |
p3 = q->getThickP2();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (areAlmostEqual(p1.x, p2.x) && areAlmostEqual(p2.x, p3.x) &&
|
|
Shinya Kitaoka |
120a6e |
areAlmostEqual(p1.y, p2.y) && areAlmostEqual(p2.y, p3.y) &&
|
|
Shinya Kitaoka |
120a6e |
(!checkThickness || (areAlmostEqual(p1.thick, p2.thick) &&
|
|
Shinya Kitaoka |
120a6e |
areAlmostEqual(p2.thick, p3.thick))))
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawControlPoints(const TVectorRenderData &rd, TStroke *stroke,
|
|
Shinya Kitaoka |
120a6e |
double pixelSize, bool allPoints = true) {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
TPointD p;
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglMultMatrix(rd.m_aff);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPointSize(2.0);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_POINTS);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (allPoints) {
|
|
Shinya Kitaoka |
120a6e |
int n = stroke->getControlPointCount();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < n; ++i) {
|
|
Shinya Kitaoka |
120a6e |
p = stroke->getControlPoint(i);
|
|
Shinya Kitaoka |
120a6e |
glColor3d((i + 1) & 1, i & 1, 0.0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(p.x, p.y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int n = stroke->getChunkCount();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < n; ++i) {
|
|
Shinya Kitaoka |
120a6e |
const TThickQuadratic *chunk = stroke->getChunk(i);
|
|
Shinya Kitaoka |
120a6e |
p = chunk->getP0();
|
|
Shinya Kitaoka |
120a6e |
glColor3d(1.0, 0.0, 0.0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(p.x, p.y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
const TThickQuadratic *chunk = stroke->getChunk(n - 1);
|
|
Shinya Kitaoka |
120a6e |
glColor3d(1.0, 0.0, 0.0);
|
|
Shinya Kitaoka |
120a6e |
p = chunk->getP2();
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(p.x, p.y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1e17ed |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
1e17ed |
|
|
Campbell Barton |
e4aac6 |
static void drawArrows(TStroke *stroke, bool onlyFirstPoint) {
|
|
Jeremy Bullock |
1e17ed |
double length = stroke->getLength(0.0, 1.0);
|
|
Jeremy Bullock |
1e17ed |
int points = length / 20;
|
|
Jeremy Bullock |
1e17ed |
if (points < 2) points += 1;
|
|
Jeremy Bullock |
1e17ed |
double currentPosition = 0.0;
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
TPointD prePoint, point, postPoint;
|
|
Jeremy Bullock |
1e17ed |
glColor3d(1.0, 0.0, 0.0);
|
|
Jeremy Bullock |
1e17ed |
for (int i = 0; i <= points; i++) {
|
|
Jeremy Bullock |
1e17ed |
currentPosition = i / (double)points;
|
|
Jeremy Bullock |
1e17ed |
point = stroke->getPointAtLength(length * currentPosition);
|
|
shun-iwasawa |
18a7c6 |
prePoint =
|
|
shun-iwasawa |
18a7c6 |
(i == 0) ? point
|
|
shun-iwasawa |
18a7c6 |
: stroke->getPointAtLength(length * (currentPosition - 0.02));
|
|
shun-iwasawa |
18a7c6 |
postPoint =
|
|
shun-iwasawa |
18a7c6 |
(i == points)
|
|
shun-iwasawa |
18a7c6 |
? point
|
|
shun-iwasawa |
18a7c6 |
: stroke->getPointAtLength(length * (currentPosition + 0.02));
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
if (prePoint == postPoint) continue;
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
double radian =
|
|
Jeremy Bullock |
1e17ed |
std::atan2(postPoint.y - prePoint.y, postPoint.x - prePoint.x);
|
|
Jeremy Bullock |
1e17ed |
double degree = radian * 180.0 / 3.14159265;
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
glPushMatrix();
|
|
Jeremy Bullock |
1e17ed |
glTranslated(point.x, point.y, 0);
|
|
Jeremy Bullock |
1e17ed |
glRotated(degree, 0, 0, 1);
|
|
Jeremy Bullock |
1e17ed |
glBegin(GL_LINES);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(0, 0);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(-3, -3);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(0, 0);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(-3, 3);
|
|
Jeremy Bullock |
1e17ed |
glEnd();
|
|
Jeremy Bullock |
1e17ed |
glPopMatrix();
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
if (onlyFirstPoint) break;
|
|
Jeremy Bullock |
1e17ed |
// make the arrow blue from the second one
|
|
Jeremy Bullock |
1e17ed |
glColor3d(0.0, 0.0, 1.0);
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
1e17ed |
// Used for Guided Drawing
|
|
Campbell Barton |
e4aac6 |
static void drawFirstControlPoint(const TVectorRenderData &rd,
|
|
Campbell Barton |
e4aac6 |
TStroke *stroke) {
|
|
Jeremy Bullock |
1e17ed |
TPointD p = stroke->getPoint(0.0);
|
|
Jeremy Bullock |
1e17ed |
double length = stroke->getLength(0.0, 1.0);
|
|
Jeremy Bullock |
1e17ed |
int msecs = QTime::currentTime().msec();
|
|
Jeremy Bullock |
1e17ed |
double modifier = (msecs / 100) * 0.1;
|
|
Jeremy Bullock |
1e17ed |
TPointD startPoint = stroke->getPointAtLength(length * modifier);
|
|
Jeremy Bullock |
1e17ed |
TPointD endPoint = stroke->getPointAtLength(length * 0.10);
|
|
Jeremy Bullock |
1e17ed |
double j = 0.025;
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
glPushMatrix();
|
|
Jeremy Bullock |
1e17ed |
tglMultMatrix(rd.m_aff);
|
|
Jeremy Bullock |
1e17ed |
if (!rd.m_animatedGuidedDrawing) glLineWidth(2.0f);
|
|
Jeremy Bullock |
1e17ed |
glColor3d(0.0, 1.0, 0.0);
|
|
Jeremy Bullock |
1e17ed |
if (!rd.m_animatedGuidedDrawing) {
|
|
Jeremy Bullock |
1e17ed |
drawArrows(stroke, false);
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
if (rd.m_animatedGuidedDrawing) {
|
|
Jeremy Bullock |
1e17ed |
drawArrows(stroke, true);
|
|
Jeremy Bullock |
1e17ed |
glColor3d(0.0, 1.0, 0.0);
|
|
Jeremy Bullock |
1e17ed |
j = 0.025 + modifier;
|
|
Jeremy Bullock |
1e17ed |
glBegin(GL_LINES);
|
|
Jeremy Bullock |
1e17ed |
// draw the first animated section
|
|
Jeremy Bullock |
1e17ed |
for (int i = 0; i < 8; i++) {
|
|
Jeremy Bullock |
1e17ed |
endPoint = stroke->getPointAtLength(length * j);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(startPoint.x, startPoint.y);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(endPoint.x, endPoint.y);
|
|
Jeremy Bullock |
1e17ed |
startPoint = endPoint;
|
|
Jeremy Bullock |
1e17ed |
j += 0.025;
|
|
Jeremy Bullock |
1e17ed |
if (j > 1) {
|
|
Jeremy Bullock |
1e17ed |
j -= 1;
|
|
Jeremy Bullock |
1e17ed |
startPoint = stroke->getPointAtLength(length * j);
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
modifier = modifier + 0.5;
|
|
Jeremy Bullock |
1e17ed |
if (modifier >= 1) modifier -= 1;
|
|
Jeremy Bullock |
1e17ed |
startPoint = stroke->getPointAtLength(length * modifier);
|
|
Jeremy Bullock |
1e17ed |
j = 0.025 + modifier;
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
// draw another animated section
|
|
Jeremy Bullock |
1e17ed |
for (int i = 0; i < 8; i++) {
|
|
Jeremy Bullock |
1e17ed |
endPoint = stroke->getPointAtLength(length * j);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(startPoint.x, startPoint.y);
|
|
Jeremy Bullock |
1e17ed |
glVertex2d(endPoint.x, endPoint.y);
|
|
Jeremy Bullock |
1e17ed |
startPoint = endPoint;
|
|
Jeremy Bullock |
1e17ed |
j += 0.025;
|
|
Jeremy Bullock |
1e17ed |
if (j > 1) {
|
|
Jeremy Bullock |
1e17ed |
j -= 1;
|
|
Jeremy Bullock |
1e17ed |
startPoint = stroke->getPointAtLength(length * j);
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
glEnd();
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
|
|
Jeremy Bullock |
1e17ed |
glLineWidth(1.0f);
|
|
Jeremy Bullock |
1e17ed |
glPopMatrix();
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*TPixel TransparencyCheckBlackBgInk = TPixel(255,255,255);
|
|
Toshihiro Shimizu |
890ddd |
TPixel TransparencyCheckWhiteBgInk = TPixel(0,0,0);
|
|
Toshihiro Shimizu |
890ddd |
TPixel TransparencyCheckPaint = TPixel(127,127,127);*/
|
|
Toshihiro Shimizu |
890ddd |
static int Index = 0;
|
|
Shinya Kitaoka |
120a6e |
void tglDraw(const TVectorRenderData &rd, TRegion *r, bool pushAttribs) {
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Shinya Kitaoka |
120a6e |
assert(r);
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Shinya Kitaoka |
120a6e |
if (!r) return;
|
|
Shinya Kitaoka |
120a6e |
bool alphaChannel = rd.m_alphaChannel;
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int j = 0;
|
|
Shinya Kitaoka |
120a6e |
bool visible = false;
|
|
Shinya Kitaoka |
120a6e |
int colorCount = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TColorStyleP style;
|
|
Shinya Kitaoka |
120a6e |
if (rd.m_paintCheckEnabled && r->getStyle() == rd.m_colorCheckIndex) {
|
|
Shinya Kitaoka |
120a6e |
static TSolidColorStyle *redColor = new TSolidColorStyle();
|
|
Shinya Kitaoka |
120a6e |
redColor->addRef();
|
|
Shinya Kitaoka |
120a6e |
redColor->setMainColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
style = redColor;
|
|
Shinya Kitaoka |
120a6e |
} else if (rd.m_tcheckEnabled) {
|
|
Shinya Kitaoka |
120a6e |
static TSolidColorStyle *color = new TSolidColorStyle();
|
|
Shinya Kitaoka |
120a6e |
color->addRef();
|
|
Shinya Kitaoka |
120a6e |
color->setMainColor(rd.m_tCheckPaint);
|
|
Shinya Kitaoka |
120a6e |
style = color;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
style = rd.m_palette->getStyle(r->getStyle());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
colorCount = style->getColorParamCount();
|
|
Shinya Kitaoka |
120a6e |
if (colorCount == 0) { // for example texture
|
|
Shinya Kitaoka |
120a6e |
visible = true;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
visible = false;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < colorCount && !visible; j++) {
|
|
Campbell Barton |
e4aac6 |
TPixel32 color = style->getColorParamValue(j);
|
|
Campbell Barton |
e4aac6 |
if (rd.m_cf) color = (*(rd.m_cf))(color);
|
|
Shinya Kitaoka |
120a6e |
if (color.m != 0) visible = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (visible) {
|
|
Shinya Kitaoka |
120a6e |
TRegionProp *prop = r->getProp(/*rd.m_palette*/);
|
|
Shinya Kitaoka |
120a6e |
/// questo codice satva dentro tregion::getprop/////
|
|
Shinya Kitaoka |
120a6e |
int styleId = r->getStyle();
|
|
Shinya Kitaoka |
120a6e |
if (styleId) {
|
|
Shinya Kitaoka |
120a6e |
// TColorStyle * style = rd.m_palette->getStyle(styleId);
|
|
Shinya Kitaoka |
120a6e |
if (!style->isRegionStyle() || style->isEnabled() == false) {
|
|
Shinya Kitaoka |
120a6e |
prop = 0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Warning: The same remark of stroke props holds here.
|
|
Shinya Kitaoka |
120a6e |
if (!prop || style.getPointer() != prop->getColorStyle()) {
|
|
Shinya Kitaoka |
120a6e |
r->setProp(style->makeRegionProp(r));
|
|
Shinya Kitaoka |
120a6e |
prop = r->getProp();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
////// draw
|
|
Shinya Kitaoka |
120a6e |
if (prop) {
|
|
Shinya Kitaoka |
120a6e |
if (pushAttribs) glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglEnableLineSmooth(true);
|
|
Toshihiro Shimizu |
890ddd |
//#define DRAW_EDGE_NUMBERS
|
|
Toshihiro Shimizu |
890ddd |
#ifdef DRAW_EDGE_NUMBERS
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
tglMultMatrix(rd.m_aff);
|
|
Shinya Kitaoka |
120a6e |
switch (Index % 7) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Green);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Blue);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Cyan);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 4:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Magenta);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 5:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Yellow);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 6:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Black);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Index++;
|
|
Shinya Kitaoka |
120a6e |
if (rIndex == 2) {
|
|
Shinya Kitaoka |
120a6e |
double y = r->getEdge(0)
|
|
Shinya Kitaoka |
120a6e |
->m_s
|
|
Shinya Kitaoka |
120a6e |
->getThickPoint(
|
|
Shinya Kitaoka |
120a6e |
(r->getEdge(0)->m_w0 + r->getEdge(0)->m_w1) / 2.0)
|
|
Shinya Kitaoka |
120a6e |
.y;
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(TPointD(-1000, y), TPointD(1000, y));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)r->getEdgeCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TEdge *e = r->getEdge(i);
|
|
Shinya Kitaoka |
120a6e |
TPointD p = e->m_s->getPoint(0.8 * e->m_w0 + 0.2 * e->m_w1);
|
|
Shinya Kitaoka |
120a6e |
if (i == 0)
|
|
Shinya Kitaoka |
120a6e |
tglDrawText(p,
|
|
Shinya Kitaoka |
120a6e |
(QString::number(rIndex) + QString("-0")).toStdString());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
tglDrawText(p, QString::number(i).toStdString());
|
|
Shinya Kitaoka |
120a6e |
if (e->m_index == 3) {
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Black);
|
|
Shinya Kitaoka |
120a6e |
TStroke *s = e->m_s;
|
|
Shinya Kitaoka |
120a6e |
drawPoint(s->getChunk(0)->getP0(), .3);
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
tglDrawText(s->getChunk(0)->getP0(),
|
|
Shinya Kitaoka |
120a6e |
QString::number(0).toStdString());
|
|
Shinya Kitaoka |
120a6e |
for (int ii = 0; ii < s->getChunkCount(); ii++) {
|
|
Shinya Kitaoka |
120a6e |
drawPoint(s->getChunk(ii)->getP2(), .3);
|
|
Shinya Kitaoka |
120a6e |
if (ii < s->getChunkCount() - 1) {
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
tglDrawText(s->getChunk(ii)->getP2(),
|
|
Shinya Kitaoka |
120a6e |
QString::number(ii + 1).toStdString());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (alphaChannel) {
|
|
Shinya Kitaoka |
120a6e |
GLboolean red, green, blue, alpha;
|
|
Shinya Kitaoka |
120a6e |
tglGetColorMask(red, green, blue, alpha);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Draw RGB channels
|
|
Shinya Kitaoka |
120a6e |
tglEnableBlending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
glColorMask(red, green, blue, GL_FALSE);
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Draw Matte channel
|
|
Shinya Kitaoka |
120a6e |
tglEnableBlending(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, alpha);
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glColorMask(red, green, blue, alpha);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// pezza: in render, le aree fillate dei custom styles sparivano.
|
|
Shinya Kitaoka |
120a6e |
if (!rd.m_isOfflineRender || !rd.m_isImagePattern)
|
|
Shinya Kitaoka |
120a6e |
tglRgbOnlyColorMask(); // RGB components only
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (pushAttribs) glPopAttrib();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (UINT i = 0; i < r->getSubregionCount(); i++)
|
|
Shinya Kitaoka |
120a6e |
tglDraw(rd, r->getSubregion(i), pushAttribs);
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void tglDrawMask(const TVectorRenderData &rd1, const TVectorImage *vim) {
|
|
Shinya Kitaoka |
120a6e |
UINT i;
|
|
Shinya Kitaoka |
120a6e |
assert(vim);
|
|
Shinya Kitaoka |
120a6e |
if (!vim) return;
|
|
Shinya Kitaoka |
120a6e |
TVectorRenderData rd(rd1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!rd.m_palette) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *vPalette = vim->getPalette();
|
|
Shinya Kitaoka |
120a6e |
assert(vPalette);
|
|
Shinya Kitaoka |
120a6e |
rd.m_palette = vPalette;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < vim->getRegionCount(); i++)
|
|
Shinya Kitaoka |
120a6e |
tglDraw(rd, vim->getRegion(i), false);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPopAttrib();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Shinya Kitaoka |
120a6e |
bool isOThick(const TStroke *s) {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < s->getControlPointCount(); i++)
|
|
Shinya Kitaoka |
120a6e |
if (s->getControlPoint(i).thick != 0) return false;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Campbell Barton |
e4aac6 |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) {
|
|
Shinya Kitaoka |
120a6e |
assert(s);
|
|
Shinya Kitaoka |
120a6e |
if (!s) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStrokeProp *prop = 0;
|
|
Shinya Kitaoka |
120a6e |
bool pushedAttribs = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
TColorStyleP style;
|
|
Shinya Kitaoka |
120a6e |
TStroke *stroke = const_cast<tstroke *="">(s);</tstroke>
|
|
Shinya Kitaoka |
120a6e |
if (rd.m_inkCheckEnabled && s->getStyle() == rd.m_colorCheckIndex) {
|
|
Shinya Kitaoka |
120a6e |
static TSolidColorStyle *redColor = new TSolidColorStyle();
|
|
Shinya Kitaoka |
120a6e |
redColor->addRef();
|
|
Shinya Kitaoka |
120a6e |
redColor->setMainColor(TPixel::Red);
|
|
Shinya Kitaoka |
120a6e |
style = redColor;
|
|
Martin van Zijl |
5b5587 |
} else if (rd.m_ink1CheckEnabled && s->getStyle() == 1) {
|
|
Martin van Zijl |
5b5587 |
// Ink #1 Check.
|
|
Martin van Zijl |
5b5587 |
// Could possibly merge with above.
|
|
Martin van Zijl |
5b5587 |
static TSolidColorStyle *redColor = new TSolidColorStyle();
|
|
Martin van Zijl |
5b5587 |
redColor->addRef();
|
|
Martin van Zijl |
5b5587 |
redColor->setMainColor(TPixel::Red);
|
|
Martin van Zijl |
5b5587 |
style = redColor;
|
|
Shinya Kitaoka |
120a6e |
} else if (rd.m_tcheckEnabled) {
|
|
Shinya Kitaoka |
120a6e |
static TSolidColorStyle *color = new TSolidColorStyle();
|
|
Shinya Kitaoka |
120a6e |
color->addRef();
|
|
Shinya Kitaoka |
120a6e |
color->setMainColor(rd.m_tCheckInk);
|
|
Shinya Kitaoka |
120a6e |
style = color;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
style = rd.m_palette->getStyle(stroke->getStyle());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!rd.m_show0ThickStrokes && isOThick(s) &&
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tsolidcolorstyle *="">(</tsolidcolorstyle>
|
|
Shinya Kitaoka |
120a6e |
style.getPointer()) // This is probably to exclude
|
|
Shinya Kitaoka |
120a6e |
// TCenterlineStrokeStyle-like styles
|
|
Shinya Kitaoka |
120a6e |
&& !rd.m_tcheckEnabled) // I wonder why this?
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// const TStroke& stroke = *s; //serve???
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(rd.m_palette);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
prop = s->getProp(/*rd.m_palette*/);
|
|
Shinya Kitaoka |
120a6e |
/////questo codice stava dentro tstroke::getprop/////////
|
|
Shinya Kitaoka |
120a6e |
if (prop) prop->getMutex()->lock();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!style->isStrokeStyle() || style->isEnabled() == false) {
|
|
Shinya Kitaoka |
120a6e |
if (prop) prop->getMutex()->unlock();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
prop = 0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Warning: the following pointers check is conceptually wrong - we
|
|
Shinya Kitaoka |
120a6e |
// keep it because the props maintain SMART POINTER-like reference to
|
|
Shinya Kitaoka |
120a6e |
// the associated style. This prevents the style from being destroyed
|
|
Shinya Kitaoka |
120a6e |
// while still referenced by the prop.
|
|
Shinya Kitaoka |
120a6e |
if (!prop || style.getPointer() != prop->getColorStyle()) {
|
|
Shinya Kitaoka |
120a6e |
if (prop) prop->getMutex()->unlock();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stroke->setProp(style->makeStrokeProp(stroke));
|
|
Shinya Kitaoka |
120a6e |
prop = stroke->getProp();
|
|
Shinya Kitaoka |
120a6e |
if (prop) prop->getMutex()->lock();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//--------- draw ------------
|
|
Shinya Kitaoka |
120a6e |
if (!prop) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (pushAttribs) glPushAttrib(GL_ALL_ATTRIB_BITS), pushedAttribs = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool alphaChannel = rd.m_alphaChannel, antialias = rd.m_antiAliasing;
|
|
Shinya Kitaoka |
120a6e |
TVectorImagePatternStrokeProp *aux =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tvectorimagepatternstrokeprop *="">(prop);</tvectorimagepatternstrokeprop>
|
|
Shinya Kitaoka |
120a6e |
if (aux) // gli image pattern vettoriali tornano in questa funzione....non
|
|
Shinya Kitaoka |
120a6e |
// facendo il corpo dell'else'si evita di disegnarli due volte!
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
if (antialias)
|
|
Shinya Kitaoka |
120a6e |
tglEnableLineSmooth(true);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
tglEnableLineSmooth(false);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (alphaChannel) {
|
|
Shinya Kitaoka |
120a6e |
GLboolean red, green, blue, alpha;
|
|
Shinya Kitaoka |
120a6e |
tglGetColorMask(red, green, blue, alpha);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Draw RGB channels
|
|
Shinya Kitaoka |
120a6e |
tglEnableBlending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
glColorMask(red, green, blue, GL_FALSE);
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Draw Matte channel
|
|
Shinya Kitaoka |
120a6e |
tglEnableBlending(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, alpha);
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glColorMask(red, green, blue, alpha);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
tglEnableBlending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
prop->draw(rd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (pushAttribs) glPopAttrib(), pushedAttribs = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
prop->getMutex()->unlock();
|
|
Shinya Kitaoka |
120a6e |
//---------------------
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
if (prop) prop->getMutex()->unlock();
|
|
Shinya Kitaoka |
120a6e |
if (pushedAttribs) glPopAttrib();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
8c6c57 |
static void tglDoDraw(const TVectorRenderData &rd, TRegion *r) {
|
|
Shinya Kitaoka |
120a6e |
bool visible = false;
|
|
Shinya Kitaoka |
120a6e |
int colorCount = 0;
|
|
Shinya Kitaoka |
120a6e |
if (!r) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TColorStyleP style = rd.m_palette->getStyle(r->getStyle());
|
|
Shinya Kitaoka |
120a6e |
colorCount = style->getColorParamCount();
|
|
Shinya Kitaoka |
120a6e |
if (colorCount == 0) // for example texture
|
|
Shinya Kitaoka |
120a6e |
visible = true;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
visible = false;
|
|
Shinya Kitaoka |
120a6e |
for (int j = 0; j < colorCount && !visible; j++) {
|
|
Campbell Barton |
e4aac6 |
TPixel32 color = style->getColorParamValue(j);
|
|
Campbell Barton |
e4aac6 |
if (rd.m_cf) color = (*(rd.m_cf))(color);
|
|
Shinya Kitaoka |
120a6e |
if (color.m != 0) visible = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (visible)
|
|
Shinya Kitaoka |
120a6e |
tglDraw(rd, r, false);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
for (UINT j = 0; j < r->getSubregionCount(); j++)
|
|
Shinya Kitaoka |
120a6e |
tglDraw(rd, r->getSubregion(j), false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
18a7c6 |
static bool tglDoDraw(const TVectorRenderData &rd, const TStroke *s) {
|
|
Shinya Kitaoka |
120a6e |
bool visible = false;
|
|
Shinya Kitaoka |
120a6e |
int colorCount = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const TPalette *palette = rd.m_palette;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int styleId = s->getStyle();
|
|
Shinya Kitaoka |
120a6e |
// assert(0<=styleId && styleId
|
|
Shinya Kitaoka |
120a6e |
TColorStyleP style = palette->getStyle(styleId);
|
|
Shinya Kitaoka |
120a6e |
assert(style);
|
|
Shinya Kitaoka |
120a6e |
colorCount = style->getColorParamCount();
|
|
Shinya Kitaoka |
120a6e |
if (colorCount == 0)
|
|
Shinya Kitaoka |
120a6e |
visible = true;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
visible = false;
|
|
Shinya Kitaoka |
120a6e |
for (int j = 0; j < style->getColorParamCount() && !visible; j++) {
|
|
Campbell Barton |
e4aac6 |
TPixel32 color = style->getColorParamValue(j);
|
|
Campbell Barton |
e4aac6 |
if (rd.m_cf) color = (*(rd.m_cf))(color);
|
|
Shinya Kitaoka |
120a6e |
if (color.m != 0) visible = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
18a7c6 |
bool ret = false;
|
|
shun-iwasawa |
18a7c6 |
|
|
Jeremy Bullock |
1e17ed |
if (visible) {
|
|
Jeremy Bullock |
1e17ed |
// Change stroke color to blue if guided drawing
|
|
Jeremy Bullock |
1e17ed |
if (rd.m_showGuidedDrawing && rd.m_highLightNow) {
|
|
Jeremy Bullock |
1e17ed |
TVectorRenderData *newRd = new TVectorRenderData(
|
|
Jeremy Bullock |
1e17ed |
rd, rd.m_aff, rd.m_clippingRect, rd.m_palette, rd.m_guidedCf);
|
|
Jeremy Bullock |
1e17ed |
tglDraw(*newRd, s, false);
|
|
Jeremy Bullock |
1e17ed |
delete newRd;
|
|
Jeremy Bullock |
1e17ed |
TStroke *new_s = (TStroke *)s;
|
|
Jeremy Bullock |
1e17ed |
drawFirstControlPoint(rd, new_s);
|
|
shun-iwasawa |
18a7c6 |
ret = rd.m_animatedGuidedDrawing;
|
|
Jeremy Bullock |
1e17ed |
} else {
|
|
Jeremy Bullock |
1e17ed |
tglDraw(rd, s, false);
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Shinya Kitaoka |
120a6e |
// drawControlPoints(rd, vim->getStroke(i), sqrt(tglGetPixelSize2()), true);
|
|
Shinya Kitaoka |
120a6e |
// assert(checkQuadraticDistance(vim->getStroke(i),true));
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
shun-iwasawa |
18a7c6 |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void doDraw(const TVectorImage *vim, const TVectorRenderData &_rd,
|
|
shun-iwasawa |
18a7c6 |
bool drawEnteredGroup, TStroke **guidedStroke = 0) {
|
|
Shinya Kitaoka |
120a6e |
static TOnionFader *fade = new TOnionFader(TPixel::White, 0.5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TVectorRenderData rd(_rd);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!rd.m_palette) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *vPalette = vim->getPalette();
|
|
Shinya Kitaoka |
120a6e |
rd.m_palette = vPalette;
|
|
Shinya Kitaoka |
120a6e |
if (!vPalette) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!drawEnteredGroup && !rd.m_isIcon && vim->isInsideGroup() > 0)
|
|
Shinya Kitaoka |
120a6e |
rd.m_cf = fade;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TVectorRenderData rdRegions = rd;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*if (rd.m_drawRegions && rd.m_isImagePattern)//gli image pattern hanno
|
|
Shinya Kitaoka |
120a6e |
bisogno dell'antialiasig per le linee, ma sulle aree ci sarebbero un sacco di
|
|
Shinya Kitaoka |
120a6e |
assert
|
|
Shinya Kitaoka |
120a6e |
rdRegions.m_alphaChannel = rdRegions.m_antiAliasing = false;*/
|
|
Shinya Kitaoka |
120a6e |
UINT strokeIndex = 0;
|
|
Shinya Kitaoka |
120a6e |
Index = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
while (strokeIndex <
|
|
Shinya Kitaoka |
120a6e |
vim->getStrokeCount()) // ogni ciclo di while disegna un gruppo
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
int currStrokeIndex = strokeIndex;
|
|
Shinya Kitaoka |
120a6e |
if (!rd.m_isIcon && vim->isInsideGroup() > 0 &&
|
|
Shinya Kitaoka |
120a6e |
((drawEnteredGroup && !vim->isEnteredGroupStroke(strokeIndex)) ||
|
|
Rozhuk Ivan |
823a31 |
(!drawEnteredGroup && vim->isEnteredGroupStroke(strokeIndex)))) {
|
|
Shinya Kitaoka |
120a6e |
while (strokeIndex < vim->getStrokeCount() &&
|
|
Shinya Kitaoka |
120a6e |
vim->sameGroup(strokeIndex, currStrokeIndex))
|
|
Shinya Kitaoka |
120a6e |
strokeIndex++;
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (rd.m_drawRegions)
|
|
Shinya Kitaoka |
120a6e |
for (UINT regionIndex = 0; regionIndex < vim->getRegionCount();
|
|
Shinya Kitaoka |
120a6e |
regionIndex++)
|
|
Shinya Kitaoka |
120a6e |
if (vim->sameGroupStrokeAndRegion(currStrokeIndex, regionIndex))
|
|
Shinya Kitaoka |
120a6e |
tglDoDraw(rdRegions, vim->getRegion(regionIndex));
|
|
Shinya Kitaoka |
120a6e |
while (strokeIndex < vim->getStrokeCount() &&
|
|
Shinya Kitaoka |
120a6e |
vim->sameGroup(strokeIndex, currStrokeIndex)) {
|
|
Jeremy Bullock |
1e17ed |
if (rd.m_indexToHighlight != strokeIndex) {
|
|
Jeremy Bullock |
1e17ed |
rd.m_highLightNow = false;
|
|
Jeremy Bullock |
1e17ed |
} else {
|
|
Jeremy Bullock |
1e17ed |
rd.m_highLightNow = true;
|
|
Jeremy Bullock |
1e17ed |
}
|
|
Toshihiro Shimizu |
890ddd |
#if DISEGNO_OUTLINE == 1
|
|
Shinya Kitaoka |
120a6e |
CurrStrokeIndex = strokeIndex;
|
|
Shinya Kitaoka |
120a6e |
CurrVimg = vim;
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
shun-iwasawa |
18a7c6 |
bool isGuided = tglDoDraw(rd, vim->getStroke(strokeIndex));
|
|
shun-iwasawa |
18a7c6 |
if (isGuided && guidedStroke) *guidedStroke = vim->getStroke(strokeIndex);
|
|
Shinya Kitaoka |
120a6e |
strokeIndex++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Campbell Barton |
e4aac6 |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
18a7c6 |
void tglDraw(const TVectorRenderData &rd, const TVectorImage *vim,
|
|
shun-iwasawa |
18a7c6 |
TStroke **guidedStroke) {
|
|
Shinya Kitaoka |
120a6e |
assert(vim);
|
|
Shinya Kitaoka |
120a6e |
if (!vim) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QMutexLocker sl(vim->getMutex());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// if(!rd.m_palette) rd.m_palette = vim->getPalette();
|
|
Shinya Kitaoka |
120a6e |
// mylog("tglDraw start; mutex=" + toString((unsigned long)&vim->getMutex()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_ALPHA_TEST);
|
|
Shinya Kitaoka |
120a6e |
glAlphaFunc(GL_GREATER, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
18a7c6 |
doDraw(vim, rd, false, guidedStroke);
|
|
shun-iwasawa |
18a7c6 |
if (!rd.m_isIcon && vim->isInsideGroup() > 0)
|
|
shun-iwasawa |
18a7c6 |
doDraw(vim, rd, true, guidedStroke);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_ALPHA_TEST);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glPopAttrib();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Shinya Kitaoka |
120a6e |
vim->drawAutocloses(rd);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
checkErrorsByGL;
|
|
Shinya Kitaoka |
120a6e |
// mylog("tglDraw stop");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|