InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IGeometry.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Jeff Argast
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 // Purpose of Interface:
24 // IGeometry is designed to be a "geometry independent" way of defining
25 // an object, meaning that nothing in the interface makes any assumption as
26 // to the item being rectangular, linear, etc.
27 //
28 // PageItems are defined by one or more points. It is up to the implementer to
29 // decide how to interpret these point in order to get a BoundingBox, etc.
30 // As a convenience there are two sets of methods, one for bounding box
31 // with stroke and one for bounding box without stroke. For certain pageitems,
32 // such as images, the path bounds and stroke bounds will be the same.
33 //
34 // Note: IGeometry does NOT draw. IShape is used for drawing and is implemented in
35 // terms of IGeometry.
36 //
37 // IGeometry is a required interface of page items.
38 //
39 //========================================================================================
40 
41 #ifndef __IGeometry__
42 #define __IGeometry__
43 
44 #include "IPMUnknown.h"
45 #include "PMReal.h"
46 #include "PMPoint.h"
47 #include "PMRect.h"
48 #include "PMMatrix.h"
49 #include "GraphicsID.h"
50 #include "TransformTypes.h"
51 
68 class IGeometry : public IPMUnknown
69 {
70 public:
71  enum { kDefaultIID = IID_IGEOMETRY };
72 
80  virtual PMRect GetStrokeBoundingBox(const PMMatrix& theMatrix) const = 0;
81 
88  virtual PMRect GetStrokeBoundingBox() const = 0;
89 
97  virtual ErrorCode SetStrokeBoundingBox(const PMRect& newBBox /*, SetAction whichAction*/) = 0;
98 
107  virtual ErrorCode SetStrokeBoundingBox(const PMMatrix& theMatrix, const PMRect& newBBox/*, SetAction whichAction*/) = 0;
108 
116  virtual PMRect GetPathBoundingBox(const PMMatrix& theMatrix) const = 0;
117 
123  virtual PMRect GetPathBoundingBox() const = 0;
124 
132  virtual ErrorCode SetPathBoundingBox(const PMRect& newBBox/*, SetAction whichAction*/) = 0;
133 
142  virtual ErrorCode SetPathBoundingBox(const PMMatrix& theMatrix, const PMRect& newBBox/*, SetAction whichAction*/) = 0;
143 
149  virtual PMReal GetStrokeProportion() const = 0;
150 
156  virtual PMReal GetPathProportion() const = 0;
157 
158 
159 
160  //These will need to be reworked when Geometry::InnerStrokeBounds() is added
161  PMRect GetBoundingBox( Geometry::BoundsKind kind, const PMMatrix& theMatrix) const
162  {
163  kind = Geometry::ResolvePreferredBounds( kind);
164  if( kind == Geometry::PathBounds()){ //BoundsKindCompare
165  return GetPathBoundingBox( theMatrix);
166  }else if( kind == Geometry::OuterStrokeBounds()){
167  return GetStrokeBoundingBox( theMatrix);
168  }else{
169  ASSERT_UNIMPLEMENTED();
170  return PMRect();
171  }
172  }
173 
174  PMRect GetBoundingBox( Geometry::BoundsKind kind) const
175  {
176  kind = Geometry::ResolvePreferredBounds( kind);
177  if( kind == Geometry::PathBounds()){ //BoundsKindCompare
178  return GetPathBoundingBox();
179  }else if( kind == Geometry::OuterStrokeBounds()){
180  return GetStrokeBoundingBox();
181  }else{
182  ASSERT_UNIMPLEMENTED();
183  return PMRect();
184  }
185  }
186 
187  ErrorCode SetBoundingBox( Geometry::BoundsKind kind, const PMRect& newBBox)
188  {
189  kind = Geometry::ResolvePreferredBounds( kind);
190  if( kind == Geometry::PathBounds()){ //BoundsKindCompare
191  return SetPathBoundingBox( newBBox);
192  }else if( kind == Geometry::OuterStrokeBounds()){
193  return SetStrokeBoundingBox( newBBox);
194  }else{
195  ASSERT_UNIMPLEMENTED();
196  return kFailure;
197  }
198  }
199 
200  ErrorCode SetBoundingBox( Geometry::BoundsKind kind, const PMMatrix& theMatrix, const PMRect& newBBox)
201  {
202  kind = Geometry::ResolvePreferredBounds( kind);
203  if( kind == Geometry::PathBounds()){ //BoundsKindCompare
204  return SetPathBoundingBox( theMatrix, newBBox);
205  }else if( kind == Geometry::OuterStrokeBounds()){
206  return SetStrokeBoundingBox( theMatrix, newBBox);
207  }else{
208  ASSERT_UNIMPLEMENTED();
209  return kFailure;
210  }
211  }
212 
213 };
214 
215 
216 #endif