31 static inline double sqr(
double val ) {
return val * val;}
35 static int CmprDbl(
double* val1,
double* val2 )
39 else if( *val1 > *val2 )
80 const a2dSignal a2dRestrictionEngine::sig_changed = wxNewId();
88 ProcessEvent( changed );
100 void a2dRestrictionEngine::SetInternal()
117 : m_lineToSnap( 0, 0, 1, 1 )
179 static void SnapIfBetterPos(
double val,
double grid,
double origin,
double* best )
183 newVal = floor( ( val - origin ) / grid + 0.5 ) * grid + origin,
185 if( fabs( dist ) < fabs( *best ) )
194 static void SnapIfBetterSize(
double oldVal,
double newVal,
double* best )
197 dist = newVal - oldVal;
198 if( fabs( dist ) < fabs( *best ) )
206 static double SnapGrid(
double val,
double grid )
209 return floor( ( val ) / grid + 0.5 ) * grid;
224 return ( fabs( dx ) < thres && fabs( dy ) < thres );
250 sourceRequired & snapToObjectPos ||
262 a2dCanvasObjectList::value_type objchild = *iter;
263 if ( !objchild->GetRelease() &&
264 objchild->GetSnapTo() &&
269 if ( objchild->GetBbox().PointInBox( x, y, thresWorld ) )
293 double rad2deg = 180 /
wxPI;
294 double dx = x - m_pointToRestrictTo.m_x;
295 double dy = y - m_pointToRestrictTo.m_y;
296 double radius = sqrt( dx * dx + dy * dy );
302 ang = atan2( dy, dx );
306 dx = cos( angn ) * radius;
307 dy = sin( angn ) * radius;
308 x = m_pointToRestrictTo.m_x + dx;
309 y = m_pointToRestrictTo.m_y + dy;
315 double rad2deg = 180 /
wxPI;
316 double dx = x - m_pointToRestrictTo.m_x;
317 double dy = y - m_pointToRestrictTo.m_y;
318 double radius = sqrt( dx * dx + dy * dy );
324 ang = atan2( dy, dx );
328 dx = cos( ang ) * radius;
329 dy = sin( ang ) * radius;
330 x = m_pointToRestrictTo.m_x + dx;
331 y = m_pointToRestrictTo.m_y + dy;
335 if ( sourceRequired & snapToPointPos ||
343 if( sourceRequired & snapToPointPos )
345 if ( fabs( x - m_pointToRestrictTo.m_x ) < thresWorld &&
346 fabs( y - m_pointToRestrictTo.m_y ) < thresWorld
349 x = m_pointToRestrictTo.m_x;
350 y = m_pointToRestrictTo.m_y;
357 if ( fabs( x - m_pointToRestrictTo.m_x ) < thresWorld )
359 x = m_pointToRestrictTo.m_x;
366 if ( fabs( y - m_pointToRestrictTo.m_y ) < thresWorld )
368 y = m_pointToRestrictTo.m_y;
375 if ( fabs( x - m_pointToRestrictTo.m_x ) < fabs( y - m_pointToRestrictTo.m_y ) )
377 x = m_pointToRestrictTo.m_x;
382 y = m_pointToRestrictTo.m_y;
401 a2dCanvasObjectList::value_type objchild = *iter;
402 if ( !objchild->GetRelease() &&
403 objchild->GetSnapTo() &&
408 if ( objchild->GetBbox().PointInBox( x, y, thresWorld ) )
459 sx = floor( ( x - m_docOriginX ) / m_docSnapDistX + 0.5 ) * m_docSnapDistX + m_docOriginX;
464 sy = floor( ( y - m_docOriginY ) / m_docSnapDistY + 0.5 ) * m_docSnapDistY + m_docOriginY;
468 if (sourceRequired & snapToGridPosForced )
469 thresWorld = wxMax( m_docSnapDistX*0.51, m_docSnapDistY*0.51 );
504 static int CmprDbl(
const void* val1,
const void* val2 )
506 if( *(
double* )val1 < * (
double* )val2 )
508 else if( *(
double* )val1 > *(
double* )val2 )
518 return floor( angle / angleSnapRad + 0.5 ) * angleSnapRad;
524 angle = atan2( *vecy, *vecx ),
525 len = sqrt( sqr( *vecx ) + sqr( *vecy ) );
527 *vecx = cos( angle ) * len;
528 *vecy = sin( angle ) * len;
534 angleOld = atan2( *vecy, *vecx ),
536 angleOther = atan2( othery, otherx ),
537 proj = *vecx * othery - *vecy * otherx;
539 if( fabs( angleNew - angleOther ) < 1e-5 )
546 angleNew1 = angleNew - angleSnapRad,
547 angleNew2 = angleNew + angleSnapRad;
548 if( fabs( angleOld - angleNew1 ) < fabs( angleOld - angleNew2 ) )
549 angleNew = angleNew1;
551 angleNew = angleNew2;
555 newx = cos( angleNew ),
556 newy = sin( angleNew ),
557 newpro = newx * othery - newy * otherx;
562 *vecx = newx * ( proj / newpro );
563 *vecy = newy * ( proj / newpro );
582 if( angle >
wxPI / 2 )
587 if( angle >
wxPI / 4 )
590 angle =
wxPI / 2 - angle;
597 mAngles = 31 * 30 / 2 + 1;
603 angles[nAngles++] = 0;
605 for( i = 1; i <= 31; i++ )
609 for(
int j = i; j <= 31; j++ )
613 assert( nAngles < mAngles );
614 angles[nAngles++] = atan(
double( i ) /
double( j ) );
621 qsort( angles, nAngles,
sizeof( *angles ), CmprDbl );
625 for( i = 1; i < nAngles; i++ )
650 while( high - low > 1 )
652 mid = ( low + high ) >> 1;
669 angle =
wxPI / 2 - angle;
670 angle += quad *
wxPI / 2;
678 angle = atan2( *vecy, *vecx ),
679 len = sqrt( sqr( *vecx ) + sqr( *vecy ) );
681 *vecx = cos( angle ) * len;
682 *vecy = sin( angle ) * len;
723 double x = seg->
m_x1;
724 double y = seg->
m_y1;
728 if ( fabs( x - seg->
m_x1 ) < fabs( dx ) && fabs( y - seg->
m_y1 ) < fabs( dy ) )
754 for ( i = 0; i < segments->size(); i++ )
762 if ( fabs( x - seg->
m_x ) < dx && fabs( y - seg->
m_y ) < dy )
764 dx = fabs( x - seg->
m_x );
765 dy = fabs( y - seg->
m_y );
781 for( a2dVertexList::iterator iter = lsegments->begin(); iter != lsegments->end(); ++iter, i++ )
789 if ( fabs( x - seg->
m_x ) < dx && fabs( y - seg->
m_y ) < dy )
791 dx = fabs( x - seg->
m_x );
792 dy = fabs( y - seg->
m_y );
842 static const double Eps = 1e-10;
853 wfa = w ? fabs( *w ) : 1,
854 hfa = h ? fabs( *h ) : 1,
875 diff = *mNew - *mOld;
878 maxOld = mOld->GetMaximum(),
882 linearZero = maxDiff <= wxMax( maxNew, maxOld ) * Eps ;
885 fabs( diff.
m_matrix[2][0] ) <= wxMax( fabs( mNew->
m_matrix[2][0] ), fabs( mOld->m_matrix[2][0] ) ) * Eps &&
886 fabs( diff.
m_matrix[2][1] ) <= wxMax( fabs( mNew->
m_matrix[2][1] ), fabs( mOld->m_matrix[2][1] ) ) * Eps ;
888 if( linearZero && shiftZero )
899 else if( linearZero )
903 else if( fabs( detDiff ) < sqr( maxDiff ) * Eps )
912 if( fabs( det1 ) <= max1 * Eps && fabs( det2 ) <= max2 * Eps )
979 a20 += a00 * fixX + a10 * fixY;
980 a21 += a01 * fixX + a11 * fixY;
1025 lenY = sqrt( sqr( a11 ) + sqr( a10 ) ),
1026 lenX = sqrt( sqr( a01 ) + sqr( a00 ) );
1029 if( a00* a11 - a01* a10 >= 0 )
1032 a10 = -a01 * lenY / lenX;
1033 a11 = a11 * lenY / lenX;
1038 a10 = a01 * lenY / lenX;
1039 a11 = -a00 * lenY / lenX;
1075 lenY = sqrt( sqr( a11 ) + sqr( a10 ) );
1093 oldLen = wfa * sqrt( sqr( a00 ) + sqr( a01 ) ),
1111 SnapIfBetterSize( oldLen, SnapGrid( wfa * sqrt( sqr( a00 ) + sqr( a01 ) ),
m_sizeX ), &best );
1119 otherLen = sqrt( sqr( a10 ) + sqr( a11 ) );
1123 prjc = wfa * ( - a00 * a11 + a01 * a10 ) / otherLen;
1127 newLen = oldLen * SnapGrid( prjc,
m_sizeX ) / prjc;
1128 SnapIfBetterSize( oldLen, newLen, &best );
1135 major = wfa * wxMax( a00, a01 );
1139 newLen = oldLen * SnapGrid( major,
m_sizeX ) / major;
1140 SnapIfBetterSize( oldLen, newLen, &best );
1150 newLen = oldLen * SnapGrid( axis,
m_sizeX ) / axis;
1151 SnapIfBetterSize( oldLen, newLen, &best );
1155 if( best != DBL_MAX )
1157 newLen = oldLen + best;
1158 if( ( modes & sizeMin ) && newLen <
m_minSizeX )
1160 else if( ( modes & sizeMax ) && newLen >
m_maxSizeX )
1164 if( newLen != oldLen )
1168 if( w && ( snapWhat &
snapWH ) )
1170 *w *= newLen / oldLen;
1174 a00 *= newLen / oldLen;
1175 a01 *= newLen / oldLen;
1219 !( ( snapWhat &
snapWH ) && w && h == w )
1229 oldLen = hfa * sqrt( sqr( a10 ) + sqr( a11 ) ),
1247 SnapIfBetterSize( oldLen, SnapGrid( hfa * sqrt( sqr( a10 ) + sqr( a11 ) ),
m_sizeY ), &best );
1255 otherLen = sqrt( sqr( a00 ) + sqr( a01 ) );
1259 prjc = hfa * ( - a10 * a01 + a11 * a00 ) / otherLen;
1263 newLen = oldLen * SnapGrid( prjc,
m_sizeY ) / prjc;
1264 SnapIfBetterSize( oldLen, newLen, &best );
1271 major = hfa * wxMax( a10, a11 );
1275 newLen = oldLen * SnapGrid( major,
m_sizeY ) / major;
1276 SnapIfBetterSize( oldLen, newLen, &best );
1286 newLen = oldLen * SnapGrid( axis,
m_sizeY ) / axis;
1287 SnapIfBetterSize( oldLen, newLen, &best );
1291 if( best != DBL_MAX )
1293 newLen = oldLen + best;
1294 if( ( modes & sizeMin ) && newLen <
m_minSizeY )
1296 else if( ( modes & sizeMax ) && newLen >
m_maxSizeY )
1300 if( newLen != oldLen )
1304 if( h && ( snapWhat & snapWH ) )
1306 *h *= newLen / oldLen;
1310 a10 *= newLen / oldLen;
1311 a11 *= newLen / oldLen;
1354 a20 -= a00 * fixX + a10 * fixY;
1355 a21 -= a01 * fixX + a11 * fixY;
1384 bestShift = DBL_MAX;
1386 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1388 SnapIfBetterPos( a00 * info->
m_left + a10 * info->
m_top + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1390 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_top + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1392 SnapIfBetterPos( a00 * info->
m_right + a10 * info->
m_top + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1394 SnapIfBetterPos( a00 * info->
m_right + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1396 SnapIfBetterPos( a00 * info->
m_right + a10 * info->
m_bottom + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1398 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_bottom + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1400 SnapIfBetterPos( a00 * info->
m_left + a10 * info->
m_bottom + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1402 SnapIfBetterPos( a00 * info->
m_left + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1408 SnapIfBetterPos( a00 * point.m_x + a10 * point.m_y + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1414 if( fabs( a00 ) < Eps * fabs( a01 ) )
1417 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_top + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1419 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1421 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_bottom + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1424 if( fabs( a10 ) < Eps * fabs( a11 ) )
1427 SnapIfBetterPos( a00 * info->
m_left + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1429 SnapIfBetterPos( a00 * info->
m_centerX + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1431 SnapIfBetterPos( a00 * info->
m_right + a10 * info->
m_centerY + a20, m_docSnapDistX, m_docOriginX, &bestShift );
1434 assert( fabs( bestShift ) <= 0.50001 * m_docSnapDistX );
1446 bestShift = DBL_MAX;
1448 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1450 SnapIfBetterPos( a01 * info->
m_left + a11 * info->
m_top + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1452 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_top + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1454 SnapIfBetterPos( a01 * info->
m_right + a11 * info->
m_top + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1456 SnapIfBetterPos( a01 * info->
m_right + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1458 SnapIfBetterPos( a01 * info->
m_right + a11 * info->
m_bottom + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1460 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_bottom + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1462 SnapIfBetterPos( a01 * info->
m_left + a11 * info->
m_bottom + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1464 SnapIfBetterPos( a01 * info->
m_left + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1470 SnapIfBetterPos( a01 * point.m_x + a11 * point.m_y + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1476 if( fabs( a01 ) < Eps * fabs( a11 ) )
1479 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_top + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1481 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1483 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_bottom + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1486 if( fabs( a01 ) < Eps * fabs( a11 ) )
1489 SnapIfBetterPos( a01 * info->
m_left + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1491 SnapIfBetterPos( a01 * info->
m_centerX + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1493 SnapIfBetterPos( a01 * info->
m_right + a11 * info->
m_centerY + a21, m_docSnapDistY, m_docOriginY, &bestShift );
1496 assert( fabs( bestShift ) <= 0.50001 * m_docSnapDistY );
1514 deg2rad =
wxPI / 180,
1515 rad2deg = 180 /
wxPI;
1533 *x = floor( ( *x - m_docOriginX ) / m_docSnapDistX + 0.5 ) * m_docSnapDistX + m_docOriginX;
1538 *y = floor( ( *y - m_docOriginY ) / m_docSnapDistY + 0.5 ) * m_docSnapDistY + m_docOriginY;
1546 return floor( angle / angleSnapRad + 0.5 ) * angleSnapRad;
1552 angle = atan2( *vecy, *vecx ),
1553 len = sqrt( sqr( *vecx ) + sqr( *vecy ) );
1555 *vecx = cos( angle ) * len;
1556 *vecy = sin( angle ) * len;
1562 angleOld = atan2( *vecy, *vecx ),
1564 angleOther = atan2( othery, otherx ),
1565 proj = *vecx * othery - *vecy * otherx;
1567 if( fabs( angleNew - angleOther ) < 1e-5 )
1574 angleNew1 = angleNew - angleSnapRad,
1575 angleNew2 = angleNew + angleSnapRad;
1576 if( fabs( angleOld - angleNew1 ) < fabs( angleOld - angleNew2 ) )
1577 angleNew = angleNew1;
1579 angleNew = angleNew2;
1583 newx = cos( angleNew ),
1584 newy = sin( angleNew ),
1585 newpro = newx * othery - newy * otherx;
1590 *vecx = newx * ( proj / newpro );
1591 *vecy = newy * ( proj / newpro );
1610 if( angle >
wxPI / 2 )
1615 if( angle >
wxPI / 4 )
1618 angle =
wxPI / 2 - angle;
1625 mAngles = 31 * 30 / 2 + 1;
1631 angles[nAngles++] = 0;
1633 for( i = 1; i <= 31; i++ )
1637 for(
int j = i; j <= 31; j++ )
1641 assert( nAngles < mAngles );
1642 angles[nAngles++] = atan(
double( i ) /
double( j ) );
1649 qsort( angles, nAngles,
sizeof( *angles ), CmprDbl );
1653 for( i = 1; i < nAngles; i++ )
1678 while( high - low > 1 )
1680 mid = ( low + high ) >> 1;
1697 angle =
wxPI / 2 - angle;
1698 angle += quad *
wxPI / 2;
1706 angle = atan2( *vecy, *vecx ),
1707 len = sqrt( sqr( *vecx ) + sqr( *vecy ) );
1709 *vecx = cos( angle ) * len;
1710 *vecy = sin( angle ) * len;
enable position snapping of object top line to grid, if x axis parallel to main axis ...
perform x position snapping to a specific point
allow only pure one axis slanting
perform snapping to boundingbox of objects
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
double m_rotationAngle
angle snapping angle in degrees
perform y position snapping to a specific point
bool GetSnap() const
is snap flag set?
enable position snapping of object right to grid
a2dPoint2D m_snappedPoint
set to point that is snapped to m_pointToSnap
double m_matrix[3][2]
array store the six double for the affine matrix
EPositionSnapModes m_posModesX
anded with m_posModesX of wxRetrictionEngine
EPositionSnapModes m_posModesX
ored EPositionSnapModes of enabled modes for x
disable all rotation restriction modes
allow only pure rotations, no slanting
enable position snapping of object bottom left to grid
ESizeSnapModes m_sizeModesX
ored ESizeSnapModes of enabled modes for x
fundamental classes used by all other modules.
enable minimum size restriction
enable maximum size restriction
a2dRestrictionEngine()
Constructor.
void AngleRestrictVectorRot(double *vecx, double *vecy)
Restrict the angle of a vector, keeping the vectors length.
int m_nAngleList
number of allowed rational angles
double m_sizeX
horizontal size snapping grid distance
void RationalRestrictVector(double *vecx, double *vecy)
Rational restrict the angle of a vector.
void RestrictEndpointAngle(double *angle, const a2dAffineMatrix &matrix, ESnapWhat snapWhat)
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...
snap segments of other objects in a2dCanvasObject::RestrictToObject()
double RationalRestrict(double angle)
Rational restrict an angle.
virtual bool RestrictCanvasObjectAtVertexes(a2dCanvasObject *object, a2dPoint2D &point, double &dx, double &dy, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
return the clossest vertex which can be snapped if any.
~a2dRestrictionEngine()
Destructor.
a2dPoint2D m_pointToSnap
set to point that is currently being snapped.
double RationalRestrict(double angle)
Rational restrict an angle.
double m_snapDistY
vertical position snapping grid distance
double m_rotationAngle
angle snapping angle in degrees
perform x position snapping
double m_left
minimum x coordinate (e.g. 0), transformed via affine transform and w
snap to pins in other objects when not connected
The base class for all drawable objects in a a2dCanvasDocument.
double m_snapDistX
horizontal position snapping grid distance
snapping engine, for snapping while editing a drawing
wxUint32 m_rotationRationalNom
bit map of possible nominators (bit1->0.. bit32->31) for rational angle snapping
snap angle of endpoints or arcs
a2dRestrictionEngineOld()
Constructor.
disable all size restriction modes
vertex array of line and arc segments.
a2dCanvasObject is the base class for Canvas Objects.
EPositionSnapModes m_posModesY
ored EPositionSnapModes of enabled modes for y
virtual bool RestrictLine(a2dLine &line, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single line.
#define A2D_PROPID_M(type, classname, propname, defaultval, mptr)
to define a get set property more easily
bool SetPointIfCloser(const a2dPoint2D &pointToSnapTo, const a2dPoint2D &pointToSnap, a2dPoint2D &bestPointSofar, double thresHoldWorld)
a2dSnapToWhatMask m_snapSourceFeatures
set to the a2dSnapToWhat features enabled by the engine for the source object
enable position snapping of object top right to grid
double GetDeterminant2() const
Calculate the determinat of the transformed x-axis vector and the shift vector.
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
vertex list of line and arc segments.
wxUint32 m_rotationRationalDen
bit map of possible denominators (bit1->0.. bit32->31) for rational angle snapping ...
a2dDrawingPart * GetActiveDrawingPart()
return the currently/last active drawing part.
double m_top
minimum y coordinate (e.g. 0), transformed via affine transform and h
a2dDoMu m_snapDistX
horizontal position snapping grid distance
void SetPointSnapResult(const a2dPoint2D &p)
set the point that was snapped to a a2dCanvasObject vertex
a2dDoMu m_originX
horizontal grid snapping origin vs. coordinate origin
class a2dVertexList * m_other
other snapping points (enabled by bits in m_posModesX/m_posModesY, NOT owned or deleted by this objec...
a2dDoMu m_originY
vertical grid snapping origins vs. coordinate origin
enable position snapping of object top to grid
enable position snapping of object v-center line to grid, if y axis parallel to main axis ...
enable position snapping of object center to grid
enable position snapping of object bottom line to grid, if x axis parallel to main axis ...
If no other snap point was closer, force to grid, even if not within threshold.
snap to other objects its vertexes, which are decided in a2dCanvasObject::RestrictToObject() ...
enable all 6 line snapping modes
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
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
double GetMaximum2() const
Calculate the maximum absolute of the elemnts entering GetDeterminant2.
enable position snapping of object left to grid
#define forEachIn(listtype, list)
easy iteration for a2dlist
wxUint32 m_rotationRationalDen
bit map of possible denominators (0..31) for rational angle snapping
double m_centerY
center y coordinate (e.g. 0.5), transformed via affine transform and h
Normal straight line segment in a2dVpath.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
virtual bool RestrictVertexes(a2dVertexArray *segments, a2dPoint2D &point, double &dx, double &dy, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
return the clossest vertex which can be snapped if any.
snap to intersections in other objects
ESnapWhat
Flags for what to touch during a restriction.
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
double m_originY
vertical grid snapping origins vs. coordinate origin
Normal straight line segment in a2dVertexList and a2dVertexArray.
ESizeSnapModes m_sizeModesX
anded with m_sizeModesX of wxRetrictionEngine
enable snapping of arc endpoint angles (rational)
enable position snapping of object right line to grid, if y axis parallel to main axis ...
double m_minSizeY
minimal vertical size
enable snapping of projection of transformed axis vector length to orthogonal of other axis vector ...
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.
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
double m_sizeY
vertical size snapping grid distance
enable position snapping of object bottom right to grid
double AngleRestrict(double angle)
Restrict an angle.
enable snapping of arc endpoint angles
enable position snapping of object other points to grid (e.g. triangle corner)
bool m_snap
if true snapping modes are enabled, else non.
during size snapping, change w/h rather than transform
Structure to descripe snapping properties of an object.
perform snapping to X or Y of a specific point
perform rotation snapping
enable rational snapping for rotations of second coordinate vektor
enable size snapping of transformed axis vector length
enable position snapping of object top left to grid
A 2x3 affine matrix class for 2D transformations.
double m_originX
horizontal grid snapping origin vs. coordinate origin
disable all posizion restriction modes
enable position snapping of object bottom to grid
double GetMaximum() const
Calculate the maximum absolute of the elemnts entering GetDeterminant.
double GetDeterminant1() const
Calculate the determinat of the shift vector and the transformed y-axis vector.
double m_maxSizeX
maximal horiontal size
while iterating a a2dCanvasDocument, this holds the context.
snap segments middle of other objects in a2dCanvasObject::RestrictToObject()
ERotationSnapModes m_rotModes
ored ERotationSnapModes of enabled modes
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
double m_x
x endpoint of line
enable angle snapping for rotations of second coordinate vektor
double GetMaximum1() const
Calculate the maximum absolute of the elemnts entering GetDeterminant1.
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
double m_y
y endpoint of line
a2dPATHSEG GetType() const
easy way to test type of segment
#define A2D_PROPID_GS(type, classname, propname, defaultval, fget, fset)
to define a get set property more easily
void RestrictPoint(double *x, double *y)
Restrict a single point of a line or polyline.
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...
perform y position snapping
~a2dRestrictionEngineOld()
Destructor.
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
enable angle snapping for rotation of first coordinate vektor
int m_snapThresHold
threshold in pixels towards the snapping point.
double m_y1
y endpoint of line
bool IsWithInThresHold(const a2dPoint2D &p)
check if point is within threshold to m_pointToSnap
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
perform rational angle snapping to a specific point
enable size snapping of transformed axis major component
perform snapping to snapping vector path returned by a2dCanvasObject::GetSnapVpath() ...
double AngleRestrict(double angle)
Restrict an angle.
enable restriction of single points (e.g. of polylines)
virtual bool RestrictAngle(double *ang, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict angle.
a2dCanvasObject * m_parentObject
parent canvas object in a2dCanvasDocument on which snapping needs to be done.
enable position snapping of object left line to grid, if y axis parallel to main axis ...
enable rational snapping for rotations of first coordinate vektor
EPositionSnapModes m_posModesY
anded with m_posModesY of wxRetrictionEngine
double m_maxSizeY
maximal vertical size
double GetDeterminant() const
Calculate the determinat of the linear transformation.
bool m_snapOnlyVisbleObjects
if true snapping modes for object is only on visible object.
void RestrictAffine(a2dAffineMatrix *mNew, const a2dAffineMatrix *mOld, ESnapWhat snapWhat, SnapObjectInfo *info, double *w=0, double *h=0)
Restrict an affine transformation.
enable position snapping of object h-center line to grid, if x axis parallel to main axis ...
void AngleRestrictVectorRot(double *vecx, double *vecy)
Restrict the angle of a vector, keeping the vectors length.
void RationalRestrictVector(double *vecx, double *vecy)
Rational restrict the angle of a vector.
a2dDrawing * GetDrawing() const
get drawing via top object
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
double m_x1
x endpoint of line
ERotationSnapModes m_rotModes
anded with m_rotModes of wxRetrictionEngine
double m_minSizeX
minimal horiontal size
a2dVpath * GetSegments()
modify point at index to x,y
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dCanvasObject for a Vector Path
perform angle snapping to multiples of m_rotationAngle to a specific point
This template class is for property ids with a known data type.
wxUint32 m_rotationRationalNom
bit map of possible nominators (0..31) for rational angle snapping
double GetSnapThresHoldWorld() const
used to snap vertexes to a pin or point, for snapping features in objects.
a2dDoMu m_snapDistY
vertical position snapping grid distance
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
bool m_shiftDown
snapping modifier when shift key is pressed
Contain one drawing as hierarchical tree of a2dCanvasObject's.
enable size snapping of projection to untronsformed axis
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
const double wxPI
defines PI
snap to pins in other objects
perform alligning to X or Y of a specific point
#define A2D_PROPID_GSI(type, classname, propname, defaultval)
to define a get set property more easily
ESizeSnapModes m_sizeModesY
anded with m_sizeModesY of wxRetrictionEngine