|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "regionstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorfunctions.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trandom.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "colorfxutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tflash.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tregion.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcurves.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmathutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstencilcontrol.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// MovingModifier implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TOutlineStyle::RegionOutlineModifier *MovingModifier::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new MovingModifier(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingModifier::modify(TRegionOutline &outline) const {
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regIt = outline.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regItEnd = outline.m_exterior.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator pIt;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator pItEnd;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (; regIt != regItEnd; ++regIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt = regIt->begin();
|
|
Shinya Kitaoka |
120a6e |
pItEnd = regIt->end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (; pIt != pItEnd; ++pIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt->x += m_move.x;
|
|
Shinya Kitaoka |
120a6e |
pIt->y += m_move.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
regIt = outline.m_interior.begin();
|
|
Shinya Kitaoka |
120a6e |
regItEnd = outline.m_interior.end();
|
|
Shinya Kitaoka |
120a6e |
for (; regIt != regItEnd; ++regIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt = regIt->begin();
|
|
Shinya Kitaoka |
120a6e |
pItEnd = regIt->end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (; pIt != pItEnd; ++pIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt->x += m_move.x;
|
|
Shinya Kitaoka |
120a6e |
pIt->y += m_move.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// MovingSolidColor implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
MovingSolidColor::MovingSolidColor(const TPixel32 &color, const TPointD &move)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(color) {
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new MovingModifier(move);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *MovingSolidColor::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new MovingSolidColor(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
MovingModifier *mov = new MovingModifier(TPointD());
|
|
Shinya Kitaoka |
120a6e |
mov->loadData(is);
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = mov;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(m_regionOutlineModifier);
|
|
Shinya Kitaoka |
120a6e |
((MovingModifier *)m_regionOutlineModifier)->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int MovingSolidColor::getParamCount() const { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType MovingSolidColor::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString MovingSolidColor::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return index == 0
|
|
Shinya Kitaoka |
120a6e |
? QCoreApplication::translate("MovingSolidColor", "Horiz Offset")
|
|
Shinya Kitaoka |
120a6e |
: QCoreApplication::translate("MovingSolidColor", "Vert Offset");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
min = -100.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double MovingSolidColor::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (index)
|
|
Shinya Kitaoka |
120a6e |
return ((MovingModifier *)m_regionOutlineModifier)->getMovePoint().y;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return ((MovingModifier *)m_regionOutlineModifier)->getMovePoint().x;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD oldMove = ((MovingModifier *)m_regionOutlineModifier)->getMovePoint();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!index) {
|
|
Shinya Kitaoka |
120a6e |
if (oldMove.x != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
oldMove.x = value;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new MovingModifier(oldMove);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (oldMove.y != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
oldMove.y = value;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new MovingModifier(oldMove);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, true, boundary);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MovingSolidColor::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier->modify(rdf.m_ro);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
rdf.drawRegionOutline(flash, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShadowStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ShadowStyle::ShadowStyle(const TPixel32 &bgColor, const TPixel32 &shadowColor,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &shadowDirection, double len,
|
|
Shinya Kitaoka |
120a6e |
double density)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowColor(shadowColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowDirection(normalize(shadowDirection))
|
|
Shinya Kitaoka |
120a6e |
, m_len(len)
|
|
Shinya Kitaoka |
120a6e |
, m_density(density) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *ShadowStyle::clone() const { return new ShadowStyle(*this); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowDirection.x >> m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
is >> m_density;
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
is >> m_len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowDirection.x << m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
os << m_density;
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
os << m_len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int ShadowStyle::getParamCount() const { return 3; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType ShadowStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString ShadowStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return QCoreApplication::translate("ShadowStyle", "Angle");
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return QCoreApplication::translate("ShadowStyle", "Density");
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return QCoreApplication::translate("ShadowStyle", "Length");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
return QString();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
return QString();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::getParamRange(int index, double &min, double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 360.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 1.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double ShadowStyle::getParamValue(TColorStyle::double_tag, int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double degree;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
degree = asin(m_shadowDirection.y);
|
|
Shinya Kitaoka |
120a6e |
if (m_shadowDirection.x < 0) degree = M_PI - degree;
|
|
Shinya Kitaoka |
120a6e |
if (degree < 0) degree += M_2PI;
|
|
Shinya Kitaoka |
120a6e |
return degree * M_180_PI;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_density;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_len;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
double degree;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
degree = value * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.x = cos(degree);
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.y = sin(degree);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_density = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_len = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::drawPolyline(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd> &polyline,</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD shadowDirection) const {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
int stepNumber;
|
|
Shinya Kitaoka |
120a6e |
double distance;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD v1, v2, diff, midPoint, ratio;
|
|
Shinya Kitaoka |
120a6e |
double len;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_shadowColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_shadowColor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_b = polyline.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_e = polyline.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
v1.x = polyline.back().x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = polyline.back().y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (it = it_b; it != it_e; ++it) {
|
|
Shinya Kitaoka |
120a6e |
v2.x = it->x;
|
|
Shinya Kitaoka |
120a6e |
v2.y = it->y;
|
|
Shinya Kitaoka |
120a6e |
if (v1 == v2) continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
diff = normalize(rotate90(v2 - v1));
|
|
Shinya Kitaoka |
120a6e |
len = diff * shadowDirection;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (len > 0) {
|
|
Shinya Kitaoka |
120a6e |
distance = tdistance(v1, v2) * m_density;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ratio = (v2 - v1) * (1.0 / distance);
|
|
Shinya Kitaoka |
120a6e |
midPoint = v1;
|
|
Shinya Kitaoka |
120a6e |
stepNumber = (int)distance;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < stepNumber; i++) {
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel32(color.r, color.g, color.b, 0));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(midPoint);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(midPoint + (shadowDirection * len * m_len * 0.5));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel32(color.r, color.g, color.b, 0));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(midPoint + (shadowDirection * len * m_len));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
midPoint += ratio;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
v1 = v2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ShadowStyle::drawRegion(const TColorFunction *cf, const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline ®ionOutline) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
////stenc->beginMask();
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d (regionOutline.m_bbox.getP00().x, regionOutline.m_bbox.getP00().y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d (regionOutline.m_bbox.getP01().x, regionOutline.m_bbox.getP01().y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d (regionOutline.m_bbox.getP11().x, regionOutline.m_bbox.getP11().y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d (regionOutline.m_bbox.getP10().x, regionOutline.m_bbox.getP10().y);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
////stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
////stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask();
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, regionOutline);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, regionOutline);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b =
|
|
Shinya Kitaoka |
120a6e |
regionOutline.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e =
|
|
Shinya Kitaoka |
120a6e |
regionOutline.m_exterior.end();
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
drawPolyline(cf, *regions_it, m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_OUTSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
regions_it_b = regionOutline.m_interior.begin();
|
|
Shinya Kitaoka |
120a6e |
regions_it_e = regionOutline.m_interior.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
drawPolyline(cf, *regions_it, -m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Shinya Kitaoka |
3bfa54 |
int ShadowStyle::drawPolyline(TFlash& flash, std::vector<t3dpointd> &polyline,</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD
|
|
Shinya Kitaoka |
120a6e |
shadowDirection, const bool isDraw) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
int stepNumber;
|
|
Toshihiro Shimizu |
890ddd |
double distance;
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
TPointD v1,v2,diff,midPoint,ratio;
|
|
Toshihiro Shimizu |
890ddd |
double len;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
TRegionOutline::PointVector::iterator it;
|
|
Toshihiro Shimizu |
890ddd |
TRegionOutline::PointVector::iterator it_b = polyline.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_e = polyline.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tsegment> segmentArray;</tsegment>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
v1.x = polyline.back().x;
|
|
Toshihiro Shimizu |
890ddd |
v1.y = polyline.back().y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for(it = it_b; it!= it_e; ++it)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
v2.x = it->x;
|
|
Toshihiro Shimizu |
890ddd |
v2.y = it->y;
|
|
Toshihiro Shimizu |
890ddd |
if (v1==v2)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
diff = normalize(rotate90(v2-v1));
|
|
Toshihiro Shimizu |
890ddd |
len=diff*shadowDirection;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if(len>0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
distance = tdistance(v1,v2)*m_density;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ratio= (v2-v1)*(1.0/distance);
|
|
Toshihiro Shimizu |
890ddd |
midPoint=v1;
|
|
Toshihiro Shimizu |
890ddd |
stepNumber= (int)distance;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for(i=0; i
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
std::vector<tsegment> sa;</tsegment>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD p0=midPoint;
|
|
Shinya Kitaoka |
120a6e |
TPointD p1=midPoint+(shadowDirection*len*m_len*0.5);
|
|
Shinya Kitaoka |
120a6e |
TPointD p2=midPoint+(shadowDirection*len*m_len);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
segmentArray.push_back(TSegment(p1,p0));
|
|
Shinya Kitaoka |
120a6e |
segmentArray.push_back(TSegment(p1,p2));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
midPoint += ratio;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
v1=v2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ( isDraw && segmentArray.size()>0 ) {
|
|
Shinya Kitaoka |
120a6e |
flash.setLineColor(m_shadowColor);
|
|
Shinya Kitaoka |
120a6e |
flash.drawSegments(segmentArray, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ( segmentArray.size()>0 )
|
|
Shinya Kitaoka |
120a6e |
return 1;
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ShadowStyle::drawRegion( TFlash& flash, const TRegion* r) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
SFlashUtils rdf(r);
|
|
Toshihiro Shimizu |
890ddd |
rdf.computeRegionOutline();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b =
|
|
Shinya Kitaoka |
120a6e |
rdf.m_ro.m_exterior->begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = rdf.m_ro.m_exterior->end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// In the GL version the shadow lines are not croped into the filled region.
|
|
Shinya Kitaoka |
120a6e |
// This is the reason why I don't calculate the number of shadow lines.
|
|
Toshihiro Shimizu |
890ddd |
// int nbDraw=0;
|
|
Toshihiro Shimizu |
890ddd |
// for( regions_it = regions_it_b ; regions_it!= regions_it_e; ++regions_it)
|
|
Toshihiro Shimizu |
890ddd |
// nbDraw+=drawPolyline(flash,*regions_it, m_shadowDirection,false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// regions_it_b = rdf.m_ro.m_interior->begin();
|
|
Shinya Kitaoka |
120a6e |
// regions_it_e = rdf.m_ro.m_interior->end();
|
|
Toshihiro Shimizu |
890ddd |
// for( regions_it = regions_it_b ; regions_it!= regions_it_e; ++regions_it)
|
|
Toshihiro Shimizu |
890ddd |
// nbDraw+=drawPolyline(flash,*regions_it,-m_shadowDirection,false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Only the bbox rectangle is croped.
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r,1);
|
|
Toshihiro Shimizu |
890ddd |
flash.setFillColor(getMainColor());
|
|
Toshihiro Shimizu |
890ddd |
flash.drawRectangle(rdf.m_ro.m_bbox);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
regions_it_b = rdf.m_ro.m_exterior->begin();
|
|
Shinya Kitaoka |
120a6e |
regions_it_e = rdf.m_ro.m_exterior->end();
|
|
Toshihiro Shimizu |
890ddd |
for( regions_it = regions_it_b ; regions_it!= regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
drawPolyline(flash,*regions_it, m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
regions_it_b = rdf.m_ro.m_interior->begin();
|
|
Shinya Kitaoka |
120a6e |
regions_it_e = rdf.m_ro.m_interior->end();
|
|
Toshihiro Shimizu |
890ddd |
for( regions_it = regions_it_b ; regions_it!= regions_it_e; ++regions_it)
|
|
Toshihiro Shimizu |
890ddd |
drawPolyline(flash,*regions_it,-m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 ShadowStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_shadowColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_shadowColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle::makeIcon(const TDimension &d) {
|
|
Shinya Kitaoka |
120a6e |
double oldVal = getParamValue(TColorStyle::double_tag(), 1);
|
|
Shinya Kitaoka |
120a6e |
setParamValue(1, oldVal * 0.25);
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::makeIcon(d);
|
|
Shinya Kitaoka |
120a6e |
setParamValue(1, oldVal);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ShadowStyle2 implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ShadowStyle2::ShadowStyle2(const TPixel32 &bgColor, const TPixel32 &shadowColor,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &shadowDirection, double shadowLength)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowColor(shadowColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowLength(shadowLength)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowDirection(normalize(shadowDirection)) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *ShadowStyle2::clone() const { return new ShadowStyle2(*this); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowDirection.x >> m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowLength;
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowDirection.x << m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowLength;
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int ShadowStyle2::getParamCount() const { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType ShadowStyle2::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString ShadowStyle2::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? QCoreApplication::translate("ShadowStyle2", "Angle")
|
|
Shinya Kitaoka |
120a6e |
: QCoreApplication::translate("ShadowStyle2", "Size");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::getParamRange(int index, double &min, double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
if (index == 0) {
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 360.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 500.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double ShadowStyle2::getParamValue(TColorStyle::double_tag, int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (index == 1) return m_shadowLength;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double degree = asin(m_shadowDirection.y);
|
|
Shinya Kitaoka |
120a6e |
if (m_shadowDirection.x < 0) degree = M_PI - degree;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (degree < 0) degree += M_2PI;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return degree * M_180_PI;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
8c6c57 |
static int nbDiffVerts(const std::vector<tpointd> &pv) {</tpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lpv;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
if (pv.size() == 0) return 0;
|
|
Shinya Kitaoka |
120a6e |
lpv.push_back(pv[0]);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 1; i < (int)pv.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
bool isDiff = true;
|
|
Shinya Kitaoka |
120a6e |
for (int j = 0; j < (int)lpv.size() && isDiff; j++)
|
|
Shinya Kitaoka |
120a6e |
isDiff = lpv[j] == pv[i] ? false : isDiff;
|
|
Shinya Kitaoka |
120a6e |
if (isDiff) {
|
|
Shinya Kitaoka |
120a6e |
lpv.push_back(pv[i]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return lpv.size();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (index == 1) {
|
|
Shinya Kitaoka |
120a6e |
m_shadowLength = value;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
double degree = value * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.x = cos(degree);
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.y = sin(degree);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawShadowLine(TPixel32 shadowColor, TPixel32 color, TPointD v1,
|
|
Shinya Kitaoka |
120a6e |
TPointD v2, TPointD diff1, TPointD diff2) {
|
|
Shinya Kitaoka |
120a6e |
v1 = v1 + diff1;
|
|
Shinya Kitaoka |
120a6e |
v2 = v2 + diff2;
|
|
Shinya Kitaoka |
120a6e |
diff1 = -diff1;
|
|
Shinya Kitaoka |
120a6e |
diff2 = -diff2;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double r1, r2;
|
|
Shinya Kitaoka |
120a6e |
double t = 0.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUAD_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (; t <= 1; t += 0.1) {
|
|
Shinya Kitaoka |
120a6e |
r1 = t * t * t;
|
|
Shinya Kitaoka |
120a6e |
r2 = 1 - r1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 c((int)(color.r * r2 + shadowColor.r * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.g * r2 + shadowColor.g * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.b * r2 + shadowColor.b * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.m * r2 + shadowColor.m * r1));
|
|
Shinya Kitaoka |
120a6e |
tglColor(c);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(v1 + t * diff1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(v2 + t * diff2);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int drawShadowLine(TFlash &flash, TPixel32 shadowColor, TPixel32 color,
|
|
Shinya Kitaoka |
120a6e |
TPointD v1, TPointD v2, TPointD diff1, TPointD diff2,
|
|
Shinya Kitaoka |
120a6e |
const bool isDraw = true) {
|
|
Shinya Kitaoka |
120a6e |
int nbDraw = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
v1 = v1 + diff1;
|
|
Shinya Kitaoka |
120a6e |
v2 = v2 + diff2;
|
|
Shinya Kitaoka |
120a6e |
diff1 = -diff1;
|
|
Shinya Kitaoka |
120a6e |
diff2 = -diff2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD vv1, vv2, ovv1, ovv2;
|
|
Shinya Kitaoka |
120a6e |
TPixel32 oc;
|
|
Shinya Kitaoka |
120a6e |
double r1, r2;
|
|
Shinya Kitaoka |
120a6e |
double t = 0.0;
|
|
Shinya Kitaoka |
120a6e |
bool isFirst = true;
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils sfu;
|
|
Shinya Kitaoka |
120a6e |
for (; t <= 1; t += 0.1) {
|
|
Shinya Kitaoka |
120a6e |
if (isFirst) {
|
|
Shinya Kitaoka |
120a6e |
r1 = t * t * t;
|
|
Shinya Kitaoka |
120a6e |
r2 = 1 - r1;
|
|
Shinya Kitaoka |
120a6e |
oc = TPixel32((int)(color.r * r2 + shadowColor.r * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.g * r2 + shadowColor.g * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.b * r2 + shadowColor.b * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.m * r2 + shadowColor.m * r1));
|
|
Shinya Kitaoka |
120a6e |
ovv1 = v1 + t * diff1;
|
|
Shinya Kitaoka |
120a6e |
ovv2 = v2 + t * diff2;
|
|
Shinya Kitaoka |
120a6e |
isFirst = false;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
r1 = t * t * t;
|
|
Shinya Kitaoka |
120a6e |
r2 = 1 - r1;
|
|
Shinya Kitaoka |
120a6e |
TPixel32 c((int)(color.r * r2 + shadowColor.r * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.g * r2 + shadowColor.g * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.b * r2 + shadowColor.b * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(color.m * r2 + shadowColor.m * r1));
|
|
Shinya Kitaoka |
120a6e |
vv1 = (v1 + t * diff1);
|
|
Shinya Kitaoka |
120a6e |
vv2 = (v2 + t * diff2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pv;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(ovv1);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(ovv2);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(vv2);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(vv1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbDV = nbDiffVerts(pv);
|
|
Shinya Kitaoka |
120a6e |
if (nbDV >= 3 && nbDV <= 4) nbDraw++;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isDraw) sfu.drawGradedPolyline(flash, pv, oc, c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
oc = c;
|
|
Shinya Kitaoka |
120a6e |
ovv1 = vv1;
|
|
Shinya Kitaoka |
120a6e |
ovv2 = vv2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbDraw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::drawPolyline(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const std::vector<t3dpointd> &polyline,</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD shadowDirection) const {
|
|
Shinya Kitaoka |
120a6e |
if (polyline.empty()) return;
|
|
Shinya Kitaoka |
120a6e |
TPointD v0, v1, diff;
|
|
Shinya Kitaoka |
120a6e |
double len1, len2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color, shadowColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(TSolidColorStyle::getMainColor());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
shadowColor = (*(cf))(m_shadowColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
shadowColor = m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(shadowColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::const_iterator it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::const_iterator it_b = polyline.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::const_iterator it_e = polyline.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int size = polyline.size();
|
|
Shinya Kitaoka |
120a6e |
std::vector<double> lens(size);</double>
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline.back().x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline.back().y;
|
|
Shinya Kitaoka |
120a6e |
int count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (it = it_b; it != it_e; ++it) {
|
|
Shinya Kitaoka |
120a6e |
v1.x = it->x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = it->y;
|
|
Shinya Kitaoka |
120a6e |
if (v1 != v0) {
|
|
Shinya Kitaoka |
120a6e |
diff = normalize(rotate90(v1 - v0));
|
|
Shinya Kitaoka |
120a6e |
len1 = diff * shadowDirection;
|
|
Shinya Kitaoka |
120a6e |
if (len1 < 0) len1 = 0;
|
|
Shinya Kitaoka |
120a6e |
lens[count++] = len1;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
lens[count++] = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
v0 = v1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double firstVal = lens.front();
|
|
Shinya Kitaoka |
120a6e |
for (count = 0; count != size - 1; count++) {
|
|
Shinya Kitaoka |
120a6e |
lens[count] = (lens[count] + lens[count + 1]) * 0.5;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
lens[size - 1] = (lens[size - 1] + firstVal) * 0.5;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (count = 0; count != size - 1; count++) {
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline[count].x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline[count].y;
|
|
Shinya Kitaoka |
120a6e |
v1.x = polyline[count + 1].x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = polyline[count + 1].y;
|
|
Shinya Kitaoka |
120a6e |
len1 = lens[count];
|
|
Shinya Kitaoka |
120a6e |
len2 = lens[count + 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (v0 != v1 && len1 >= 0 && len2 >= 0 && (len1 + len2) > 0)
|
|
Shinya Kitaoka |
120a6e |
drawShadowLine(shadowColor, color, v0, v1,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len1 * m_shadowLength,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len2 * m_shadowLength);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline[count].x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline[count].y;
|
|
Shinya Kitaoka |
120a6e |
v1.x = polyline.front().x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = polyline.front().y;
|
|
Shinya Kitaoka |
120a6e |
len1 = lens[count];
|
|
Shinya Kitaoka |
120a6e |
len2 = lens[0];
|
|
Shinya Kitaoka |
120a6e |
if (v0 != v1 && len1 >= 0 && len2 >= 0 && (len1 + len2) > 0)
|
|
Shinya Kitaoka |
120a6e |
drawShadowLine(shadowColor, color, v0, v1,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len1 * m_shadowLength,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len2 * m_shadowLength);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 ShadowStyle2::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_shadowColor : TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_shadowColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::drawRegion(const TColorFunction *cf, const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b = boundary.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = boundary.m_exterior.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
drawPolyline(cf, *regions_it, m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
int ShadowStyle2::drawPolyline(TFlash &flash, std::vector<t3dpointd> &polyline,</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD shadowDirection,
|
|
Shinya Kitaoka |
120a6e |
const bool isDraw) const {
|
|
Shinya Kitaoka |
120a6e |
int nbDraw = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD v0, v1, diff;
|
|
Shinya Kitaoka |
120a6e |
double len1, len2;
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color, shadowColor;
|
|
Shinya Kitaoka |
120a6e |
color = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
shadowColor = m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_b = polyline.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_e = polyline.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int size = polyline.size();
|
|
Shinya Kitaoka |
120a6e |
std::vector<double> lens(size);</double>
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline.back().x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline.back().y;
|
|
Shinya Kitaoka |
120a6e |
int count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (it = it_b; it != it_e; ++it) {
|
|
Shinya Kitaoka |
120a6e |
v1.x = it->x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = it->y;
|
|
Shinya Kitaoka |
120a6e |
if (v1 != v0) {
|
|
Shinya Kitaoka |
120a6e |
diff = normalize(rotate90(v1 - v0));
|
|
Shinya Kitaoka |
120a6e |
len1 = diff * shadowDirection;
|
|
Shinya Kitaoka |
120a6e |
if (len1 < 0) len1 = 0;
|
|
Shinya Kitaoka |
120a6e |
lens[count++] = len1;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
lens[count++] = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
v0 = v1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double firstVal = lens.front();
|
|
Shinya Kitaoka |
120a6e |
for (count = 0; count != size - 1; count++) {
|
|
Shinya Kitaoka |
120a6e |
lens[count] = (lens[count] + lens[count + 1]) * 0.5;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
lens[size - 1] = (lens[size - 1] + firstVal) * 0.5;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (count = 0; count != size - 1; count++) {
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline[count].x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline[count].y;
|
|
Shinya Kitaoka |
120a6e |
v1.x = polyline[count + 1].x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = polyline[count + 1].y;
|
|
Shinya Kitaoka |
120a6e |
len1 = lens[count];
|
|
Shinya Kitaoka |
120a6e |
len2 = lens[count + 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (v0 != v1 && len1 >= 0 && len2 >= 0 && (len1 + len2) > 0)
|
|
Shinya Kitaoka |
120a6e |
nbDraw += drawShadowLine(flash, shadowColor, color, v0, v1,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len1 * m_shadowLength,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len2 * m_shadowLength, isDraw);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
v0.x = polyline[count].x;
|
|
Shinya Kitaoka |
120a6e |
v0.y = polyline[count].y;
|
|
Shinya Kitaoka |
120a6e |
v1.x = polyline.front().x;
|
|
Shinya Kitaoka |
120a6e |
v1.y = polyline.front().y;
|
|
Shinya Kitaoka |
120a6e |
len1 = lens[count];
|
|
Shinya Kitaoka |
120a6e |
len2 = lens[0];
|
|
Shinya Kitaoka |
120a6e |
if (v0 != v1 && len1 >= 0 && len2 >= 0 && (len1 + len2) > 0)
|
|
Shinya Kitaoka |
120a6e |
nbDraw += drawShadowLine(flash, shadowColor, color, v0, v1,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len1 * m_shadowLength,
|
|
Shinya Kitaoka |
120a6e |
shadowDirection * len2 * m_shadowLength, isDraw);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return nbDraw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ShadowStyle2::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b = rdf.m_ro.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = rdf.m_ro.m_exterior.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbDraw = 0;
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
nbDraw += drawPolyline(flash, *regions_it, m_shadowDirection, false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbDraw + 1);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(rdf.m_ro.m_bbox);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it)
|
|
Shinya Kitaoka |
120a6e |
drawPolyline(flash, *regions_it, m_shadowDirection);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// RubberModifier implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TOutlineStyle::RegionOutlineModifier *RubberModifier::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new RubberModifier(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RubberModifier::modify(TRegionOutline &outline) const {
|
|
Shinya Kitaoka |
120a6e |
double deformSize = 40.0 + (100 - m_deform) * 0.60;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b = outline.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = outline.m_exterior.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it) {
|
|
Shinya Kitaoka |
120a6e |
RubberDeform rd(®ions_it[0]);
|
|
Shinya Kitaoka |
120a6e |
rd.deform(deformSize);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
regions_it_b = outline.m_interior.begin();
|
|
Shinya Kitaoka |
120a6e |
regions_it_e = outline.m_interior.end();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it) {
|
|
Shinya Kitaoka |
120a6e |
RubberDeform rd(®ions_it[0]);
|
|
Shinya Kitaoka |
120a6e |
rd.deform(deformSize);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TRubberFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRubberFillStyle::TRubberFillStyle(const TPixel32 &color, double deform)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(color) {
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new RubberModifier(deform);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TRubberFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TRubberFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::makeIcon(const TDimension &d) {
|
|
Shinya Kitaoka |
120a6e |
// Saves the values of member variables and sets the right icon values
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
RubberModifier *prm = (RubberModifier *)(m_regionOutlineModifier);
|
|
Shinya Kitaoka |
120a6e |
double LDeform = prm->getDeform();
|
|
Shinya Kitaoka |
120a6e |
prm->setDeform(LDeform);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::makeIcon(d);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Loads the original values
|
|
Shinya Kitaoka |
120a6e |
prm->setDeform(LDeform);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TRubberFillStyle::getParamCount() const { return 1; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TRubberFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TRubberFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return QCoreApplication::translate("TRubberFillStyle", "Intensity");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 1);
|
|
Shinya Kitaoka |
120a6e |
min = 0.;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TRubberFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 1);
|
|
Shinya Kitaoka |
120a6e |
return ((RubberModifier *)m_regionOutlineModifier)->getDeform();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double oldDeform = ((RubberModifier *)m_regionOutlineModifier)->getDeform();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (oldDeform != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new RubberModifier(value);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
RubberModifier *rub = new RubberModifier(0.0);
|
|
Shinya Kitaoka |
120a6e |
rub->loadData(is);
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = rub;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(m_regionOutlineModifier);
|
|
Shinya Kitaoka |
120a6e |
((RubberModifier *)m_regionOutlineModifier)->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, true, boundary);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRubberFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier->modify(rdf.m_ro);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
rdf.drawRegionOutline(flash);
|
|
Shinya Kitaoka |
120a6e |
// If Valentina prefers the angled version use this
|
|
Shinya Kitaoka |
120a6e |
// rdf.drawRegionOutline(flash,false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TPointShadowFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointShadowFillStyle::TPointShadowFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &shadowColor,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &shadowDirection,
|
|
Shinya Kitaoka |
120a6e |
double density, double shadowSize,
|
|
Shinya Kitaoka |
120a6e |
double pointSize)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowColor(shadowColor)
|
|
Shinya Kitaoka |
120a6e |
, m_shadowDirection(normalize(shadowDirection))
|
|
Shinya Kitaoka |
120a6e |
, m_shadowSize(shadowSize)
|
|
Shinya Kitaoka |
120a6e |
, m_density(density)
|
|
Shinya Kitaoka |
120a6e |
, m_pointSize(pointSize) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TPointShadowFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TPointShadowFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TPointShadowFillStyle::getParamCount() const { return 4; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TPointShadowFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TPointShadowFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPointShadowFillStyle", "Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPointShadowFillStyle", "Density");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPointShadowFillStyle", "Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPointShadowFillStyle", "Point Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 360.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 1.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
min = 0.01;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TPointShadowFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double degree = 0.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
degree = asin(m_shadowDirection.y);
|
|
Shinya Kitaoka |
120a6e |
if (m_shadowDirection.x < 0) degree = M_PI - degree;
|
|
Shinya Kitaoka |
120a6e |
if (degree < 0) degree += M_2PI;
|
|
Shinya Kitaoka |
120a6e |
return degree * M_180_PI;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_density;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_shadowSize;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return m_pointSize;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// never
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double degree = 0.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
degree = value * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.x = cos(degree);
|
|
Shinya Kitaoka |
120a6e |
m_shadowDirection.y = sin(degree);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_density = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_shadowSize = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_pointSize = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowDirection.x >> m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
is >> m_density;
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointSize;
|
|
Shinya Kitaoka |
120a6e |
is >> m_shadowColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowDirection.x << m_shadowDirection.y;
|
|
Shinya Kitaoka |
120a6e |
os << m_density;
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointSize;
|
|
Shinya Kitaoka |
120a6e |
os << m_shadowColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TPointShadowFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_shadowColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::setColorParamValue(int index,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_shadowColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TPointShadowFillStyle::triangleArea(const TPointD &a, const TPointD &b,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &c) const {
|
|
Shinya Kitaoka |
120a6e |
double ab = tdistance(a, b);
|
|
Shinya Kitaoka |
120a6e |
double ac = tdistance(a, c);
|
|
Shinya Kitaoka |
120a6e |
double bc = tdistance(b, c);
|
|
Shinya Kitaoka |
120a6e |
double s = (ab + bc + ac) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
return sqrt(s * (s - ab) * (s - ac) * (s - bc));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::shadowOnEdge_parallel(const TPointD &p0,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &p1,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
TRandom &rnd) const {
|
|
Shinya Kitaoka |
120a6e |
if (p0 == p1 || p1 == p2) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD diff = normalize(rotate90(p1 - p0));
|
|
Shinya Kitaoka |
120a6e |
double len1 = diff * m_shadowDirection;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
diff = normalize(rotate90(p2 - p1));
|
|
Shinya Kitaoka |
120a6e |
double len2 = diff * m_shadowDirection;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (len1 >= 0 && len2 >= 0 && (len1 + len2) > 0) {
|
|
Shinya Kitaoka |
120a6e |
TPointD la = p1 + m_shadowDirection * len1 * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
TPointD lb = p2 + m_shadowDirection * len2 * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
double t = triangleArea(p1, p2, lb) + triangleArea(p2, lb, la);
|
|
Shinya Kitaoka |
120a6e |
int nb = (int)(m_density * t);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < nb; i++) {
|
|
Shinya Kitaoka |
120a6e |
double q = rnd.getUInt(1001) / 1000.0;
|
|
Shinya Kitaoka |
120a6e |
double r = rnd.getUInt(1001) / 1000.0;
|
|
Shinya Kitaoka |
120a6e |
r = r * r;
|
|
Shinya Kitaoka |
120a6e |
TPointD u = p1 + (p2 - p1) * q;
|
|
Shinya Kitaoka |
120a6e |
u = u +
|
|
Shinya Kitaoka |
120a6e |
r * (len1 * (1.0 - q) + len2 * q) * m_shadowDirection * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
tglColor(TPixel32(m_shadowColor.r, m_shadowColor.g, m_shadowColor.b,
|
|
Shinya Kitaoka |
120a6e |
(int)((1.0 - r) * (double)m_shadowColor.m)));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(u);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TPointShadowFillStyle::shadowOnEdge_parallel(
|
|
Shinya Kitaoka |
120a6e |
TFlash &flash, const TPointD &p0, const TPointD &p1, const TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
TRandom &rnd, const double radius, const bool isDraw) const {
|
|
Shinya Kitaoka |
120a6e |
int nbDraw = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (p0 == p1 || p1 == p2) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD diff = normalize(rotate90(p1 - p0));
|
|
Shinya Kitaoka |
120a6e |
double len1 = diff * m_shadowDirection;
|
|
Shinya Kitaoka |
120a6e |
len1 = std::max(0.0, len1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
diff = normalize(rotate90(p2 - p1));
|
|
Shinya Kitaoka |
120a6e |
double len2 = diff * m_shadowDirection;
|
|
Shinya Kitaoka |
120a6e |
len2 = std::max(0.0, len2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((len1 + len2) > 0) {
|
|
Shinya Kitaoka |
120a6e |
TPointD la = p1 + m_shadowDirection * len1 * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
TPointD lb = p2 + m_shadowDirection * len2 * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
double t = triangleArea(p1, p2, lb) + triangleArea(p2, lb, la);
|
|
Shinya Kitaoka |
120a6e |
int nb = (int)(m_density * t);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < nb; i++) {
|
|
Shinya Kitaoka |
120a6e |
double q = rnd.getUInt(1001) / 1000.0;
|
|
Shinya Kitaoka |
120a6e |
double r = rnd.getUInt(1001) / 1000.0;
|
|
Shinya Kitaoka |
120a6e |
r = r * r;
|
|
Shinya Kitaoka |
120a6e |
TPointD u = p1 + (p2 - p1) * q;
|
|
Shinya Kitaoka |
120a6e |
u = u +
|
|
Shinya Kitaoka |
120a6e |
r * (len1 * (1.0 - q) + len2 * q) * m_shadowDirection * m_shadowSize;
|
|
Shinya Kitaoka |
120a6e |
nbDraw++;
|
|
Shinya Kitaoka |
120a6e |
if (isDraw) {
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TPixel32(m_shadowColor.r, m_shadowColor.g,
|
|
Shinya Kitaoka |
120a6e |
m_shadowColor.b, (int)((1.0 - r) * 255)));
|
|
Shinya Kitaoka |
120a6e |
flash.drawEllipse(u, radius, radius);
|
|
Shinya Kitaoka |
120a6e |
// flash.drawDot(u,radius);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbDraw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::deleteSameVerts(
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator &rit, std::vector<t3dpointd> &pv) const {</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
pv.clear();
|
|
Shinya Kitaoka |
120a6e |
if (rit->size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_beg = rit->begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it_end = rit->end();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator it = it_beg;
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(*it);
|
|
Shinya Kitaoka |
120a6e |
it++;
|
|
Shinya Kitaoka |
120a6e |
for (; it != it_end; it++) {
|
|
Shinya Kitaoka |
120a6e |
if (tdistance(*it, pv.back()) > TConsts::epsilon) {
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(*it);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (pv.size() > 2) {
|
|
Shinya Kitaoka |
120a6e |
if (tdistance(*(pv.begin()), pv.back()) <= TConsts::epsilon) pv.pop_back();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
GLfloat pointSizeSave;
|
|
Shinya Kitaoka |
120a6e |
glGetFloatv(GL_POINT_SIZE, &pointSizeSave);
|
|
Shinya Kitaoka |
120a6e |
GLfloat sizes[2];
|
|
Shinya Kitaoka |
120a6e |
glGetFloatv(GL_POINT_SIZE_RANGE, sizes);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_POINT_SMOOTH);
|
|
Shinya Kitaoka |
120a6e |
// glPointSize((float)(sizes[0]+(sizes[1]-sizes[0])*m_pointSize*0.01));
|
|
Shinya Kitaoka |
120a6e |
tglEnablePointSmooth(
|
|
Shinya Kitaoka |
120a6e |
(float)(sizes[0] + (sizes[1] - sizes[0]) * m_pointSize * 0.01));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b = boundary.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = boundary.m_exterior.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_shadowColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRandom rnd;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd> pv;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
deleteSameVerts(regions_it, pv);
|
|
Shinya Kitaoka |
120a6e |
if (pv.size() < 3) continue;
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_beg = pv.begin();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_end = pv.end();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_last = it_end - 1;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it0, it1, it2;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_POINTS);
|
|
Shinya Kitaoka |
120a6e |
for (it1 = it_beg; it1 != it_end; it1++) {
|
|
Shinya Kitaoka |
120a6e |
it0 = it1 == it_beg ? it_last : it1 - 1;
|
|
Shinya Kitaoka |
120a6e |
it2 = it1 == it_last ? it_beg : it1 + 1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
shadowOnEdge_parallel(TPointD(it0->x, it0->y), TPointD(it1->x, it1->y),
|
|
Shinya Kitaoka |
120a6e |
TPointD(it2->x, it2->y), rnd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPointSize(pointSizeSave);
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TPointShadowFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_b = rdf.m_ro.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regions_it_e = rdf.m_ro.m_exterior.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color = m_shadowColor;
|
|
Shinya Kitaoka |
120a6e |
TRandom rnd;
|
|
Shinya Kitaoka |
120a6e |
rnd.reset();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double sizes[2] = {0.15, 10.0};
|
|
Shinya Kitaoka |
120a6e |
double radius = (sizes[0] + (sizes[1] - sizes[0]) * m_pointSize * 0.01);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbDraw = 0;
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd> pv;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
deleteSameVerts(regions_it, pv);
|
|
Shinya Kitaoka |
120a6e |
if (pv.size() < 3) continue;
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_beg = pv.begin();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_end = pv.end();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_last = it_end - 1;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it0, it1, it2;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
for (it1 = it_beg; it1 != it_end; it1++) {
|
|
Shinya Kitaoka |
120a6e |
it0 = it1 == it_beg ? it_last : it1 - 1;
|
|
Shinya Kitaoka |
120a6e |
it2 = it1 == it_last ? it_beg : it1 + 1;
|
|
Shinya Kitaoka |
120a6e |
nbDraw += shadowOnEdge_parallel(
|
|
Shinya Kitaoka |
120a6e |
flash, TPointD(it0->x, it0->y), TPointD(it1->x, it1->y),
|
|
Shinya Kitaoka |
120a6e |
TPointD(it2->x, it2->y), rnd, radius, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
rnd.reset();
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbDraw + 1); // +1 bbox
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(rdf.m_ro.m_bbox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
for (regions_it = regions_it_b; regions_it != regions_it_e; ++regions_it) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd> pv;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
deleteSameVerts(regions_it, pv);
|
|
Shinya Kitaoka |
120a6e |
if (pv.size() < 3) continue;
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_beg = pv.begin();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_end = pv.end();</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it_last = it_end - 1;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<t3dpointd>::iterator it0, it1, it2;</t3dpointd>
|
|
Shinya Kitaoka |
120a6e |
for (it1 = it_beg; it1 != it_end; it1++) {
|
|
Shinya Kitaoka |
120a6e |
it0 = it1 == it_beg ? it_last : it1 - 1;
|
|
Shinya Kitaoka |
120a6e |
it2 = it1 == it_last ? it_beg : it1 + 1;
|
|
Shinya Kitaoka |
120a6e |
shadowOnEdge_parallel(flash, TPointD(it0->x, it0->y),
|
|
Shinya Kitaoka |
120a6e |
TPointD(it1->x, it1->y), TPointD(it2->x, it2->y),
|
|
Shinya Kitaoka |
120a6e |
rnd, radius, true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TDottedFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TDottedFillStyle::TDottedFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor,
|
|
Shinya Kitaoka |
120a6e |
const double dotSize, const double dotDist,
|
|
Shinya Kitaoka |
120a6e |
const bool isShifted)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_dotSize(dotSize)
|
|
Shinya Kitaoka |
120a6e |
, m_dotDist(dotDist)
|
|
Shinya Kitaoka |
120a6e |
, m_isShifted(isShifted) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDottedFillStyle::TDottedFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32(0, 0, 200))
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_dotSize(3.0)
|
|
Shinya Kitaoka |
120a6e |
, m_dotDist(15.0)
|
|
Shinya Kitaoka |
120a6e |
, m_isShifted(true) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TDottedFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TDottedFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TDottedFillStyle::getParamCount() const { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TDottedFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TDottedFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return index == 0
|
|
Shinya Kitaoka |
120a6e |
? QCoreApplication::translate("TDottedFillStyle", "Dot Size")
|
|
Shinya Kitaoka |
120a6e |
: QCoreApplication::translate("TDottedFillStyle", "Dot Distance");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
if (index == 0) {
|
|
Shinya Kitaoka |
120a6e |
min = 0.001;
|
|
Shinya Kitaoka |
120a6e |
max = 30.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
min = 2.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TDottedFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!index)
|
|
Shinya Kitaoka |
120a6e |
return m_dotSize;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return m_dotDist;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!index) {
|
|
Shinya Kitaoka |
120a6e |
m_dotSize = value;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
m_dotDist = value;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_dotSize;
|
|
Shinya Kitaoka |
120a6e |
is >> m_dotDist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_dotSize;
|
|
Shinya Kitaoka |
120a6e |
os << m_dotDist;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TDottedFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
double LDotDist = std::max(m_dotDist, 0.1);
|
|
Shinya Kitaoka |
120a6e |
// double LDotSize=m_dotSize;
|
|
Shinya Kitaoka |
120a6e |
bool LIsShifted = m_isShifted;
|
|
Shinya Kitaoka |
120a6e |
const bool isTransparent = m_pointColor.m < 255;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (double y = boundary.m_bbox.y0; y <= boundary.m_bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
y += LDotDist, ++i) {
|
|
Shinya Kitaoka |
120a6e |
double x = LIsShifted && (i % 2) == 1 ? boundary.m_bbox.x0 + LDotDist / 2.0
|
|
Shinya Kitaoka |
120a6e |
: boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
for (; x <= boundary.m_bbox.x1; x += LDotDist)
|
|
Shinya Kitaoka |
120a6e |
tglDrawDisk(TPointD(x, y), m_dotSize);
|
|
Shinya Kitaoka |
120a6e |
// tglDrawCircle(TPointD(x,y),m_dotSize);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
// glDisable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TDottedFillStyle::nbClip(const double LDotDist, const bool LIsShifted,
|
|
Shinya Kitaoka |
120a6e |
const TRectD &bbox) const {
|
|
Shinya Kitaoka |
120a6e |
int nbClipLayers = 1; // the bbox rectangle
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (double y = bbox.y0; y <= bbox.y1; y += LDotDist, ++i) {
|
|
Shinya Kitaoka |
120a6e |
double x = LIsShifted && (i % 2) == 1 ? bbox.x0 + LDotDist / 2.0 : bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
for (; x <= bbox.x1; x += LDotDist) nbClipLayers++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbClipLayers;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TDottedFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
double LDotDist = std::max(m_dotDist, 0.1);
|
|
Shinya Kitaoka |
120a6e |
double LDotSize = m_dotSize;
|
|
Shinya Kitaoka |
120a6e |
bool LIsShifted = m_isShifted;
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TPixel::Black);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, true);
|
|
Shinya Kitaoka |
120a6e |
int nClip = nbClip(LDotDist, LIsShifted, bbox);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nClip);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (double y = bbox.y0; y <= bbox.y1; y += LDotDist, ++i) {
|
|
Shinya Kitaoka |
120a6e |
double x = LIsShifted && (i % 2) == 1 ? bbox.x0 + LDotDist / 2.0 : bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
for (; x <= bbox.x1; x += LDotDist)
|
|
Shinya Kitaoka |
120a6e |
flash.drawEllipse(TPointD(x, y), LDotSize, LDotSize);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TCheckedFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCheckedFillStyle::TCheckedFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor,
|
|
Shinya Kitaoka |
120a6e |
const double HDist, const double HAngle,
|
|
Shinya Kitaoka |
120a6e |
const double VDist, const double VAngle,
|
|
Shinya Kitaoka |
120a6e |
const double Thickness)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_HDist(HDist)
|
|
Shinya Kitaoka |
120a6e |
, m_HAngle(HAngle)
|
|
Shinya Kitaoka |
120a6e |
, m_VDist(VDist)
|
|
Shinya Kitaoka |
120a6e |
, m_VAngle(VAngle)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(Thickness) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TCheckedFillStyle::TCheckedFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::Transparent)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_HDist(15.0)
|
|
Shinya Kitaoka |
120a6e |
, m_HAngle(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_VDist(15.0)
|
|
Shinya Kitaoka |
120a6e |
, m_VAngle(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(6.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TCheckedFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TCheckedFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TCheckedFillStyle::getParamCount() const { return 5; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TCheckedFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TCheckedFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCheckedFillStyle", "Horiz Dist");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCheckedFillStyle", "Horiz Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCheckedFillStyle", "Vert Dist");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCheckedFillStyle", "Vert Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 4:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCheckedFillStyle", "Thickness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 5);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = -45.0;
|
|
Shinya Kitaoka |
120a6e |
max = 45.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
min = -45.0;
|
|
Shinya Kitaoka |
120a6e |
max = 45.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 4:
|
|
Shinya Kitaoka |
120a6e |
min = 0.5;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TCheckedFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_HDist;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_HAngle;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_VDist;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return m_VAngle;
|
|
Shinya Kitaoka |
120a6e |
case 4:
|
|
Shinya Kitaoka |
120a6e |
return m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_HDist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_HAngle = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_VDist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_VAngle = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 4:
|
|
Shinya Kitaoka |
120a6e |
m_Thickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_HDist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_HAngle;
|
|
Shinya Kitaoka |
120a6e |
is >> m_VDist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_VAngle;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_HDist;
|
|
Shinya Kitaoka |
120a6e |
os << m_HAngle;
|
|
Shinya Kitaoka |
120a6e |
os << m_VDist;
|
|
Shinya Kitaoka |
120a6e |
os << m_VAngle;
|
|
Shinya Kitaoka |
120a6e |
os << m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TCheckedFillStyle::getHThickline(const TPointD &lc, const double lx,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p0, TPointD &p1, TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p3) const {
|
|
Shinya Kitaoka |
120a6e |
double l = m_Thickness / cos(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
l *= 0.5;
|
|
Shinya Kitaoka |
120a6e |
p0 = TPointD(lc.x, lc.y - l);
|
|
Shinya Kitaoka |
120a6e |
p1 = TPointD(lc.x, lc.y + l);
|
|
Shinya Kitaoka |
120a6e |
double y = lc.y + lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
p2 = TPointD(lc.x + lx, y + l);
|
|
Shinya Kitaoka |
120a6e |
p3 = TPointD(lc.x + lx, y - l);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TCheckedFillStyle::getVThickline(const TPointD &lc, const double ly,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p0, TPointD &p1, TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p3) const {
|
|
Shinya Kitaoka |
120a6e |
double l = m_Thickness / cos(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
l *= 0.5;
|
|
Shinya Kitaoka |
120a6e |
p0 = TPointD(lc.x - l, lc.y);
|
|
Shinya Kitaoka |
120a6e |
p1 = TPointD(lc.x + l, lc.y);
|
|
Shinya Kitaoka |
120a6e |
double x = lc.x + ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
p2 = TPointD(x + l, lc.y + ly);
|
|
Shinya Kitaoka |
120a6e |
p3 = TPointD(x - l, lc.y + ly);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TCheckedFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const bool isTransparent = m_pointColor.m < 255;
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Horizontal Lines
|
|
Shinya Kitaoka |
120a6e |
double lx = boundary.m_bbox.x1 - boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = boundary.m_bbox.y1 - boundary.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = boundary.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = boundary.m_bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_HAngle <= 0 ? beg : beg - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
end = m_HAngle >= 0 ? end : end - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_HDist / cos(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double y = beg; y <= end; y += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getHThickline(TPointD(boundary.m_bbox.x0, y), lx, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p0);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p2);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p3);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Vertical Lines
|
|
Shinya Kitaoka |
120a6e |
beg = boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
end = boundary.m_bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
beg = (-m_VAngle) <= 0 ? beg : beg - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
end = (-m_VAngle) >= 0 ? end : end - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
dist = m_VDist / cos(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getVThickline(TPointD(x, boundary.m_bbox.y0), ly, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p0);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p2);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p3);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
// glDisable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TCheckedFillStyle::nbClip(const TRectD &bbox) const {
|
|
Shinya Kitaoka |
120a6e |
int nbClip = 1; // the bbox rectangle
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_HAngle <= 0 ? beg : beg - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
end = m_HAngle >= 0 ? end : end - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_HDist / cos(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double y = beg; y <= end; y += dist) nbClip++;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Vertical lines
|
|
Shinya Kitaoka |
120a6e |
beg = bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
end = bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
beg = (-m_VAngle) <= 0 ? beg : beg - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
end = (-m_VAngle) >= 0 ? end : end - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
dist = m_VDist / cos(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += dist) nbClip++;
|
|
Shinya Kitaoka |
120a6e |
return nbClip;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TCheckedFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// flash.drawRegion(*r,true);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip(bbox));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
// Horizontal Lines
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_HAngle <= 0 ? beg : beg - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
end = m_HAngle >= 0 ? end : end - lx * tan(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_HDist / cos(degree2rad(m_HAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double y = beg; y <= end; y += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getHThickline(TPointD(bbox.x0, y), lx, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> v;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Vertical lines
|
|
Shinya Kitaoka |
120a6e |
beg = bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
end = bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
beg = (-m_VAngle) <= 0 ? beg : beg - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
end = (-m_VAngle) >= 0 ? end : end - ly * tan(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
dist = m_VDist / cos(degree2rad(-m_VAngle));
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getVThickline(TPointD(x, bbox.y0), ly, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> v;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ArtisticModifier implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticModifier::modify(TRegionOutline &outline) const {
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regIt = outline.m_exterior.begin();
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary::iterator regItEnd = outline.m_exterior.end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator pIt;
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::PointVector::iterator pItEnd;
|
|
Shinya Kitaoka |
120a6e |
TRandom rnd;
|
|
Shinya Kitaoka |
120a6e |
double counter = 0;
|
|
Shinya Kitaoka |
120a6e |
double maxcounter = 0;
|
|
Shinya Kitaoka |
120a6e |
for (; regIt != regItEnd; ++regIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt = regIt->begin();
|
|
Shinya Kitaoka |
120a6e |
pItEnd = regIt->end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (; pIt != pItEnd; ++pIt) {
|
|
Shinya Kitaoka |
120a6e |
if (counter >= maxcounter) {
|
|
Shinya Kitaoka |
120a6e |
double tmp = (201 - m_period) * (rnd.getFloat() + 1);
|
|
Shinya Kitaoka |
120a6e |
maxcounter = tmp * tmp;
|
|
Shinya Kitaoka |
120a6e |
counter = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (pIt != regIt->begin()) {
|
|
Shinya Kitaoka |
120a6e |
double distance = (pIt->x - (pIt - 1)->x) * (pIt->x - (pIt - 1)->x) +
|
|
Shinya Kitaoka |
120a6e |
(pIt->y - (pIt - 1)->y) * (pIt->y - (pIt - 1)->y);
|
|
Shinya Kitaoka |
120a6e |
counter += distance;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
double wave = 1;
|
|
Shinya Kitaoka |
120a6e |
if (maxcounter) wave = sin(M_2PI * counter / maxcounter);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pIt->x += m_move.x * wave;
|
|
Shinya Kitaoka |
120a6e |
pIt->y += m_move.y * wave;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
regIt = outline.m_interior.begin();
|
|
Shinya Kitaoka |
120a6e |
regItEnd = outline.m_interior.end();
|
|
Shinya Kitaoka |
120a6e |
for (; regIt != regItEnd; ++regIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt = regIt->begin();
|
|
Shinya Kitaoka |
120a6e |
pItEnd = regIt->end();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (; pIt != pItEnd; ++pIt) {
|
|
Shinya Kitaoka |
120a6e |
pIt->x += (0.5 - rnd.getFloat()) * m_move.x;
|
|
Shinya Kitaoka |
120a6e |
pIt->y += (0.5 - rnd.getFloat()) * m_move.y;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TOutlineStyle::RegionOutlineModifier *ArtisticModifier::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new ArtisticModifier(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ArtisticSolidColor implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ArtisticSolidColor::ArtisticSolidColor(const TPixel32 &color,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &move, double period)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(color) {
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new ArtisticModifier(move, period);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *ArtisticSolidColor::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new ArtisticSolidColor(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
ArtisticModifier *mov = new ArtisticModifier(TPointD(), double());
|
|
Shinya Kitaoka |
120a6e |
mov->loadData(is);
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = mov;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(m_regionOutlineModifier);
|
|
Shinya Kitaoka |
120a6e |
((ArtisticModifier *)m_regionOutlineModifier)->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int ArtisticSolidColor::getParamCount() const { return 3; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType ArtisticSolidColor::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString ArtisticSolidColor::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("ArtisticSolidColor", "Horiz Offset");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("ArtisticSolidColor", "Vert Offset");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("ArtisticSolidColor", "Noise");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 20.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 20.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 200.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double ArtisticSolidColor::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
double value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = ((ArtisticModifier *)m_regionOutlineModifier)->getMovePoint().x;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = ((ArtisticModifier *)m_regionOutlineModifier)->getMovePoint().y;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = ((ArtisticModifier *)m_regionOutlineModifier)->getPeriod();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD oldMove =
|
|
Shinya Kitaoka |
120a6e |
((ArtisticModifier *)m_regionOutlineModifier)->getMovePoint();
|
|
Shinya Kitaoka |
120a6e |
double oldPeriod = ((ArtisticModifier *)m_regionOutlineModifier)->getPeriod();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
if (oldMove.x != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
oldMove.x = value;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new ArtisticModifier(oldMove, oldPeriod);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
if (oldMove.y != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
oldMove.y = value;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new ArtisticModifier(oldMove, oldPeriod);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
if (oldPeriod != value) {
|
|
Shinya Kitaoka |
120a6e |
delete m_regionOutlineModifier;
|
|
Shinya Kitaoka |
120a6e |
oldPeriod = value;
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier = new ArtisticModifier(oldMove, oldPeriod);
|
|
Shinya Kitaoka |
120a6e |
updateVersionNumber();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, true, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ArtisticSolidColor::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Shinya Kitaoka |
120a6e |
m_regionOutlineModifier->modify(rdf.m_ro);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
rdf.drawRegionOutline(flash, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TChalkFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TChalkFillStyle::TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1,
|
|
Shinya Kitaoka |
120a6e |
const double density, const double size)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(color1)
|
|
Shinya Kitaoka |
120a6e |
, m_color0(color0)
|
|
Shinya Kitaoka |
120a6e |
, m_density(density)
|
|
Shinya Kitaoka |
120a6e |
, m_size(size) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TChalkFillStyle::TChalkFillStyle(const TPixel32 &color0, const TPixel32 &color1)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(color0)
|
|
Shinya Kitaoka |
120a6e |
, m_color0(color1)
|
|
Shinya Kitaoka |
120a6e |
, m_density(25.0)
|
|
Shinya Kitaoka |
120a6e |
, m_size(1.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TChalkFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TChalkFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TChalkFillStyle::getParamCount() const { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TChalkFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TChalkFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TChalkFillStyle", "Density");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TChalkFillStyle", "Dot Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::loadData(int ids, TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
if (ids != 1133)
|
|
Shinya Kitaoka |
120a6e |
throw TException("Chalk Fill style: unknown obsolete format");
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_color0 >> m_density >> m_size;
|
|
Shinya Kitaoka |
120a6e |
m_density = m_density / 1000;
|
|
Shinya Kitaoka |
120a6e |
if (m_density > 100) m_density = 100;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::getParamRange(int index, double &min, double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
max = 10.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TChalkFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Shinya Kitaoka |
120a6e |
double value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = m_density;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = m_size;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_density = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_size = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_color0;
|
|
Shinya Kitaoka |
120a6e |
is >> m_density;
|
|
Shinya Kitaoka |
120a6e |
is >> m_size;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_color0;
|
|
Shinya Kitaoka |
120a6e |
os << m_density;
|
|
Shinya Kitaoka |
120a6e |
os << m_size;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TChalkFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_color0 : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_color0 = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
// const bool isTransparent=m_color0.m<255;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// TRegionOutline::Boundary& exter=*(boundary.m_exterior);
|
|
Shinya Kitaoka |
120a6e |
// TRegionOutline::Boundary& inter=*(boundary.m_interior);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color0;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color0 = (*(cf))(m_color0);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color0 = m_color0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int chalkId = glGenLists(1);
|
|
Shinya Kitaoka |
120a6e |
glNewList(chalkId, GL_COMPILE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(m_size, m_size);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-m_size, m_size);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-m_size, -m_size);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(m_size, -m_size);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glEndList();
|
|
Shinya Kitaoka |
120a6e |
TRandom rnd;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double lx = boundary.m_bbox.x1 - boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = boundary.m_bbox.y1 - boundary.m_bbox.y0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// cioe' imposta una densita' tale, per cui in una regione che ha bbox 200x200
|
|
Shinya Kitaoka |
120a6e |
// inserisce esattamente m_density punti
|
|
Shinya Kitaoka |
120a6e |
int pointNumber = (int)(m_density * ((lx * ly) * 0.02));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < pointNumber; i++) {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 tmpcolor = color0;
|
|
Shinya Kitaoka |
120a6e |
double shiftx = boundary.m_bbox.x0 + rnd.getFloat() * lx;
|
|
Shinya Kitaoka |
120a6e |
double shifty = boundary.m_bbox.y0 + rnd.getFloat() * ly;
|
|
Shinya Kitaoka |
120a6e |
tmpcolor.m = (UCHAR)(tmpcolor.m * rnd.getFloat());
|
|
Shinya Kitaoka |
120a6e |
tglColor(tmpcolor);
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(shiftx, shifty, 0.0);
|
|
Shinya Kitaoka |
120a6e |
glCallList(chalkId);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// glEnd(); e questo che era???
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glDeleteLists(chalkId, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChalkFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 bgColor = TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double minDensity;
|
|
Shinya Kitaoka |
120a6e |
double maxDensity;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
getParamRange(0, minDensity, maxDensity);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double r1 = (m_density - minDensity) / (maxDensity - minDensity);
|
|
Shinya Kitaoka |
120a6e |
double r2 = 1.0 - r1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color((int)(bgColor.r * r2 + m_color0.r * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(bgColor.g * r2 + m_color0.g * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(bgColor.b * r2 + m_color0.b * r1),
|
|
Shinya Kitaoka |
120a6e |
(int)(bgColor.m * r2 + m_color0.m * r1));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(color);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils rdf(r);
|
|
Shinya Kitaoka |
120a6e |
rdf.computeRegionOutline();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRandom rnd;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const bool isTransparent=m_color0.m<255;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary& exter=*(rdf.m_ro.m_exterior);
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline::Boundary& inter=*(rdf.m_ro.m_interior);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color0=m_color0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double lx=rdf.m_ro.m_bbox.x1-rdf.m_ro.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly=rdf.m_ro.m_bbox.y1-rdf.m_ro.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// cioe' imposta una densita' tale, per cui in una regione che ha bbox 200x200
|
|
Shinya Kitaoka |
120a6e |
// inserisce esattamente m_density punti
|
|
Shinya Kitaoka |
120a6e |
int pointNumber= (int)(m_density*((lx*ly)*0.000025));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r,pointNumber+1); // -1 i don't know why
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(TRectD(TPointD(rdf.m_ro.m_bbox.x0,rdf.m_ro.m_bbox.y0),
|
|
Shinya Kitaoka |
120a6e |
TPointD(rdf.m_ro.m_bbox.x1,rdf.m_ro.m_bbox.y1)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
for( int i=0;i< pointNumber; i++ ) {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 tmpcolor=color0;
|
|
Shinya Kitaoka |
120a6e |
double shiftx=rdf.m_ro.m_bbox.x0+rnd.getFloat()*lx;
|
|
Shinya Kitaoka |
120a6e |
double shifty=rdf.m_ro.m_bbox.y0+rnd.getFloat()*ly;
|
|
Shinya Kitaoka |
120a6e |
tmpcolor.m=(UCHAR)(tmpcolor.m*rnd.getFloat());
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(tmpcolor);
|
|
Shinya Kitaoka |
120a6e |
flash.pushMatrix();
|
|
Shinya Kitaoka |
120a6e |
TTranslation tM(shiftx, shifty);
|
|
Shinya Kitaoka |
120a6e |
flash.multMatrix(tM);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(TRectD(TPointD(-1,-1),TPointD(1,1)));
|
|
Shinya Kitaoka |
120a6e |
flash.popMatrix();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TChessFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TChessFillStyle::TChessFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor, const double HDist,
|
|
Shinya Kitaoka |
120a6e |
const double VDist, const double Angle)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_HDist(HDist)
|
|
Shinya Kitaoka |
120a6e |
, m_VDist(VDist)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(Angle) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TChessFillStyle::TChessFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::White)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_HDist(10.0)
|
|
Shinya Kitaoka |
120a6e |
, m_VDist(10.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(0.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TChessFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TChessFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TChessFillStyle::getParamCount() const { return 3; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TChessFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TChessFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TChessFillStyle", "Horiz Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TChessFillStyle", "Vert Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TChessFillStyle", "Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::getParamRange(int index, double &min, double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = -45.0;
|
|
Shinya Kitaoka |
120a6e |
max = 45.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TChessFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_HDist;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_VDist;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_Angle;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_HDist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_VDist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_Angle = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_HDist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_VDist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Angle;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_HDist;
|
|
Shinya Kitaoka |
120a6e |
os << m_VDist;
|
|
Shinya Kitaoka |
120a6e |
os << m_Angle;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TChessFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::makeGrid(TRectD &bbox, TRotation &rotM,
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> &grid, int &nbClip) const {</tpointd>
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
TPointD center =
|
|
Shinya Kitaoka |
120a6e |
TPointD((bbox.x1 + bbox.x0) * 0.5, (bbox.y1 + bbox.y0) * 0.5);
|
|
Shinya Kitaoka |
120a6e |
double l = (lx + ly) / 1.3;
|
|
Shinya Kitaoka |
120a6e |
double l2 = l / 2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isFirst = true;
|
|
Shinya Kitaoka |
120a6e |
for (double y = -l2; y < (l2 + m_VDist); y += m_VDist) {
|
|
Shinya Kitaoka |
120a6e |
double x = isFirst ? -l2 : -l2 + m_HDist;
|
|
Shinya Kitaoka |
120a6e |
isFirst = !isFirst;
|
|
Shinya Kitaoka |
120a6e |
for (; x < (l2 + m_HDist); x += 2 * m_HDist) {
|
|
Shinya Kitaoka |
120a6e |
grid.push_back(rotM * TPointD(x, y) + center);
|
|
Shinya Kitaoka |
120a6e |
nbClip++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
// const bool isTransparent=m_pointColor.m<255;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD vert[4];
|
|
Shinya Kitaoka |
120a6e |
vert[0].x = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[0].y = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[1].x = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[1].y = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[2].x = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[2].y = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[3].x = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[3].y = 0.5;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRotation rotM(m_Angle);
|
|
Shinya Kitaoka |
120a6e |
TScale scaleM(m_HDist, m_VDist);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 4; i++) vert[i] = rotM * scaleM * vert[i];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int chessId = glGenLists(1);
|
|
Shinya Kitaoka |
120a6e |
glNewList(chessId, GL_COMPILE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(vert[0].x, vert[0].y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(vert[1].x, vert[1].y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(vert[2].x, vert[2].y);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(vert[3].x, vert[3].y);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glEndList();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbClip = 1;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> grid;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
makeGrid(boundary.m_bbox, rotM, grid, nbClip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd>::const_iterator it = grid.begin();</tpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd>::const_iterator ite = grid.end();</tpointd>
|
|
Shinya Kitaoka |
120a6e |
for (; it != ite; it++) {
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(it->x, it->y, 0.0);
|
|
Shinya Kitaoka |
120a6e |
glCallList(chessId);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
glDeleteLists(chessId, 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TChessFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD vert[4];
|
|
Shinya Kitaoka |
120a6e |
vert[0].x = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[0].y = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[1].x = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[1].y = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[2].x = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[2].y = -0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[3].x = 0.5;
|
|
Shinya Kitaoka |
120a6e |
vert[3].y = 0.5;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRotation rotM(m_Angle);
|
|
Shinya Kitaoka |
120a6e |
TScale scaleM(m_HDist, m_VDist);
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 4; i++) vert[i] = rotM * scaleM * vert[i];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbClip = 1; // just for the getMainColor() rectangle
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> grid;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
makeGrid(bbox, rotM, grid, nbClip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// flash.drawRegion(*r,true);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd>::const_iterator it = grid.begin();</tpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd>::const_iterator ite = grid.end();</tpointd>
|
|
Shinya Kitaoka |
120a6e |
for (; it != ite; it++) {
|
|
Shinya Kitaoka |
120a6e |
TTranslation trM(it->x, it->y);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lvert;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(trM * vert[0]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(trM * vert[1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(trM * vert[2]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(trM * vert[3]);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(lvert);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TStripeFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStripeFillStyle::TStripeFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor,
|
|
Shinya Kitaoka |
120a6e |
const double Dist, const double Angle,
|
|
Shinya Kitaoka |
120a6e |
const double Thickness)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_Dist(Dist)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(Angle)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(Thickness) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStripeFillStyle::TStripeFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::Transparent)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_Dist(15.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(6.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TStripeFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TStripeFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TStripeFillStyle::getParamCount() const { return 3; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TStripeFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TStripeFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TStripeFillStyle", "Distance");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TStripeFillStyle", "Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TStripeFillStyle", "Thickness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = -90.0;
|
|
Shinya Kitaoka |
120a6e |
max = 90.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.5;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TStripeFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_Dist;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_Angle;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_Dist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_Angle = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_Thickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_Dist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Angle;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_Dist;
|
|
Shinya Kitaoka |
120a6e |
os << m_Angle;
|
|
Shinya Kitaoka |
120a6e |
os << m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::getThickline(const TPointD &lc, const double lx,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p0, TPointD &p1, TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
TPointD &p3) const {
|
|
Shinya Kitaoka |
120a6e |
double l = m_Thickness / cos(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
l *= 0.5;
|
|
Shinya Kitaoka |
120a6e |
p0 = TPointD(lc.x, lc.y - l);
|
|
Shinya Kitaoka |
120a6e |
p1 = TPointD(lc.x, lc.y + l);
|
|
Shinya Kitaoka |
120a6e |
double y = lc.y + lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
p2 = TPointD(lc.x + lx, y + l);
|
|
Shinya Kitaoka |
120a6e |
p3 = TPointD(lc.x + lx, y - l);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TStripeFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void trim(TPointD &p0, TPointD &p1, double y0, double y1) {
|
|
Shinya Kitaoka |
120a6e |
if (p0.y < y0) {
|
|
Shinya Kitaoka |
120a6e |
// Trim the first extreme of the segment at y0
|
|
Shinya Kitaoka |
120a6e |
double t = (y0 - p0.y) / (p1.y - p0.y);
|
|
Shinya Kitaoka |
120a6e |
p0.x = p0.x + t * (p1.x - p0.x);
|
|
Shinya Kitaoka |
120a6e |
p0.y = y0;
|
|
Shinya Kitaoka |
120a6e |
} else if (p0.y > y1) {
|
|
Shinya Kitaoka |
120a6e |
// The same, at y1
|
|
Shinya Kitaoka |
120a6e |
double t = (y1 - p0.y) / (p1.y - p0.y);
|
|
Shinya Kitaoka |
120a6e |
p0.x = p0.x + t * (p1.x - p0.x);
|
|
Shinya Kitaoka |
120a6e |
p0.y = y1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Same for p1
|
|
Shinya Kitaoka |
120a6e |
if (p1.y < y0) {
|
|
Shinya Kitaoka |
120a6e |
double t = (y0 - p1.y) / (p0.y - p1.y);
|
|
Shinya Kitaoka |
120a6e |
p1.x = p1.x + t * (p0.x - p1.x);
|
|
Shinya Kitaoka |
120a6e |
p1.y = y0;
|
|
Shinya Kitaoka |
120a6e |
} else if (p1.y > y1) {
|
|
Shinya Kitaoka |
120a6e |
double t = (y1 - p1.y) / (p0.y - p1.y);
|
|
Shinya Kitaoka |
120a6e |
p1.x = p1.x + t * (p0.x - p1.x);
|
|
Shinya Kitaoka |
120a6e |
p1.y = y1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
const bool isTransparent = m_pointColor.m < 255;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask();
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Horizontal Lines
|
|
Shinya Kitaoka |
120a6e |
if (fabs(m_Angle) != 90) {
|
|
Shinya Kitaoka |
120a6e |
double lx = boundary.m_bbox.x1 - boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
// double ly=boundary.m_bbox.y1-boundary.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = boundary.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = boundary.m_bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_Angle <= 0 ? beg : beg - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
end = m_Angle >= 0 ? end : end - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_Dist / cos(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double y;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc2 = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
stenc2->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
for (y = beg; y <= end; y += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getThickline(TPointD(boundary.m_bbox.x0, y), lx, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p0);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p2);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p3);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
stenc2->endMask();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc2->enableMask(TStencilControl::SHOW_OUTSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_Angle != 0) // ANTIALIASING
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_LINE_SMOOTH);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglEnableLineSmooth();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// NOTE: Trimming the fat lines is necessary outside the (-60, 60) angles
|
|
Shinya Kitaoka |
120a6e |
// interval
|
|
Shinya Kitaoka |
120a6e |
// seemingly due to a bug in MAC-Leopard's openGL implementation...
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
for (y = beg; y <= end; y += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getThickline(TPointD(boundary.m_bbox.x0, y), lx, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
trim(p1, p2, boundary.m_bbox.y0, boundary.m_bbox.y1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
trim(p0, p3, boundary.m_bbox.y0, boundary.m_bbox.y1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p0);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p3);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc2->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
double beg = boundary.m_bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double end = boundary.m_bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
double y0 = boundary.m_bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double y1 = boundary.m_bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += m_Dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0(x, y0);
|
|
Shinya Kitaoka |
120a6e |
TPointD p1(x + m_Thickness, y0);
|
|
Shinya Kitaoka |
120a6e |
TPointD p2(x, y1);
|
|
Shinya Kitaoka |
120a6e |
TPointD p3(x + m_Thickness, y1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p0);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p3);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(p2);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TStripeFillStyle::nbClip(const TRectD &bbox) const {
|
|
Shinya Kitaoka |
120a6e |
int nbClip = 1; // the bbox rectangle
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (fabs(m_Angle) != 90) {
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
// double ly=bbox.y1-bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_Angle <= 0 ? beg : beg - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
end = m_Angle >= 0 ? end : end - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_Dist / cos(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
for (double y = beg; y <= end; y += dist) nbClip++;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
// double y0=bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
// double y1=bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += m_Dist) nbClip++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return nbClip;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// flash.drawRegion(*r,true);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip(bbox)); // -1 i don't know why
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
// Horizontal Lines
|
|
Shinya Kitaoka |
120a6e |
if (fabs(m_Angle) != 90) {
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
// double ly=bbox.y1-bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
beg = m_Angle <= 0 ? beg : beg - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
end = m_Angle >= 0 ? end : end - lx * tan(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
double dist = m_Dist / cos(degree2rad(m_Angle));
|
|
Shinya Kitaoka |
120a6e |
for (double y = beg; y <= end; y += dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
getThickline(TPointD(bbox.x0, y), lx, p0, p1, p2, p3);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> v;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
double beg = bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double end = bbox.x1;
|
|
Shinya Kitaoka |
120a6e |
double y0 = bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double y1 = bbox.y1;
|
|
Shinya Kitaoka |
120a6e |
for (double x = beg; x <= end; x += m_Dist) {
|
|
Shinya Kitaoka |
120a6e |
TPointD p0(x, y0);
|
|
Shinya Kitaoka |
120a6e |
TPointD p1(x + m_Thickness, y0);
|
|
Shinya Kitaoka |
120a6e |
TPointD p2(x, y1);
|
|
Shinya Kitaoka |
120a6e |
TPointD p3(x + m_Thickness, y1);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> v;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TStripeFillStyle::makeIcon(const TDimension &d) {
|
|
Shinya Kitaoka |
120a6e |
// Saves the values of member variables and sets the right icon values
|
|
Shinya Kitaoka |
120a6e |
double LDist = m_Dist;
|
|
Shinya Kitaoka |
120a6e |
double LAngle = m_Angle;
|
|
Shinya Kitaoka |
120a6e |
double LThickness = m_Thickness;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_Dist *= 1.33;
|
|
Shinya Kitaoka |
120a6e |
m_Thickness *= 1.66;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::makeIcon(d);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_Dist = LDist;
|
|
Shinya Kitaoka |
120a6e |
m_Angle = LAngle;
|
|
Shinya Kitaoka |
120a6e |
m_Thickness = LThickness;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TLinGradFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TLinGradFillStyle::TLinGradFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor,
|
|
Shinya Kitaoka |
120a6e |
const double Angle, const double XPos,
|
|
Shinya Kitaoka |
120a6e |
const double YPos, const double Size)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(Angle)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(XPos)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(YPos)
|
|
Shinya Kitaoka |
120a6e |
, m_Size(Size) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLinGradFillStyle::TLinGradFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::White)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_Angle(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Size(100.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TLinGradFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TLinGradFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TLinGradFillStyle::getParamCount() const { return 4; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TLinGradFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TLinGradFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TLinGradFillStyle", "Angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TLinGradFillStyle", "X Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TLinGradFillStyle", "Y Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TLinGradFillStyle", "Smoothness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = -180.0;
|
|
Shinya Kitaoka |
120a6e |
max = 180.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = -100.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = -100.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
min = 1.0;
|
|
Shinya Kitaoka |
120a6e |
max = 500.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TLinGradFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_Angle;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_XPos;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_YPos;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return m_Size;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_Angle = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_XPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_YPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_Size = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_Angle;
|
|
Shinya Kitaoka |
120a6e |
is >> m_XPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_YPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Size;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_Angle;
|
|
Shinya Kitaoka |
120a6e |
os << m_XPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_YPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_Size;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TLinGradFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::getRects(const TRectD &bbox, std::vector<tpointd> &r0,</tpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> &r1,</tpointd>
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> &r2) const {</tpointd>
|
|
Shinya Kitaoka |
120a6e |
r0.clear();
|
|
Shinya Kitaoka |
120a6e |
r1.clear();
|
|
Shinya Kitaoka |
120a6e |
r2.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD p0, p1, p2, p3;
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) / 2.0, (bbox.y1 + bbox.y0) / 2.0);
|
|
Shinya Kitaoka |
120a6e |
center = center + TPointD(m_XPos * 0.01 * lx * 0.5, m_YPos * 0.01 * ly * 0.5);
|
|
Shinya Kitaoka |
120a6e |
double l = tdistance(TPointD(bbox.x0, bbox.y0), TPointD(bbox.x1, bbox.y1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
r0.push_back(TPointD(-m_Size - l, l));
|
|
Shinya Kitaoka |
120a6e |
r0.push_back(TPointD(-m_Size - l, -l));
|
|
Shinya Kitaoka |
120a6e |
r0.push_back(TPointD(-m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
r0.push_back(TPointD(-m_Size, l));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
r1.push_back(TPointD(-m_Size, l));
|
|
Shinya Kitaoka |
120a6e |
r1.push_back(TPointD(-m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
r1.push_back(TPointD(m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
r1.push_back(TPointD(m_Size, l));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
r2.push_back(TPointD(m_Size, l));
|
|
Shinya Kitaoka |
120a6e |
r2.push_back(TPointD(m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
r2.push_back(TPointD(m_Size + l, -l));
|
|
Shinya Kitaoka |
120a6e |
r2.push_back(TPointD(m_Size + l, l));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRotation rotM(m_Angle);
|
|
Shinya Kitaoka |
120a6e |
TTranslation traM(center);
|
|
Shinya Kitaoka |
120a6e |
TAffine M(traM * rotM);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 4; i++) {
|
|
Shinya Kitaoka |
120a6e |
r0[i] = M * r0[i];
|
|
Shinya Kitaoka |
120a6e |
r1[i] = M * r1[i];
|
|
Shinya Kitaoka |
120a6e |
r2[i] = M * r2[i];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
// only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// compute colors
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color1, color2;
|
|
Shinya Kitaoka |
120a6e |
if (cf) {
|
|
Shinya Kitaoka |
120a6e |
color1 = (*(cf))(TSolidColorStyle::getMainColor());
|
|
Shinya Kitaoka |
120a6e |
color2 = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
color1 = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
color2 = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// compute points
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(boundary.m_bbox);
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> r0, r1, r2;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
getRects(bbox, r0, r1, r2);
|
|
Shinya Kitaoka |
120a6e |
assert(r0.size() == 4);
|
|
Shinya Kitaoka |
120a6e |
assert(r1.size() == 4);
|
|
Shinya Kitaoka |
120a6e |
assert(r2.size() == 4);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// draw
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color2);
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (; i < 4; tglVertex(r0[i++]))
|
|
Shinya Kitaoka |
120a6e |
;
|
|
Shinya Kitaoka |
120a6e |
tglVertex(r1[0]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(r1[1]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglColor(color1);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(r1[2]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(r1[3]);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < 4; tglVertex(r2[i++]))
|
|
Shinya Kitaoka |
120a6e |
;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// It is the new version, which uses XPos, YPos, Smooth parameters.
|
|
Toshihiro Shimizu |
890ddd |
// There is a gap between the flat and graded regions. This is the reason,
|
|
Toshihiro Shimizu |
890ddd |
// why the old version (without XPos, YPos, Smooth parameters) is used.
|
|
Shinya Kitaoka |
120a6e |
void TLinGradFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> rect;</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) / 2.0, (bbox.y1 + bbox.y0) / 2.0);
|
|
Shinya Kitaoka |
120a6e |
center = center + TPointD(m_XPos * 0.01 * (bbox.x1 - bbox.x0) * 0.5,
|
|
Shinya Kitaoka |
120a6e |
m_YPos * 0.01 * (bbox.y1 - bbox.y0) * 0.5);
|
|
Shinya Kitaoka |
120a6e |
double l = tdistance(TPointD(bbox.x0, bbox.y0), TPointD(bbox.x1, bbox.y1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine M(TTranslation(center) * TRotation(m_Angle));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
rect.push_back(M * TPointD(-m_Size, l));
|
|
Shinya Kitaoka |
120a6e |
rect.push_back(M * TPointD(-m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
rect.push_back(M * TPointD(m_Size, -l));
|
|
Shinya Kitaoka |
120a6e |
rect.push_back(M * TPointD(m_Size, l));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SFlashUtils sfu;
|
|
Shinya Kitaoka |
120a6e |
sfu.drawGradedRegion(flash, rect, m_pointColor, getMainColor(), *r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
// --- Old version ---
|
|
Toshihiro Shimizu |
890ddd |
void TLinGradFillStyle::drawRegion(TFlash& flash, const TRegion* r) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r,1);
|
|
Toshihiro Shimizu |
890ddd |
TRectD bbox(r->getBBox());
|
|
Toshihiro Shimizu |
890ddd |
TPointD p0,p1,p2,p3;
|
|
Toshihiro Shimizu |
890ddd |
p0=TPointD(bbox.x0,bbox.y0);
|
|
Toshihiro Shimizu |
890ddd |
p1=TPointD(bbox.x0,bbox.y1);
|
|
Toshihiro Shimizu |
890ddd |
p2=TPointD(bbox.x1,bbox.y0);
|
|
Toshihiro Shimizu |
890ddd |
p3=TPointD(bbox.x1,bbox.y1);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tpointd> pv;</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
if ( fabs(m_Angle)!=90 ) {
|
|
Shinya Kitaoka |
120a6e |
double tga=tan(degree2rad(fabs(m_Angle)));
|
|
Shinya Kitaoka |
120a6e |
double lx=bbox.x1-bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly=bbox.y1-bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double ax=lx/(tga*tga+1);
|
|
Shinya Kitaoka |
120a6e |
double bx=lx-ax;
|
|
Shinya Kitaoka |
120a6e |
double mx=ax*tga;
|
|
Shinya Kitaoka |
120a6e |
double rlylx=ly/lx;
|
|
Shinya Kitaoka |
120a6e |
double ay=ax*rlylx;
|
|
Shinya Kitaoka |
120a6e |
double by=bx*rlylx;
|
|
Shinya Kitaoka |
120a6e |
double my=mx*rlylx;
|
|
Shinya Kitaoka |
120a6e |
if ( m_Angle<=0.0) {
|
|
Shinya Kitaoka |
120a6e |
p0=p0+TPointD(-my,by);
|
|
Shinya Kitaoka |
120a6e |
p1=p1+TPointD(bx,mx);
|
|
Shinya Kitaoka |
120a6e |
p2=p2+TPointD(-bx,-mx);
|
|
Shinya Kitaoka |
120a6e |
p3=p3+TPointD(my,-by);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
p0=p0+TPointD(bx,-mx);
|
|
Shinya Kitaoka |
120a6e |
p1=p1+TPointD(-my,-by);
|
|
Shinya Kitaoka |
120a6e |
p2=p2+TPointD(my,by);
|
|
Shinya Kitaoka |
120a6e |
p3=p3+TPointD(-bx,mx);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p2);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Shinya Kitaoka |
120a6e |
if ( m_Angle==-90 ) {
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p0);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
SFlashUtils sfu;
|
|
Toshihiro Shimizu |
890ddd |
sfu.drawGradedPolyline(flash,pv,m_pointColor,getMainColor());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TRadGradFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRadGradFillStyle::TRadGradFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &pointColor,
|
|
Shinya Kitaoka |
120a6e |
const double XPos, const double YPos,
|
|
Shinya Kitaoka |
120a6e |
const double Radius, const double Smooth)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(XPos)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(YPos)
|
|
Shinya Kitaoka |
120a6e |
, m_Radius(Radius)
|
|
Shinya Kitaoka |
120a6e |
, m_Smooth(Smooth) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRadGradFillStyle::TRadGradFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::White)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Radius(50.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Smooth(50) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TRadGradFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TRadGradFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TRadGradFillStyle::getParamCount() const { return 4; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TRadGradFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TRadGradFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TRadGradFillStyle", "X Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TRadGradFillStyle", "Y Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TRadGradFillStyle", "Radius");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TRadGradFillStyle", "Smoothness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = -100.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = -100.0;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.01;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
min = 0.01;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TRadGradFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_XPos;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_YPos;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_Radius;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return m_Smooth;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_XPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_YPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_Radius = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_Smooth = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_XPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_YPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Radius;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Smooth;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_XPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_YPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_Radius;
|
|
Shinya Kitaoka |
120a6e |
os << m_Smooth;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TRadGradFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
// only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor, color;
|
|
Shinya Kitaoka |
120a6e |
if (cf) {
|
|
Shinya Kitaoka |
120a6e |
backgroundColor = (*(cf))(TSolidColorStyle::getMainColor());
|
|
Shinya Kitaoka |
120a6e |
color = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
color = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(boundary.m_bbox);
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double r2 = std::max(lx, ly) * 5.0;
|
|
Shinya Kitaoka |
120a6e |
double r1 = 0.5 * std::max(lx, ly) * m_Radius * 0.01;
|
|
Shinya Kitaoka |
120a6e |
double r0 = r1 * (100.0 - m_Smooth) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) / 2.0, (bbox.y1 + bbox.y0) / 2.0);
|
|
Shinya Kitaoka |
120a6e |
center = center + TPointD(m_XPos * 0.01 * lx * 0.5, m_YPos * 0.01 * ly * 0.5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const double dAngle = 5.0;
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> sincos;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
for (double angle = 0.0; angle <= 360.0; angle += dAngle)
|
|
Shinya Kitaoka |
120a6e |
sincos.push_back(TPointD(sin(degree2rad(angle)), cos(degree2rad(angle))));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_TRIANGLE_FAN);
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center);
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (; i < (int)sincos.size(); i++)
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center + TPointD(r0 * sincos[i].x, r0 * sincos[i].y));
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fabs(r0 - r1) > TConsts::epsilon) {
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUAD_STRIP);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)sincos.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
tglColor(color);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center + TPointD(r0 * sincos[i].x, r0 * sincos[i].y));
|
|
Shinya Kitaoka |
120a6e |
tglColor(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center + TPointD(r1 * sincos[i].x, r1 * sincos[i].y));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglColor(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUAD_STRIP);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)sincos.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center + TPointD(r1 * sincos[i].x, r1 * sincos[i].y));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(center + TPointD(r2 * sincos[i].x, r2 * sincos[i].y));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TRadGradFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
double r1 = 0.5 * std::max(lx, ly) * m_Radius * 0.01;
|
|
Shinya Kitaoka |
120a6e |
if (m_Smooth < 50) r1 *= (0.3 * ((100 - m_Smooth) / 50.0) + 0.7);
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) / 2.0, (bbox.y1 + bbox.y0) / 2.0);
|
|
Shinya Kitaoka |
120a6e |
center = center + TPointD(m_XPos * 0.01 * lx * 0.5, m_YPos * 0.01 * ly * 0.5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
TPixel32 mc(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.setGradientFill(false, m_pointColor, mc, m_Smooth);
|
|
Shinya Kitaoka |
120a6e |
const double flashGrad = 16384.0; // size of gradient square
|
|
Shinya Kitaoka |
120a6e |
TTranslation tM(center.x, center.y);
|
|
Shinya Kitaoka |
120a6e |
TScale sM(2.0 * r1 / (flashGrad), 2.0 * r1 / (flashGrad));
|
|
Shinya Kitaoka |
120a6e |
flash.setFillStyleMatrix(tM * sM);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TCircleStripeFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TCircleStripeFillStyle::TCircleStripeFillStyle(
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &bgColor, const TPixel32 &pointColor, const double XPos,
|
|
Shinya Kitaoka |
120a6e |
const double YPos, const double Dist, const double Thickness)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(pointColor)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(XPos)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(YPos)
|
|
Shinya Kitaoka |
120a6e |
, m_Dist(Dist)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(Thickness) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TCircleStripeFillStyle::TCircleStripeFillStyle(const TPixel32 &color)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(TPixel32::Transparent)
|
|
Shinya Kitaoka |
120a6e |
, m_pointColor(color)
|
|
Shinya Kitaoka |
120a6e |
, m_XPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_YPos(0.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Dist(15.0)
|
|
Shinya Kitaoka |
120a6e |
, m_Thickness(3.0) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TCircleStripeFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TCircleStripeFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TCircleStripeFillStyle::getParamCount() const { return 4; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TCircleStripeFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TCircleStripeFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCircleStripeFillStyle", "X Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCircleStripeFillStyle", "Y Position");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCircleStripeFillStyle", "Distance");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TCircleStripeFillStyle", "Thickness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
min = -200.0;
|
|
Shinya Kitaoka |
120a6e |
max = 200.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
min = -200.0;
|
|
Shinya Kitaoka |
120a6e |
max = 200.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
min = 0.5;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
min = 0.5;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TCircleStripeFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
return m_XPos;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return m_YPos;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return m_Dist;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_XPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_YPos = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_Dist = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_Thickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_XPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_YPos;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Dist;
|
|
Shinya Kitaoka |
120a6e |
is >> m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_XPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_YPos;
|
|
Shinya Kitaoka |
120a6e |
os << m_Dist;
|
|
Shinya Kitaoka |
120a6e |
os << m_Thickness;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TCircleStripeFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
return index == 0 ? m_pointColor : TSolidColorStyle::getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::setColorParamValue(int index,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor = color;
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::getCircleStripeQuads(
|
|
Shinya Kitaoka |
120a6e |
const TPointD ¢er, const double r1, const double r2,
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> &pv) const {</tpointd>
|
|
Shinya Kitaoka |
120a6e |
pv.clear();
|
|
Shinya Kitaoka |
120a6e |
const double dAng = 10.0;
|
|
Shinya Kitaoka |
120a6e |
for (double ang = 0.0; ang <= 360; ang += dAng) {
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(center +
|
|
Shinya Kitaoka |
120a6e |
TPointD(r1 * cos(degree2rad(ang)), r1 * sin(degree2rad(ang))));
|
|
Shinya Kitaoka |
120a6e |
pv.push_back(center +
|
|
Shinya Kitaoka |
120a6e |
TPointD(r2 * cos(degree2rad(ang)), r2 * sin(degree2rad(ang))));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TCircleStripeFillStyle::drawCircleStripe(const TPointD ¢er,
|
|
Shinya Kitaoka |
120a6e |
const double r1, const double r2,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &col) const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pv;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
getCircleStripeQuads(center, r1, r2, pv);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stencil = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
stencil->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUAD_STRIP);
|
|
Shinya Kitaoka |
120a6e |
tglColor(col);
|
|
Shinya Kitaoka |
120a6e |
int i = 0;
|
|
Shinya Kitaoka |
120a6e |
for (; i < (int)pv.size(); i++) tglVertex(pv[i]);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stencil->endMask();
|
|
Shinya Kitaoka |
120a6e |
stencil->enableMask(TStencilControl::SHOW_OUTSIDE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_LINE_SMOOTH);
|
|
Shinya Kitaoka |
120a6e |
tglEnableLineSmooth();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Just for the antialiasing
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_STRIP);
|
|
Shinya Kitaoka |
120a6e |
tglColor(col);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)pv.size(); i += 2) tglVertex(pv[i]);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_STRIP);
|
|
Shinya Kitaoka |
120a6e |
tglColor(col);
|
|
Shinya Kitaoka |
120a6e |
for (i = 1; i < (int)pv.size(); i += 2) tglVertex(pv[i]);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stencil->disableMask();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
const bool isTransparent = m_pointColor.m < 255;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 foregroundColor;
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
foregroundColor = (*(cf))(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
foregroundColor = m_pointColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox = boundary.m_bbox;
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) * 0.5, (bbox.y1 + bbox.y0) * 0.5);
|
|
Shinya Kitaoka |
120a6e |
center.x = center.x + m_XPos * 0.01 * 0.5 * lx;
|
|
Shinya Kitaoka |
120a6e |
center.y = center.y + m_YPos * 0.01 * 0.5 * ly;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double maxDist = 0.0;
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x0, bbox.y0)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x0, bbox.y1)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x1, bbox.y0)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x1, bbox.y1)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double halfThick = m_Thickness * 0.5;
|
|
Shinya Kitaoka |
120a6e |
for (double d = 0; d <= maxDist; d += m_Dist)
|
|
Shinya Kitaoka |
120a6e |
drawCircleStripe(center, d - halfThick, d + halfThick, foregroundColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isTransparent) {
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
// glDisable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TCircleStripeFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double lx = bbox.x1 - bbox.x0;
|
|
Shinya Kitaoka |
120a6e |
double ly = bbox.y1 - bbox.y0;
|
|
Shinya Kitaoka |
120a6e |
TPointD center((bbox.x1 + bbox.x0) * 0.5, (bbox.y1 + bbox.y0) * 0.5);
|
|
Shinya Kitaoka |
120a6e |
center.x = center.x + m_XPos * 0.01 * 0.5 * lx;
|
|
Shinya Kitaoka |
120a6e |
center.y = center.y + m_YPos * 0.01 * 0.5 * ly;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double maxDist = 0.0;
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x0, bbox.y0)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x0, bbox.y1)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x1, bbox.y0)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
maxDist = std::max(tdistance(center, TPointD(bbox.x1, bbox.y1)), maxDist);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbClip = 2;
|
|
Shinya Kitaoka |
120a6e |
double d = m_Dist;
|
|
Shinya Kitaoka |
120a6e |
for (; d <= maxDist; d += m_Dist) nbClip++;
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TPixel::Black);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
flash.setLineColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
d = m_Thickness / 2.0;
|
|
Shinya Kitaoka |
120a6e |
flash.drawEllipse(center, d, d);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TPixel32(0, 0, 0, 0));
|
|
Shinya Kitaoka |
120a6e |
flash.setLineColor(m_pointColor);
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(m_Thickness / 2.0);
|
|
Shinya Kitaoka |
120a6e |
for (d = m_Dist; d <= maxDist; d += m_Dist) flash.drawEllipse(center, d, d);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TMosaicFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMosaicFillStyle::TMosaicFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 pointColor[4],
|
|
Shinya Kitaoka |
120a6e |
const double size, const double deform,
|
|
Shinya Kitaoka |
120a6e |
const double minThickness,
|
|
Shinya Kitaoka |
120a6e |
const double maxThickness)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_size(size)
|
|
Shinya Kitaoka |
120a6e |
, m_deform(deform)
|
|
Shinya Kitaoka |
120a6e |
, m_minThickness(minThickness)
|
|
Shinya Kitaoka |
120a6e |
, m_maxThickness(maxThickness) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 4; i++) m_pointColor[i] = pointColor[i];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMosaicFillStyle::TMosaicFillStyle(const TPixel32 bgColor)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_size(25.0)
|
|
Shinya Kitaoka |
120a6e |
, m_deform(70.0)
|
|
Shinya Kitaoka |
120a6e |
, m_minThickness(20)
|
|
Shinya Kitaoka |
120a6e |
, m_maxThickness(40) {
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[0] = TPixel32::Blue;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[1] = TPixel32::Green;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[2] = TPixel32::Yellow;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[3] = TPixel32::Cyan;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TMosaicFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TMosaicFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TMosaicFillStyle::getParamCount() const { return 4; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TMosaicFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TMosaicFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TMosaicFillStyle", "Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TMosaicFillStyle", "Distortion");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TMosaicFillStyle", "Min Thick");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TMosaicFillStyle", "Max Thick");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::getParamRange(int index, double &min,
|
|
Shinya Kitaoka |
120a6e |
double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
min = (index == 0) ? 2 : 0.001;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TMosaicFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = m_size;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = m_deform;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = m_minThickness;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
value = m_maxThickness;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 4);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_size = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_deform = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_minThickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
m_maxThickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_size;
|
|
Shinya Kitaoka |
120a6e |
is >> m_deform;
|
|
Shinya Kitaoka |
120a6e |
is >> m_minThickness;
|
|
Shinya Kitaoka |
120a6e |
is >> m_maxThickness;
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor[0];
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor[1];
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor[2];
|
|
Shinya Kitaoka |
120a6e |
is >> m_pointColor[3];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_size;
|
|
Shinya Kitaoka |
120a6e |
os << m_deform;
|
|
Shinya Kitaoka |
120a6e |
os << m_minThickness;
|
|
Shinya Kitaoka |
120a6e |
os << m_maxThickness;
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor[0];
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor[1];
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor[2];
|
|
Shinya Kitaoka |
120a6e |
os << m_pointColor[3];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TMosaicFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 tmp;
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
tmp = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
else if (index >= 1 && index <= 4)
|
|
Shinya Kitaoka |
120a6e |
tmp = m_pointColor[index - 1];
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
assert(!"bad color index");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return tmp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
else if (index >= 1 && index <= 4)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[index - 1] = color;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
assert(!"bad color index");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
void TMosaicFillStyle::preaprePos(const TRectD &box, std::vector<tpointd> &v,</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int &lX, int &lY, TRandom &rand) const {
|
|
Shinya Kitaoka |
120a6e |
double dist = 5.0 + (60.0 - 5.0) * tcrop(m_size, 0.0, 100.0) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
lY = lX = 0;
|
|
Shinya Kitaoka |
120a6e |
double ld = 0.4 * tcrop(m_deform, 0.0, 100.0) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
for (double y = box.y0 - dist; y <= (box.y1 + dist); y += dist, lY++) {
|
|
Shinya Kitaoka |
120a6e |
lX = 0;
|
|
Shinya Kitaoka |
120a6e |
for (double x = box.x0 - dist; x <= (box.x1 + dist); x += dist, lX++) {
|
|
Shinya Kitaoka |
120a6e |
double dx = (rand.getInt(0, 2001) * 0.001 - 1.0) * ld * dist;
|
|
Shinya Kitaoka |
120a6e |
double dy = (rand.getInt(0, 2001) * 0.001 - 1.0) * ld * dist;
|
|
Shinya Kitaoka |
120a6e |
TPointD pos(x + dx, y + dy);
|
|
Shinya Kitaoka |
120a6e |
v.push_back(pos);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TMosaicFillStyle::getQuad(const int ix, const int iy, const int lX,
|
|
Shinya Kitaoka |
120a6e |
const int lY, std::vector<tpointd> &v,</tpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD *pquad, TRandom &rand) const {
|
|
Shinya Kitaoka |
120a6e |
if (ix < 0 || iy < 0 || ix >= (lX - 1) || iy >= (lY - 1)) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double dmin = tcrop(m_minThickness, 0.0, 100.0) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
double dmax = tcrop(m_maxThickness, 0.0, 100.0) * 0.01;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD &p1 = v[iy * lX + ix];
|
|
Shinya Kitaoka |
120a6e |
TPointD &p2 = v[iy * lX + ix + 1];
|
|
Shinya Kitaoka |
120a6e |
TPointD &p3 = v[(iy + 1) * lX + ix + 1];
|
|
Shinya Kitaoka |
120a6e |
TPointD &p4 = v[(iy + 1) * lX + ix];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double q1 = 0.5 * (dmin + (dmax - dmin) * rand.getInt(0, 101) * 0.01);
|
|
Shinya Kitaoka |
120a6e |
double q2 = 0.5 * (dmin + (dmax - dmin) * rand.getInt(0, 101) * 0.01);
|
|
Shinya Kitaoka |
120a6e |
double q3 = 0.5 * (dmin + (dmax - dmin) * rand.getInt(0, 101) * 0.01);
|
|
Shinya Kitaoka |
120a6e |
double q4 = 0.5 * (dmin + (dmax - dmin) * rand.getInt(0, 101) * 0.01);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pquad[0] = (1.0 - q1) * p1 + q1 * p3;
|
|
Shinya Kitaoka |
120a6e |
pquad[1] = (1.0 - q2) * p2 + q2 * p4;
|
|
Shinya Kitaoka |
120a6e |
pquad[2] = (1.0 - q3) * p3 + q3 * p1;
|
|
Shinya Kitaoka |
120a6e |
pquad[3] = (1.0 - q4) * p4 + q4 * p2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color[4];
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 4; i++) {
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color[i] = (*(cf))(m_pointColor[i]);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color[i] = m_pointColor[i];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TPixel32 currentColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pos;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int posLX, posLY;
|
|
Shinya Kitaoka |
120a6e |
TRandom rand;
|
|
Shinya Kitaoka |
120a6e |
TPointD quad[4];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
preaprePos(boundary.m_bbox, pos, posLX, posLY, rand);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* ma serve ?
|
|
Shinya Kitaoka |
120a6e |
tglColor(getMainColor());
|
|
Shinya Kitaoka |
120a6e |
tglVertex(TPointD(boundary.m_bbox.x0,boundary.m_bbox.y0));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(TPointD(boundary.m_bbox.x0,boundary.m_bbox.y1));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(TPointD(boundary.m_bbox.x1,boundary.m_bbox.y1));
|
|
Shinya Kitaoka |
120a6e |
tglVertex(TPointD(boundary.m_bbox.x1,boundary.m_bbox.y0));
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < (posLY - 1); y++)
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < (posLX - 1); x++)
|
|
Shinya Kitaoka |
120a6e |
if (getQuad(x, y, posLX, posLY, pos, quad, rand)) {
|
|
Shinya Kitaoka |
120a6e |
currentColor = color[rand.getInt(0, 4)];
|
|
Shinya Kitaoka |
120a6e |
if (currentColor.m != 0) {
|
|
Shinya Kitaoka |
120a6e |
tglColor(currentColor);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[0]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[1]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[2]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[3]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TMosaicFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pos;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int posLX, posLY;
|
|
Shinya Kitaoka |
120a6e |
TRandom rand;
|
|
Shinya Kitaoka |
120a6e |
TPointD quad[4];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
preaprePos(bbox, pos, posLX, posLY, rand);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (pos.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int nbClip = (posLX - 1) * (posLY - 1) + 1;
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TSolidColorStyle::getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0);
|
|
Shinya Kitaoka |
120a6e |
flash.drawRectangle(bbox);
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < (posLY - 1); y++)
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < (posLX - 1); x++)
|
|
Shinya Kitaoka |
120a6e |
if (getQuad(x, y, posLX, posLY, pos, quad, rand)) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lvert;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[0]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[2]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[3]);
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor[rand.getInt(0, 4)]);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(lvert);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TPatchFillStyle implementation
|
|
Toshihiro Shimizu |
890ddd |
//***************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPatchFillStyle::TPatchFillStyle(const TPixel32 &bgColor,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 pointColor[6],
|
|
Shinya Kitaoka |
120a6e |
const double size, const double deform,
|
|
Shinya Kitaoka |
120a6e |
const double thickness)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor)
|
|
Shinya Kitaoka |
120a6e |
, m_size(size)
|
|
Shinya Kitaoka |
120a6e |
, m_deform(deform)
|
|
Shinya Kitaoka |
120a6e |
, m_thickness(thickness) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 6; i++) m_pointColor[i] = pointColor[i];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPatchFillStyle::TPatchFillStyle(const TPixel32 &bgColor)
|
|
Shinya Kitaoka |
120a6e |
: TSolidColorStyle(bgColor), m_size(25.0), m_deform(50.0), m_thickness(30) {
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[0] = TPixel32::Red;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[1] = TPixel32::Green;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[2] = TPixel32::Yellow;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[3] = TPixel32::Cyan;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[4] = TPixel32::Magenta;
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[5] = TPixel32::White;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TPatchFillStyle::clone() const {
|
|
Shinya Kitaoka |
120a6e |
return new TPatchFillStyle(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TPatchFillStyle::getParamCount() const { return 3; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle::ParamType TPatchFillStyle::getParamType(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < getParamCount());
|
|
Shinya Kitaoka |
120a6e |
return TColorStyle::DOUBLE;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString TPatchFillStyle::getParamNames(int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
QString value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPatchFillStyle", "Size");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPatchFillStyle", "Distortion");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = QCoreApplication::translate("TPatchFillStyle", "Thickness");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::getParamRange(int index, double &min, double &max) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
min = (index == 0) ? 2 : 0.001;
|
|
Shinya Kitaoka |
120a6e |
max = 100.0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double TPatchFillStyle::getParamValue(TColorStyle::double_tag,
|
|
Shinya Kitaoka |
120a6e |
int index) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double value;
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
value = m_size;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
value = m_deform;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
value = m_thickness;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::setParamValue(int index, double value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= index && index < 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (index) {
|
|
Shinya Kitaoka |
120a6e |
case 0:
|
|
Shinya Kitaoka |
120a6e |
m_size = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
m_deform = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
m_thickness = value;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::loadData(TInputStreamInterface &is) {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::loadData(is);
|
|
Shinya Kitaoka |
120a6e |
is >> m_size;
|
|
Shinya Kitaoka |
120a6e |
is >> m_deform;
|
|
Shinya Kitaoka |
120a6e |
is >> m_thickness;
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 6; i++) is >> m_pointColor[i];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::saveData(TOutputStreamInterface &os) const {
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::saveData(os);
|
|
Shinya Kitaoka |
120a6e |
os << m_size;
|
|
Shinya Kitaoka |
120a6e |
os << m_deform;
|
|
Shinya Kitaoka |
120a6e |
os << m_thickness;
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 6; i++) os << m_pointColor[i];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
TPixel32 TPatchFillStyle::getColorParamValue(int index) const {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 tmp;
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
tmp = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
else if (index >= 1 && index <= 6)
|
|
Shinya Kitaoka |
120a6e |
tmp = m_pointColor[index - 1];
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
assert(!"bad color index");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return tmp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::setColorParamValue(int index, const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
else if (index >= 1 && index <= 6)
|
|
Shinya Kitaoka |
120a6e |
m_pointColor[index - 1] = color;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
assert(!"bad color index");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
void TPatchFillStyle::preaprePos(const TRectD &box, std::vector<tpointd> &v,</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int &lX, int &lY, TRandom &rand) const {
|
|
Shinya Kitaoka |
120a6e |
double q = tcrop(m_size, 0.0, 100.0) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
double r = 5.0 + (60.0 - 5.0) * q;
|
|
Shinya Kitaoka |
120a6e |
double m = r * sqrt(3.0) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
lY = 5 + (int)((box.y1 - box.y0) / (2 * m));
|
|
Shinya Kitaoka |
120a6e |
int ix = 0;
|
|
Shinya Kitaoka |
120a6e |
for (double x = box.x0 - r; x <= (box.x1 + r); ix++) {
|
|
Shinya Kitaoka |
120a6e |
int nb = ix % 4;
|
|
Shinya Kitaoka |
120a6e |
double y = (nb == 0 || nb == 1) ? box.y0 - 2 * m : box.y0 - m;
|
|
Shinya Kitaoka |
120a6e |
for (int iy = 0; iy < lY; iy++, y += (2 * m)) v.push_back(TPointD(x, y));
|
|
Shinya Kitaoka |
120a6e |
x = (nb == 0 || nb == 2) ? x + r : x + r / 2.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
lX = ix;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double maxDeform = r * 0.6 * tcrop(m_deform, 0.0, 100.0) * 0.01;
|
|
Shinya Kitaoka |
120a6e |
for (UINT i = 0; i < v.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
v[i].x += (rand.getInt(0, 200) - 100) * 0.01 * maxDeform;
|
|
Shinya Kitaoka |
120a6e |
v[i].y += (rand.getInt(0, 200) - 100) * 0.01 * maxDeform;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TPatchFillStyle::getQuadLine(const TPointD &a, const TPointD &b,
|
|
Shinya Kitaoka |
120a6e |
const double thickn, TPointD *quad) const {
|
|
Shinya Kitaoka |
120a6e |
if (tdistance(a, b) < TConsts::epsilon) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD ab(b - a);
|
|
Shinya Kitaoka |
120a6e |
ab = normalize(ab);
|
|
Shinya Kitaoka |
120a6e |
ab = rotate90(ab);
|
|
Shinya Kitaoka |
120a6e |
ab = ab * thickn;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
quad[0] = a + ab;
|
|
Shinya Kitaoka |
120a6e |
quad[1] = a - ab;
|
|
Shinya Kitaoka |
120a6e |
quad[2] = b - ab;
|
|
Shinya Kitaoka |
120a6e |
quad[3] = b + ab;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::drawGLQuad(const TPointD *quad) const {
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_QUADS);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[0]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[1]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[2]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(quad[3]);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
double r = tdistance(quad[0], quad[1]) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
tglDrawDisk(quad[0] * 0.5 + quad[1] * 0.5, r);
|
|
Shinya Kitaoka |
120a6e |
tglDrawDisk(quad[2] * 0.5 + quad[3] * 0.5, r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::drawRegion(const TColorFunction *cf,
|
|
Shinya Kitaoka |
120a6e |
const bool antiAliasing,
|
|
Shinya Kitaoka |
120a6e |
TRegionOutline &boundary) const {
|
|
Shinya Kitaoka |
120a6e |
TStencilControl *stenc = TStencilControl::instance();
|
|
Shinya Kitaoka |
120a6e |
TPixel32 backgroundColor = TSolidColorStyle::getMainColor();
|
|
Shinya Kitaoka |
120a6e |
if (cf) backgroundColor = (*(cf))(backgroundColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (backgroundColor.m == 0) { // only to create stencil mask
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle appStyle(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(); // does not draw on screen
|
|
Shinya Kitaoka |
120a6e |
appStyle.drawRegion(0, false, boundary);
|
|
Shinya Kitaoka |
120a6e |
} else { // create stencil mask and draw on screen
|
|
Shinya Kitaoka |
120a6e |
stenc->beginMask(TStencilControl::DRAW_ALSO_ON_SCREEN);
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle::drawRegion(cf, antiAliasing, boundary);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
stenc->endMask();
|
|
Shinya Kitaoka |
120a6e |
stenc->enableMask(TStencilControl::SHOW_INSIDE);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// glEnable(GL_BLEND);
|
|
Shinya Kitaoka |
120a6e |
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
Shinya Kitaoka |
120a6e |
//// <-- tglEnableBlending();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color[6];
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 6; i++)
|
|
Shinya Kitaoka |
120a6e |
if (cf)
|
|
Shinya Kitaoka |
120a6e |
color[i] = (*(cf))(m_pointColor[i]);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
color[i] = m_pointColor[i];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 currentColor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pos;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int posLX, posLY;
|
|
Shinya Kitaoka |
120a6e |
TRandom rand;
|
|
Shinya Kitaoka |
120a6e |
TPointD quad[4];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
preaprePos(boundary.m_bbox, pos, posLX, posLY, rand);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_TRIANGLES);
|
|
Shinya Kitaoka |
120a6e |
int x = 2;
|
|
Shinya Kitaoka |
120a6e |
for (; x < (posLX - 2); x += 2)
|
|
Shinya Kitaoka |
120a6e |
for (int y = 1; y < posLY; y++) {
|
|
Shinya Kitaoka |
120a6e |
TPointD q[6];
|
|
Shinya Kitaoka |
120a6e |
if ((x % 4) == 2) {
|
|
Shinya Kitaoka |
120a6e |
q[0] = pos[(x - 1) * posLY + y];
|
|
Shinya Kitaoka |
120a6e |
q[1] = pos[(x)*posLY + y];
|
|
Shinya Kitaoka |
120a6e |
q[2] = pos[(x + 1) * posLY + y];
|
|
Shinya Kitaoka |
120a6e |
q[3] = pos[(x + 2) * posLY + y];
|
|
Shinya Kitaoka |
120a6e |
q[4] = pos[(x + 1) * posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
q[5] = pos[(x)*posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
q[0] = pos[(x - 1) * posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
q[1] = pos[(x)*posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
q[2] = pos[(x + 1) * posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
q[3] = pos[(x + 2) * posLY + y - 1];
|
|
Shinya Kitaoka |
120a6e |
q[4] = pos[(x + 1) * posLY + y];
|
|
Shinya Kitaoka |
120a6e |
q[5] = pos[(x)*posLY + y];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
currentColor = color[rand.getInt(0, 6)];
|
|
Shinya Kitaoka |
120a6e |
if (currentColor.m != 0) {
|
|
Shinya Kitaoka |
120a6e |
tglColor(currentColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[0]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[1]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[2]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[2]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[3]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[4]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[4]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[5]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[0]);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[0]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[2]);
|
|
Shinya Kitaoka |
120a6e |
tglVertex(q[4]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double thickn = tcrop(m_thickness, 0.0, 100.0) * 0.01 * 5.0;
|
|
Shinya Kitaoka |
120a6e |
if (thickn > 0.001) tglColor(backgroundColor);
|
|
Shinya Kitaoka |
120a6e |
for (x = 0; x < (posLX - 1); x++) {
|
|
Shinya Kitaoka |
120a6e |
int nb = x % 4;
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < posLY; y++) {
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y], thickn,
|
|
Shinya Kitaoka |
120a6e |
quad))
|
|
Shinya Kitaoka |
120a6e |
drawGLQuad(quad);
|
|
Shinya Kitaoka |
120a6e |
if (y > 0 && nb == 1)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y - 1],
|
|
Shinya Kitaoka |
120a6e |
thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
drawGLQuad(quad);
|
|
Shinya Kitaoka |
120a6e |
if (y < (posLY - 1) && nb == 3)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y + 1],
|
|
Shinya Kitaoka |
120a6e |
thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
drawGLQuad(quad);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// tglColor(TPixel32::White);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stenc->disableMask();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int TPatchFillStyle::nbClip(const int lX, const int lY,
|
|
Shinya Kitaoka |
120a6e |
const std::vector<tpointd> &v) const {</tpointd>
|
|
Shinya Kitaoka |
120a6e |
TPointD quad[4];
|
|
Shinya Kitaoka |
120a6e |
double thickn = tcrop(m_thickness, 0.0, 100.0) * 0.01 * 5.0;
|
|
Shinya Kitaoka |
120a6e |
int nbC = 0;
|
|
Shinya Kitaoka |
120a6e |
int x = 2;
|
|
Shinya Kitaoka |
120a6e |
for (; x < (lX - 2); x += 2)
|
|
Shinya Kitaoka |
120a6e |
for (int y = 1; y < lY; y++) nbC += 1;
|
|
Shinya Kitaoka |
120a6e |
if (thickn > 0.001)
|
|
Shinya Kitaoka |
120a6e |
for (x = 0; x < (lX - 1); x++) {
|
|
Shinya Kitaoka |
120a6e |
int nb = x % 4;
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < lY; y++) {
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(v[x * lY + y], v[(x + 1) * lY + y], thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
nbC += 3;
|
|
Shinya Kitaoka |
120a6e |
if (y > 0 && nb == 1)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(v[x * lY + y], v[(x + 1) * lY + y - 1], thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
nbC += 3;
|
|
Shinya Kitaoka |
120a6e |
if (y < (lY - 1) && nb == 3)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(v[x * lY + y], v[(x + 1) * lY + y + 1], thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
nbC += 3;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbC;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::drawFlashQuad(TFlash &flash, const TPointD *quad) const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lvert;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[0]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[2]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(quad[3]);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(lvert);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double r = tdistance(quad[0], quad[1]) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
flash.drawEllipse(quad[0] * 0.5 + quad[1] * 0.5, r, r);
|
|
Shinya Kitaoka |
120a6e |
flash.drawEllipse(quad[2] * 0.5 + quad[3] * 0.5, r, r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::drawFlashTriangle(TFlash &flash, const TPointD &p1,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &p2,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &p3) const {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lvert;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(p1);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(p2);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(p3);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(lvert);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void TPatchFillStyle::drawRegion(TFlash &flash, const TRegion *r) const {
|
|
Shinya Kitaoka |
120a6e |
TRectD bbox(r->getBBox());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> pos;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
int posLX, posLY;
|
|
Shinya Kitaoka |
120a6e |
TRandom rand;
|
|
Shinya Kitaoka |
120a6e |
TPointD quad[4];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
preaprePos(bbox, pos, posLX, posLY, rand);
|
|
Shinya Kitaoka |
120a6e |
if (pos.size() <= 0) return;
|
|
Shinya Kitaoka |
120a6e |
flash.drawRegion(*r, nbClip(posLX, posLY, pos));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
int x;
|
|
Shinya Kitaoka |
120a6e |
for (x = 2; x < (posLX - 2); x += 2)
|
|
Shinya Kitaoka |
120a6e |
for (int y = 1; y < posLY; y++) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tpointd> lvert;</tpointd>
|
|
Shinya Kitaoka |
120a6e |
if ((x % 4) == 2) {
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x - 1) * posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x)*posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 1) * posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 2) * posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 1) * posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x)*posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x - 1) * posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x)*posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 1) * posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 2) * posLY + y - 1]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x + 1) * posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
lvert.push_back(pos[(x)*posLY + y]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(m_pointColor[rand.getInt(0, 6)]);
|
|
Shinya Kitaoka |
120a6e |
flash.drawPolyline(lvert);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
flash.setFillColor(TSolidColorStyle::getMainColor());
|
|
Shinya Kitaoka |
120a6e |
flash.setThickness(0.0);
|
|
Shinya Kitaoka |
120a6e |
double thickn = tcrop(m_thickness, 0.0, 100.0) * 0.01 * 5.0;
|
|
Shinya Kitaoka |
120a6e |
if (thickn > 0.001)
|
|
Shinya Kitaoka |
120a6e |
for (x = 0; x < (posLX - 1); x++) {
|
|
Shinya Kitaoka |
120a6e |
int nb = x % 4;
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < posLY; y++) {
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y], thickn,
|
|
Shinya Kitaoka |
120a6e |
quad))
|
|
Shinya Kitaoka |
120a6e |
drawFlashQuad(flash, quad);
|
|
Shinya Kitaoka |
120a6e |
if (y > 0 && nb == 1)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y - 1],
|
|
Shinya Kitaoka |
120a6e |
thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
drawFlashQuad(flash, quad);
|
|
Shinya Kitaoka |
120a6e |
if (y < (posLY - 1) && nb == 3)
|
|
Shinya Kitaoka |
120a6e |
if (getQuadLine(pos[x * posLY + y], pos[(x + 1) * posLY + y + 1],
|
|
Shinya Kitaoka |
120a6e |
thickn, quad))
|
|
Shinya Kitaoka |
120a6e |
drawFlashQuad(flash, quad);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|