InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StrokeBoundsOutlineInfo.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: jargast
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __StrokeBoundsOutlineInfo__
25 #define __StrokeBoundsOutlineInfo__
26 
27 #include "IOutlineInfo.h"
28 #include "PMPoint.h"
29 #include "PMRect.h"
30 #include "PMMatrix.h"
31 #include "PMBezierCurve.h"
32 
33 const int32 kSegmentWindow = 3;
34 
35 class IPathEndStroker;
36 
37 
51 {
52 public:
66  (
67  const PMReal& strokeWeight,
68  const PMReal& miterLimit,
69  int32 joinType,
70  int32 lineCap,
71  const PMMatrix& xForm,
72  IGraphicStyleDescriptor* styleDescriptor
73  );
74 
81 
85  virtual void BeginPath();
86 
90  virtual void EndPath();
91 
98  virtual void moveto(const PMReal& x, const PMReal& y);
99 
108  virtual void lineto(const PMReal& x, const PMReal& y);
109 
125  virtual void curveto(const PMReal& x1, const PMReal& y1, const PMReal& x2, const PMReal& y2, const PMReal& x3, const PMReal& y3);
126 
137  virtual void closepath();
138 
139 private:
141 
142 private:
143  // Compute the bounds of the one and only segment
144  void ComputeSingleSegmentBoundsWithEnds();
145 
146  // Compute the first segment bounds and include an end calculation
147  // at the beginning
148  void ComputeFirstSegmentBoundsWithEnd();
149 
150  // Compute the last segment bounds and include an end calculation
151  // at the end. This assumes the segment to miter with is
152  // fNumSegments - 1
153  void ComputeLastSegmentBoundsWithEnd();
154 
155  // Compute the given segment bounds. Will use whichsegment - 1 as the segment
156  // to miter to
157  void ComputeSegmentBounds (int32 whichSegment);
158 
159  // Compute a single closed segment bounds. There is only one segment in this
160  // case and no end calculations
161  void ComputeSingleSegmentBounds();
162 
163  // Compute the first segment bounds assuming the path is closed. Use the last segment
164  // to miter with
165  void ComputeFirstSegmentBounds();
166 
167  // Compute the bounds of the Bezier
168  void ComputeBezierBounds(PMPoint* ptList);
169 
170  // Compute the bounds of the line
171  void ComputeLineBounds(const PMPoint& P0, const PMPoint& P1);
172 
173  // Compute the miter point
174  void ComputeMiterBounds
175  (
176  PMPoint* B,
177  int32 segmentType,
178  int32 previousSegment
179  );
180 
181  // Compute the miter point
182  void ComputeRoundJoinBounds
183  (
184  PMPoint* B,
185  int32 segmentType,
186  int32 previousSegment
187  );
188 
189  // Compute the bbox for the starting path end
190  void ComputeStartPathEnd (PMPoint* ptList, int32 segType);
191 
192  // Compute the bbox for the ending path end
193  void ComputeEndPathEnd (PMPoint* ptList, int32 segType);
194 
195  // Single method that both of the above call. Passes in start pt and end pt
196  void ComputePathEnd (const PMPoint& Pfrom, const PMPoint& Pto);
197 
198  // Compute bounds at the given param location
199  void ComputeCurveBounds (const PMBezierCurve& bezCurve, const PMReal& u);
200 
201 private:
202  IGraphicStyleDescriptor* fStyleDescriptor;
203 
204  PMPoint fFirstSegmentStorage[4];
205  int32 fFirstSegmentType;
206 
207  PMPoint fSegmentStorage[kSegmentWindow][4]; // Three segments, each having up to 4 points
208  int32 fSegmentType[kSegmentWindow];
209 
210  int32 fNumSegments;
211 
212  PMReal fLastX, fLastY;
213  PMReal fFirstX, fFirstY;
214 
215  // The following values comprise the bounds
216  PMRect fBounds;
217 
218  bool16 fBoundsSet;
219 
220  bool16 fStartedWithMoveTo;
221  bool16 fComputeBoundsForFirstSegment;
222  bool16 fComputeBoundsForLastSegment;
223 
224  PMMatrix fXform;
225  PMMatrix fStrokeMat;
226  bool16 fIsMatrixIdentity;
227 
228  int32 fJoinType;
229  int32 fLineCap;
230  PMReal fMiterLimit;
231 
232  PMReal fStrokeWeight;
233  PMReal fHalfStrokeWeight;
234  PMReal fXStrokeWeight;
235  PMReal fYStrokeWeight;
236 
237  // temp storage for line methods
238  PMPoint fP0, fP1, fP2, fP3;
239 
240  // temp storage for curve methods
241  PMBezierCurve fCurve1, fCurve2;
242 };
243 
244 
245 #endif
246