Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
hdicorePathArt.h
Go to the documentation of this file.
1 
7 #ifndef __HDI_CORE_PATH_ART__
8 #define __HDI_CORE_PATH_ART__
9 
10 #include <vector>
11 
12 #include "hdicoreArtboardPoint.h"
13 #include "hdicorePathStyle.h"
14 
15 namespace hdi
16 {
17  namespace core
18  {
19  class Angle;
20  class Art;
21  class Bezier;
22  class HitData;
23  class ArtboardSegPoint;
24 
28  class PathArt
29  {
30  public:
31  typedef std::vector<ArtboardSegPoint> ArtboardSegPointVector;
32  typedef std::vector< HitData* > HitDataVector;
33 
37  static const int16_t maxSegments = 32000;
38 
43  {
44  WindingUnknown = 0,
45  Clockwise = 1, // determined by positive area
46  CounterClockwise = 2 // determined by negative area
47  };
48 
58  {
59  SegPointNotSelected = 0,
60  SegPointAnchorSelected = 1 << 0,
61  SegPointInSelected = 1 << 1,
62  SegPointOutSelected = 1 << 2,
63  SegPointAllSelected = (SegPointAnchorSelected | SegPointInSelected | SegPointOutSelected)
64  };
65 
71  {
72  TrimGreaterDirectionOnly = 1 << 0,
73  TrimLesserDirectionOnly = 1 << 1,
74  TrimBothDirections = (TrimGreaterDirectionOnly | TrimLesserDirectionOnly)
75  };
76 
80  enum TrimError
81  {
82  NoTrimError = 0,
83  HitDataArtMustMatchTrimPathArtError = 10,
84  TrimPathIsClosedError = 20,
85  TrimPathNeedsAtLeast2PointsError = 30,
86  InvalidSourcePathForTrimming = 40
87  };
88 
93  {
94  NoExtendError = 0,
95  HitDataArtMustMatchExtendPathArtError = 110,
96  NoExtendIntersectionsFoundError = 120,
97  ExtendPathEndSegmentsOnlyError = 130,
98  ExtendPathIsClosedError = 140,
99  ExtendPathNeedsAtLeast2PointsError = 150,
100  InvalidSourcePathForExtending = 160
101  };
102 
108  ~PathArt();
109 
117  bool isGuide() const;
118 
126  bool closed() const;
127 
135  void setClosed(const bool closed_);
136 
144  PathStyle style() const;
145 
153  void setStyle(const PathStyle& style_);
154 
163  int16_t segCount() const;
164 
172  int16_t segPointCount() const;
173 
191  void setSegCount(const int16_t count_);
192 
206  void setSegPointCount(const int16_t count_);
207 
217  std::auto_ptr<hdi::core::Bezier> bezier(const int16_t segIndex_) const;
218 
226  ArtboardPoint midPoint() const;
227 
239  void endPoints(ArtboardPoint& start__, ArtboardPoint& end__) const;
240 
251  bool hasLength() const;
252 
260  double length() const;
261 
271  double sublength(const int16_t startSegPt_, const int16_t endSegPt_) const;
272 
284  double sublength(
285  const int16_t startSeg_,
286  const double startT_,
287  const int16_t endSeg_,
288  const double endT_
289  ) const;
290 
300  double tAtLength(const int16_t segNum_, const double length_) const;
301 
309  double area() const;
310 
318  bool hasStraightSegs() const;
319 
327  bool isStraight() const;
328 
336  bool isRectangular() const;
337 
345  bool isCircular() const;
346 
357  bool angle(Angle& angle__) const;
358 
376  ArtboardSegPointVector segs(const int16_t segIndex_, const int16_t count_) const;
377 
389  ArtboardSegPointVector segPoints(const int16_t segPtIndex_, const int16_t count_) const;
390 
400  ArtboardSegPointVector phantomSeg() const;
401 
411  ArtboardSegPointVector phantomSegPoints() const;
412 
431  void setSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
432 
446  void setSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
447 
455  bool allSegPointsSelected() const;
456 
467  bool segSelected(const int16_t segIndex_) const;
468 
492  SegPointSelectionState segPointSelected(const int16_t segPtIndex_) const;
493 
504  bool setSegPointSelected(const int16_t segPtIndex_, const SegPointSelectionState selected_);
505 
521  void insertSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
522 
537  void insertSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
538 
547  void deleteSegs(const int16_t segIndex_, const int16_t count_);
548 
557  void deleteSegPoints(const int16_t segPtIndex_, const int16_t count_);
558 
571  void rotateSegPoints(const int16_t delta_);
572 
578  void reverseSegs();
579 
588 
601  void setWindingOrder(const WindingOrderType winding_);
602 
603  #if HDI_CORE_COMPILE_AI17_PLUS
604 
608  {
609  UnknownStrokeAlignment = 0,
610  CenterStrokeAlignment = 10,
611  InsideStrokeAlignment = 20,
612  OutsideStrokeAlignment = 30
613  };
614 
624  void setStrokeAlignment(const StrokeAlignment align_);
625  #endif
626 
638  void insertSegPointAtT(const int16_t segIndex_, const double t_);
639 
648  int16_t segPointClosestToPoint(const ArtboardPoint& pt_) const;
649 
658  bool containsPoint(const ArtboardPoint& pt_) const;
659 
672  HitDataVector getIntersections(const bool guides_ = false) const;
673 
688  HitDataVector getIntersections(const Art& target_, const bool guides_ = false) const;
689 
716  TrimError trim(
717  const HitData& center_,
718  const bool delete_,
719  const TrimDirectionType dir_,
720  const bool guides_,
721  Art& split__
722  );
723 
742  ExtendError extend(const HitData& from_, const HitData& to_, const bool guides_);
743 
744 
745  private:
746  // Only Art can construct a new PathArt object
747  friend class Art;
748 
752  Art* __art;
753 
759  PathArt();
760 
768  PathArt(Art* const art_);
769 
775  PathArt(const PathArt&);
776 
782  PathArt& operator=(const PathArt&);
783  };
784  }
785 }
786 
790 );
791 
795 );
796 
800 );
801 
805 );
806 
807 #endif
808 // __HDI_CORE_PATH_ART__
Handles general art-related functionality.
Definition: hdicoreArt.h:47
StrokeAlignment
Describes how a path's stroke should be aligned.
Definition: hdicorePathArt.h:607
static const int16_t maxSegments
Maximum number of segments allowed in a path.
Definition: hdicorePathArt.h:37
SegPointSelectionState segPointSelected(const int16_t segPtIndex_) const
Gets the selection state of a given segment point.
int16_t segCount() const
Gets the count of segments in the path, taking into account phantom segments of closed paths...
WindingOrderType windingOrder() const
Gets the winding order of the path.
ArtboardPoint midPoint() const
Gets the midpoint along a path.
void reverseSegs()
Reverses the winding order of the segment points in the path.
void setSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_)
Sets a series of segment points in the path to new values.
int16_t segPointCount() const
Gets the count of individual segment points in the path.
WindingOrderType
Describes which direction the (closed) art is wound.
Definition: hdicorePathArt.h:42
bool allSegPointsSelected() const
Gets whether all the segments points of a path are selected.
bool angle(Angle &angle__) const
Gets the angle of the path relative to the x-axis, if the path is a perfectly straight line...
bool containsPoint(const ArtboardPoint &pt_) const
Gets whether a given point is contained inside the path.
void setStyle(const PathStyle &style_)
Sets the target path's style.
double tAtLength(const int16_t segNum_, const double length_) const
Gets the t-value at a given length of a given path segment.
Describes all styling attributes of a path.
Definition: hdicorePathStyle.h:427
TrimDirectionType
Describes which direction a trim should take place (to the greater, lesser, or both sides of a given ...
Definition: hdicorePathArt.h:70
TrimError trim(const HitData &center_, const bool delete_, const TrimDirectionType dir_, const bool guides_, Art &split__)
Trims a path around a given "center" point, either to one or both sides.
double length() const
Gets the total length of the path.
void setSegPointCount(const int16_t count_)
Sets the count of individual segment points in the path.
ArtboardSegPointVector phantomSeg() const
Gets two segment points describing the phantom segment of a path.
Allows for path manipulation, metadata access, trimming, extending, etc.
Definition: hdicorePathArt.h:28
void insertSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_)
Inserts new segment points into the target path after a given segment point index.
Allows for hit data creation, metadata access, snapping, etc.
Definition: hdicoreHitData.h:29
PathStyle style() const
Gets the target path's style.
SegPointSelectionState
Describes how an individual segment point is selected, if at all.
Definition: hdicorePathArt.h:57
bool isStraight() const
Gets whether the entire path forms a perfectly straight line.
bool isCircular() const
Gets whether the entire path forms a circle.
ArtboardSegPointVector segs(const int16_t segIndex_, const int16_t count_) const
Gets a series of points describing the requested path segments.
void setClosed(const bool closed_)
Sets whether the target path is closed.
Header file for path style-related classes.
Header file for geometric point manipulation on the Illustrator artboard.
bool isRectangular() const
Gets whether the entire path forms a rectangular shape.
double area() const
Gets the area of the path.
bool hasLength() const
Gets whether the path has any length.
void rotateSegPoints(const int16_t delta_)
Rotates segment point indices by a given delta, while keeping the points at the same location in spac...
void setSegs(const int16_t segIndex_, const ArtboardSegPointVector &segPts_)
Sets a series of segments in the path to new values.
void insertSegs(const int16_t segIndex_, const ArtboardSegPointVector &segPts_)
Inserts new segments into the target path at a given segment index.
bool hasStraightSegs() const
Gets whether each individual path segment is straight.
ArtboardSegPointVector segPoints(const int16_t segPtIndex_, const int16_t count_) const
Gets a series of path segment points.
bool isGuide() const
Gets whether the path is a guide.
bool setSegPointSelected(const int16_t segPtIndex_, const SegPointSelectionState selected_)
Sets the selection state of a given segment point.
void deleteSegs(const int16_t segIndex_, const int16_t count_)
Deletes a given number of segments from a given segment index forward.
ExtendError extend(const HitData &from_, const HitData &to_, const bool guides_)
Extends a path from a given "point" to another "point".
Definition: hdicoreaiArray.h:12
~PathArt()
Destructs a PathArt object.
ExtendError
Describes various errors that can occur when trimming a path.
Definition: hdicorePathArt.h:92
void insertSegPointAtT(const int16_t segIndex_, const double t_)
"Safely" inserts a new segment point in a given segment
void setSegCount(const int16_t count_)
Sets the count of segments in the path.
HitDataVector getIntersections(const bool guides_=false) const
Gets all path segment intersections along the target path.
void endPoints(ArtboardPoint &start__, ArtboardPoint &end__) const
Gets the end points of a path.
TrimError
Describes various errors that can occur when trimming a path.
Definition: hdicorePathArt.h:80
void deleteSegPoints(const int16_t segPtIndex_, const int16_t count_)
Deletes a given number of segment points from a given segment point index forward.
std::auto_ptr< hdi::core::Bezier > bezier(const int16_t segIndex_) const
Gets a Bezier object for a given segment index.
void setStrokeAlignment(const StrokeAlignment align_)
Sets the stroke alignment for the target path.
bool closed() const
Gets whether the target path is closed.
Describes an angle, and allows for easy conversion between various units.
Definition: hdicoreAngle.h:25
Describes a point on the Illustrator artboard.
Definition: hdicoreArtboardPoint.h:28
void setWindingOrder(const WindingOrderType winding_)
Sets the winding order of the path.
double sublength(const int16_t startSegPt_, const int16_t endSegPt_) const
Gets the length of a subpath from one segment point to another.
ArtboardSegPointVector phantomSegPoints() const
Gets the two phantom segment points.
bool segSelected(const int16_t segIndex_) const
Gets whether a given segment is selected.
int16_t segPointClosestToPoint(const ArtboardPoint &pt_) const
Gets the index of the segment point that is closest to a given point in space.