13 #ifndef __RESTRICT_H__
14 #define __RESTRICT_H__
103 snapToNone = 0x00000000,
104 snapToObjectPosX = 0x00000001,
105 snapToObjectPosY = 0x00000002,
107 snapToObjectPos = snapToObjectPosX | snapToObjectPosY,
109 snapToStart = 0x00000100,
110 snapToEnd = 0x00000200,
111 snapToPins = 0x00000400,
112 snapToPinsUnconnected
114 snapToObjectIntersection
118 snapToObjectSegmentsMiddle
123 snapToGridPosX = 0x00010000,
124 snapToGridPosY = 0x00020000,
125 snapToGridPos = snapToGridPosX | snapToGridPosY,
127 snapToPointPosX = 0x00040000,
128 snapToPointPosY = 0x00080000,
129 snapToPointPosXorY = 0x00100000,
130 snapToPointPosXorYForce = 0x00200000,
131 snapToPointPos = snapToPointPosX | snapToPointPosY,
133 snapToPointAngleMod = 0x00400000,
134 snapToPointAngleRational = 0x00800000,
135 snapToPointAngle = snapToPointAngleMod | snapToPointAngleRational,
137 snapToBoundingBox = 0x01000000,
139 snapToObjectSnapVPath = 0x02000000,
141 snapToGridPosForced = 0x04000000,
143 snapToAll = 0xFFFFFFFF
147 friend a2dSnapToWhat
operator | ( a2dSnapToWhat a, a2dSnapToWhat b ) {
return ( a2dSnapToWhat ) ( ( int )a | (
int )b );}
161 void SetSnapOriginX(
const a2dDoMu& x ) { m_originX = x; SetInternal(); SignalChange(); }
162 void SetSnapOriginY(
const a2dDoMu& y ) { m_originY = y; SetInternal(); SignalChange(); }
186 double GetSnapThresHoldWorld()
const;
189 void SetSnap(
bool snap ) { m_snap = snap; SignalChange(); }
210 m_rotationRationalNom = nomMask; m_rotationRationalDen = denMask; SignalChange();
215 void SetSnapSourceFeatures( wxUint32 snapSourceFeatures ) { m_snapSourceFeatures = snapSourceFeatures; SignalChange(); }
220 m_snapSourceFeatures = value ? m_snapSourceFeatures | snapSourceFeature :
221 m_snapSourceFeatures & ( snapToAll ^ snapSourceFeature );
231 void SetSnapTargetFeatures( wxUint32 snapTargetFeatures ) { m_snapTargetFeatures = snapTargetFeatures; SignalChange(); }
236 m_snapTargetFeatures = value ? m_snapTargetFeatures | snapTargetFeature :
237 m_snapTargetFeatures & ( snapToAll ^ snapTargetFeature );
244 return ( m_snapTargetFeatures & snapTargetFeature ) > 0;
265 virtual bool RestrictCanvasObjectAtVertexes(
a2dCanvasObject*
object,
a2dPoint2D& point,
double& dx,
double& dy, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
276 virtual bool RestrictVertexes(
a2dVertexArray* segments,
a2dPoint2D& point,
double& dx,
double& dy, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
287 virtual bool RestrictVertexes(
a2dVertexList* lsegments,
a2dPoint2D& point,
double& dx,
double& dy, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
306 virtual bool RestrictPoint(
double& x,
double& y, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
316 virtual bool RestrictLine(
a2dLine& line, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
326 virtual bool RestrictAngle(
double* ang, wxUint32 sourceRequired = snapToAll,
bool ignoreEngine =
false );
357 void SetPointSnapResult(
const a2dPoint2D& p );
360 bool IsWithInThresHold(
const a2dPoint2D& p );
405 virtual a2dObject* DoClone( CloneOptions options,
a2dRefMap* refs )
const {
return NULL; }
408 #if wxART2D_USE_CVGIO
410 virtual void DoLoad( wxObject* WXUNUSED( parent ),
a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) ) { wxASSERT( 0 ); }
411 #endif //wxART2D_USE_CVGIO
420 double AngleRestrict(
double angle );
422 void AngleRestrictVectorRot(
double* vecx,
double* vecy );
424 void AngleRestrictVectorSkew(
double* vecx,
double* vecy,
double otherx,
double othery );
427 double RationalRestrict(
double angle );
429 void RationalRestrictVector(
double* vecx,
double* vecy );
468 double m_docSnapDistX;
469 double m_docSnapDistY;
490 static const a2dSignal sig_changed;
496 #if defined(WXART2D_USINGDLL)
595 posCenter = 0x00000001,
596 posTopLeft = 0x00000002,
598 posTopRight = 0x00000008,
599 posRight = 0x00000010,
600 posBottomRight = 0x00000020,
601 posBottom = 0x00000040,
602 posBottomLeft = 0x00000080,
603 posLeft = 0x00000100,
604 posLineTop = 0x00000200,
605 posLineHCenter = 0x00000400,
606 posLineBottom = 0x00000800,
607 posLineLeft = 0x00001000,
608 posLineVCenter = 0x00002000,
609 posLineRight = 0x00004000,
610 posOther = 0x00008000,
611 posSngl = 0x00010000,
613 posEqual = 0x80000000,
614 posNone = 0x00000000,
617 pos6L = posLineTop | posLineHCenter | posLineBottom | posLineLeft | posLineVCenter | posLineRight,
621 pos2P = posCenter | posTopLeft,
623 pos3P = posCenter | posTopLeft | posBottomRight,
625 pos5P = posCenter | posTopLeft | posTopRight | posBottomRight | posBottomLeft,
627 pos9P = posCenter | posTopLeft | posTop | posTopRight | posRight | posBottomRight | posBottom | posBottomLeft | posLeft,
629 posAny = pos9P | pos6L | posSngl,
631 pos1P6L = posCenter | pos6L,
633 friend EPositionSnapModes
operator | ( EPositionSnapModes a, EPositionSnapModes b ) {
return ( EPositionSnapModes ) ( ( int )a | (
int )b );}
638 sizeLength = 0x00000001,
639 sizeProject = 0x00000002,
640 sizeMajor = 0x00000004,
641 sizeAxis = 0x00000008,
642 sizePos = 0x00000010,
643 sizeMin = 0x00000020,
644 sizeMax = 0x00000040,
645 sizeEqual = 0x80000000,
646 sizeNone = 0x00000000,
649 friend ESizeSnapModes
operator | ( ESizeSnapModes a, ESizeSnapModes b ) {
return ( ESizeSnapModes ) ( ( int )a | (
int )b );}
655 rotVectorAngleX = 0x00000001,
656 rotVectorRationalX = 0x00000002,
657 rotVectorAngleY = 0x00000004,
658 rotVectorRationalY = 0x00000008,
659 rotPureRotations = 0x00000010,
660 rotPureSlanting = 0x00000020,
663 rotEndpointAngle = 0x00000040,
664 rotEndpointRational = 0x00000080,
665 rotEndpointUntrans = 0x00000100,
667 rotNone = 0x00000000,
668 rotAllAngle = rotVectorAngleX | rotVectorAngleY | rotEndpointAngle,
669 rotAllRational = rotVectorRationalX | rotVectorRationalY | rotEndpointRational,
672 friend ERotationSnapModes
operator | ( ERotationSnapModes a, ERotationSnapModes b ) {
return ( ERotationSnapModes ) ( ( int )a | (
int )b );}
677 snapPosX = 0x00000001,
678 snapPosY = 0x00000002,
679 snapSizeX = 0x00000004,
680 snapSizeY = 0x00000008,
681 snapRot = 0x00000010,
682 snapSkew = 0x00000020,
684 snapEndAngle = 0x00000080,
685 snapStart = 0x00000100,
686 snapEnd = 0x00000200,
687 snapPointI = 0x80000000,
688 snapPos = snapPosX | snapPosY,
689 snapSize = snapSizeX | snapSizeY,
690 snapPosSize = snapPos | snapSize,
691 snapSizeWH = snapSize | snapWH,
693 friend ESnapWhat
operator | ( ESnapWhat a, ESnapWhat b ) {
return ( ESnapWhat ) ( ( int )a | (
int )b );}
716 EPositionSnapModes GetPosModesY() {
return m_posModesY;}
722 ESizeSnapModes GetSizeModesY() {
return m_sizeModesY;}
730 void SetSnapGrid(
double x,
double y ) {m_snapDistX = x; m_snapDistY = y; m_sizeX = x, m_sizeY = y; }
732 void SetPosGrid(
double x,
double y ) {m_snapDistX = x; m_snapDistY = y;}
734 void SetSizeGrid(
double x,
double y ) {m_sizeX = x; m_sizeY = y;}
738 void SetMinSize(
double x,
double y ) {m_minSizeX = x; m_minSizeY = y; }
740 void SetMaxSize(
double x,
double y ) {m_maxSizeX = x; m_maxSizeY = y; }
746 m_rotationRationalNom = nomMask; m_rotationRationalDen = denMask;
757 void RestrictAffine(
a2dAffineMatrix* mNew,
const a2dAffineMatrix* mOld, ESnapWhat snapWhat, SnapObjectInfo* info,
double* w = 0,
double* h = 0 );
762 void RestrictEndpointAngle(
double* angle,
const a2dAffineMatrix& matrix, ESnapWhat snapWhat );
765 void RestrictPoint(
double* x,
double* y );
774 virtual a2dObject* DoClone( CloneOptions WXUNUSED( options ) )
const { wxASSERT( 0 );
return 0; }
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
783 double AngleRestrict(
double angle );
785 void AngleRestrictVectorRot(
double* vecx,
double* vecy );
787 void AngleRestrictVectorSkew(
double* vecx,
double* vecy,
double otherx,
double othery );
790 double RationalRestrict(
double angle );
792 void RationalRestrictVector(
double* vecx,
double* vecy );
815 double m_docSnapDistX;
816 double m_docSnapDistY;
822 #endif // __RESTRICT_H__
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
double m_rotationAngle
angle snapping angle in degrees
a2dPoint2D m_snappedPoint
set to point that is snapped to m_pointToSnap
EPositionSnapModes m_posModesX
anded with m_posModesX of wxRetrictionEngine
EPositionSnapModes m_posModesX
ored EPositionSnapModes of enabled modes for x
ESizeSnapModes m_sizeModesX
ored ESizeSnapModes of enabled modes for x
fundamental classes used by all other modules.
class to map references to objects stored in XML, in order to make the connection later on...
const a2dDoMu & GetSnapGridX() const
Get horizontal center snapping distance (zero if disabled)
a2dDocumentRenderStyle operator|(a2dDocumentRenderStyle a, a2dDocumentRenderStyle b)
OR-ing a2dDocumentRenderStyle is allowed.
void SetSizeGrid(double x, double y)
Set snapping grid (only size)
int m_nAngleList
number of allowed rational angles
double m_sizeX
horizontal size snapping grid distance
void SetRotationModes(ERotationSnapModes mode)
Set rotation/slanting snap modes (ored ERotationSnapModes)
void SetSnapGrid(const a2dDoMu &x, const a2dDoMu &y)
Set snapping grid (only position)
void SetRotationAngle(double a)
Set rotation angle raster.
a2dPoint2D m_pointToSnap
set to point that is currently being snapped.
double m_snapDistY
vertical position snapping grid distance
double m_rotationAngle
angle snapping angle in degrees
Input and output handler for the XmlSer format.
double m_left
minimum x coordinate (e.g. 0), transformed via affine transform and w
void SetSnapSourceFeature(a2dSnapToWhat snapSourceFeature, bool value=true)
set one of the snapping features for the source to true or false, leaf others as is ...
const a2dDoMu & GetSnapOriginX() const
Get snapping origin X (position grid offset/shift)
void SetRotationRational(wxUint32 nomMask, wxUint32 denMask)
Set rotation rational raster nominator/denominator mask.
a2dLine & GetLineToSnap()
to ask engine for the line that needs to be snapped to a a2dCanvasObject
int GetSnapThresHold() const
used to snap vertexes to a pin or point like snapping features in objects.
double m_snapDistX
horizontal position snapping grid distance
wxUint32 m_rotationRationalNom
bit map of possible nominators (bit1->0.. bit32->31) for rational angle snapping
ERotationSnapModes GetRotationModes()
Get rotation/slanting snap modes (ored ERotationSnapModes)
void SetSnapTargetFeature(a2dSnapToWhat snapTargetFeature, bool value=true)
set one of the snapping features for targets to true or false, leaf others as is
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
vertex array of line and arc segments.
a2dCanvasObject is the base class for Canvas Objects.
EPositionSnapModes
Position snap modes/flags (once for x any y)
EPositionSnapModes m_posModesY
ored EPositionSnapModes of enabled modes for y
a2dSnapToWhatMask m_snapSourceFeatures
set to the a2dSnapToWhat features enabled by the engine for the source object
vertex list of line and arc segments.
bool GetShiftKeyDown() const
some snapping may depend on shift key being down
store and convert number to number with unit and visa versa. e.g. 1.23e-6 => 1.23 * 1e-6 ...
wxUint32 m_rotationRationalDen
bit map of possible denominators (bit1->0.. bit32->31) for rational angle snapping ...
double m_top
minimum y coordinate (e.g. 0), transformed via affine transform and h
a2dDoMu m_snapDistX
horizontal position snapping grid distance
a2dDoMu m_originX
horizontal grid snapping origin vs. coordinate origin
a2dSnapToWhatMask GetSnapTargetFeatures() const
class a2dVertexList * m_other
other snapping points (enabled by bits in m_posModesX/m_posModesY, NOT owned or deleted by this objec...
void SetPosGrid(double x, double y)
Set snapping grid (only position)
a2dDoMu m_originY
vertical grid snapping origins vs. coordinate origin
const a2dPoint2D & GetRestrictPoint() const
to ask engine for the restrict point
ESizeSnapModes
Size snap modes/flags (once for x and y)
bool GetReleaseSnap() const
do not snap if set
classes for initializing the artbase modules, and set paths to be used for fonts etc.
int m_nAngleList
number of allowed rational angles
ESizeSnapModes m_sizeModesY
ored ESizeSnapModes of enabled modes for y
double * m_angleList
sorted list of allowed rational angles
void SetParentSnapObjects(a2dCanvasObject *obj)
parent object of objects that need to be snapped to
a2dCanvasObject * GetParentSnapObjects() const
return pointer of the current parent object
a2dSmrtPtr< a2dRestrictionEngine > a2dRestrictionEnginePtr
Smart pointer type for restriction engine.
wxUint32 m_rotationRationalDen
bit map of possible denominators (0..31) for rational angle snapping
void SetSnapOnlyVisibleObjects(bool snapOnlyVisbleObjects)
enable all snapping features for object only for visible object.
double m_centerY
center y coordinate (e.g. 0.5), transformed via affine transform and h
ESnapWhat
Flags for what to touch during a restriction.
double m_originY
vertical grid snapping origins vs. coordinate origin
ESizeSnapModes m_sizeModesX
anded with m_sizeModesX of wxRetrictionEngine
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
a2dPoint2D GetPointToSnap() const
to ask engine for the point that needs to be snapped to a a2dCanvasObject
bool GetSnap() const
enable all snapping features or not
void SetSnapSourceFeatures(wxUint32 snapSourceFeatures)
double m_minSizeY
minimal vertical size
ERotationSnapModes
Rotation/Slanting snap modes/flags.
a2dSnapToWhatMask m_snapTargetFeatures
set to the a2dSnapToWhat target features enabled by the engine and/or snap source object ...
bool m_releaseSnap
to not snap inside snapping engine.
Restriction engine for editing restrictions like snapping.
bool GetSnapTargetFeature(a2dSnapToWhat snapTargetFeature) const
return the setting of a specific snapping feature
ESizeSnapModes GetSizeModesX()
Get size snap modes (ored ESizeSnapModes)
Input and output handler for the XmlSer format.
double GetCenterSnapX()
Get horizontal center snapping distance (zero if disabled)
double m_sizeY
vertical size snapping grid distance
bool m_snap
if true snapping modes are enabled, else non.
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
Structure to descripe snapping properties of an object.
void SetRotationRational(wxUint32 nomMask, wxUint32 denMask)
Set rotation rational raster nominator/denominator mask.
A 2x3 affine matrix class for 2D transformations.
void SetSnapOrigin(const a2dDoMu &x, const a2dDoMu &y)
Set snapping origin (position grid offest/shift)
double m_originX
horizontal grid snapping origin vs. coordinate origin
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
void SetPosModes(EPositionSnapModes modeX, EPositionSnapModes modeY=posEqual)
Set position snap modes (ored EPositionSnapModes)
double m_maxSizeX
maximal horiontal size
ERotationSnapModes m_rotModes
ored ERotationSnapModes of enabled modes
double m_right
maximum x coordinate (e.g. 1), transformed via affine transform and w
double m_bottom
maximum y coordinate (e.g. 1), transformed via affine transform and h
DEPRECATED Restriction engine for editing restrictions like snapping.
void SetReleaseSnap(bool releaseSnap)
do not snap if set
void SetSizeModes(ESizeSnapModes modeX, ESizeSnapModes modeY=sizeEqual)
Set size snap modes (ored ESizeSnapModes)
void SetRotationAngle(double a)
Set rotation angle raster.
bool GetSnapOnlyVisibleObjects() const
all snapping features for object only for visible object?
int m_snapThresHold
threshold in pixels towards the snapping point.
void SetShiftKeyDown(bool shiftDown)
some snapping may depend on shift key being down
const a2dDoMu & GetSnapOriginY() const
Get snapping origin Y (position grid offset/shift)
double * m_angleList
sorted list of allowed rational angles
double m_centerX
center x coordinate (e.g. 0.5), transformed via affine transform and w
EPositionSnapModes GetPosModesX()
Get position snap modes (ored EPositionSnapModes)
void SetSnapGrid(double x, double y)
Set snapping grid (position and size)
smart pointer class and list.
double GetCenterSnapY()
Get vertical center snapping distance (zero if disabled)
a2dCanvasObject * m_parentObject
parent canvas object in a2dCanvasDocument on which snapping needs to be done.
EPositionSnapModes m_posModesY
anded with m_posModesY of wxRetrictionEngine
double m_maxSizeY
maximal vertical size
bool m_snapOnlyVisbleObjects
if true snapping modes for object is only on visible object.
ERotationSnapModes m_rotModes
anded with m_rotModes of wxRetrictionEngine
double m_minSizeX
minimal horiontal size
void SetSnapOrigin(double x, double y)
Set snapping origin (position grid offest/shift)
a2dSnapToWhatMask GetSnapSourceFeatures() const
void SetSnapThresHold(int thresHold)
used to snap vertexes to a pin or point like snapping features in objects.
void SetMaxSize(double x, double y)
Set maximum size.
This template class is for property ids with a known data type.
void SetSnap(bool snap)
enable all snapping features or not
const a2dDoMu & GetSnapGridY() const
Get vertical center snapping distance (zero if disabled)
wxUint32 m_rotationRationalNom
bit map of possible nominators (0..31) for rational angle snapping
void SetMinSize(double x, double y)
Set minimum size.
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
a2dDoMu m_snapDistY
vertical position snapping grid distance
bool m_shiftDown
snapping modifier when shift key is pressed
void SetSnapTargetFeatures(wxUint32 snapTargetFeatures)
ESizeSnapModes m_sizeModesY
anded with m_sizeModesY of wxRetrictionEngine
double GetRotationAngle() const
Get rotation angle raster.