InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TransformTypes.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: psorrick
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 
25 #ifndef __TransformTypes__
26 #define __TransformTypes__
27 
28 class GeometryFacade;
29 class TransformFacade;
30 
31 
32 
33 /* This file implements type-safe enums and value objects used throughout the
34 transform and geometry API stacks. In particular:
35 
36  Type Legal values
37  Geometry::BoundsKind
38  Geometry::OuterStrokeBounds()
39  Geometry::PathBounds()
40  Geometry::PreferredBoundsKind()
41 
42  Geometry::ResizeValue
43  Geometry::MultiplyBy( Geometry::KeepCurrentValue(), y_factor)
44  Geometry::MultiplyBy( x_factor, Geometry::KeepCurrentValue())
45  Geometry::MultiplyBy( Geometry::KeepCurrentProportions(), y_factor)
46  Geometry::MultiplyBy( x_factor, Geometry::KeepCurrentProportions())
47  Geometry::MultiplyBy( x_factor, y_factor)
48 
49  Geometry::MakeTallAspectRatio()
50  Geometry::MakeWideAspectRatio()
51  Geometry::InvertAspectRatio()
52  Geometry::ReshapeArea( width_to_height_ratio)
53  Geometry::ReshapeArea( x_portion, y_portion)
54  Geometry::ReshapeBorder( width_to_height_ratio)
55  Geometry::ReshapeBorder( x_portion, y_portion)
56 
57  //the following optionally take a coordinateSpace parameter
58  Geometry::AddTo( Geometry::KeepCurrentValue(), y_delta)
59  Geometry::AddTo( x_delta, Geometry::KeepCurrentValue())
60  Geometry::AddTo( Geometry::KeepCurrentProportions(), y_delta)
61  Geometry::AddTo( x_delta, Geometry::KeepCurrentProportions())
62  Geometry::AddTo( x_delta, y_delta)
63 
64  Geometry::ResizeTo( Geometry::KeepCurrentValue(), y_value)
65  Geometry::ResizeTo( x_value, Geometry::KeepCurrentValue())
66  Geometry::ResizeTo( Geometry::KeepCurrentProportions(), y_value)
67  Geometry::ResizeTo( x_value, Geometry::KeepCurrentProportions())
68  Geometry::ResizeTo( x_value, y_value)
69 
70  Transform::CoordinateSpace
71  Transform::PasteboardCoordinates()
72  Transform::SpreadCoordinates()
73  Transform::ParentCoordinates()
74  Transform::InnerCoordinates()
75 
76  Transform::TransformOrigin
77  Transform::PasteboardLocation( x, y)
78  Transform::PasteboardLocation( PMPoint(x, y))
79  Transform::SpreadLocation( x, y)
80  Transform::SpreadLocation( PMPoint(x, y))
81  Transform::ParentLocation( x, y)
82  Transform::ParentLocation( PMPoint(x, y))
83  Transform::InnerLocation( x, y)
84  Transform::InnerLocation( PMPoint(x, y))
85  Transform::TransformLocation( x, y)
86  Transform::TransformLocation( PMPoint(x, y))
87  Transform::CurrentOrigin()
88 
89  Transform::RulerLocation( PMPoint(x, y), rulerNumber)
90  Transform::RulerLocation( PMPoint(x, y), Transform::LeftTopLocation()) //or similar
91 
92  Transform::BoundsLocation( boundsKind, x, y)
93  Transform::BoundsLocation( boundsKind, PMPoint(x, y))
94  Transform::BoundsLocation( coordinateSpace, boundsKind, x, y)
95  Transform::BoundsLocation( coordinateSpace, boundsKind, PMPoint(x, y))
96  //the following optionally take a boundsKind parameter with OuterStrokeBounds() as the default
97  Transform::LeftTopLocation()
98  Transform::LeftMiddleLocation()
99  Transform::LeftBottomLocation()
100  Transform::RightTopLocation()
101  Transform::RightMiddleLocation()
102  Transform::RightBottomLocation()
103  Transform::MiddleTopLocation()
104  Transform::MiddleBottomLocation()
105  Transform::CenterLocation()
106 
107  Transform::TransformValue
108  Transform::ScaleBy( xscale, yscale)
109  Transform::ScaleTo( xscale, yscale)
110  Transform::SkewBy( degrees)
111  Transform::SkewTo( degrees)
112  Transform::SkewBySlope( slope)
113  Transform::SkewToSlope( slope)
114  Transform::RotateBy( degrees)
115  Transform::RotateTo( degrees)
116  Transform::RotateBy( cosine, sine)
117  Transform::RotateTo( cosine, sine)
118  Transform::TranslateBy( deltaX, deltaY)
119  Transform::TranslateTo( x, y)
120  Transform::TransformBy( matrix)
121  Transform::TransformTo( matrix, matrixContent)
122 
123  Transform::Target
124  Transform::OriginalItems()
125  Transform::DuplicateItems()
126  Transform::SpreadItems()
127 
128 
129 
130 Further, the following constants are defined for use in the ITransformSuite and ITransformFacade interfaces:
131  Transform::kScaleXValue, Transform::kScaleYValue, Transform::kSkewValue, Transform::kRotationValue, Transform::kTranslationXValue, Transform::kTranslationYValue
132 
133 
134 Other constructs in this file should be considered implementation details for
135 the types and values listed above.
136 */
137 
138 
139 namespace Transform
140 {
141  /* The structs below implement type-safe enums. (For example, even using
142  * casts, you can't assign a variable of type Transform::View to an int or
143  * vice-versa. Nor can you assign an object of type Transform::View to
144  * a Transform::Action.) The transform APIs use the types to help prevent
145  * "silly" bugs that are hard to detect. See the remarks on the inlines
146  * below for sample usage.
147  */
148 
149  typedef uint32 value_type;
150  template< typename, value_type v> struct Int2Type { enum { value = v};};
151 
153  {
159 
160 
161  /*--------trickery below--------*/
162  template<value_type v> CoordinateSpace( const Int2Type<CoordinateSpace, v>&, const PMMatrix& m)
163  : base_space(v),final_space(m) { }
164  friend bool operator==( const CoordinateSpace& lhs, const CoordinateSpace& rhs) { return lhs.base_space == rhs.base_space; } //search for CoordinateCompare and Coordinate_Compare_OK
165  friend bool operator!=( const CoordinateSpace& lhs, const CoordinateSpace& rhs) { return lhs.base_space != rhs.base_space; }
166  private: value_type base_space;
167  public: PMMatrix final_space;
168  };
169  inline CoordinateSpace PasteboardCoordinates( const PMMatrix& m = PMMatrix())
171  inline CoordinateSpace SpreadCoordinates( const PMMatrix& m = PMMatrix())
172  { return CoordinateSpace( CoordinateSpace::Spread(), m);}
173  inline CoordinateSpace ParentCoordinates( const PMMatrix& m = PMMatrix())
174  { return CoordinateSpace( CoordinateSpace::Parent(), m);}
175  inline CoordinateSpace InnerCoordinates( const PMMatrix& m = PMMatrix())
176  { return CoordinateSpace( CoordinateSpace::Inner(), m);}
177  inline CoordinateSpace PageCoordinates( const PMMatrix& m = PMMatrix())
178  { return CoordinateSpace( CoordinateSpace::Page(), m);}
179 }
180 
181 
182 
183 namespace Geometry
184 {
185  typedef uint32 value_type;
186  template< typename, value_type v> struct Int2Type { enum { value = v};};
187 
189  {
195 
196 
197  /*--------trickery below--------*/
198  template<value_type v> ResizeMethod( const Int2Type<ResizeMethod, v>& ) : resize_method(v) { }
199  friend bool operator==( const ResizeMethod& lhs, const ResizeMethod& rhs) { return lhs.resize_method == rhs.resize_method; }
200  friend bool operator!=( const ResizeMethod& lhs, const ResizeMethod& rhs) { return lhs.resize_method != rhs.resize_method; }
201  private: value_type resize_method;
202  };
203 
204  inline ResizeMethod ResizeEqual() { return ResizeMethod::Equal();}
205  inline ResizeMethod ResizeAdd() { return ResizeMethod::Add();}
206  inline ResizeMethod ResizeMultiply() { return ResizeMethod::Multiply();}
207  inline ResizeMethod AspectRatioArea() { return ResizeMethod::ConstantArea();}
208  inline ResizeMethod AspectRatioBorder() { return ResizeMethod::ConstantPerimeter();}
209 
210 
211 
212 
213  struct BoundsKind
214  {
218  //not yet typedef Int2Type< BoundsKind, 0> InnerStroke;
219 
220 
221  /*--------trickery below--------*/
222  template<value_type v> BoundsKind( const Int2Type<BoundsKind, v>& ) : bounds_kind(v) { }
223  friend bool operator==( const BoundsKind& lhs, const BoundsKind& rhs) { return lhs.bounds_kind == rhs.bounds_kind; } //BoundsKindCompare
224  friend bool operator!=( const BoundsKind& lhs, const BoundsKind& rhs) { return lhs.bounds_kind != rhs.bounds_kind; }
225  private: value_type bounds_kind;
226  };
227 
228  inline BoundsKind OuterStrokeBounds() { return BoundsKind::OuterStroke();}
229  inline BoundsKind PathBounds() { return BoundsKind::Path();}
230  //not yet inline BoundsKind InnerStrokeBounds() { return BoundsKind::InnerStroke();}
231 
232  BoundsKind ResolvePreferredBounds( BoundsKind kind);
233 #if 0
234  inline BoundsKind PreferredBoundsKind(){ return ResolvePreferredBounds( BoundsKind::Preferred());} //check the pref right now!
235 #else
236  inline BoundsKind PreferredBoundsKind() { return BoundsKind::Preferred();} //be lazy--wait until the bounds kind is needed before checking the pref
237 #endif
238 
239 
240 
241 
242 
244  {
250 
251 
252  /*--------trickery below--------*/
253  template<value_type v> ResizeConstraint( const Int2Type<ResizeConstraint, v>& ) : resize_constraint(v) { }
254  friend bool operator==( const ResizeConstraint& lhs, const ResizeConstraint& rhs) { return lhs.resize_constraint == rhs.resize_constraint; }
255  friend bool operator!=( const ResizeConstraint& lhs, const ResizeConstraint& rhs) { return lhs.resize_constraint != rhs.resize_constraint; }
256  private: value_type resize_constraint;
257  };
258 
259  inline ResizeConstraint IgnoreCurrentProportions() { return ResizeConstraint::IgnoreProportions();} //Dismiss, Release ...?
260  inline ResizeConstraint KeepCurrentProportions() { return ResizeConstraint::KeepProportions();} //Retain, Preserve ...?
261  inline ResizeConstraint KeepCurrentValue() { return ResizeConstraint::IgnoreProportions();}
262  inline ResizeConstraint MakeTallAspect() { return ResizeConstraint::TallProportions();}
263  inline ResizeConstraint MakeWideAspect() { return ResizeConstraint::WideProportions();}
264  inline ResizeConstraint InvertAspect() { return ResizeConstraint::InverseProportions();}
265 
266  enum ValueSource { kValueProvided, kValueCalculated};
268  {
269  ResizeValue();
270  public:
271  Transform::CoordinateSpace provided_coordinates;
272  ResizeMethod method;
273  ResizeConstraint constraint;
274  ValueSource x_source;
275  ValueSource y_source;
276  ValueSource coordinates_source;
277  PMReal provided_x;
278  PMReal provided_y;
279 
280  ResizeValue( ResizeMethod method_, ResizeConstraint constraint_,
281  ValueSource x_source_, PMReal provided_x_,
282  ValueSource y_source_, PMReal provided_y_,
283  ValueSource coordinates_source_, const Transform::CoordinateSpace& provided_coordinates_
284  ) : method(method_), constraint(constraint_),
285  x_source(x_source_), provided_x(provided_x_),
286  y_source(y_source_), provided_y(provided_y_),
287  coordinates_source(coordinates_source_), provided_coordinates(provided_coordinates_)
288  {}
289  };
290 
291 
292  inline ResizeValue AddTo( ResizeConstraint constrainX, PMReal y_delta)
293  {
294  return ResizeValue( ResizeAdd(), constrainX, kValueCalculated, 0, kValueProvided, y_delta, kValueCalculated, Transform::InnerCoordinates());
295  }
296 
297  inline ResizeValue AddTo( ResizeConstraint constrainX, PMReal y_delta, const Transform::CoordinateSpace& coordinateSpace)
298  {
299  return ResizeValue( ResizeAdd(), constrainX, kValueCalculated, 0, kValueProvided, y_delta, kValueProvided, coordinateSpace);
300  }
301 
302 
303  inline ResizeValue AddTo( PMReal x_delta, ResizeConstraint constrainY)
304  {
305  return ResizeValue( ResizeAdd(), constrainY, kValueProvided, x_delta, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
306  }
307 
308  inline ResizeValue AddTo( PMReal x_delta, ResizeConstraint constrainY, const Transform::CoordinateSpace& coordinateSpace)
309  {
310  return ResizeValue( ResizeAdd(), constrainY, kValueProvided, x_delta, kValueCalculated, 0, kValueProvided, coordinateSpace);
311  }
312 
313 
314  inline ResizeValue AddTo( PMReal x_delta, PMReal y_delta)
315  {
316  return ResizeValue( ResizeAdd(), IgnoreCurrentProportions(), kValueProvided, x_delta, kValueProvided, y_delta, kValueCalculated, Transform::InnerCoordinates());
317  }
318 
319  inline ResizeValue AddTo( PMReal x_delta, PMReal y_delta, const Transform::CoordinateSpace& coordinateSpace)
320  {
321  return ResizeValue( ResizeAdd(), IgnoreCurrentProportions(), kValueProvided, x_delta, kValueProvided, y_delta, kValueProvided, coordinateSpace);
322  }
323 
324 
325  inline ResizeValue MultiplyBy( ResizeConstraint constrainX, PMReal y_factor)
326  {
327  return ResizeValue( ResizeMultiply(), constrainX, kValueCalculated, y_factor, kValueProvided, y_factor, kValueCalculated, Transform::InnerCoordinates()); //question do we pass proportional down or calc proportion here?
328  }
329 
330  inline ResizeValue MultiplyBy( PMReal x_factor, ResizeConstraint constrainY)
331  {
332  return ResizeValue( ResizeMultiply(), constrainY, kValueProvided, x_factor, kValueCalculated, x_factor, kValueCalculated, Transform::InnerCoordinates()); //see note above
333  }
334 
335  inline ResizeValue MultiplyBy( PMReal x_factor, PMReal y_factor)
336  {
337  return ResizeValue( ResizeMultiply(), IgnoreCurrentProportions(), kValueProvided, x_factor, kValueProvided, y_factor, kValueCalculated, Transform::InnerCoordinates());
338  }
339 
340 
341  inline ResizeValue ResizeTo( ResizeConstraint constrainX, PMReal y_value)
342  {
343  return ResizeValue( ResizeEqual(), constrainX, kValueCalculated, 0, kValueProvided, y_value, kValueCalculated, Transform::InnerCoordinates());
344  }
345 
346  inline ResizeValue ResizeTo( ResizeConstraint constrainX, PMReal y_value, const Transform::CoordinateSpace& coordinateSpace)
347  {
348  return ResizeValue( ResizeEqual(), constrainX, kValueCalculated, 0, kValueProvided, y_value, kValueProvided, coordinateSpace);
349  }
350 
351 
352  inline ResizeValue ResizeTo( PMReal x_value, ResizeConstraint constrainY)
353  {
354  return ResizeValue( ResizeEqual(), constrainY, kValueProvided, x_value, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
355  }
356 
357  inline ResizeValue ResizeTo( PMReal x_value, ResizeConstraint constrainY, const Transform::CoordinateSpace& coordinateSpace)
358  {
359  return ResizeValue( ResizeEqual(), constrainY, kValueProvided, x_value, kValueCalculated, 0, kValueProvided, coordinateSpace);
360  }
361 
362 
363  inline ResizeValue ResizeTo( PMReal x_value, PMReal y_value)
364  {
365  return ResizeValue( ResizeEqual(), IgnoreCurrentProportions(), kValueProvided, x_value, kValueProvided, y_value, kValueCalculated, Transform::InnerCoordinates());
366  }
367 
368  inline ResizeValue ResizeTo( PMReal x_value, PMReal y_value, const Transform::CoordinateSpace& coordinateSpace)
369  {
370  return ResizeValue( ResizeEqual(), IgnoreCurrentProportions(), kValueProvided, x_value, kValueProvided, y_value, kValueProvided, coordinateSpace);
371  }
372 
373 
374 
375 
376  inline ResizeValue ReshapeArea( ResizeConstraint orientation)
377  {
378  return ResizeValue( AspectRatioArea(), orientation, kValueCalculated, 0, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
379  }
380 
381  inline ResizeValue ReshapeArea( PMReal width_to_height_ratio)
382  {
383  return ResizeValue( AspectRatioArea(), IgnoreCurrentProportions(), kValueProvided, width_to_height_ratio, kValueProvided, 1, kValueCalculated, Transform::InnerCoordinates());
384  }
385 
386  inline ResizeValue ReshapeArea( PMReal x_portion, PMReal y_portion)
387  {
388  return ResizeValue( AspectRatioArea(), IgnoreCurrentProportions(), kValueProvided, x_portion, kValueProvided, y_portion, kValueCalculated, Transform::InnerCoordinates());
389  }
390 
391 
392  inline ResizeValue ReshapeBorder( ResizeConstraint orientation)
393  {
394  return ResizeValue( AspectRatioBorder(), orientation, kValueCalculated, 0, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
395  }
396 
397  inline ResizeValue ReshapeBorder( PMReal width_to_height_ratio)
398  {
399  return ResizeValue( AspectRatioBorder(), IgnoreCurrentProportions(), kValueProvided, width_to_height_ratio, kValueProvided, 1, kValueCalculated, Transform::InnerCoordinates());
400  }
401 
402  inline ResizeValue ReshapeBorder( PMReal x_portion, PMReal y_portion)
403  {
404  return ResizeValue( AspectRatioBorder(), IgnoreCurrentProportions(), kValueProvided, x_portion, kValueProvided, y_portion, kValueCalculated, Transform::InnerCoordinates());
405  }
406 
407  inline ResizeValue MakeTallAspectRatio()
408  {
409  return ReshapeArea( Geometry::MakeTallAspect()); //ReshapeBorder would have the same effect
410  }
411 
412  inline ResizeValue MakeWideAspectRatio()
413  {
414  return ReshapeArea( Geometry::MakeWideAspect()); //ReshapeBorder would have the same effect
415  }
416 
417  inline ResizeValue InvertAspectRatio()
418  {
419  return ReshapeArea( Geometry::InvertAspect()); //ReshapeBorder would have the same effect
420  }
421 
422 
423 } //namespace Geometry
424 
425 
426 
427 namespace Transform
428 {
429 
430  struct Target
431  {
435 
436  /*--------trickery below--------*/
437  template<value_type v> Target( const Int2Type<Target, v>& ) : transform_target(v) { }
438  friend bool operator==( const Target& lhs, const Target& rhs) { return lhs.transform_target == rhs.transform_target; }
439  friend bool operator!=( const Target& lhs, const Target& rhs) { return lhs.transform_target != rhs.transform_target; }
440  private: value_type transform_target;
441  };
442 
443  struct Action
444  {
455 
456  /*--------trickery below--------*/
457  template<value_type v> Action( const Int2Type< Action, v>& ) : transform_action(v) { }
458  friend bool operator==( const Action& lhs, const Action& rhs) { return lhs.transform_action == rhs.transform_action; }
459  friend bool operator!=( const Action& lhs, const Action& rhs) { return lhs.transform_action != rhs.transform_action; }
460  private: value_type transform_action;
461  };
462 
463 
464  /* Note these inlines below serve two purposes.
465  * First they are more convenient to use.
466  * use: ScaleSelection(.... Transform::ScaleBy().....)
467  * instead of: ScaleSelection(.... Transform::Action::ScaleBy().....)
468  *
469  * Second they work with the ?: tertiary operator.
470  * works: absolute ? Transform::ScaleTo() : Transform::ScaleBy()
471  * doesn't work: absolute ? Transform::Action::ScaleTo() : Transform::Action::ScaleBy()
472  */
473 
474  inline Target OriginalItems() { return Target::OriginalItems();}
475  inline Target DuplicateItems() { return Target::DuplicateItems();}
476  inline Target SpreadItems() { return Target::SpreadItems();}
477 
478  inline Action ScaleBy() { return Action::ScaleBy();}
479  inline Action ScaleTo() { return Action::ScaleTo();}
480  inline Action SkewBy() { return Action::SkewBy();}
481  inline Action SkewTo() { return Action::SkewTo();}
482  inline Action RotateBy() { return Action::RotateBy();}
483  inline Action RotateTo() { return Action::RotateTo();}
484  inline Action TranslateBy() { return Action::TranslateBy();}
485  inline Action TranslateTo() { return Action::TranslateTo();}
486  inline Action TransformBy() { return Action::TransformBy();}
487  inline Action TransformTo() { return Action::TransformTo();}
488 
489 
491  {
495 
496 
497  /*--------trickery below--------*/
498  template<value_type v> LocationSpace( const Int2Type<LocationSpace, v>& ) : location_space(v) { }
499  friend bool operator==( const LocationSpace& lhs, const LocationSpace& rhs)
500  { return lhs.location_space == rhs.location_space;}
501  friend bool operator!=( const LocationSpace& lhs, const LocationSpace& rhs) { return lhs.location_space != rhs.location_space; }
502  private: value_type location_space;
503  };
504 
505 
507  {
508  TransformOrigin();
509  public:
510  CoordinateSpace coordinateSpace;
511  LocationSpace locationSpace;
512  Geometry::BoundsKind boundsKind;
513  PMPoint originLocation, pageLocator;
514  //in TransformSpace case, a non-zero altValue means ignore coordinateSpace member and use coordinates specified in param list
515  //in RulerSpace case, (altValue/2) non-zero means use the (altValue/2)th rulers on the spread, otherwise use BoundsSpace(), coordinateSpace, boundsKind, pageLocator to figure which spread rulers to use
516  //in BoundsSpace case, a non-zero altValue means use inner coordinates for a single item and pasteboard coordinates for multiple items, otherwise use bounding box aligned with the specified coordinate system
517  uint32 altValue, pageAltValue;
518 
519  TransformOrigin( const CoordinateSpace& coordinates, const PMPoint& location)
520  : locationSpace( LocationSpace::TransformSpace()),
521  originLocation(location),
522  altValue(0), //use CoordinateSpace provided in this constructor
523  coordinateSpace( coordinates),
524  //ignored members...
525  boundsKind(Geometry::PathBounds()), //always ignored for TransformSpace
526  pageLocator( PMPoint(0,0)), //always ignored for TransformSpace
527  pageAltValue(0) //always ignored when not RulerSpace
528  {}
529 
530  TransformOrigin( const PMPoint& location) //MPSIssue kill this constructor and make callers use Transform::PasteboardLocation( PBPMPoint p)
531  : locationSpace( LocationSpace::TransformSpace()),
532  originLocation(location),
533  altValue(0), //use CoordinateSpace provided in this constructor
534  coordinateSpace( PasteboardCoordinates()),
535  //ignored members...
536  boundsKind(Geometry::PathBounds()), //always ignored for TransformSpace
537  pageLocator( PMPoint(0,0)), //always ignored for TransformSpace
538  pageAltValue(0) //always ignored when not RulerSpace
539  {}
540 
541  TransformOrigin( const PMPoint& location, char* )
542  : locationSpace( LocationSpace::TransformSpace()),
543  originLocation(location),
544  altValue(1), //use the same CoordinateSpace already provided elsewhere in the parameter list of the client function
545  //ignored members...
546  coordinateSpace( InnerCoordinates()), //ignored when altValue is non-zero
547  boundsKind(Geometry::PathBounds()), //always ignored for TransformSpace
548  pageLocator( PMPoint(0,0)), //always ignored for TransformSpace
549  pageAltValue(0) //always ignored when not RulerSpace
550  {}
551 
552 
553  TransformOrigin( const CoordinateSpace& coordinates, Geometry::BoundsKind bounds, const PMPoint& location)
554  : locationSpace( LocationSpace::BoundsSpace()),
555  boundsKind( bounds),
556  originLocation( location),
557  altValue(0), //use coordinate space provided no matter how many items are being transformed
558  coordinateSpace( coordinates),
559  //ignored members...
560  pageLocator( PMPoint(0,0)), //always ignored for BoundsSpace
561  pageAltValue(0) //always ignored when not RulerSpace
562  {}
563 
564  TransformOrigin( Geometry::BoundsKind bounds, const PMPoint& location)
565  : locationSpace( LocationSpace::BoundsSpace()),
566  boundsKind( bounds),
567  originLocation( location),
568  altValue(1), //use inner coordinates for a single item and pasteboard coordinates for multiple items
569  coordinateSpace( PasteboardCoordinates()), //when altValue is non-zero, use PasteboardCoordinates() for multiple items case
570  //ignored members...
571  pageLocator( PMPoint(0,0)), //always ignored for BoundsSpace
572  pageAltValue(0) //always ignored when not RulerSpace
573  {}
574 
575 
576  TransformOrigin( const PMPoint& location, uint32 spreadRuler, bool16 useRulerUnits = false)
577  : locationSpace( LocationSpace::RulerSpace()),
578  originLocation( location),
579  altValue( (2*spreadRuler) + (useRulerUnits ? 1 : 0)), // 0 means originLocation is in points, 1 means use current ruler units for the page
580  //ignored members...
581  coordinateSpace( InnerCoordinates()), //ignored when altValue is non-zero
582  boundsKind( Geometry::PathBounds()), //ignored when altValue is non-zero
583  pageLocator( PMPoint(0,0)), //ignored when altValue is non-zero
584  pageAltValue(0) //ignored when altValue is non-zero
585  {
586  ASSERT( spreadRuler != 0);
587  }
588 
589  TransformOrigin( const PMPoint& location, const TransformOrigin& pageFinder, bool16 useRulerUnits = false)
590  : locationSpace( LocationSpace::RulerSpace()),
591  originLocation( location),
592  altValue( useRulerUnits ? 1 : 0), // 0 means originLocation is in points, 1 means use current ruler units for the page
593  coordinateSpace( pageFinder.coordinateSpace),
594  boundsKind( pageFinder.boundsKind),
595  pageLocator( pageFinder.originLocation),
596  pageAltValue( pageFinder.altValue)
597  //no ignored members
598  {
599  ASSERT( pageFinder.locationSpace == LocationSpace::BoundsSpace());
600  }
601 
602 
603 // friend bool operator==( const TransformOrigin& lhs, const TransformOrigin& rhs) //XFIssue stronger test than necessary //CoordinateCompare
604 // { return lhs.locationSpace == rhs.locationSpace
605 // && lhs.coordinateSpace == rhs.coordinateSpace
606 // && lhs.boundsKind == rhs.boundsKind
607 // && lhs.originLocation == rhs.originLocation
608 // && lhs.pageLocator == rhs.pageLocator
609 // && lhs.altValue == rhs.altValue
610 // && lhs.pageAltValue == rhs.pageAltValue;
611 // }
612 // friend bool operator!=( const TransformOrigin& lhs, const TransformOrigin& rhs) { return !(lhs == rhs); }
613  };
614 
615  inline TransformOrigin PasteboardLocation( PMPoint l)
616  {
617  return TransformOrigin( PasteboardCoordinates(), l);
618  }
619  inline TransformOrigin PasteboardLocation( PMReal x, PMReal y)
620  {
621  return PasteboardLocation( PMPoint(x,y));
622  }
623  inline TransformOrigin SpreadLocation( PMPoint l)
624  {
625  return TransformOrigin( SpreadCoordinates(), l);
626  }
627  inline TransformOrigin SpreadLocation( PMReal x, PMReal y)
628  {
629  return SpreadLocation( PMPoint(x,y));
630  }
631  inline TransformOrigin ParentLocation( PMPoint l)
632  {
633  return TransformOrigin( ParentCoordinates(), l);
634  }
635  inline TransformOrigin ParentLocation( PMReal x, PMReal y)
636  {
637  return ParentLocation( PMPoint(x,y));
638  }
639  inline TransformOrigin InnerLocation( PMPoint l)
640  {
641  return TransformOrigin( InnerCoordinates(), l);
642  }
643  inline TransformOrigin InnerLocation( PMReal x, PMReal y)
644  {
645  return InnerLocation( PMPoint(x,y));
646  }
647  inline TransformOrigin TransformLocation( PMPoint l)
648  {
649  return TransformOrigin( l, (char*)0/*dummy*/);
650  }
651  inline TransformOrigin TransformLocation( PMReal x, PMReal y)
652  {
653  return TransformLocation( PMPoint(x,y));
654  }
655  inline TransformOrigin CurrentOrigin()
656  {
657  return TransformLocation( 0,0);
658  }
659 
660 
661  inline TransformOrigin RulerLocation( PMPoint l, uint32 spreadRuler, bool16 useRulerUnits = false)
662  {
663  return TransformOrigin( l, spreadRuler, useRulerUnits);
664  }
665  inline TransformOrigin RulerLocation( PMPoint l, const TransformOrigin& boundsLocation, bool16 useRulerUnits = false)
666  {
667  return TransformOrigin( l, boundsLocation, useRulerUnits);
668  }
669 
670 
671  inline TransformOrigin BoundsLocation( const CoordinateSpace& coordinates, Geometry::BoundsKind boundsKind, PMPoint l)
672  {
673  return TransformOrigin( coordinates, boundsKind, l);
674  }
675  inline TransformOrigin BoundsLocation( const CoordinateSpace& coordinates, Geometry::BoundsKind boundsKind, PMReal x, PMReal y)
676  {
677  return BoundsLocation( coordinates, boundsKind, PMPoint(x,y));
678  }
679  inline TransformOrigin BoundsLocation( Geometry::BoundsKind boundsKind, PMPoint l)
680  {
681  return TransformOrigin( boundsKind, l);
682  }
683  inline TransformOrigin BoundsLocation( Geometry::BoundsKind boundsKind, PMReal x, PMReal y)
684  {
685  return BoundsLocation( boundsKind, PMPoint(x,y));
686  }
687 
688 
689  inline TransformOrigin LeftTopLocation( Geometry::BoundsKind boundsKind)
690  {
691  return BoundsLocation( boundsKind, 0.0, 0.0);
692  }
693  inline TransformOrigin MiddleTopLocation( Geometry::BoundsKind boundsKind)
694  {
695  return BoundsLocation( boundsKind, 0.5, 0.0);
696  }
697  inline TransformOrigin RightTopLocation( Geometry::BoundsKind boundsKind)
698  {
699  return BoundsLocation( boundsKind, 1.0, 0.0);
700  }
701  inline TransformOrigin LeftMiddleLocation( Geometry::BoundsKind boundsKind)
702  {
703  return BoundsLocation( boundsKind, 0.0, 0.5);
704  }
705  inline TransformOrigin CenterLocation( Geometry::BoundsKind boundsKind)
706  {
707  return BoundsLocation( boundsKind, 0.5, 0.5);
708  }
709  inline TransformOrigin RightMiddleLocation( Geometry::BoundsKind boundsKind)
710  {
711  return BoundsLocation( boundsKind, 1.0, 0.5);
712  }
713  inline TransformOrigin LeftBottomLocation( Geometry::BoundsKind boundsKind)
714  {
715  return BoundsLocation( boundsKind, 0.0, 1.0);
716  }
717  inline TransformOrigin MiddleBottomLocation( Geometry::BoundsKind boundsKind)
718  {
719  return BoundsLocation( boundsKind, 0.5, 1.0);
720  }
721  inline TransformOrigin RightBottomLocation( Geometry::BoundsKind boundsKind)
722  {
723  return BoundsLocation( boundsKind, 1.0, 1.0);
724  }
725 
726 
727 
728 
730  {
731  TransformValue();
732  public:
733  PMMatrix transformMatrix;
734  Action transformAction;
735  uint32 matrixContent;
736 
737  TransformValue( Action action, const PMMatrix& matrix, uint32 content)
738  : transformAction(action), transformMatrix(matrix), matrixContent(content)
739  {}
740  };
741 
742 
743  inline TransformValue TransformBy( const PMMatrix& m)
744  {
745  return TransformValue( TransformBy(), m, 0);
746  }
747 
748  inline TransformValue TransformTo( const PMMatrix& m, uint32 matrixContent)
749  {
750  return TransformValue( TransformTo(), m, matrixContent);
751  }
752 
753  inline TransformValue ScaleBy( PMReal xscale, PMReal yscale)
754  {
755  return TransformValue( ScaleBy(), PMMatrix( xscale, 0, 0, yscale, 0, 0), 0);
756  }
757 
758  inline TransformValue ScaleTo( PMReal xscale, PMReal yscale)
759  {
760  return TransformValue( ScaleTo(), PMMatrix( xscale, 0, 0, yscale, 0, 0), PMMatrix::kHasScaleContent);
761  }
762 
763  inline TransformValue SkewBy( PMReal degrees)
764  {
765  PMMatrix m;
766  m.SkewHorizontal( -degrees); //XFIssue LH coordinates
767  return TransformValue( SkewBy(), m, 0);
768  }
769 
770  inline TransformValue SkewTo( PMReal degrees)
771  {
772  PMMatrix m;
773  m.SkewHorizontal( -degrees); //XFIssue LH coordinates
774  return TransformValue( SkewTo(), m, PMMatrix::kHasSkewContent);
775  }
776 
777  inline TransformValue SkewBySlope( PMReal k)
778  {
779  return TransformValue( SkewBy(), PMMatrix( 1, 0, -k, 1, 0, 0), 0); //XFIssue LH coordinates
780  }
781 
782  inline TransformValue SkewToSlope( PMReal k)
783  {
784  return TransformValue( SkewTo(), PMMatrix( 1, 0, -k, 1, 0, 0), PMMatrix::kHasSkewContent); //XFIssue LH coordinates
785  }
786 
787  inline TransformValue RotateBy( PMReal degrees)
788  {
789  PMMatrix m;
790  m.Rotate( -degrees); //XFIssue LH coordinates
791  return TransformValue( RotateBy(), m, 0);
792  }
793 
794  inline TransformValue RotateTo( PMReal degrees)
795  {
796  PMMatrix m;
797  m.Rotate( -degrees); //XFIssue LH coordinates
798  return TransformValue( RotateTo(), m, PMMatrix::kHasRotateContent);
799  }
800 
801  inline TransformValue RotateBy( PMReal cosine, PMReal sine)
802  {
803  return TransformValue( RotateBy(), PMMatrix( cosine, -sine, sine, cosine, 0, 0), 0); //XFIssue LH coordinates
804  }
805 
806  inline TransformValue RotateTo( PMReal cosine, PMReal sine)
807  {
808  return TransformValue( RotateTo(), PMMatrix( cosine, -sine, sine, cosine, 0, 0), PMMatrix::kHasRotateContent); //XFIssue LH coordinates
809  }
810 
811  inline TransformValue TranslateBy( PMReal deltaX, PMReal deltaY)
812  {
813  return TransformValue( TranslateBy(), PMMatrix( 1, 0, 0, 1, deltaX, deltaY), 0);
814  }
815 
816  inline TransformValue TranslateBy( PMPoint delta)
817  {
818  return TranslateBy( delta.X(), delta.Y());
819  }
820 
821  inline TransformValue TranslateTo( PMReal x, PMReal y)
822  {
823  return TransformValue( TranslateTo(), PMMatrix( 1, 0, 0, 1, x, y), PMMatrix::kHasTranslateContent);
824  }
825 
826  inline TransformValue TranslateTo( PMPoint p)
827  {
828  return TranslateTo( p.X(), p.Y());
829  }
830 
831 
832  const uint32 kNoTransformValues = 0;
833  const uint32 kScaleXValue = 1;
834  const uint32 kScaleYValue = 2;
835  const uint32 kScaleValue = kScaleXValue | kScaleYValue;
836  const uint32 kSkewValue = 4;
837  const uint32 kRotationValue = 8;
838  const uint32 kTranslationXValue = 16;
839  const uint32 kTranslationYValue = 32;
840  const uint32 kTranslationValue = kTranslationXValue | kTranslationYValue;
841  const uint32 kAllTransformValues = kScaleValue | kSkewValue | kRotationValue | kTranslationValue;
842 
843 
850  struct ScaleMethod
851  {
855 
856 
857  /*--------trickery below--------*/
858  template<value_type v> ScaleMethod( const Int2Type<ScaleMethod, v>& ) : scale_method(v) { }
859  friend bool operator==( const ScaleMethod& lhs, const ScaleMethod& rhs) { return lhs.scale_method == rhs.scale_method; }
860  friend bool operator!=( const ScaleMethod& lhs, const ScaleMethod& rhs) { return lhs.scale_method != rhs.scale_method; }
861  private: value_type scale_method;
862  };
863  inline ScaleMethod UseLensScaling() { return ScaleMethod::LensScaling();}
864  inline ScaleMethod UseContentScaling() { return ScaleMethod::ContentScaling();}
865  inline ScaleMethod ConsultScalingPreference() { return ScaleMethod::ScalingPreference();}
866 
867 
868 
869 } //namespace Transform
870 
871 
872 
873 
874 
875 
876 #endif // __TransformTypes__
877 
878