Hot Door CORE 0.8.3
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
403 ArtboardSegPointVector segs(
404 const int16_t segIndex_,
405 const int16_t count_,
406 const bool wrap_ = false
407 ) const;
408
423 ArtboardSegPointVector segPoints(
424 const int16_t segPtIndex_,
425 const int16_t count_,
426 const bool wrap_ = false
427 ) const;
428
438 ArtboardSegPointVector phantomSeg() const;
439
449 ArtboardSegPointVector phantomSegPoints() const;
450
469 void setSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
470
484 void setSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
485
494
505 bool segSelected(const int16_t segIndex_) const;
506
530 SegPointSelectionState segPointSelected(const int16_t segPtIndex_) const;
531
542 bool setSegPointSelected(const int16_t segPtIndex_, const SegPointSelectionState selected_);
543
559 void insertSegs(const int16_t segIndex_, const ArtboardSegPointVector& segPts_);
560
575 void insertSegPoints(const int16_t segPtIndex_, const ArtboardSegPointVector& segPts_);
576
585 void deleteSegs(const int16_t segIndex_, const int16_t count_);
586
595 void deleteSegPoints(const int16_t segPtIndex_, const int16_t count_);
596
609 void rotateSegPoints(const int16_t delta_);
610
617
626
639 void setWindingOrder(const WindingOrderType winding_);
640
645 {
646 UnknownStrokeAlignment = 0,
647 CenterStrokeAlignment = 10,
648 InsideStrokeAlignment = 20,
649 OutsideStrokeAlignment = 30
650 };
651
662
674 void insertSegPointAtT(const int16_t segIndex_, const double t_);
675
684 int16_t segPointClosestToPoint(const ArtboardPoint& pt_) const;
685
694 bool containsPoint(const ArtboardPoint& pt_) const;
695
706 bool simplify(const double flatness_);
707
720 HitDataVector getIntersections(const int16_t max_ = 0, const bool guides_ = false) const;
721
736 HitDataVector getIntersections(
737 const Art& target_,
738 const int16_t max_ = 0,
739 const bool guides_ = false
740 ) const;
741
769 const HitData& center_,
770 const bool delete_,
771 const TrimDirectionType dir_,
772 const bool guides_,
773 Art& split__
774 );
775
794 ExtendError extend(const HitData& from_, const HitData& to_, const bool guides_);
795
796
797 private:
798 // Only Art can construct a new PathArt object
799 friend class Art;
800
804 void* __data;
805
811 PathArt();
812
820 PathArt(void* const art_);
821
827 PathArt(const PathArt&);
828
834 PathArt& operator=(const PathArt&);
835 };
836 }
837}
838
842);
843
847);
848
852);
853
857);
858
859#endif
860// HDI_CORE_AIP_MODE
861
862#endif
863// __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:645
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.
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.
ArtboardSegPointVector segPoints(const int16_t segPtIndex_, const int16_t count_, const bool wrap_=false) const
Gets a series of path segment points.
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 segs(const int16_t segIndex_, const int16_t count_, const bool wrap_=false) const
Gets a series of points describing the requested path segments.
~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.