Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "tcolorstyles.h"
Toshihiro Shimizu 890ddd
#include "tsimplecolorstyles.h"
Toshihiro Shimizu 890ddd
//#include "tstrokeoutline.h"
Toshihiro Shimizu 890ddd
#include "tstrokeprop.h"
Toshihiro Shimizu 890ddd
#include "tgl.h"
Toshihiro Shimizu 890ddd
//#include "tcolorfunctions.h"
Toshihiro Shimizu 890ddd
#include "tvectorrenderdata.h"
Toshihiro Shimizu 890ddd
#include "tmathutil.h"
Toshihiro Shimizu 890ddd
//#include "tcurves.h"
Toshihiro Shimizu 890ddd
//#include "tstrokeutil.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "tstroke.h"
Toshihiro Shimizu 890ddd
//#include "tflash.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TSimpleStrokeProp::TSimpleStrokeProp(const TStroke *stroke, TSimpleStrokeStyle *style)
Toshihiro Shimizu 890ddd
	: TStrokeProp(stroke), m_colorStyle(style)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
	m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TSimpleStrokeProp::~TSimpleStrokeProp()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_colorStyle->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const TColorStyle *TSimpleStrokeProp::getColorStyle() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TStrokeProp *TSimpleStrokeProp::clone(const TStroke *stroke) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TSimpleStrokeProp *prop = new TSimpleStrokeProp(stroke, m_colorStyle);
Toshihiro Shimizu 890ddd
	prop->m_strokeChanged = m_strokeChanged;
Toshihiro Shimizu 890ddd
	return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSimpleStrokeProp::draw(const TVectorRenderData &rd) /*assenza di const non e' una dimenticanza! Alcune sottoclassi devono ridefinire questo metodo e serve che non sia const*/
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (rd.m_clippingRect != TRect() && !rd.m_is3dView && !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (!rd.m_show0ThickStrokes) {
Toshihiro Shimizu 890ddd
		// >:(  This is not an implementation detail of TCenterlineStrokeStyle because the drawStroke()
Toshihiro Shimizu 890ddd
		//      function does not have access to rd - should modify the interface... it would be best.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		const TCenterLineStrokeStyle *cs = dynamic_cast<const *="" tcenterlinestrokestyle="">(m_colorStyle);</const>
Toshihiro Shimizu 890ddd
		if (cs && cs->getParamValue(TColorStyle::double_tag(), 0) == 0)
Toshihiro Shimizu 890ddd
			return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	glPushMatrix();
Toshihiro Shimizu 890ddd
	tglMultMatrix(rd.m_aff);
Toshihiro Shimizu 890ddd
	m_colorStyle->drawStroke(rd.m_cf, m_stroke);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TSimpleStrokeProp::draw(TFlash &flash)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	getColorStyle()->drawStroke(flash, getStroke());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TRasterImagePatternStrokeProp::TRasterImagePatternStrokeProp(const TStroke *stroke, TRasterImagePatternStrokeStyle *style)
Toshihiro Shimizu 890ddd
	: TStrokeProp(stroke), m_colorStyle(style)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_styleVersionNumber = style->getVersionNumber();
Toshihiro Shimizu 890ddd
	m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TRasterImagePatternStrokeProp::~TRasterImagePatternStrokeProp()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_colorStyle->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const TColorStyle *TRasterImagePatternStrokeProp::getColorStyle() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TStrokeProp *TRasterImagePatternStrokeProp::clone(const TStroke *stroke) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TRasterImagePatternStrokeProp *prop = new TRasterImagePatternStrokeProp(stroke, m_colorStyle);
Toshihiro Shimizu 890ddd
	prop->m_strokeChanged = m_strokeChanged;
Toshihiro Shimizu 890ddd
	prop->m_transformations = m_transformations;
Toshihiro Shimizu 890ddd
	return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TRasterImagePatternStrokeProp::draw(const TVectorRenderData &rd) /*assenza di const non e' una dimenticanza! Alcune sottoclassi devono ridefinire questo metodo e serbve che non sia const*/
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (rd.m_clippingRect != TRect() && !rd.m_is3dView && !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_strokeChanged || m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Toshihiro Shimizu 890ddd
		m_strokeChanged = false;
Toshihiro Shimizu 890ddd
		m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
		m_colorStyle->computeTransformations(m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	m_colorStyle->drawStroke(rd, m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TRasterImagePatternStrokeProp::draw(TFlash &flash)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	getColorStyle()->drawStroke(flash, getStroke());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TVectorImagePatternStrokeProp::TVectorImagePatternStrokeProp(const TStroke *stroke, TVectorImagePatternStrokeStyle *style)
Toshihiro Shimizu 890ddd
	: TStrokeProp(stroke), m_colorStyle(style)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_styleVersionNumber = style->getVersionNumber();
Toshihiro Shimizu 890ddd
	m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TVectorImagePatternStrokeProp::~TVectorImagePatternStrokeProp()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_colorStyle->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const TColorStyle *TVectorImagePatternStrokeProp::getColorStyle() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TStrokeProp *TVectorImagePatternStrokeProp::clone(const TStroke *stroke) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TVectorImagePatternStrokeProp *prop = new TVectorImagePatternStrokeProp(stroke, m_colorStyle);
Toshihiro Shimizu 890ddd
	prop->m_strokeChanged = m_strokeChanged;
Toshihiro Shimizu 890ddd
	prop->m_transformations = m_transformations;
Toshihiro Shimizu 890ddd
	return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TVectorImagePatternStrokeProp::draw(const TVectorRenderData &rd) /*assenza di const non e' una dimenticanza! Alcune sottoclassi devono ridefinire questo metodo e serbve che non sia const*/
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (rd.m_clippingRect != TRect() && !rd.m_is3dView && !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_strokeChanged || m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Toshihiro Shimizu 890ddd
		m_strokeChanged = false;
Toshihiro Shimizu 890ddd
		m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
		m_colorStyle->computeTransformations(m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	m_colorStyle->drawStroke(rd, m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TVectorImagePatternStrokeProp::draw(TFlash &flash)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	getColorStyle()->drawStroke(flash, getStroke());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
void TSimpleStrokeProp::draw(TFlash &flash) 
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
  // fintissima!!!! quella vera deve risalire per m_colorStyle->drawStroke()
Toshihiro Shimizu 890ddd
  // come la sua sorellina di sopra
Toshihiro Shimizu 890ddd
  int i, n = m_stroke->getControlPointCount();
Toshihiro Shimizu 890ddd
  flash.setColor(m_colorStyle->getMainColor());
Toshihiro Shimizu 890ddd
  for(i=0;i
Toshihiro Shimizu 890ddd
    {
Toshihiro Shimizu 890ddd
     TPointD a = m_stroke->getControlPoint(i);
Toshihiro Shimizu 890ddd
     TPointD b = m_stroke->getControlPoint(i+1);
Toshihiro Shimizu 890ddd
     flash.drawLine(a,b);
Toshihiro Shimizu 890ddd
    }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
OutlineStrokeProp::OutlineStrokeProp(const TStroke *stroke, const TOutlineStyleP style)
Toshihiro Shimizu 890ddd
	: TStrokeProp(stroke), m_colorStyle(style), m_outline(), m_outlinePixelSize(0)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TStrokeProp *OutlineStrokeProp::clone(const TStroke *stroke) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	OutlineStrokeProp *prop = new OutlineStrokeProp(stroke, m_colorStyle);
Toshihiro Shimizu 890ddd
	prop->m_strokeChanged = m_strokeChanged;
Toshihiro Shimizu 890ddd
	prop->m_outline = m_outline;
Toshihiro Shimizu 890ddd
	prop->m_outlinePixelSize = m_outlinePixelSize;
Toshihiro Shimizu 890ddd
	return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const TColorStyle *OutlineStrokeProp::getColorStyle() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_colorStyle.getPointer();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void OutlineStrokeProp::draw(const TVectorRenderData &rd)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (rd.m_clippingRect != TRect() && !rd.m_is3dView && !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	glPushMatrix();
Toshihiro Shimizu 890ddd
	tglMultMatrix(rd.m_aff);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double pixelSize = sqrt(tglGetPixelSize2());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Toshihiro Shimizu 890ddd
	if (m_stroke->isCenterLine() && m_colorStyle->getTagId() != 99)
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
	if (m_stroke->isCenterLine())
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TCenterLineStrokeStyle *appStyle = new TCenterLineStrokeStyle(m_colorStyle->getAverageColor(), 0, 0);
Toshihiro Shimizu 890ddd
		appStyle->drawStroke(rd.m_cf, m_stroke);
Toshihiro Shimizu 890ddd
		delete appStyle;
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		if (!isAlmostZero(pixelSize - m_outlinePixelSize, 1e-5) || m_strokeChanged || m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Toshihiro Shimizu 890ddd
			m_strokeChanged = false;
Toshihiro Shimizu 890ddd
			m_outlinePixelSize = pixelSize;
Toshihiro Shimizu 890ddd
			TOutlineUtil::OutlineParameter param;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			m_outline.getArray().clear();
Toshihiro Shimizu 890ddd
			m_colorStyle->computeOutline(m_stroke, m_outline, param);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			//TOutlineStyle::StrokeOutlineModifier *modifier = m_colorStyle->getStrokeOutlineModifier();
Toshihiro Shimizu 890ddd
			//if(modifier)
Toshihiro Shimizu 890ddd
			//  modifier->modify(m_outline);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void OutlineStrokeProp::draw(TFlash &flash)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_colorStyle->drawStroke(flash, getStroke());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/* ora e' virtuale pura
Toshihiro Shimizu 890ddd
void TStrokeProp::draw(TFlash &flash) 
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
getColorStyle()->drawStroke(flash, getStroke());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================