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
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TSimpleStrokeProp::TSimpleStrokeProp(const TStroke *stroke,
Shinya Kitaoka 120a6e
                                     TSimpleStrokeStyle *style)
Shinya Kitaoka 120a6e
    : TStrokeProp(stroke)
Shinya Kitaoka 120a6e
    , m_colorStyle(style)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
  m_styleVersionNumber = m_colorStyle->getVersionNumber();
Shinya Kitaoka 120a6e
  m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TSimpleStrokeProp::~TSimpleStrokeProp() { m_colorStyle->release(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
const TColorStyle *TSimpleStrokeProp::getColorStyle() const {
Shinya Kitaoka 120a6e
  return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TStrokeProp *TSimpleStrokeProp::clone(const TStroke *stroke) const {
Shinya Kitaoka 120a6e
  TSimpleStrokeProp *prop = new TSimpleStrokeProp(stroke, m_colorStyle);
Shinya Kitaoka 120a6e
  prop->m_strokeChanged   = m_strokeChanged;
Shinya Kitaoka 120a6e
  return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TSimpleStrokeProp::draw(
Shinya Kitaoka 120a6e
    const TVectorRenderData
Shinya Kitaoka 120a6e
        &rd) /*assenza di const non e' una dimenticanza! Alcune sottoclassi
Shinya Kitaoka 120a6e
                devono ridefinire questo metodo e serve che non sia const*/
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
  if (rd.m_clippingRect != TRect() && !rd.m_is3dView &&
Shinya Kitaoka 120a6e
      !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (!rd.m_show0ThickStrokes) {
Shinya Kitaoka 120a6e
    // >:(  This is not an implementation detail of TCenterlineStrokeStyle
Shinya Kitaoka 120a6e
    // because the drawStroke()
Shinya Kitaoka 120a6e
    //      function does not have access to rd - should modify the interface...
Shinya Kitaoka 120a6e
    //      it would be best.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    const TCenterLineStrokeStyle *cs =
Shinya Kitaoka 120a6e
        dynamic_cast<const *="" tcenterlinestrokestyle="">(m_colorStyle);</const>
Shinya Kitaoka 120a6e
    if (cs && cs->getParamValue(TColorStyle::double_tag(), 0) == 0) return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  tglMultMatrix(rd.m_aff);
Shinya Kitaoka 120a6e
  m_colorStyle->drawStroke(rd.m_cf, m_stroke);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRasterImagePatternStrokeProp::TRasterImagePatternStrokeProp(
Shinya Kitaoka 120a6e
    const TStroke *stroke, TRasterImagePatternStrokeStyle *style)
Shinya Kitaoka 120a6e
    : TStrokeProp(stroke), m_colorStyle(style) {
Shinya Kitaoka 120a6e
  m_styleVersionNumber = style->getVersionNumber();
Shinya Kitaoka 120a6e
  m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRasterImagePatternStrokeProp::~TRasterImagePatternStrokeProp() {
Shinya Kitaoka 120a6e
  m_colorStyle->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
const TColorStyle *TRasterImagePatternStrokeProp::getColorStyle() const {
Shinya Kitaoka 120a6e
  return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TStrokeProp *TRasterImagePatternStrokeProp::clone(const TStroke *stroke) const {
Shinya Kitaoka 120a6e
  TRasterImagePatternStrokeProp *prop =
Shinya Kitaoka 120a6e
      new TRasterImagePatternStrokeProp(stroke, m_colorStyle);
Shinya Kitaoka 120a6e
  prop->m_strokeChanged   = m_strokeChanged;
Shinya Kitaoka 120a6e
  prop->m_transformations = m_transformations;
Shinya Kitaoka 120a6e
  return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 38fd86
void TRasterImagePatternStrokeProp::draw(
Shinya Kitaoka 38fd86
    const TVectorRenderData &rd) /*assenza di const non e' una
Shinya Kitaoka 38fd86
                                    dimenticanza! Alcune
Shinya Kitaoka 38fd86
                                    sottoclassi devono
Shinya Kitaoka 38fd86
                                    ridefinire questo metodo e
Shinya Kitaoka 38fd86
                                    serbve che non sia const*/
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
  if (rd.m_clippingRect != TRect() && !rd.m_is3dView &&
Shinya Kitaoka 120a6e
      !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_strokeChanged ||
Shinya Kitaoka 120a6e
      m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Shinya Kitaoka 120a6e
    m_strokeChanged      = false;
Shinya Kitaoka 120a6e
    m_styleVersionNumber = m_colorStyle->getVersionNumber();
Shinya Kitaoka 120a6e
    m_colorStyle->computeTransformations(m_transformations, m_stroke);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_colorStyle->drawStroke(rd, m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TVectorImagePatternStrokeProp::TVectorImagePatternStrokeProp(
Shinya Kitaoka 120a6e
    const TStroke *stroke, TVectorImagePatternStrokeStyle *style)
Shinya Kitaoka 120a6e
    : TStrokeProp(stroke), m_colorStyle(style) {
Shinya Kitaoka 120a6e
  m_styleVersionNumber = style->getVersionNumber();
Shinya Kitaoka 120a6e
  m_colorStyle->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TVectorImagePatternStrokeProp::~TVectorImagePatternStrokeProp() {
Shinya Kitaoka 120a6e
  m_colorStyle->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
const TColorStyle *TVectorImagePatternStrokeProp::getColorStyle() const {
Shinya Kitaoka 120a6e
  return m_colorStyle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TStrokeProp *TVectorImagePatternStrokeProp::clone(const TStroke *stroke) const {
Shinya Kitaoka 120a6e
  TVectorImagePatternStrokeProp *prop =
Shinya Kitaoka 120a6e
      new TVectorImagePatternStrokeProp(stroke, m_colorStyle);
Shinya Kitaoka 120a6e
  prop->m_strokeChanged   = m_strokeChanged;
Shinya Kitaoka 120a6e
  prop->m_transformations = m_transformations;
Shinya Kitaoka 120a6e
  return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 38fd86
void TVectorImagePatternStrokeProp::draw(
Shinya Kitaoka 38fd86
    const TVectorRenderData &rd) /*assenza di const non e' una
Shinya Kitaoka 38fd86
                                    dimenticanza! Alcune
Shinya Kitaoka 38fd86
                                    sottoclassi devono
Shinya Kitaoka 38fd86
                                    ridefinire questo metodo e
Shinya Kitaoka 38fd86
                                    serbve che non sia const*/
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
  if (rd.m_clippingRect != TRect() && !rd.m_is3dView &&
Shinya Kitaoka 120a6e
      !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_strokeChanged ||
Shinya Kitaoka 120a6e
      m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Shinya Kitaoka 120a6e
    m_strokeChanged      = false;
Shinya Kitaoka 120a6e
    m_styleVersionNumber = m_colorStyle->getVersionNumber();
Shinya Kitaoka 120a6e
    m_colorStyle->computeTransformations(m_transformations, m_stroke);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_colorStyle->drawStroke(rd, m_transformations, m_stroke);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
OutlineStrokeProp::OutlineStrokeProp(const TStroke *stroke,
Shinya Kitaoka 120a6e
                                     const TOutlineStyleP style)
Shinya Kitaoka 120a6e
    : TStrokeProp(stroke)
Shinya Kitaoka 120a6e
    , m_colorStyle(style)
Shinya Kitaoka 120a6e
    , m_outline()
Shinya Kitaoka 120a6e
    , m_outlinePixelSize(0) {
Shinya Kitaoka 120a6e
  m_styleVersionNumber = m_colorStyle->getVersionNumber();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TStrokeProp *OutlineStrokeProp::clone(const TStroke *stroke) const {
Shinya Kitaoka 120a6e
  OutlineStrokeProp *prop  = new OutlineStrokeProp(stroke, m_colorStyle);
Shinya Kitaoka 120a6e
  prop->m_strokeChanged    = m_strokeChanged;
Shinya Kitaoka 120a6e
  prop->m_outline          = m_outline;
Shinya Kitaoka 120a6e
  prop->m_outlinePixelSize = m_outlinePixelSize;
Shinya Kitaoka 120a6e
  return prop;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
const TColorStyle *OutlineStrokeProp::getColorStyle() const {
Shinya Kitaoka 120a6e
  return m_colorStyle.getPointer();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void OutlineStrokeProp::draw(const TVectorRenderData &rd) {
Shinya Kitaoka 120a6e
  if (rd.m_clippingRect != TRect() && !rd.m_is3dView &&
Shinya Kitaoka 120a6e
      !convert(rd.m_aff * m_stroke->getBBox()).overlaps(rd.m_clippingRect))
Shinya Kitaoka 120a6e
    return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  tglMultMatrix(rd.m_aff);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double pixelSize = sqrt(tglGetPixelSize2());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  if (m_stroke->isCenterLine() && m_colorStyle->getTagId() != 99)
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  if (m_stroke->isCenterLine())
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    TCenterLineStrokeStyle *appStyle =
Shinya Kitaoka 120a6e
        new TCenterLineStrokeStyle(m_colorStyle->getAverageColor(), 0, 0);
Shinya Kitaoka 120a6e
    appStyle->drawStroke(rd.m_cf, m_stroke);
Shinya Kitaoka 120a6e
    delete appStyle;
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    if (!isAlmostZero(pixelSize - m_outlinePixelSize, 1e-5) ||
Shinya Kitaoka 120a6e
        m_strokeChanged ||
Shinya Kitaoka 120a6e
        m_styleVersionNumber != m_colorStyle->getVersionNumber()) {
Shinya Kitaoka 120a6e
      m_strokeChanged    = false;
Shinya Kitaoka 120a6e
      m_outlinePixelSize = pixelSize;
Shinya Kitaoka 120a6e
      TOutlineUtil::OutlineParameter param;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      m_outline.getArray().clear();
Shinya Kitaoka 120a6e
      m_colorStyle->computeOutline(m_stroke, m_outline, param);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      // TOutlineStyle::StrokeOutlineModifier *modifier =
Shinya Kitaoka 120a6e
      // m_colorStyle->getStrokeOutlineModifier();
Shinya Kitaoka 120a6e
      // if(modifier)
Shinya Kitaoka 120a6e
      //  modifier->modify(m_outline);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      m_styleVersionNumber = m_colorStyle->getVersionNumber();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_colorStyle->drawStroke(rd.m_cf, &m_outline, m_stroke);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================