Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TSTROKE_H
Toshihiro Shimizu 890ddd
#define TSTROKE_H
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
Toshihiro Shimizu 890ddd
#include "tsmartpointer.h"
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tthreadmessage.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qmutex></qmutex>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TVECTORIMAGE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TStrokeStyle;
Toshihiro Shimizu 890ddd
class TVectorRenderData;
Toshihiro Shimizu 890ddd
class TColorStyle;
Toshihiro Shimizu 890ddd
class TThickQuadratic;
Toshihiro Shimizu 890ddd
class TStrokeProp;
Toshihiro Shimizu 890ddd
class TSegment;
Toshihiro Shimizu 890ddd
class TFlash;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
//    TStroke class
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  This is the new release of TStroke (Version 4).
Toshihiro Shimizu 890ddd
  It's possible to use style to set brush, texture, pattern,
Toshihiro Shimizu 890ddd
  TStroke now are smart pointer.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStroke final : public TSmartObject {
Shinya Kitaoka 120a6e
  DECLARE_CLASS_CODE
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  //! Pimpl of a TStroke
Shinya Kitaoka 120a6e
  struct Imp;
Shinya Kitaoka 120a6e
  std::unique_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  struct OutlineOptions;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef BYTE TStrokeFlag;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static const TStrokeFlag c_selected_flag;
Shinya Kitaoka 120a6e
  static const TStrokeFlag c_changed_region_flag;
Shinya Kitaoka 120a6e
  static const TStrokeFlag c_dirty_flag;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! to be erased
Shinya Kitaoka 120a6e
  TStroke(const TStroke &stroke);
Shinya Kitaoka 120a6e
  //! to be erased
Shinya Kitaoka 120a6e
  TStroke &operator=(const TStroke &other);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! Costructor
Shinya Kitaoka 120a6e
  TStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! Build a stroke from an array of ThickPoint.
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
TStroke constructor build a stroke from an array of control points.
Shinya Kitaoka 120a6e
If chunks are n control points are 2*n+1.
Shinya Kitaoka 120a6e
\note Common control points between two chunks are supposed not replicated.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStroke(const std::vector<tthickpoint> &);</tthickpoint>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Build a stroke from an array of TPointD
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
TStroke constructor build a stroke from an array of control points.
Shinya Kitaoka 120a6e
If chunks are n control points are 2*n+1.
Shinya Kitaoka 120a6e
\note Common control points between two chunks are supposed not replicated,
Shinya Kitaoka 120a6e
      and thickness is equal 0.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStroke(const std::vector<tpointd> &v);</tpointd>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~TStroke();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! mark invalid the length and the outline. The next computeOutlines() will
Shinya Kitaoka 120a6e
  //! update them
Shinya Kitaoka 120a6e
  void invalidate();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! computes outlines (only if it's needed). call it before drawing.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\return false if the bbox doesn't contain the point
Shinya Kitaoka 120a6e
\par p is input point to test
Shinya Kitaoka 120a6e
\par outT is parameter of minimum
Shinya Kitaoka 120a6e
\par chunkIndex is chunk of stroke where is minimum
Shinya Kitaoka 120a6e
\par distance2 is square distance of minimum
Shinya Kitaoka 120a6e
\par checkBBox (default true) is a flag to check or not in bounding box
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  bool getNearestChunk(const TPointD &p, double &outT, int &chunkIndex,
Shinya Kitaoka 120a6e
                       double &distance2, bool checkBBox = true) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool getNearestW(const TPointD &p, double &outW, double &distance2,
Shinya Kitaoka 120a6e
                   bool checkBBox = true) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\finds all points on stroke which are "enough" close to point p. return the
Shinya Kitaoka 120a6e
number of such points.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  int getNearChunks(const TThickPoint &p,
Shinya Kitaoka 120a6e
                    std::vector<tthickpoint> &pointsOnStroke,</tthickpoint>
Shinya Kitaoka 120a6e
                    bool checkBBox = true) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! \return number of chunks in the stroke
Shinya Kitaoka 120a6e
  int getChunkCount() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return number of control points in a stroke
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return number of control points in a stroke
Shinya Kitaoka 120a6e
\note the control point in common between adjacent chunks
Shinya Kitaoka 120a6e
  is counted only once. e.g.: A n-chunk TStroke has n*2+1 CP
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  int getControlPointCount() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void getControlPoints(std::vector<tthickpoint> &v) const;</tthickpoint>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
 Return the n-th control point
Shinya Kitaoka 120a6e
 \note n is clamped to [0,ControlPointCount-1] interval
Shinya Kitaoka 120a6e
 \par n index of desired control point
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TThickPoint getControlPoint(int n) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
 Return control point nearest of parameter w.
Shinya Kitaoka 120a6e
 \note w is clamped to [0,1] interval
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TThickPoint getControlPointAtParameter(double w) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getControlPointIndexAfterParameter(double w) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Set the position of n-th control point.
Shinya Kitaoka 120a6e
If "n" is not a valid position no points are changed
Shinya Kitaoka 120a6e
If the CP is shared between two chunks, then both chunks are modified
Shinya Kitaoka 120a6e
The first method doesn't change the point thickness
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setControlPoint(int n, const TThickPoint &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Set the position of n-th control point.
Shinya Kitaoka 120a6e
If "n" is not a valid position no points are changed
Shinya Kitaoka 120a6e
If the CP is shared between two chunks, then both chunks are modified
Shinya Kitaoka 120a6e
The first method doesn't change the point thickness
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setControlPoint(int n, const TPointD &pos) {
Shinya Kitaoka 120a6e
    setControlPoint(n, TThickPoint(pos, getControlPoint(n).thick));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Reshape stroke
Shinya Kitaoka 120a6e
  void reshape(const TThickPoint pos[], int count);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return chunk at position index
Shinya Kitaoka 120a6e
If index is not valid return NULL
Shinya Kitaoka 120a6e
\note it is used mainly for drawing
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const TThickQuadratic *getChunk(int index) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the bbox of the stroke
Shinya Kitaoka 120a6e
  TRectD getBBox(double w0 = 0.0, double w1 = 1.0) const;
Shinya Kitaoka 120a6e
  void computeBBox();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the bbox of the stroke without thickness.
Shinya Kitaoka 120a6e
  TRectD getCenterlineBBox() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Returns the length of the stroke at passed chunk-param.
Shinya Kitaoka 120a6e
  double getLength(int chunk, double t) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return length of a stroke
Shinya Kitaoka 120a6e
  double getLength(double w0, double w1) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return length of a stroke
Shinya Kitaoka 120a6e
  double getLength(double w1 = 1.0) const { return getLength(0.0, w1); }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return approximate length of a stroke
Shinya Kitaoka 120a6e
  double getApproximateLength(double w0, double w1, double error) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Add a control point (in fact delete one and add three) without changing the
Shinya Kitaoka 120a6e
stroke shape.
Shinya Kitaoka 120a6e
s is the position of the new CP along the stroke itself. (0
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
\note  if a control point already exists near s, then the stroke remains
Shinya Kitaoka 120a6e
unchanged
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void insertControlPointsAtLength(double s);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Add a control point (in fact delete one and add three) without changing the
Shinya Kitaoka 120a6e
stroke shape.
Shinya Kitaoka 120a6e
w is the position of the new CP along parameter. (0
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
\note if a control point already exists near w, then the stroke remains
Shinya Kitaoka 120a6e
unchanged
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void insertControlPoints(double w);  // , minDistance2 = .1
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Reduce the number of control point according to \b maxError parameter
Shinya Kitaoka 120a6e
  void reduceControlPoints(double maxError);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Reduce the number of control point according to \b maxError parameter.
Shinya Kitaoka 120a6e
  //! The vector corners contain the corner of the stroke.
Shinya Kitaoka 120a6e
  void reduceControlPoints(double maxError, std::vector<int> corners);</int>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return a thickpoint at w (parameter (0<=w<=1))
Shinya Kitaoka 120a6e
\note w is 0 at begin of the stroke and is 1.0 at the end.
Shinya Kitaoka 120a6e
    Parameter value for a chunk is stored in the vector
Shinya Kitaoka 120a6e
    m_parameterValueAtChunk.
Shinya Kitaoka 120a6e
    Every change (subdivision of a stroke, resample, insertion of a control
Shinya Kitaoka 120a6e
point)
Shinya Kitaoka 120a6e
    computes a new value for parameter.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TThickPoint getThickPoint(double w) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
same that getThickPoint but return a TPointD
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  inline TPointD getPoint(double w) const { return convert(getThickPoint(w)); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return a thickpoint at s (length of arc)
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TThickPoint getThickPointAtLength(double s) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
same that getThickPointAtLength but return a TPointD
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  inline TPointD getPointAtLength(double s) const {
Shinya Kitaoka 120a6e
    return convert(getThickPointAtLength(s));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return parameter in (based on arc length)
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  double getParameterAtLength(double s) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Return parameter for a control point
Shinya Kitaoka 120a6e
\note if control point is not on curve return middle value between
Shinya Kitaoka 120a6e
      two adjacent control point
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  double getParameterAtControlPoint(int n) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the stroke leght at passed control point
Shinya Kitaoka 120a6e
  double getLengthAtControlPoint(int) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Freeze parameter of a stroke in last valid status
Shinya Kitaoka 120a6e
  void disableComputeOfCaches();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void enableComputeOfCaches();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return parameter w at point position
Shinya Kitaoka 120a6e
  double getW(const TPointD &) const;
Shinya Kitaoka 120a6e
  double getW(int chunkIndex, double t) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Get speed at parameter w
Shinya Kitaoka 120a6e
  // \note w is clamped to [0,1] parameter
Shinya Kitaoka 120a6e
  // if the stroke has a cuspide on w, the tangents are two different;
Shinya Kitaoka 120a6e
  // outSpeed = false return tangent in w-,
Shinya Kitaoka 120a6e
  // outspeed = true returns tangent in w+
Shinya Kitaoka 120a6e
  TPointD getSpeed(double w, bool outSpeed = false) const;
Shinya Kitaoka 120a6e
  //! Returns true if speed1!=speed0, so it is an edge in w
Shinya Kitaoka 120a6e
  bool getSpeedTwoValues(double w, TPointD &speed0, TPointD &speed1) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Get speed at length s
Shinya Kitaoka 120a6e
  // \note s is clamped to [0,getLength] parameter
Shinya Kitaoka 120a6e
  TPointD getSpeedAtLength(double s) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Split a stroke at parameter t
Shinya Kitaoka 120a6e
\note Chunk of null length are removed.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void split(double w, TStroke &f, TStroke &s) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Swap the contents of two strokes
Shinya Kitaoka 120a6e
  void swap(TStroke &ref);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Swapd the geometrical data of two strokes
Shinya Kitaoka 120a6e
  void swapGeometry(TStroke &ref);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Transform a stroke using an affine
Shinya Kitaoka 120a6e
  void transform(const TAffine &aff, bool doChangeThickness = false);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! \return Style
Shinya Kitaoka 120a6e
  int getStyle() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
 Set a style
Shinya Kitaoka 120a6e
 \note If the same style exists, it is replaced by new
Shinya Kitaoka 120a6e
 \note TStroke becomes the owner of TStrokeStyle
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setStyle(int styleId);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return a \b TStrokeProp
Shinya Kitaoka 120a6e
  TStrokeProp *getProp(/*const TVectorPalette *palette*/) const;
Shinya Kitaoka 120a6e
  //! Set \b TSrokePrope of a stroke
Shinya Kitaoka 120a6e
  void setProp(TStrokeProp *prop);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // void deleteStyle(int);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Only for debug
Shinya Kitaoka 120a6e
  void print(std::ostream &os = std::cout) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! change tangent versus in the stroke
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
change tangent versus in a stroke
Shinya Kitaoka 120a6e
\note Change versus of all thickquadratric and change its postion in list
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStroke &changeDirection();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Set \b TStrokeFlag of the stroke
Shinya Kitaoka 120a6e
  void setFlag(TStrokeFlag flag, bool status);
Shinya Kitaoka 120a6e
  //! Return \b TStrokeFlag of the stroke
Shinya Kitaoka 120a6e
  bool getFlag(TStrokeFlag flag) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Gets the chunk and its parameter at stroke parameter \b w; returns true if
Shinya Kitaoka 120a6e
  //! a chunk was found.
Shinya Kitaoka 120a6e
  bool getChunkAndT(double w, int &chunk, double &t) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Gets the chunk and its parameter at stroke length \b s; returns true if a
Shinya Kitaoka 120a6e
  //! chunk was found.
Shinya Kitaoka 120a6e
  bool getChunkAndTAtLength(double s, int &chunk, double &t) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TThickPoint getCentroid() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Set a loop stroke
Shinya Kitaoka 120a6e
  void setSelfLoop(bool loop = true);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return true if the stroke is looped
Shinya Kitaoka 120a6e
  bool isSelfLoop() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return true if all control points have negative thickness
Shinya Kitaoka 120a6e
  bool isCenterLine() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Get a stroke from a \b TThickPoint vector
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Create a \b T3DPointD vector froma a \b TThickPoint vector. The \b T3DPointD
Shinya Kitaoka 120a6e
vector is used to
Shinya Kitaoka 120a6e
find a \b TCubicStroke; than find the quadratic stroke.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  static TStroke *interpolate(const std::vector<tthickpoint> &points,</tthickpoint>
Shinya Kitaoka 120a6e
                              double error, bool findCorners = true);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Get a stroke from a \b TThickQuadratic vector
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Take from \b curves the control points used to create the stroke
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  static TStroke *create(const std::vector<tthickquadratic *=""> &curves);</tthickquadratic>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getId() const;
Shinya Kitaoka 120a6e
  void setId(int id);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the average value of stroke thickness
Shinya Kitaoka 120a6e
  double getAverageThickness() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double getMaxThickness();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Set the average value of stroke thickness to \b thickness
Shinya Kitaoka 120a6e
  void setAverageThickness(double thickness);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool operator==(const TStroke &s) const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool operator!=(const TStroke &s) const { return !operator==(s); }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  OutlineOptions &outlineOptions();
Shinya Kitaoka 120a6e
  const OutlineOptions &outlineOptions() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef TSmartPointerT<tstroke> TStrokeP;</tstroke>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
//    TStrokeProp class
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TStrokeProp {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  const TStroke *m_stroke;
Shinya Kitaoka 120a6e
  bool m_strokeChanged;
Shinya Kitaoka 120a6e
  int m_styleVersionNumber;
Shinya Kitaoka 120a6e
  TThread::Mutex m_mutex;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TStrokeProp(const TStroke *stroke);
Shinya Kitaoka 120a6e
  virtual ~TStrokeProp() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual TStrokeProp *clone(const TStroke *stroke) const = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TThread::Mutex *getMutex() { return &m_mutex; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void draw(const TVectorRenderData &rd) = 0;
Shinya Kitaoka 120a6e
  virtual void draw(TFlash &flash)               = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual const TColorStyle *getColorStyle() const = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TStroke *getStroke() const { return m_stroke; }
Shinya Kitaoka 120a6e
  virtual void notifyStrokeChange() { m_strokeChanged = true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TStrokeProp(const TStrokeProp &);
Shinya Kitaoka 120a6e
  TStrokeProp &operator=(const TStrokeProp &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  friend class TStroke;
Shinya Kitaoka 120a6e
  void setStroke(const TStroke *stroke) { m_stroke = stroke; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
//    TStroke::OutlineOptions structure
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Contains complementary stroke parameters used in the process of transforming
Toshihiro Shimizu 890ddd
  the raw (centerline) stroke data in its drawable (outline) form.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
struct DVAPI TStroke::OutlineOptions {
Shinya Kitaoka 120a6e
  enum CapStyle { BUTT_CAP = 0, ROUND_CAP, PROJECTING_CAP };
Shinya Kitaoka 120a6e
  enum JoinStyle { MITER_JOIN = 0, ROUND_JOIN, BEVEL_JOIN };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  UCHAR m_capStyle;
Shinya Kitaoka 120a6e
  UCHAR m_joinStyle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double m_miterLower;
Shinya Kitaoka 120a6e
  double m_miterUpper;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  OutlineOptions();
Shinya Kitaoka 120a6e
  OutlineOptions(UCHAR capStyle, UCHAR JoinStyle, double lower, double upper);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
//    Related Non-member functions
Toshihiro Shimizu 890ddd
//***************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! return the stroke equal to the join of stroke1 and stroke2 (that are not
Shinya Kitaoka 120a6e
//! deleted)
Toshihiro Shimizu 890ddd
DVAPI TStroke *joinStrokes(const TStroke *stroke1, const TStroke *stroke2);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
/*!
Toshihiro Shimizu 890ddd
  Intersection between stroke and segment.
Toshihiro Shimizu 890ddd
  \par stroke to intersect
Toshihiro Shimizu 890ddd
  \par segment to intersect
Shinya Kitaoka 120a6e
  \ret a vector of pair of double (first value is stroke parameter second is
Shinya Kitaoka 120a6e
  segment parameter)
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka 120a6e
DVAPI int intersect(const TStroke &stroke, const TSegment &segment,
Shinya Kitaoka 120a6e
                    std::vector<doublepair> &intersections);</doublepair>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI int intersect(const TSegment &segment, const TStroke &stroke,
Shinya Kitaoka 120a6e
                    std::vector<doublepair> &intersections);</doublepair>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
/*!
Toshihiro Shimizu 890ddd
  Intersection between stroke.
Toshihiro Shimizu 890ddd
  \par  first stroke
Shinya Kitaoka 120a6e
  \par  second stroke
Toshihiro Shimizu 890ddd
  \par  vector for intersection
Shinya Kitaoka 120a6e
  \par  checkBBox (?)
Toshihiro Shimizu 890ddd
  \ret number of intersections
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka 120a6e
DVAPI int intersect(const TStroke *s1, const TStroke *s2,
Shinya Kitaoka 120a6e
                    std::vector<doublepair> &intersections,</doublepair>
Shinya Kitaoka 120a6e
                    bool checkBBox = true);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI int intersect(const TStroke &stroke, const TPointD ¢er, double radius,
Shinya Kitaoka 120a6e
                    std::vector<double> &intersections);</double>
Toshihiro Shimizu 890ddd
//======================================s=======================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
  To be replaced with new split
Toshihiro Shimizu 890ddd
  and a specialyzed function.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka 120a6e
DVAPI void splitStroke(const TStroke &tq, const std::vector<double> &pars,</double>
Shinya Kitaoka 120a6e
                       std::vector<tstroke *=""> &v);</tstroke>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
/* !puts in corners the indexes of quadric junctions of the stroke that create
Shinya Kitaoka 120a6e
angles greater
Toshihiro Shimizu 890ddd
than minDegree */
Shinya Kitaoka 120a6e
DVAPI void detectCorners(const TStroke *stroke, double minDegree,
Shinya Kitaoka 120a6e
                         std::vector<int> &corners);</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! retrieve stroke parameter from chunk and chunk parameter
Shinya Kitaoka 120a6e
inline double getWfromChunkAndT(const TStroke *ref, UINT chunkIndex, double t) {
Shinya Kitaoka 120a6e
  assert(ref);
Shinya Kitaoka 120a6e
  assert(ref->getChunkCount());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return (chunkIndex + t) / ref->getChunkCount();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI void computeQuadraticsFromCubic(
Shinya Kitaoka 120a6e
    const TThickPoint &p0, const TThickPoint &p1, const TThickPoint &p2,
Shinya Kitaoka 120a6e
    const TThickPoint &p3, double error,
Shinya Kitaoka 120a6e
    std::vector<tthickquadratic *=""> &chunkArray);</tthickquadratic>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TSTROKE_H