Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
hdicorePathArt.h
Go to the documentation of this file.
1
7#ifndef __HDI_CORE_PATH_ART__
8#define __HDI_CORE_PATH_ART__
9
10#if defined(HDI_CORE_AIP_MODE)
11
12#include <vector>
13
15#include "hdicorePathStyle.h"
16
17namespace hdi
18{
19 namespace core
20 {
21 class Angle;
22 class Art;
23 class Bezier;
24 class HitData;
25 class ArtboardSegPoint;
26
30 class PathArt
31 {
32 public:
33 typedef std::vector<ArtboardSegPoint> ArtboardSegPointVector;
34 typedef std::vector< std::shared_ptr<HitData> > HitDataVector;
35
39 static const int16_t maxSegments = 32000;
40
45 {
46 WindingUnknown = 0,
47 Clockwise = 1, // determined by positive area
48 CounterClockwise = 2 // determined by negative area
49 };
50
60 {
61 SegPointNotSelected = 0,
62 SegPointAnchorSelected = 1 << 0,
63 SegPointInSelected = 1 << 1,
64 SegPointOutSelected = 1 << 2,
65 SegPointAllSelected = (SegPointAnchorSelected | SegPointInSelected | SegPointOutSelected)
66 };
67
73 {
74 TrimGreaterDirectionOnly = 1 << 0,
75 TrimLesserDirectionOnly = 1 << 1,
76 TrimBothDirections = (TrimGreaterDirectionOnly | TrimLesserDirectionOnly)
77 };
78
83 {
84 NoTrimError = 0,
85 HitDataArtMustMatchTrimPathArtError = 10,
86 TrimPathIsClosedError = 20,
87 TrimPathNeedsAtLeast2PointsError = 30,
88 InvalidSourcePathForTrimming = 40
89 };
90
95 {
96 NoExtendError = 0,
97 HitDataArtMustMatchExtendPathArtError = 110,
98 NoExtendIntersectionsFoundError = 120,
99 ExtendPathEndSegmentsOnlyError = 130,
100 ExtendPathIsClosedError = 140,
101 ExtendPathNeedsAtLeast2PointsError = 150,
102 InvalidSourcePathForExtending = 160
103 };
104
111
119 bool isGuide() const;
120
128 bool closed() const;
129
137 void setClosed(const bool closed_);
138
147
155 void setStyle(const PathStyle& style_);
156
165 int16_t segCount() const;
166
174 int16_t segPointCount() const;
175
193 void setSegCount(const int16_t count_);
194
208 void setSegPointCount(const int16_t count_);
209
219 std::unique_ptr<hdi::core::Bezier> bezier(const int16_t segIndex_) const;
220
229
241 void endPoints(ArtboardPoint& start__, ArtboardPoint& end__) const;
242
253 bool hasLength() const;
254
262 double length() const;
263
273 double sublength(const int16_t startSegPt_, const int16_t endSegPt_) const;
274
286 double sublength(
287 const int16_t startSeg_,
288 const double startT_,
289 const int16_t endSeg_,
290 const double endT_
291 ) const;
292
302 double tAtLength(const int16_t segNum_, const double length_) const;
303
311 double area() const;
312
320 bool hasStraightSegs() const;
321
329 bool isStraight() const;
330
338 bool isRectangular() const;
339
347 bool isCircular() const;
348
356 bool isEllipse() const;
357
370
381 bool angle(Angle& angle__) const;
382
400 ArtboardSegPointVector segs(const int16_t segIndex_, const int16_t count_) const;
401
413 ArtboardSegPointVector segPoints(const int16_t segPtIndex_, const int16_t count_) const;
414
424 ArtboardSegPointVector phantomSeg() const;
425
435 ArtboardSegPointVector phantomSegPoints() const;
436
455 void setSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
456
470 void setSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
471
480
491 bool segSelected(const int16_t segIndex_) const;
492
516 SegPointSelectionState segPointSelected(const int16_t segPtIndex_) const;
517
528 bool setSegPointSelected(const int16_t segPtIndex_, const SegPointSelectionState selected_);
529
545 void insertSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
546
561 void insertSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
562
571 void deleteSegs(const int16_t segIndex_, const int16_t count_);
572
581 void deleteSegPoints(const int16_t segPtIndex_, const int16_t count_);
582
595 void rotateSegPoints(const int16_t delta_);
596
603
612
625 void setWindingOrder(const WindingOrderType winding_);
626
631 {
632 UnknownStrokeAlignment = 0,
633 CenterStrokeAlignment = 10,
634 InsideStrokeAlignment = 20,
635 OutsideStrokeAlignment = 30
636 };
637
648
660 void insertSegPointAtT(const int16_t segIndex_, const double t_);
661
670 int16_t segPointClosestToPoint(const ArtboardPoint& pt_) const;
671
680 bool containsPoint(const ArtboardPoint& pt_) const;
681
692 bool simplify(const double flatness_);
693
706 HitDataVector getIntersections(const int16_t max_ = 0, const bool guides_ = false) const;
707
722 HitDataVector getIntersections(
723 const Art& target_,
724 const int16_t max_ = 0,
725 const bool guides_ = false
726 ) const;
727
755 const HitData& center_,
756 const bool delete_,
757 const TrimDirectionType dir_,
758 const bool guides_,
759 Art& split__
760 );
761
780 ExtendError extend(const HitData& from_, const HitData& to_, const bool guides_);
781
782
783 private:
784 // Only Art can construct a new PathArt object
785 friend class Art;
786
790 void* __data;
791
797 PathArt();
798
806 PathArt(void* const art_);
807
813 PathArt(const PathArt&);
814
820 PathArt& operator=(const PathArt&);
821 };
822 }
823}
824
828);
829
833);
834
838);
839
843);
844
845#endif
846// HDI_CORE_AIP_MODE
847
848#endif
849// __HDI_CORE_PATH_ART__
Describes an angle, and allows for easy conversion between various units.
Definition: hdicoreAngle.h:26
Handles general art-related functionality.
Definition: hdicoreArt.h:51
Describes a point on the Illustrator artboard.
Definition: hdicoreArtboardPoint.h:31
Allows for hit data creation, metadata access, snapping, etc.
Definition: hdicoreHitData.h:32
Allows for path manipulation, metadata access, trimming, extending, etc.
Definition: hdicorePathArt.h:31
bool simplify(const double flatness_)
Attempts to reduce the number of segment points in the path by converting them to a series of points ...
void endPoints(ArtboardPoint &start__, ArtboardPoint &end__) const
Gets the end points of a path.
SegPointSelectionState segPointSelected(const int16_t segPtIndex_) const
Gets the selection state of a given segment point.
bool angle(Angle &angle__) const
Gets the angle of the path relative to the x-axis, if the path is a perfectly straight line.
StrokeAlignment
Describes how a path's stroke should be aligned.
Definition: hdicorePathArt.h:631
static const int16_t maxSegments
Maximum number of segments allowed in a path.
Definition: hdicorePathArt.h:39
void setSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_)
Sets a series of segment points in the path to new values.
ArtboardPoint centroid() const
Calculates the centroid of the path.
void setWindingOrder(const WindingOrderType winding_)
Sets the winding order of the path.
HitDataVector getIntersections(const Art &target_, const int16_t max_=0, const bool guides_=false) const
Gets path segment intersections along the target path.
PathStyle style() const
Gets the target path's style.
ArtboardSegPointVector phantomSeg() const
Gets two segment points describing the phantom segment of a path.
int16_t segCount() const
Gets the count of segments in the path, taking into account phantom segments of closed paths.
bool allSegPointsSelected() const
Gets whether all the segments points of a path are selected.
bool hasStraightSegs() const
Gets whether each individual path segment is straight.
double tAtLength(const int16_t segNum_, const double length_) const
Gets the t-value at a given length of a given path segment.
bool isGuide() const
Gets whether the path is a guide.
bool segSelected(const int16_t segIndex_) const
Gets whether a given segment is selected.
ArtboardSegPointVector segs(const int16_t segIndex_, const int16_t count_) const
Gets a series of points describing the requested path segments.
double length() const
Gets the total length of the path.
bool isStraight() const
Gets whether the entire path forms a perfectly straight line.
TrimError
Describes various errors that can occur when trimming a path.
Definition: hdicorePathArt.h:83
void deleteSegs(const int16_t segIndex_, const int16_t count_)
Deletes a given number of segments from a given segment index forward.
bool hasLength() const
Gets whether the path has any length.
void setSegs(const int16_t segIndex_, const ArtboardSegPointVector &segPts_)
Sets a series of segments in the path to new values.
void setSegCount(const int16_t count_)
Sets the count of segments in the path.
ExtendError extend(const HitData &from_, const HitData &to_, const bool guides_)
Extends a path from a given "point" to another "point".
std::unique_ptr< hdi::core::Bezier > bezier(const int16_t segIndex_) const
Gets a Bezier object for a given segment index.
bool setSegPointSelected(const int16_t segPtIndex_, const SegPointSelectionState selected_)
Sets the selection state of a given segment point.
void setStrokeAlignment(const StrokeAlignment align_)
Sets the stroke alignment for the target path.
bool isEllipse() const
Gets whether the entire path forms an ellipse.
SegPointSelectionState
Describes how an individual segment point is selected, if at all.
Definition: hdicorePathArt.h:60
bool isCircular() const
Gets whether the entire path forms a circle.
void rotateSegPoints(const int16_t delta_)
Rotates segment point indices by a given delta, while keeping the points at the same location in spac...
int16_t segPointClosestToPoint(const ArtboardPoint &pt_) const
Gets the index of the segment point that is closest to a given point in space.
bool containsPoint(const ArtboardPoint &pt_) const
Gets whether a given point is contained inside the path.
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 sublength(const int16_t startSegPt_, const int16_t endSegPt_) const
Gets the length of a subpath from one segment point to another.
ArtboardPoint midPoint() const
Gets the midpoint along a path.
void deleteSegPoints(const int16_t segPtIndex_, const int16_t count_)
Deletes a given number of segment points from a given segment point index forward.
WindingOrderType
Describes which direction the (closed) art is wound.
Definition: hdicorePathArt.h:45
WindingOrderType windingOrder() const
Gets the winding order of the path.
ArtboardSegPointVector phantomSegPoints() const
Gets the two phantom segment points.
bool isRectangular() const
Gets whether the entire path forms a rectangular shape.
void insertSegs(const int16_t segIndex_, const ArtboardSegPointVector &segPts_)
Inserts new segments into the target path at a given segment index.
void insertSegPointAtT(const int16_t segIndex_, const double t_)
"Safely" inserts a new segment point in a given segment
double area() const
Gets the area of the path.
HitDataVector getIntersections(const int16_t max_=0, const bool guides_=false) const
Gets all path segment intersections along the target path.
bool closed() const
Gets whether the target path is closed.
void setClosed(const bool closed_)
Sets whether the target path is closed.
TrimDirectionType
Describes which direction a trim should take place (to the greater, lesser, or both sides of a given ...
Definition: hdicorePathArt.h:73
ArtboardSegPointVector segPoints(const int16_t segPtIndex_, const int16_t count_) const
Gets a series of path segment points.
~PathArt()
Destructs a PathArt object.
void setSegPointCount(const int16_t count_)
Sets the count of individual segment points in the path.
int16_t segPointCount() const
Gets the count of individual segment points in the path.
void insertSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_)
Inserts new segment points into the target path after a given segment point index.
ExtendError
Describes various errors that can occur when trimming a path.
Definition: hdicorePathArt.h:95
double sublength(const int16_t startSeg_, const double startT_, const int16_t endSeg_, const double endT_) const
Gets the length of a subpath, from segment point at a t-value to another.
void setStyle(const PathStyle &style_)
Sets the target path's style.
void reverseSegs()
Reverses the winding order of the segment points in the path.
Describes all styling attributes of a path.
Definition: hdicorePathStyle.h:442
Header file for geometric point manipulation on the Illustrator artboard.
Header file for path style-related classes.