InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IPathInfoUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Bernd Paradies
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 __IPathInfoUtils__
25 #define __IPathInfoUtils__
26 
27 #include "GenericID.h"
28 #include "IPMUnknown.h"
29 #include "Utils.h"
30 
31 #include "PMLine.h"
32 #include "PMPoint.h"
33 #include "TransformTypes.h"
34 
35 
36 
37 class UIDList;
38 class IGeometry;
39 class IPathGeometry;
40 class IPathInfoUtils;
41 
42 // PathInfo is used to analyze a list of objects to determine if they form a point or straight line
43 
44 class PathInfo
45 {
46 public:
47 
48 
49  inline PathInfo():
50  fSomePath(kTrue),
51  fPointsAreCoLinear(kFalse),
52  fPointA(),
53  fPointB()
54  {
55  }
56 
57 
58  inline bool16 IsStraightLine() const;
59  // Points are colinear and there is some visible path
60  // i.e. 0----0 0 is considered a line but 0 0 0 is not
61 
62  inline bool16 IsVerticalLine() const;
63 
64  inline bool16 IsHorizontalLine() const;
65 
66  inline PMLine GetLine() const;
67  // Call IsStraightLine() first
68 
69  inline bool16 IsPoint() const;
70 
71  inline PMPoint GetPoint() const; //no callers
72  // call IsPoint() first
73 
74  inline bool16 PointsAreCoLinear() const;
75 
76  // True for points or lines
77 
78  inline PathInfo Combine(const PathInfo& pathInfo1, const PathInfo& pathInfo2) const;
79 
80 
81 private:
82  friend class PathInfoUtils;
83 
84  PMPoint fPointA; // First anchor point
85  PMPoint fPointB; // Last anchor point
86  bool16 fPointsAreCoLinear; // True if all points, including control points are the same or on the same line
87  bool16 fSomePath; // True if 1 or more paths has width or height > 0.
88 };
89 
90 
91 
95 class IPathInfoUtils : public IPMUnknown
96 {
97 public:
98  enum { kDefaultIID = IID_IPATHINFOUTILS };
99 
100  virtual bool16 IsStraightLine( const PathInfo& pathInfo ) const = 0;
101  // Points are colinear and there is some visible path
102  // i.e. 0----0 0 is considered a line but 0 0 0 is not
103 
104  virtual bool16 IsVerticalLine( const PathInfo& pathInfo ) const = 0;
105  virtual bool16 IsHorizontalLine( const PathInfo& pathInfo ) const = 0;
106  virtual PMLine GetLine( const PathInfo& pathInfo ) const = 0; // Call IsStraightLine() first
107 
108  virtual bool16 IsPoint( const PathInfo& pathInfo ) const = 0;
109  virtual PMPoint GetPoint( const PathInfo& pathInfo ) const = 0; // call IsPoint() first //no callers
110 
111  virtual bool16 PointsAreCoLinear( const PathInfo& pathInfo ) const = 0;
112  // True for points or lines
113 
114  virtual bool16 IsEqual( const PathInfo& pathInfo1, const PathInfo& pathInfo2 ) const = 0;
115 
116 
117  // Line testing. (Used by Transform Panel to detect lines, and show Length
118  // rather than width and height
119 
120 
121  virtual PathInfo GetPathInfo(IPathGeometry* pathGeometry, const PMMatrix* matrix = nil) const = 0;
122  // Determines whether all points of all paths of the specified path geometry
123  // are on the same straight line. A matrix value of nil means use pasteboard coordinates.
124 
125  virtual PathInfo GetPathInfo(IGeometry* geometry, const PMMatrix* matrix = nil) const = 0;
126  // Determines whether all points of all paths of the specified geometry
127  // are on the same straight line. Should work for guides and other non-path
128  // geometries with 0 width or height A matrix value of nil means use pasteboard coordinates.
129 
130  virtual PathInfo GetPathInfo(const UIDList& items, const Transform::CoordinateSpace& coordinateSpace = Transform::PasteboardCoordinates()) const = 0;
131  // Determines whether all points of all paths of the specified items
132  // are on the same straight line. If any item does not have a path geometry
133  // PathInfo.fIsStraightLine will be false. All items must have coordinateSpace as
134  // a common parent for the result to have any useful meaning. Thus if
135  // coordinateSpace == InnerCoordinates(), the list can contain only contain one item.
136  // If coordinateSpace == SpreadCoordinates() or ParentCoordinates(), the items must
137  // all be on the same spread. If coordinateSpace == PageCoordinates, the items must
138  // all be on the same page.
139 
140  virtual bool16 IsVerticalLine(IGeometry* pageItem) const = 0; //in inner coordinates
141 
142  virtual bool16 IsHorizontalLine(IGeometry* pageItem) const = 0; //in inner coordinates
143 
144  virtual bool16 IsPoint(IGeometry* pageItem) const = 0;
145 };
146 
147 inline bool16 operator ==(const PathInfo& a, const PathInfo& b)
148 {
149  return Utils<IPathInfoUtils>()->IsEqual( a, b );
150 }
151 
152 inline bool16 operator !=(const PathInfo& a, const PathInfo& b)
153 {
154  return !Utils<IPathInfoUtils>()->IsEqual( a, b );
155 }
156 
157 inline bool16 PathInfo::IsStraightLine() const { return Utils<IPathInfoUtils>()->IsStraightLine( *this ); }
158 inline bool16 PathInfo::IsVerticalLine() const { return Utils<IPathInfoUtils>()->IsVerticalLine( *this ); }
159 inline bool16 PathInfo::IsHorizontalLine() const { return Utils<IPathInfoUtils>()->IsHorizontalLine( *this ); }
160 inline PMLine PathInfo::GetLine() const { return Utils<IPathInfoUtils>()->GetLine( *this ); }
161 inline bool16 PathInfo::IsPoint() const { return Utils<IPathInfoUtils>()->IsPoint( *this ); }
162 inline PMPoint PathInfo::GetPoint() const { return Utils<IPathInfoUtils>()->GetPoint( *this ); }
163 inline bool16 PathInfo::PointsAreCoLinear() const { return Utils<IPathInfoUtils>()->PointsAreCoLinear( *this ); }
164 
165 
166 #endif // __IPathInfoUtils__