#include <restrict.h>


Public Types | |
| enum | EPositionSnapModes { posCenter = 0x00000001, posTopLeft = 0x00000002, posTop = 0x00000004, posTopRight = 0x00000008, posRight = 0x00000010, posBottomRight = 0x00000020, posBottom = 0x00000040, posBottomLeft = 0x00000080, posLeft = 0x00000100, posLineTop = 0x00000200, posLineHCenter = 0x00000400, posLineBottom = 0x00000800, posLineLeft = 0x00001000, posLineVCenter = 0x00002000, posLineRight = 0x00004000, posOther = 0x00008000, posSngl = 0x00010000, posEqual = 0x80000000, posNone = 0x00000000, pos6L = posLineTop|posLineHCenter|posLineBottom|posLineLeft|posLineVCenter|posLineRight, pos1P = posCenter, pos2P = posCenter|posTopLeft, pos3P = posCenter|posTopLeft|posBottomRight, pos5P = posCenter|posTopLeft|posTopRight|posBottomRight|posBottomLeft, pos9P = posCenter|posTopLeft|posTop|posTopRight|posRight|posBottomRight|posBottom|posBottomLeft|posLeft, posAny = pos9P|pos6L|posSngl, pos1P6L = posCenter|pos6L } |
| Position snap modes/flags (once for x any y). More... | |
| enum | ESizeSnapModes { sizeLength = 0x00000001, sizeProject = 0x00000002, sizeMajor = 0x00000004, sizeAxis = 0x00000008, sizePos = 0x00000010, sizeMin = 0x00000020, sizeMax = 0x00000040, sizeEqual = 0x80000000, sizeNone = 0x00000000, sizeAny = 0x0000007F } |
| Size snap modes/flags (once for x and y). More... | |
| enum | ERotationSnapModes { rotVectorAngleX = 0x00000001, rotVectorRationalX = 0x00000002, rotVectorAngleY = 0x00000004, rotVectorRationalY = 0x00000008, rotPureRotations = 0x00000010, rotPureSlanting = 0x00000020, rotEndpointAngle = 0x00000040, rotEndpointRational = 0x00000080, rotEndpointUntrans = 0x00000100, rotNone = 0x00000000, rotAllAngle = rotVectorAngleX|rotVectorAngleY|rotEndpointAngle, rotAllRational = rotVectorRationalX|rotVectorRationalY|rotEndpointRational, rotAll = 0x000001FF } |
| Rotation/Slanting snap modes/flags. More... | |
| enum | ESnapWhat { snapPosX = 0x00000001, snapPosY = 0x00000002, snapSizeX = 0x00000004, snapSizeY = 0x00000008, snapRot = 0x00000010, snapSkew = 0x00000020, snapWH = 0x00000040, snapEndAngle = 0x00000080, snapStart = 0x00000100, snapEnd = 0x00000200, snapPointI = 0x80000000, snapPos = snapPosX|snapPosY, snapSize = snapSizeX|snapSizeY, snapPosSize = snapPos|snapSize, snapSizeWH = snapSize|snapWH } |
| Flags for what to touch during a restriction. More... | |
Public Member Functions | |
| a2dRestrictionEngineOld () | |
| Constructor. | |
| ~a2dRestrictionEngineOld () | |
| Destructor. | |
| void | SetPosModes (EPositionSnapModes modeX, EPositionSnapModes modeY=posEqual) |
| Set position snap modes (ored EPositionSnapModes). | |
| EPositionSnapModes | GetPosModesX () |
| Get position snap modes (ored EPositionSnapModes). | |
| EPositionSnapModes | GetPosModesY () |
| void | SetSizeModes (ESizeSnapModes modeX, ESizeSnapModes modeY=sizeEqual) |
| Set size snap modes (ored ESizeSnapModes). | |
| ESizeSnapModes | GetSizeModesX () |
| Get size snap modes (ored ESizeSnapModes). | |
| ESizeSnapModes | GetSizeModesY () |
| void | SetRotationModes (ERotationSnapModes mode) |
| Set rotation/slanting snap modes (ored ERotationSnapModes). | |
| ERotationSnapModes | GetRotationModes () |
| Get rotation/slanting snap modes (ored ERotationSnapModes). | |
| void | SetSnapGrid (double x, double y) |
| Set snapping grid (position and size). | |
| void | SetPosGrid (double x, double y) |
| Set snapping grid (only position). | |
| void | SetSizeGrid (double x, double y) |
| Set snapping grid (only size). | |
| void | SetSnapOrigin (double x, double y) |
| Set snapping origin (position grid offest/shift). | |
| void | SetMinSize (double x, double y) |
| Set minimum size. | |
| void | SetMaxSize (double x, double y) |
| Set maximum size. | |
| void | SetRotationAngle (double a) |
| Set rotation angle raster. | |
| void | SetRotationRational (wxUint32 nomMask, wxUint32 denMask) |
| Set rotation rational raster nominator/denominator mask. | |
| void | RestrictAffine (a2dAffineMatrix *mNew, const a2dAffineMatrix *mOld, ESnapWhat snapWhat, SnapObjectInfo *info, double *w=0, double *h=0) |
| Restrict an affine transformation. | |
| void | RestrictEndpointAngle (double *angle, const a2dAffineMatrix &matrix, ESnapWhat snapWhat) |
| void | RestrictPoint (double *x, double *y) |
| Restrict a single point of a line or polyline. | |
| double | GetCenterSnapX () |
| Get horizontal center snapping distance (zero if disabled). | |
| double | GetCenterSnapY () |
| Get vertical center snapping distance (zero if disabled). | |
Protected Member Functions | |
| double | AngleRestrict (double angle) |
| Restrict an angle. | |
| void | AngleRestrictVectorRot (double *vecx, double *vecy) |
| Restrict the angle of a vector, keeping the vectors length. | |
| void | AngleRestrictVectorSkew (double *vecx, double *vecy, double otherx, double othery) |
| Restrict the angle of a vector, keeping the vectors projection on the orthogonal of another vector. | |
| double | RationalRestrict (double angle) |
| Rational restrict an angle. | |
| void | RationalRestrictVector (double *vecx, double *vecy) |
| Rational restrict the angle of a vector. | |
Protected Attributes | |
| EPositionSnapModes | m_posModesX |
| ored EPositionSnapModes of enabled modes for x | |
| EPositionSnapModes | m_posModesY |
| ored EPositionSnapModes of enabled modes for y | |
| ESizeSnapModes | m_sizeModesX |
| ored ESizeSnapModes of enabled modes for x | |
| ESizeSnapModes | m_sizeModesY |
| ored ESizeSnapModes of enabled modes for y | |
| ERotationSnapModes | m_rotModes |
| ored ERotationSnapModes of enabled modes | |
| double | m_snapDistX |
| horizontal position snapping grid distance | |
| double | m_snapDistY |
| vertical position snapping grid distance | |
| double | m_originX |
| horizontal grid snapping origin vs. coordinate origin | |
| double | m_originY |
| vertical grid snapping origins vs. coordinate origin | |
| double | m_sizeX |
| horizontal size snapping grid distance | |
| double | m_sizeY |
| vertical size snapping grid distance | |
| double | m_minSizeX |
| minimal horiontal size | |
| double | m_minSizeY |
| minimal vertical size | |
| double | m_maxSizeX |
| maximal horiontal size | |
| double | m_maxSizeY |
| maximal vertical size | |
| double | m_rotationAngle |
| angle snapping angle in degrees | |
| wxUint32 | m_rotationRationalNom |
| bit map of possible nominators (0..31) for rational angle snapping | |
| wxUint32 | m_rotationRationalDen |
| bit map of possible denominators (0..31) for rational angle snapping | |
| double * | m_angleList |
| sorted list of allowed rational angles | |
| int | m_nAngleList |
| number of allowed rational angles | |
| double | m_docSnapDistX |
| double | m_docSnapDistY |
| double | m_docOriginX |
| double | m_docOriginY |
Friends | |
| EPositionSnapModes | operator| (EPositionSnapModes a, EPositionSnapModes b) |
| ESizeSnapModes | operator| (ESizeSnapModes a, ESizeSnapModes b) |
| ERotationSnapModes | operator| (ERotationSnapModes a, ERotationSnapModes b) |
| ESnapWhat | operator| (ESnapWhat a, ESnapWhat b) |
Classes | |
| struct | SnapObjectInfo |
| Structure to descripe snapping properties of an object. More... | |
The restriction engine is used by editing tools to restrict editing of points and affine transformations.
With rational snapping i mean snapping to angles whose tangent is a rational number with a small integer nominatior and denominator. The max nominator/denominator is the snapping parameter. For slanting angles, the absolute slanting angle (that is angle to the coordinate axis) is used, not the slanting angle relative to the rotated coordinate system. With rational snapping, you can solve many problems of slant and angle snapping, where you want to snap also to the horizontal and vertical grid. If we snap to angles with a small rational tan, the resulting points will also snap to a small fraction of the horiontal or vertical grid.
Each of these snapping modes may be enabled separately.
void MyDrawFrm::OnDrawRasterSnap(wxCommandEvent &event) { if( event.IsChecked() ) { a2dRestrictionEngineOld *restrict=new a2dRestrictionEngineOld(); restrict->SetSnapGrid(20,20); restrict->SetPosModes(a2dRestrictionEngineOld::pos3P|a2dRestrictionEngineOld::posSngl|a2dRestrictionEngineOld::posOther); restrict->SetSizeModes(a2dRestrictionEngineOld::sizeLength|a2dRestrictionEngineOld::sizeMin); restrict->SetRotationModes(a2dRestrictionEngineOld::rotAllAngle); restrict->SetRotationAngle(15); a2dCanvasGlobals->SetRestrictionEngine(restrict); } else { a2dCanvasGlobals->SetRestrictionEngine(0); } }
Definition at line 561 of file restrict.h.
Position snap modes/flags (once for x any y).
Definition at line 571 of file restrict.h.
Size snap modes/flags (once for x and y).
Definition at line 614 of file restrict.h.
Rotation/Slanting snap modes/flags.
Definition at line 630 of file restrict.h.
Flags for what to touch during a restriction.
Definition at line 653 of file restrict.h.
| void a2dRestrictionEngineOld::RestrictAffine | ( | a2dAffineMatrix * | mNew, | |
| const a2dAffineMatrix * | mOld, | |||
| ESnapWhat | snapWhat, | |||
| SnapObjectInfo * | info, | |||
| double * | w = 0, |
|||
| double * | h = 0 | |||
| ) |
Restrict an affine transformation.
| mNew | the edited tranformation matrix, that will be restricted | |
| mOld | the tranformation matrix as it was prior to editing | |
| snapWhat | enable various snapping options | |
| info | snapping info | |
| w | if (snapWhat & snapWH) the w parameter reflects the width, rather than the matrix | |
| h | if (snapWhat & snapWH) the h parameter reflects the height, rather than the matrix |
Definition at line 852 of file restrict.cpp.
| void a2dRestrictionEngineOld::RestrictEndpointAngle | ( | double * | angle, | |
| const a2dAffineMatrix & | matrix, | |||
| ESnapWhat | snapWhat | |||
| ) |
Restrict a starting /ending angle of e.g. an elliptic arc The angle is in degrees The matrix is required for e.g. untransformed snapping
Definition at line 1509 of file restrict.cpp.