wxArt2D
restrict.h
Go to the documentation of this file.
1 /*! \file wx/canvas/restrict.h
2  \brief snapping engine, for snapping while editing a drawing
3  \author Michael Sögtrop
4  \date Created 10/27/2003
5 
6  Copyright: 2003-2004 (c) Michael Sögtrop
7 
8  Licence: wxWidgets Licence
9 
10  RCS-ID: $Id: restrict.h,v 1.22 2008/09/05 19:01:10 titato Exp $
11 */
12 
13 #ifndef __RESTRICT_H__
14 #define __RESTRICT_H__
15 
16 #ifndef WX_PRECOMP
17 #include "wx/wx.h"
18 #endif
19 
20 #include "wx/general/smrtptr.h"
21 #include "wx/general/gen.h"
22 #include "wx/artbase/artglob.h"
23 #include "wx/canvas/candefs.h"
24 
25 //! mask for a2dSnapToWhat flags
26 typedef wxUint32 a2dSnapToWhatMask;
27 
28 //!Restriction engine for editing restrictions like snapping
29 /*!
30  The restriction engine is used by editing tools to restrict/snap editing
31  of points, handles, pins, segments to the same things in other objects or
32  to a grid on the whole drawing area. We call the object which needs to be snapped the source,
33  while the object and points to which we want to snap the targets.
34  When the source is a single vertex, the is no extra feature to be set.
35  But if the source is a a2dCanvasObject, one can specify which features in it can be snapped to.
36  This set by a2dSnapToWhat flags in m_snapSourceFeatures.
37  For the targets, there are in general more options, set by a2dSnapToWhat flags in m_snapTargetFeatures.
38 
39  With rational snapping is meant snapping to angles whose tangent is a rational
40  number with a small integer nominatior and denominator. The max
41  nominator/denominator is the snapping parameter. For slanting angles,
42  the absolute slanting angle (that is angle to the coordinate axis) is used,
43  not the slanting angle relative to the rotated coordinate system. With
44  rational snapping, you can solve many problems of slant and angle snapping,
45  where you want to snap also to the horizontal and vertical grid. If we snap
46  to angles with a small rational tangent, the resulting points will also snap to
47  a small fraction of the horizontal or vertical grid.
48 
49  Each of these snapping modes may be enabled separately.
50 
51  What snapping features in the targets need to be enabled in this specific case is in several cases set
52  by the parameter called sourceRequired. The member m_snapTargetFeatures contains the default target snapping
53  features which are enabled, and the sourceRequired is indicating what the source object (point, canvasobject),
54  requires to be enabled in that. m_snapSourceFeatures stays the same, and is only indicating
55  what vertexes/features will be snapped, taking them from the input source object (point/canvas object).
56  IOW The source canvas object in e.g the dragtool, can decide/require to which vertexes in the target
57  objects it wants to snap. It does not always make sense to snap to all enabled target features.
58  This way one can enable it central, and a tool use/require it in a local manner.
59 
60  A same approach could be implemented for the source objects, meaning enabling/disabling m_snapSourceFeatures
61  parts when calling restrict on a source, but sofar there was no need for it.
62 
63  An example menu handler to enable/disable snapping:
64 
65  \code
66  void MyDrawFrm::OnDrawRasterSnap(wxCommandEvent &event)
67  {
68  if( event.IsChecked() )
69  {
70  a2dRestrictionEngine
71  *restrict=new a2dRestrictionEngine();
72  restrict->SetSnapGrid(20,20);
73  restrict->SetRotationAngle(15);
74  restrict->SetSnapTargetFeatures( snapToGridPos |
75  snapToObjectPos | snapToPinsUnconnected |
76  snapToObjectVertexes | snapToPointAngleMod );
77 
78  a2dCanvasGlobals->SetRestrictionEngine(restrict);
79  }
80  else
81  {
82  a2dCanvasGlobals->SetRestrictionEngine(0);
83  }
84  }
85  \endcode
86 
87 */
88 class A2DCANVASDLLEXP a2dRestrictionEngine : public a2dObject
89 {
90  DECLARE_EVENT_TABLE()
91 
92 public:
93  //! Constructor
95 
96  //! Destructor
98 
99  //! Flags for defining to what should be snapped to.
100  //! To the drawing/snapping grid, and inside other a2dCanvasObject's
102  {
103  snapToNone = 0x00000000, //!< no snap to modes specified
104  snapToObjectPosX = 0x00000001, //!< perform x position snapping
105  snapToObjectPosY = 0x00000002, //!< perform y position snapping
106 
107  snapToObjectPos = snapToObjectPosX | snapToObjectPosY,
108 
109  snapToStart = 0x00000100, //!< snap start point of line
110  snapToEnd = 0x00000200, //!< snap end point of line
111  snapToPins = 0x00000400, //!< snap to pins in other objects
112  snapToPinsUnconnected
113  = 0x00000800, //!< snap to pins in other objects when not connected
114  snapToObjectIntersection
115  = 0x00001000, //!< snap to intersections in other objects
116  snapToObjectVertexes
117  = 0x00002000, //!< snap to other objects its vertexes, which are decided in a2dCanvasObject::RestrictToObject()
118  snapToObjectSegmentsMiddle
119  = 0x00004000, //!< snap segments middle of other objects in a2dCanvasObject::RestrictToObject()
120  snapToObjectSegments
121  = 0x00008000, //!< snap segments of other objects in a2dCanvasObject::RestrictToObject()
122 
123  snapToGridPosX = 0x00010000, //!< perform x grid snapping
124  snapToGridPosY = 0x00020000, //!< perform y grid snapping
125  snapToGridPos = snapToGridPosX | snapToGridPosY,
126 
127  snapToPointPosX = 0x00040000, //!< perform x position snapping to a specific point
128  snapToPointPosY = 0x00080000, //!< perform y position snapping to a specific point
129  snapToPointPosXorY = 0x00100000, //!< perform snapping to X or Y of a specific point
130  snapToPointPosXorYForce = 0x00200000, //!< perform alligning to X or Y of a specific point
131  snapToPointPos = snapToPointPosX | snapToPointPosY,
132 
133  snapToPointAngleMod = 0x00400000, //!< perform angle snapping to multiples of m_rotationAngle to a specific point
134  snapToPointAngleRational = 0x00800000, //!< perform rational angle snapping to a specific point
135  snapToPointAngle = snapToPointAngleMod | snapToPointAngleRational,
136 
137  snapToBoundingBox = 0x01000000, //!< perform snapping to boundingbox of objects
138 
139  snapToObjectSnapVPath = 0x02000000, //!< perform snapping to snapping vector path returned by a2dCanvasObject::GetSnapVpath()
140 
141  snapToGridPosForced = 0x04000000, //!< If no other snap point was closer, force to grid, even if not within threshold.
142 
143  snapToAll = 0xFFFFFFFF //! mask to allow all possible snapping modes.
144 
145  };
146 
147  friend a2dSnapToWhat operator | ( a2dSnapToWhat a, a2dSnapToWhat b ) {return ( a2dSnapToWhat ) ( ( int )a | ( int )b );}
148 
149  //! Set snapping grid (only position)
150  void SetSnapGrid( const a2dDoMu& x, const a2dDoMu& y ) {m_snapDistX = x; m_snapDistY = y; SetInternal(); SignalChange(); }
151 
152  //! Get horizontal center snapping distance (zero if disabled)
153  const a2dDoMu& GetSnapGridX() const {return m_snapDistX; }
154 
155  //! Get vertical center snapping distance (zero if disabled)
156  const a2dDoMu& GetSnapGridY() const {return m_snapDistY; }
157 
158  //! Set snapping origin (position grid offest/shift)
159  void SetSnapOrigin( const a2dDoMu& x, const a2dDoMu& y ) {m_originX = x; m_originY = y; SetInternal(); SignalChange(); }
160 
161  void SetSnapOriginX( const a2dDoMu& x ) { m_originX = x; SetInternal(); SignalChange(); }
162  void SetSnapOriginY( const a2dDoMu& y ) { m_originY = y; SetInternal(); SignalChange(); }
163 
164  //! Get snapping origin X (position grid offset/shift)
165  const a2dDoMu& GetSnapOriginX() const {return m_originX;}
166 
167  //! Get snapping origin Y (position grid offset/shift)
168  const a2dDoMu& GetSnapOriginY() const {return m_originY;}
169 
170  //! Set rotation angle raster
171  void SetRotationAngle( double a ) {m_rotationAngle = a; SignalChange(); }
172 
173  //! Get rotation angle raster
174  double GetRotationAngle() const { return m_rotationAngle; }
175 
176  //! used to snap vertexes to a pin or point like snapping features in objects.
177  int GetSnapThresHold() const { return m_snapThresHold; }
178 
179  //! used to snap vertexes to a pin or point like snapping features in objects.
180  void SetSnapThresHold( int thresHold ) { m_snapThresHold = thresHold; SignalChange(); }
181 
182  //! used to snap vertexes to a pin or point, for snapping features in objects.
183  /*!
184  Calculated from m_snapThresHold, taking into account the active a2dCanvasView.
185  */
186  double GetSnapThresHoldWorld() const;
187 
188  //! enable all snapping features or not
189  void SetSnap( bool snap ) { m_snap = snap; SignalChange(); }
190 
191  //! enable all snapping features or not
192  bool GetSnap() const {return m_snap;}
193 
194  //! enable all snapping features for object only for visible object.
195  void SetSnapOnlyVisibleObjects( bool snapOnlyVisbleObjects ) { m_snapOnlyVisbleObjects = snapOnlyVisbleObjects; SignalChange(); }
196 
197  //! all snapping features for object only for visible object?
198  bool GetSnapOnlyVisibleObjects() const { return m_snapOnlyVisbleObjects; }
199 
200  //! Set rotation rational raster nominator/denominator mask
201  /*!
202  nomMask bitX / denMask bit Y present an angle in radians to which can be snapped.
203  e.g. if bit 2 is set in nomMask, and bit 6 is set in denMask, we will have 1/5 snap to 2*PI/5
204 
205  \param nomMask each bit set here presents a number (bit1 number 0 until bit32 number 31)
206  \param denMask each bit set here presents a number (bit1 number 0 until bit32 number 31)
207  */
208  void SetRotationRational( wxUint32 nomMask, wxUint32 denMask )
209  {
210  m_rotationRationalNom = nomMask; m_rotationRationalDen = denMask; SignalChange();
211  }
212 
213  //! set what snapping features or enabled for the source to snap to.
214  //! see a2dSnapToWhat for snapping features.
215  void SetSnapSourceFeatures( wxUint32 snapSourceFeatures ) { m_snapSourceFeatures = snapSourceFeatures; SignalChange(); }
216 
217  //! set one of the snapping features for the source to true or false, leaf others as is
218  void SetSnapSourceFeature( a2dSnapToWhat snapSourceFeature, bool value = true )
219  {
220  m_snapSourceFeatures = value ? m_snapSourceFeatures | snapSourceFeature :
221  m_snapSourceFeatures & ( snapToAll ^ snapSourceFeature );
222  SignalChange();
223  }
224 
225  //! set what snapping features or enabled for the source to snap to.
226  //! see a2dSnapToWhat for snapping features.
227  a2dSnapToWhatMask GetSnapSourceFeatures() const { return m_snapSourceFeatures; }
228 
229  //! set what snapping features or enabled for the target to snap to.
230  //! see a2dSnapToWhat for snapping features.
231  void SetSnapTargetFeatures( wxUint32 snapTargetFeatures ) { m_snapTargetFeatures = snapTargetFeatures; SignalChange(); }
232 
233  //! set one of the snapping features for targets to true or false, leaf others as is
234  void SetSnapTargetFeature( a2dSnapToWhat snapTargetFeature, bool value = true )
235  {
236  m_snapTargetFeatures = value ? m_snapTargetFeatures | snapTargetFeature :
237  m_snapTargetFeatures & ( snapToAll ^ snapTargetFeature );
238  SignalChange();
239  }
240 
241  //! return the setting of a specific snapping feature
242  bool GetSnapTargetFeature( a2dSnapToWhat snapTargetFeature ) const
243  {
244  return ( m_snapTargetFeatures & snapTargetFeature ) > 0;
245  }
246 
247  //! set what snapping features or enabled for the target to snap to.
248  //! see a2dSnapToWhat for snapping features.
249  a2dSnapToWhatMask GetSnapTargetFeatures() const { return m_snapTargetFeatures; }
250 
251  //! return the clossest vertex which can be snapped if any.
252  /*!
253  The source a2dCanvasObject is asked for its snapping features/vertexes via a2dCanvasObject::GetSnapVpath(),
254  but only those ementioned in m_snapSourceFeatures. All the features returned will be tried to snap to neighbouring
255  canvas objects, and eventually the grid. e.g. It calls for each vertex in the snapping path the function RestrictPoint(),
256  and the clossest snapped point will be snapped to.
257 
258  \param object object to be snapped to other snapping targets
259  \param point if a point to snap is found, it is stored here.
260  \param dx x distance from the returned point to the snapping point.
261  \param dy y distance from the returned point to the snapping point.
262  \param sourceRequired what the caller wants the snapping points in the object to restrict to. ( is ANDed with m_snapTargetFeatures )
263  \param ignoreEngine set to ignore engine its own snap modes.
264  */
265  virtual bool RestrictCanvasObjectAtVertexes( a2dCanvasObject* object, a2dPoint2D& point, double& dx, double& dy, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
266 
267  //! return the clossest vertex which can be snapped if any.
268  /*!
269  \param segments segments to be snapped to other snapping targets
270  \param point if a point to snap is found, it is stored here.
271  \param dx x distance from the returned point to the snapping point.
272  \param dy y distance from the returned point to the snapping point.
273  \param sourceRequired what the caller wants the snapping points to restrict to. ( is ANDed with m_snapTargetFeatures )
274  \param ignoreEngine set to ignore engine its own snap modes.
275  */
276  virtual bool RestrictVertexes( a2dVertexArray* segments, a2dPoint2D& point, double& dx, double& dy, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
277 
278  //! return the clossest vertex which can be snapped if any.
279  /*!
280  \param lsegments segments to be snapped to other snapping targets
281  \param point if a point to snap is found, it is stored here.
282  \param dx x distance from the returned point to the snapping point.
283  \param dy y distance from the returned point to the snapping point.
284  \param sourceRequired what the caller wants the snapping points to restrict to. ( is ANDed with m_snapTargetFeatures )
285  \param ignoreEngine set to ignore engine its own snap modes.
286  */
287  virtual bool RestrictVertexes( a2dVertexList* lsegments, a2dPoint2D& point, double& dx, double& dy, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
288 
289  //! Restrict a single point of a line or polyline
290  /*!
291  The input point( x,y ) is snapped to the targets, being:
292  - all child canvasobjects of m_parentObject by pins (connected or not).
293  - all child canvasobjects of m_parentObject object vertexes.
294  - all child canvasobjects of m_parentObject using a snap vector path, returned by object.
295  - snap to grid
296  Which features in the tragets can be snapped to, depends on sourceRequired.
297 
298  \param x input x and output x after restriction
299  \param y input y and output y after restriction
300  \param sourceRequired what the caller wants the (x,y) to restrict to inside the targets.
301  ( is ANDed with m_snapTargetFeatures )
302  \param ignoreEngine set to ignore engine its own snap modes.
303 
304  \return true if the point was restricted
305  */
306  virtual bool RestrictPoint( double& x, double& y, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
307 
308  //! Restrict a single line
309  /*!
310  \param line the line to restrict
311  \param sourceRequired what the caller wants the (x,y) to restrict to. ( is ANDed with m_snapTargetFeatures )
312  \param ignoreEngine set to ignore engine its own snap modes.
313 
314  \return true if the point was restricted
315  */
316  virtual bool RestrictLine( a2dLine& line, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
317 
318  //! Restrict angle
319  /*!
320  \param ang input angle and output angle after restriction
321  \param sourceRequired what the caller wants the (x,y) to restrict to. ( is ANDed with m_snapTargetFeatures )
322  \param ignoreEngine set to ignore engine its own snap modes.
323 
324  \return true if the point was restricted
325  */
326  virtual bool RestrictAngle( double* ang, wxUint32 sourceRequired = snapToAll, bool ignoreEngine = false );
327 
328  //! sets the point for snapping to
329  /*!
330  In modes:
331  - a2dSnapToWhat::snapToPointPos
332  - a2dSnapToWhat::snapToPointPosX
333  - a2dSnapToWhat::snapToPointPosY
334  - a2dSnapToWhat::snapToPointPos
335  - a2dSnapToWhat::snapToPointPosXorY
336  */
337  void SetRestrictPoint( double xSnap, double ySnap ) { m_pointToRestrictTo = a2dPoint2D( xSnap, ySnap ); SignalChange(); }
338 
339  //! to ask engine for the restrict point
340  /*!
341  For snapping modes that restrict to X,Y of the restrict Point.
342  */
343  const a2dPoint2D& GetRestrictPoint() const { return m_pointToRestrictTo; }
344 
345  //! to ask engine for the point that needs to be snapped to a a2dCanvasObject
346  /*!
347  When engine is asked to snap a vertex/point, the result point to snap is set.
348  This can be used by e.g. a2dCanvasObject::RestrictToObject() to snap to pins etc.
349  */
350  a2dPoint2D GetPointToSnap() const { return m_pointToSnap; }
351 
352  //! set the point that was snapped to a a2dCanvasObject vertex
353  /*!
354  When engine is asked to snap a vertex/point, the result point is set here.
355  This is used e.g. a2dCanvasObject::RestrictToObject() to snap to pins etc.
356  */
357  void SetPointSnapResult( const a2dPoint2D& p );
358 
359  //! check if point is within threshold to m_pointToSnap
360  bool IsWithInThresHold( const a2dPoint2D& p );
361 
362  //! to ask engine for the line that needs to be snapped to a a2dCanvasObject
363  /*!
364  When engine is asked to snape a line, the line to snap is set.
365  This can be used by e.g. a2dCanvasObject::RestrictToObject() to snap to other lines, pins etc.
366  */
367  a2dLine& GetLineToSnap() { return m_lineToSnap; }
368 
369  //! parent object of objects that need to be snapped to
370  /*!
371  For snapping features where canvas objects are involved, this needs to be set to the
372  parent object of the objects which can be snaped or can be snapped to.
373  For example when needing to snap a vertex/point to the objects in a a2dcanvasView,
374  set this parent object to the a2dcanvasView::GetShowObject().
375 
376  \remark when using the restriction engine, you much make sure this is set right each time.
377 
378  \param obj: pointer to object to set as parent
379  */
380  void SetParentSnapObjects( a2dCanvasObject* obj ) { m_parentObject = obj; }
381 
382  //! return pointer of the current parent object
383  /*!
384  \return: pointer to the current parent object.
385  */
386  a2dCanvasObject* GetParentSnapObjects() const { return m_parentObject; }
387 
388 
389  //! some snapping may depend on shift key being down
390  void SetShiftKeyDown( bool shiftDown ) { m_shiftDown = shiftDown;}
391 
392  //! some snapping may depend on shift key being down
393  bool GetShiftKeyDown() const { return m_shiftDown; }
394 
395  //! do not snap if set
396  void SetReleaseSnap( bool releaseSnap ) { m_releaseSnap = releaseSnap;}
397 
398  //! do not snap if set
399  bool GetReleaseSnap() const { return m_releaseSnap; }
400 
401  //! react on activation of a view, to set snap margin
402  //void OnActivate( a2dViewEvent& viewevent );
403 
404 private:
405  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
406 
407 
408 #if wxART2D_USE_CVGIO
409  virtual void DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) ) { wxASSERT( 0 ); }
410  virtual void DoLoad( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) ) { wxASSERT( 0 ); }
411 #endif //wxART2D_USE_CVGIO
412 
413 protected:
414 
415  void SignalChange();
416 
417  void SetInternal();
418 
419  //! Restrict an angle
420  double AngleRestrict( double angle );
421  //! Restrict the angle of a vector, keeping the vectors length
422  void AngleRestrictVectorRot( double* vecx, double* vecy );
423  //! Restrict the angle of a vector, keeping the vectors projection on the orthogonal of another vector
424  void AngleRestrictVectorSkew( double* vecx, double* vecy, double otherx, double othery );
425 
426  //! Rational restrict an angle
427  double RationalRestrict( double angle );
428  //! Rational restrict the angle of a vector
429  void RationalRestrictVector( double* vecx, double* vecy );
430 
431  //! set to the a2dSnapToWhat features enabled by the engine for the source object
433 
434  //! set to the a2dSnapToWhat target features enabled by the engine and/or snap source object
436 
437  a2dDoMu m_snapDistX; //!< horizontal position snapping grid distance
438  a2dDoMu m_snapDistY; //!< vertical position snapping grid distance
439  a2dDoMu m_originX; //!< horizontal grid snapping origin vs. coordinate origin
440  a2dDoMu m_originY; //!< vertical grid snapping origins vs. coordinate origin
441  double m_rotationAngle; //!< angle snapping angle in degrees
442  wxUint32 m_rotationRationalNom; //!< bit map of possible nominators (bit1->0.. bit32->31) for rational angle snapping
443  wxUint32 m_rotationRationalDen; //!< bit map of possible denominators (bit1->0.. bit32->31) for rational angle snapping
444  double* m_angleList; //!< sorted list of allowed rational angles
445  int m_nAngleList; //!< number of allowed rational angles
446 
447  //! threshold in pixels towards the snapping point.
449 
450  //! set to point that is currently being snapped.
452 
453  //! set to point that is snapped to m_pointToSnap
455 
456  a2dPoint2D m_pointToRestrictTo;
457 
458  a2dLine m_lineToSnap;
459 
460  bool m_snapOnlyVisbleObjects; //!< if true snapping modes for object is only on visible object.
461  bool m_snap; //!< if true snapping modes are enabled, else non.
462  bool m_releaseSnap; //!< to not snap inside snapping engine.
463  bool m_shiftDown; //!< snapping modifier when shift key is pressed
464 
465  //! parent canvas object in a2dCanvasDocument on which snapping needs to be done.
467 
468  double m_docSnapDistX;
469  double m_docSnapDistY;
470  double m_docOriginX;
471  double m_docOriginY;
472 
473 public:
474 
475  static a2dPropertyIdUint32* PROPID_SnapSourceFeaturesMem;
476  static a2dPropertyIdUint32* PROPID_SnapSourceFeatures;
477  static a2dPropertyIdUint32* PROPID_SnapTargetFeatures;
478  static a2dPropertyIdDouble* PROPID_RotationAngle;
479  static a2dPropertyIdUint32* PROPID_RotationRationalNom;
480  static a2dPropertyIdUint32* PROPID_RotationRationalDen;
481  static a2dPropertyIdInt32* PROPID_SnapThresHold;
482  static a2dPropertyIdPoint2D* PROPID_PointToSnap;
483  static a2dPropertyIdPoint2D* PROPID_PointToRestrictTo;
484  static a2dPropertyIdBool* PROPID_SnapOnlyVisbleObjects;
485  static a2dPropertyIdBool* PROPID_Snap;
486  static a2dPropertyIdBool* PROPID_SnapGetSet;
487  static a2dPropertyIdBool* PROPID_AltDown;
488  static a2dPropertyIdBool* PROPID_ShiftDown;
489 
490  static const a2dSignal sig_changed;
491 
493 };
494 
495 //! Smart pointer type for restriction engine
496 #if defined(WXART2D_USINGDLL)
497 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dRestrictionEngine>;
498 #endif
499 typedef a2dSmrtPtr<a2dRestrictionEngine> a2dRestrictionEnginePtr;
500 
501 
502 
503 
504 
505 
506 
507 
508 
509 
510 //! DEPRECATED Restriction engine for editing restrictions like snapping
511 /*!
512 The restriction engine is used by editing tools to restrict editing
513 of points and affine transformations.
514 
515 - For affine transformations, the following restrictions are implemented
516 
517  -# Snapping of position
518  -# Snapping of the size
519  -# Snapping of the rotation in frations of a full rotation or rational
520  snapping.
521  -# Snapping of the slanting angles in fractions of a full rotation or
522  rational snapping
523  -# Minimum and maximum size
524 
525  With rational snapping i mean snapping to angles whose tangent is a rational
526  number with a small integer nominatior and denominator. The max
527  nominator/denominator is the snapping parameter. For slanting angles,
528  the absolute slanting angle (that is angle to the coordinate axis) is used,
529  not the slanting angle relative to the rotated coordinate system. With
530  rational snapping, you can solve many problems of slant and angle snapping,
531  where you want to snap also to the horizontal and vertical grid. If we snap
532  to angles with a small rational tan, the resulting points will also snap to
533  a small fraction of the horiontal or vertical grid.
534 
535 - For position snapping of affine transformations, any of the 4 corner,
536  4 midline or the center point can snap to a grid. Each point can be enabled
537  separately. Snapping of the non-center points can also be enabled only
538  in the case, that they are connected to a vertical or horizontal border line.
539 
540 - For size snapping of affine transformations assume that the affine transformation
541  transformes the origin and two unity length coordinate axis vectors to a different
542  origin with different axis orientation and length. This way, the transformation
543  consits of three vectors, the origin vector, the x-axis vector and the
544  y-axis vector. The x-size can be one of the following:
545 
546  -# the length of the transformed x-axis vector
547  -# the projection of the transformed x-axis vector on a line perpendicular
548  to the transformed y-axis
549  -# the larger component of the x-axis vector
550  -# the first (horizontal) component of the x-axis vector.
551 
552  Each of these snapping modes may be enabled separately.
553 
554 - Points and lines are simply snapped to a grid.
555 
556 - An example menu handler to enable/disable snapping:
557 
558 \code
559 void MyDrawFrm::OnDrawRasterSnap(wxCommandEvent &event)
560 {
561  if( event.IsChecked() )
562  {
563  a2dRestrictionEngineOld
564  *restrict=new a2dRestrictionEngineOld();
565  restrict->SetSnapGrid(20,20);
566  restrict->SetPosModes(a2dRestrictionEngineOld::pos3P|a2dRestrictionEngineOld::posSngl|a2dRestrictionEngineOld::posOther);
567  restrict->SetSizeModes(a2dRestrictionEngineOld::sizeLength|a2dRestrictionEngineOld::sizeMin);
568  restrict->SetRotationModes(a2dRestrictionEngineOld::rotAllAngle);
569  restrict->SetRotationAngle(15);
570  a2dCanvasGlobals->SetRestrictionEngine(restrict);
571  }
572  else
573  {
574  a2dCanvasGlobals->SetRestrictionEngine(0);
575  }
576 }
577 \endcode
578 
579 \todo Implement angle snapping for lines with length snapping or snapping of
580 the endpoints to vertical or horizontal grodlines.
581 */
582 
583 class A2DCANVASDLLEXP a2dRestrictionEngineOld : public a2dObject
584 {
585 public:
586  //! Constructor
588 
589  //! Destructor
591 
592  //! Position snap modes/flags (once for x any y)
594  {
595  posCenter = 0x00000001, //!< enable position snapping of object center to grid
596  posTopLeft = 0x00000002, //!< enable position snapping of object top left to grid
597  posTop = 0x00000004, //!< enable position snapping of object top to grid
598  posTopRight = 0x00000008, //!< enable position snapping of object top right to grid
599  posRight = 0x00000010, //!< enable position snapping of object right to grid
600  posBottomRight = 0x00000020, //!< enable position snapping of object bottom right to grid
601  posBottom = 0x00000040, //!< enable position snapping of object bottom to grid
602  posBottomLeft = 0x00000080, //!< enable position snapping of object bottom left to grid
603  posLeft = 0x00000100, //!< enable position snapping of object left to grid
604  posLineTop = 0x00000200, //!< enable position snapping of object top line to grid, if x axis parallel to main axis
605  posLineHCenter = 0x00000400, //!< enable position snapping of object h-center line to grid, if x axis parallel to main axis
606  posLineBottom = 0x00000800, //!< enable position snapping of object bottom line to grid, if x axis parallel to main axis
607  posLineLeft = 0x00001000, //!< enable position snapping of object left line to grid, if y axis parallel to main axis
608  posLineVCenter = 0x00002000, //!< enable position snapping of object v-center line to grid, if y axis parallel to main axis
609  posLineRight = 0x00004000, //!< enable position snapping of object right line to grid, if y axis parallel to main axis
610  posOther = 0x00008000, //!< enable position snapping of object other points to grid (e.g. triangle corner)
611  posSngl = 0x00010000, //!< enable restriction of single points (e.g. of polylines)
612 
613  posEqual = 0x80000000, //!< used internally
614  posNone = 0x00000000, //!< disable all posizion restriction modes
615 
616  //! enable all 6 line snapping modes
617  pos6L = posLineTop | posLineHCenter | posLineBottom | posLineLeft | posLineVCenter | posLineRight,
618  //! enable center point snapping modes
619  pos1P = posCenter,
620  //! enable center + top left point snapping modes
621  pos2P = posCenter | posTopLeft,
622  //! enable center + top left + bottom right point snapping modes
623  pos3P = posCenter | posTopLeft | posBottomRight,
624  //! enable all center + 4 corner point snapping modes
625  pos5P = posCenter | posTopLeft | posTopRight | posBottomRight | posBottomLeft,
626  //! enable all 9 point snapping modes
627  pos9P = posCenter | posTopLeft | posTop | posTopRight | posRight | posBottomRight | posBottom | posBottomLeft | posLeft,
628  //! enable all position restriction modes, except other point modes
629  posAny = pos9P | pos6L | posSngl,
630  //! enable center point and all 6 line snapping modes
631  pos1P6L = posCenter | pos6L,
632  };
633  friend EPositionSnapModes operator | ( EPositionSnapModes a, EPositionSnapModes b ) {return ( EPositionSnapModes ) ( ( int )a | ( int )b );}
634 
635  //! Size snap modes/flags (once for x and y)
637  {
638  sizeLength = 0x00000001, //!< enable size snapping of transformed axis vector length
639  sizeProject = 0x00000002, //!< enable snapping of projection of transformed axis vector length to orthogonal of other axis vector
640  sizeMajor = 0x00000004, //!< enable size snapping of transformed axis major component
641  sizeAxis = 0x00000008, //!< enable size snapping of projection to untronsformed axis
642  sizePos = 0x00000010, //!< snap size by snapping individual points
643  sizeMin = 0x00000020, //!< enable minimum size restriction
644  sizeMax = 0x00000040, //!< enable maximum size restriction
645  sizeEqual = 0x80000000, //!< used internally
646  sizeNone = 0x00000000, //!< disable all size restriction modes
647  sizeAny = 0x0000007F //!< enable all size restriction modes
648  };
649  friend ESizeSnapModes operator | ( ESizeSnapModes a, ESizeSnapModes b ) {return ( ESizeSnapModes ) ( ( int )a | ( int )b );}
650 
651  //! Rotation/Slanting snap modes/flags
653  {
654  // affine rotation/skew snapping
655  rotVectorAngleX = 0x00000001, //!< enable angle snapping for rotation of first coordinate vektor
656  rotVectorRationalX = 0x00000002, //!< enable rational snapping for rotations of first coordinate vektor
657  rotVectorAngleY = 0x00000004, //!< enable angle snapping for rotations of second coordinate vektor
658  rotVectorRationalY = 0x00000008, //!< enable rational snapping for rotations of second coordinate vektor
659  rotPureRotations = 0x00000010, //!< allow only pure rotations, no slanting
660  rotPureSlanting = 0x00000020, //!< allow only pure one axis slanting
661 
662  // endpoint angle snapping
663  rotEndpointAngle = 0x00000040, //!< enable snapping of arc endpoint angles
664  rotEndpointRational = 0x00000080, //!< enable snapping of arc endpoint angles (rational)
665  rotEndpointUntrans = 0x00000100, //!< enable snapping of arc ednpoints in untransformed coordinate system
666 
667  rotNone = 0x00000000, //!< disable all rotation restriction modes
668  rotAllAngle = rotVectorAngleX | rotVectorAngleY | rotEndpointAngle,
669  rotAllRational = rotVectorRationalX | rotVectorRationalY | rotEndpointRational,
670  rotAll = 0x000001FF
671  };
672  friend ERotationSnapModes operator | ( ERotationSnapModes a, ERotationSnapModes b ) {return ( ERotationSnapModes ) ( ( int )a | ( int )b );}
673 
674  //! Flags for what to touch during a restriction
676  {
677  snapPosX = 0x00000001, //!< perform x position snapping
678  snapPosY = 0x00000002, //!< perform y position snapping
679  snapSizeX = 0x00000004, //!< perform x size snapping
680  snapSizeY = 0x00000008, //!< perform y size snapping
681  snapRot = 0x00000010, //!< perform rotation snapping
682  snapSkew = 0x00000020, //!< perform skew snapping
683  snapWH = 0x00000040, //!< during size snapping, change w/h rather than transform
684  snapEndAngle = 0x00000080, //!< snap angle of endpoints or arcs
685  snapStart = 0x00000100, //!< snap start point of line
686  snapEnd = 0x00000200, //!< snap end point of line
687  snapPointI = 0x80000000, //!< snap point i of polygon (ored with i, other flags are invalid)
688  snapPos = snapPosX | snapPosY,
689  snapSize = snapSizeX | snapSizeY,
690  snapPosSize = snapPos | snapSize,
691  snapSizeWH = snapSize | snapWH,
692  };
693  friend ESnapWhat operator | ( ESnapWhat a, ESnapWhat b ) {return ( ESnapWhat ) ( ( int )a | ( int )b );}
694 
695  //! Structure to descripe snapping properties of an object
697  {
698  double m_left; //!< minimum x coordinate (e.g. 0), transformed via affine transform and w
699  double m_top; //!< minimum y coordinate (e.g. 0), transformed via affine transform and h
700  double m_right; //!< maximum x coordinate (e.g. 1), transformed via affine transform and w
701  double m_bottom; //!< maximum y coordinate (e.g. 1), transformed via affine transform and h
702  double m_centerX; //!< center x coordinate (e.g. 0.5), transformed via affine transform and w
703  double m_centerY; //!< center y coordinate (e.g. 0.5), transformed via affine transform and h
704  EPositionSnapModes m_posModesX; //!< anded with m_posModesX of wxRetrictionEngine
705  EPositionSnapModes m_posModesY; //!< anded with m_posModesY of wxRetrictionEngine
706  ESizeSnapModes m_sizeModesX; //!< anded with m_sizeModesX of wxRetrictionEngine
707  ESizeSnapModes m_sizeModesY; //!< anded with m_sizeModesY of wxRetrictionEngine
708  ERotationSnapModes m_rotModes; //!< anded with m_rotModes of wxRetrictionEngine
709  class a2dVertexList* m_other; //!< other snapping points (enabled by bits in m_posModesX/m_posModesY, NOT owned or deleted by this object)
710  };
711 
712  //! Set position snap modes (ored EPositionSnapModes)
713  void SetPosModes( EPositionSnapModes modeX, EPositionSnapModes modeY = posEqual ) {m_posModesX = modeX; m_posModesY = modeY == posEqual ? modeX : modeY;}
714  //! Get position snap modes (ored EPositionSnapModes)
715  EPositionSnapModes GetPosModesX() {return m_posModesX;}
716  EPositionSnapModes GetPosModesY() {return m_posModesY;}
717 
718  //! Set size snap modes (ored ESizeSnapModes)
719  void SetSizeModes( ESizeSnapModes modeX, ESizeSnapModes modeY = sizeEqual ) {m_sizeModesX = modeX; m_sizeModesY = modeY == sizeEqual ? modeX : modeY;}
720  //! Get size snap modes (ored ESizeSnapModes)
721  ESizeSnapModes GetSizeModesX() {return m_sizeModesX;}
722  ESizeSnapModes GetSizeModesY() {return m_sizeModesY;}
723 
724  //! Set rotation/slanting snap modes (ored ERotationSnapModes)
725  void SetRotationModes( ERotationSnapModes mode ) {m_rotModes = mode;}
726  //! Get rotation/slanting snap modes (ored ERotationSnapModes)
727  ERotationSnapModes GetRotationModes() {return m_rotModes;}
728 
729  //! Set snapping grid (position and size)
730  void SetSnapGrid( double x, double y ) {m_snapDistX = x; m_snapDistY = y; m_sizeX = x, m_sizeY = y; }
731  //! Set snapping grid (only position)
732  void SetPosGrid( double x, double y ) {m_snapDistX = x; m_snapDistY = y;}
733  //! Set snapping grid (only size)
734  void SetSizeGrid( double x, double y ) {m_sizeX = x; m_sizeY = y;}
735  //! Set snapping origin (position grid offest/shift)
736  void SetSnapOrigin( double x, double y ) {m_originX = x; m_originY = y;}
737  //! Set minimum size
738  void SetMinSize( double x, double y ) {m_minSizeX = x; m_minSizeY = y; }
739  //! Set maximum size
740  void SetMaxSize( double x, double y ) {m_maxSizeX = x; m_maxSizeY = y; }
741  //! Set rotation angle raster
742  void SetRotationAngle( double a ) {m_rotationAngle = a; }
743  //! Set rotation rational raster nominator/denominator mask
744  void SetRotationRational( wxUint32 nomMask, wxUint32 denMask )
745  {
746  m_rotationRationalNom = nomMask; m_rotationRationalDen = denMask;
747  }
748 
749  //! Restrict an affine transformation
750  /*! \param mNew the edited tranformation matrix, that will be restricted
751  * \param mOld the tranformation matrix as it was prior to editing
752  * \param snapWhat enable various snapping options
753  * \param info snapping info
754  * \param w if (snapWhat & snapWH) the w parameter reflects the width, rather than the matrix
755  * \param h if (snapWhat & snapWH) the h parameter reflects the height, rather than the matrix
756  */
757  void RestrictAffine( a2dAffineMatrix* mNew, const a2dAffineMatrix* mOld, ESnapWhat snapWhat, SnapObjectInfo* info, double* w = 0, double* h = 0 );
758 
759  //! Restrict a starting /ending angle of e.g. an elliptic arc
760  //! The angle is in degrees
761  //! The matrix is required for e.g. untransformed snapping
762  void RestrictEndpointAngle( double* angle, const a2dAffineMatrix& matrix, ESnapWhat snapWhat );
763 
764  //! Restrict a single point of a line or polyline
765  void RestrictPoint( double* x, double* y );
766 
767  //! Get horizontal center snapping distance (zero if disabled)
768  double GetCenterSnapX() {return ( m_posModesX & posAny ) ? m_snapDistX : 0;}
769  //! Get vertical center snapping distance (zero if disabled)
770  double GetCenterSnapY() {return ( m_posModesY & posAny ) ? m_snapDistY : 0;}
771 
772 private:
773  //! Some stuff nedded by the ref counting base class
774  virtual a2dObject* DoClone( CloneOptions WXUNUSED( options ) ) const { wxASSERT( 0 ); return 0; }
775 
776 #if wxART2D_USE_CVGIO
777  virtual void DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) ) { wxASSERT( 0 ); }
778  virtual void DoLoad( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) ) { wxASSERT( 0 ); }
779 #endif //wxART2D_USE_CVGIO
780 
781 protected:
782  //! Restrict an angle
783  double AngleRestrict( double angle );
784  //! Restrict the angle of a vector, keeping the vectors length
785  void AngleRestrictVectorRot( double* vecx, double* vecy );
786  //! Restrict the angle of a vector, keeping the vectors projection on the orthogonal of another vector
787  void AngleRestrictVectorSkew( double* vecx, double* vecy, double otherx, double othery );
788 
789  //! Rational restrict an angle
790  double RationalRestrict( double angle );
791  //! Rational restrict the angle of a vector
792  void RationalRestrictVector( double* vecx, double* vecy );
793 
794  EPositionSnapModes m_posModesX; //!< ored EPositionSnapModes of enabled modes for x
795  EPositionSnapModes m_posModesY; //!< ored EPositionSnapModes of enabled modes for y
796  ESizeSnapModes m_sizeModesX; //!< ored ESizeSnapModes of enabled modes for x
797  ESizeSnapModes m_sizeModesY; //!< ored ESizeSnapModes of enabled modes for y
798  ERotationSnapModes m_rotModes; //!< ored ERotationSnapModes of enabled modes
799  double m_snapDistX; //!< horizontal position snapping grid distance
800  double m_snapDistY; //!< vertical position snapping grid distance
801  double m_originX; //!< horizontal grid snapping origin vs. coordinate origin
802  double m_originY; //!< vertical grid snapping origins vs. coordinate origin
803  double m_sizeX; //!< horizontal size snapping grid distance
804  double m_sizeY; //!< vertical size snapping grid distance
805  double m_minSizeX; //!< minimal horiontal size
806  double m_minSizeY; //!< minimal vertical size
807  double m_maxSizeX; //!< maximal horiontal size
808  double m_maxSizeY; //!< maximal vertical size
809  double m_rotationAngle; //!< angle snapping angle in degrees
810  wxUint32 m_rotationRationalNom; //!< bit map of possible nominators (0..31) for rational angle snapping
811  wxUint32 m_rotationRationalDen; //!< bit map of possible denominators (0..31) for rational angle snapping
812  double* m_angleList; //!< sorted list of allowed rational angles
813  int m_nAngleList; //!< number of allowed rational angles
814 
815  double m_docSnapDistX;
816  double m_docSnapDistY;
817  double m_docOriginX;
818  double m_docOriginY;
819 
820 };
821 
822 #endif // __RESTRICT_H__
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
double m_rotationAngle
angle snapping angle in degrees
Definition: restrict.h:441
a2dPoint2D m_snappedPoint
set to point that is snapped to m_pointToSnap
Definition: restrict.h:454
EPositionSnapModes m_posModesX
anded with m_posModesX of wxRetrictionEngine
Definition: restrict.h:704
EPositionSnapModes m_posModesX
ored EPositionSnapModes of enabled modes for x
Definition: restrict.h:794
ESizeSnapModes m_sizeModesX
ored ESizeSnapModes of enabled modes for x
Definition: restrict.h:796
fundamental classes used by all other modules.
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
const a2dDoMu & GetSnapGridX() const
Get horizontal center snapping distance (zero if disabled)
Definition: restrict.h:153
a2dDocumentRenderStyle operator|(a2dDocumentRenderStyle a, a2dDocumentRenderStyle b)
OR-ing a2dDocumentRenderStyle is allowed.
Definition: canglob.h:50
void SetSizeGrid(double x, double y)
Set snapping grid (only size)
Definition: restrict.h:734
int m_nAngleList
number of allowed rational angles
Definition: restrict.h:813
double m_sizeX
horizontal size snapping grid distance
Definition: restrict.h:803
void SetRotationModes(ERotationSnapModes mode)
Set rotation/slanting snap modes (ored ERotationSnapModes)
Definition: restrict.h:725
void SetSnapGrid(const a2dDoMu &x, const a2dDoMu &y)
Set snapping grid (only position)
Definition: restrict.h:150
Ref Counted base object.
Definition: gen.h:1045
void SetRotationAngle(double a)
Set rotation angle raster.
Definition: restrict.h:171
a2dPoint2D m_pointToSnap
set to point that is currently being snapped.
Definition: restrict.h:451
double m_snapDistY
vertical position snapping grid distance
Definition: restrict.h:800
double m_rotationAngle
angle snapping angle in degrees
Definition: restrict.h:809
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
double m_left
minimum x coordinate (e.g. 0), transformed via affine transform and w
Definition: restrict.h:698
void SetSnapSourceFeature(a2dSnapToWhat snapSourceFeature, bool value=true)
set one of the snapping features for the source to true or false, leaf others as is ...
Definition: restrict.h:218
const a2dDoMu & GetSnapOriginX() const
Get snapping origin X (position grid offset/shift)
Definition: restrict.h:165
void SetRotationRational(wxUint32 nomMask, wxUint32 denMask)
Set rotation rational raster nominator/denominator mask.
Definition: restrict.h:208
a2dLine & GetLineToSnap()
to ask engine for the line that needs to be snapped to a a2dCanvasObject
Definition: restrict.h:367
int GetSnapThresHold() const
used to snap vertexes to a pin or point like snapping features in objects.
Definition: restrict.h:177
double m_snapDistX
horizontal position snapping grid distance
Definition: restrict.h:799
wxUint32 m_rotationRationalNom
bit map of possible nominators (bit1-&gt;0.. bit32-&gt;31) for rational angle snapping
Definition: restrict.h:442
ERotationSnapModes GetRotationModes()
Get rotation/slanting snap modes (ored ERotationSnapModes)
Definition: restrict.h:727
void SetSnapTargetFeature(a2dSnapToWhat snapTargetFeature, bool value=true)
set one of the snapping features for targets to true or false, leaf others as is
Definition: restrict.h:234
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
Definition: gen.h:835
vertex array of line and arc segments.
Definition: polyver.h:494
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
EPositionSnapModes
Position snap modes/flags (once for x any y)
Definition: restrict.h:593
EPositionSnapModes m_posModesY
ored EPositionSnapModes of enabled modes for y
Definition: restrict.h:795
a2dSnapToWhatMask m_snapSourceFeatures
set to the a2dSnapToWhat features enabled by the engine for the source object
Definition: restrict.h:432
vertex list of line and arc segments.
Definition: polyver.h:600
defenitions an no more
bool GetShiftKeyDown() const
some snapping may depend on shift key being down
Definition: restrict.h:393
store and convert number to number with unit and visa versa. e.g. 1.23e-6 =&gt; 1.23 * 1e-6 ...
Definition: artglob.h:208
wxUint32 m_rotationRationalDen
bit map of possible denominators (bit1-&gt;0.. bit32-&gt;31) for rational angle snapping ...
Definition: restrict.h:443
double m_top
minimum y coordinate (e.g. 0), transformed via affine transform and h
Definition: restrict.h:699
a2dDoMu m_snapDistX
horizontal position snapping grid distance
Definition: restrict.h:437
a2dDoMu m_originX
horizontal grid snapping origin vs. coordinate origin
Definition: restrict.h:439
a2dSnapToWhatMask GetSnapTargetFeatures() const
Definition: restrict.h:249
class a2dVertexList * m_other
other snapping points (enabled by bits in m_posModesX/m_posModesY, NOT owned or deleted by this objec...
Definition: restrict.h:709
void SetPosGrid(double x, double y)
Set snapping grid (only position)
Definition: restrict.h:732
a2dDoMu m_originY
vertical grid snapping origins vs. coordinate origin
Definition: restrict.h:440
const a2dPoint2D & GetRestrictPoint() const
to ask engine for the restrict point
Definition: restrict.h:343
ESizeSnapModes
Size snap modes/flags (once for x and y)
Definition: restrict.h:636
bool GetReleaseSnap() const
do not snap if set
Definition: restrict.h:399
classes for initializing the artbase modules, and set paths to be used for fonts etc.
int m_nAngleList
number of allowed rational angles
Definition: restrict.h:445
ESizeSnapModes m_sizeModesY
ored ESizeSnapModes of enabled modes for y
Definition: restrict.h:797
double * m_angleList
sorted list of allowed rational angles
Definition: restrict.h:444
void SetParentSnapObjects(a2dCanvasObject *obj)
parent object of objects that need to be snapped to
Definition: restrict.h:380
a2dCanvasObject * GetParentSnapObjects() const
return pointer of the current parent object
Definition: restrict.h:386
a2dSmrtPtr< a2dRestrictionEngine > a2dRestrictionEnginePtr
Smart pointer type for restriction engine.
Definition: restrict.h:499
wxUint32 m_rotationRationalDen
bit map of possible denominators (0..31) for rational angle snapping
Definition: restrict.h:811
void SetSnapOnlyVisibleObjects(bool snapOnlyVisbleObjects)
enable all snapping features for object only for visible object.
Definition: restrict.h:195
double m_centerY
center y coordinate (e.g. 0.5), transformed via affine transform and h
Definition: restrict.h:703
ESnapWhat
Flags for what to touch during a restriction.
Definition: restrict.h:675
double m_originY
vertical grid snapping origins vs. coordinate origin
Definition: restrict.h:802
ESizeSnapModes m_sizeModesX
anded with m_sizeModesX of wxRetrictionEngine
Definition: restrict.h:706
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
Definition: gen.cpp:1657
a2dPoint2D GetPointToSnap() const
to ask engine for the point that needs to be snapped to a a2dCanvasObject
Definition: restrict.h:350
bool GetSnap() const
enable all snapping features or not
Definition: restrict.h:192
void SetSnapSourceFeatures(wxUint32 snapSourceFeatures)
Definition: restrict.h:215
double m_minSizeY
minimal vertical size
Definition: restrict.h:806
ERotationSnapModes
Rotation/Slanting snap modes/flags.
Definition: restrict.h:652
a2dSnapToWhatMask m_snapTargetFeatures
set to the a2dSnapToWhat target features enabled by the engine and/or snap source object ...
Definition: restrict.h:435
bool m_releaseSnap
to not snap inside snapping engine.
Definition: restrict.h:462
Restriction engine for editing restrictions like snapping.
Definition: restrict.h:88
bool GetSnapTargetFeature(a2dSnapToWhat snapTargetFeature) const
return the setting of a specific snapping feature
Definition: restrict.h:242
ESizeSnapModes GetSizeModesX()
Get size snap modes (ored ESizeSnapModes)
Definition: restrict.h:721
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
double GetCenterSnapX()
Get horizontal center snapping distance (zero if disabled)
Definition: restrict.h:768
double m_sizeY
vertical size snapping grid distance
Definition: restrict.h:804
bool m_snap
if true snapping modes are enabled, else non.
Definition: restrict.h:461
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
Definition: restrict.h:26
Structure to descripe snapping properties of an object.
Definition: restrict.h:696
void SetRotationRational(wxUint32 nomMask, wxUint32 denMask)
Set rotation rational raster nominator/denominator mask.
Definition: restrict.h:744
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
void SetSnapOrigin(const a2dDoMu &x, const a2dDoMu &y)
Set snapping origin (position grid offest/shift)
Definition: restrict.h:159
double m_originX
horizontal grid snapping origin vs. coordinate origin
Definition: restrict.h:801
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
Definition: gen.cpp:1699
void SetPosModes(EPositionSnapModes modeX, EPositionSnapModes modeY=posEqual)
Set position snap modes (ored EPositionSnapModes)
Definition: restrict.h:713
double m_maxSizeX
maximal horiontal size
Definition: restrict.h:807
ERotationSnapModes m_rotModes
ored ERotationSnapModes of enabled modes
Definition: restrict.h:798
double m_right
maximum x coordinate (e.g. 1), transformed via affine transform and w
Definition: restrict.h:700
double m_bottom
maximum y coordinate (e.g. 1), transformed via affine transform and h
Definition: restrict.h:701
Line calculations.
Definition: liner.h:36
DEPRECATED Restriction engine for editing restrictions like snapping.
Definition: restrict.h:583
void SetReleaseSnap(bool releaseSnap)
do not snap if set
Definition: restrict.h:396
void SetSizeModes(ESizeSnapModes modeX, ESizeSnapModes modeY=sizeEqual)
Set size snap modes (ored ESizeSnapModes)
Definition: restrict.h:719
void SetRotationAngle(double a)
Set rotation angle raster.
Definition: restrict.h:742
bool GetSnapOnlyVisibleObjects() const
all snapping features for object only for visible object?
Definition: restrict.h:198
int m_snapThresHold
threshold in pixels towards the snapping point.
Definition: restrict.h:448
void SetShiftKeyDown(bool shiftDown)
some snapping may depend on shift key being down
Definition: restrict.h:390
const a2dDoMu & GetSnapOriginY() const
Get snapping origin Y (position grid offset/shift)
Definition: restrict.h:168
double * m_angleList
sorted list of allowed rational angles
Definition: restrict.h:812
double m_centerX
center x coordinate (e.g. 0.5), transformed via affine transform and w
Definition: restrict.h:702
EPositionSnapModes GetPosModesX()
Get position snap modes (ored EPositionSnapModes)
Definition: restrict.h:715
void SetSnapGrid(double x, double y)
Set snapping grid (position and size)
Definition: restrict.h:730
smart pointer class and list.
double GetCenterSnapY()
Get vertical center snapping distance (zero if disabled)
Definition: restrict.h:770
a2dCanvasObject * m_parentObject
parent canvas object in a2dCanvasDocument on which snapping needs to be done.
Definition: restrict.h:466
EPositionSnapModes m_posModesY
anded with m_posModesY of wxRetrictionEngine
Definition: restrict.h:705
double m_maxSizeY
maximal vertical size
Definition: restrict.h:808
bool m_snapOnlyVisbleObjects
if true snapping modes for object is only on visible object.
Definition: restrict.h:460
ERotationSnapModes m_rotModes
anded with m_rotModes of wxRetrictionEngine
Definition: restrict.h:708
double m_minSizeX
minimal horiontal size
Definition: restrict.h:805
void SetSnapOrigin(double x, double y)
Set snapping origin (position grid offest/shift)
Definition: restrict.h:736
a2dSnapToWhatMask GetSnapSourceFeatures() const
Definition: restrict.h:227
void SetSnapThresHold(int thresHold)
used to snap vertexes to a pin or point like snapping features in objects.
Definition: restrict.h:180
void SetMaxSize(double x, double y)
Set maximum size.
Definition: restrict.h:740
This template class is for property ids with a known data type.
Definition: id.h:477
void SetSnap(bool snap)
enable all snapping features or not
Definition: restrict.h:189
const a2dDoMu & GetSnapGridY() const
Get vertical center snapping distance (zero if disabled)
Definition: restrict.h:156
wxUint32 m_rotationRationalNom
bit map of possible nominators (0..31) for rational angle snapping
Definition: restrict.h:810
list of a2dObject&#39;s
Definition: gen.h:3157
void SetMinSize(double x, double y)
Set minimum size.
Definition: restrict.h:738
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
Definition: restrict.h:337
a2dDoMu m_snapDistY
vertical position snapping grid distance
Definition: restrict.h:438
bool m_shiftDown
snapping modifier when shift key is pressed
Definition: restrict.h:463
void SetSnapTargetFeatures(wxUint32 snapTargetFeatures)
Definition: restrict.h:231
ESizeSnapModes m_sizeModesY
anded with m_sizeModesY of wxRetrictionEngine
Definition: restrict.h:707
double GetRotationAngle() const
Get rotation angle raster.
Definition: restrict.h:174
restrict.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation