Class SnapPointFinder
- Namespace
- CADability.GeoObject
- Assembly
- CADability.dll
Ths class serves as a parameter to FindSnapPoint(SnapPointFinder). It keeps the best snappoint, the object, which caused it and the distance to the mouse point.
public class SnapPointFinder
- Inheritance
-
SnapPointFinder
- Inherited Members
Constructors
SnapPointFinder()
Creates an uninitialized finder. Call Init(Point, Projection, SnapModes, int) (or the overload with a base point) before use.
public SnapPointFinder()
Fields
BasePoint
The base point (in model coordinates) for the snap modes that refer to a previously defined point: SnapToDropPoint, SnapToTangentPoint and AdjustOrtho. Only meaningful when BasePointValid is true.
public GeoPoint BasePoint
Field Value
BasePointValid
True when BasePoint has been set, i.e. when the Init(Point, Projection, SnapModes, int, GeoPoint) overload was used.
public bool BasePointValid
Field Value
BestDist
Distance (on the projection plane) of the best snap point found so far from the mouse position. Starts at MaxValue; Check(GeoPoint, IGeoObject, DidSnapModes) replaces the current snap point by one of the same priority only when it is closer.
public double BestDist
Field Value
BestObject
The object that provided the current SnapPoint, or null if no object was involved (grid, origin, orthogonal adjustment or no snapping at all). Views keep it as LastSnapObject.
public IGeoObject BestObject
Field Value
DidSnap
The result: the snap mode that produced the current SnapPoint, or DidNotSnap.
public SnapPointFinder.DidSnapModes DidSnap
Field Value
FilterList
Filter deciding which objects take part in the snap search (usually FilterList), see Accept(IGeoObject). May be null, in which case all objects are accepted.
public FilterList FilterList
Field Value
IgnoreList
Objects excluded from the snap search, typically the object that is currently being modified with the mouse. May be null.
public GeoObjectList IgnoreList
Field Value
MaxDist
Maximum distance (measured on the projection plane, in model units) a snap point may have from the mouse position to be accepted. Computed by Init(Point, Projection, SnapModes, int) from the pixel distance passed there.
public double MaxDist
Field Value
Projection
The projection of the view in which the snapping takes place. It provides the drawing plane and the conversion between model coordinates and the projection plane.
public Projection Projection
Field Value
Snap30
If true, circles, arcs and ellipses additionally offer the points at multiples of 30 degrees as object snap points (DidSnapToObjectSnapPoint).
public bool Snap30
Field Value
Snap45
If true, circles, arcs and ellipses additionally offer the points at multiples of 45 degrees as object snap points (DidSnapToObjectSnapPoint).
public bool Snap45
Field Value
SnapGlobalOrigin
If true, the origin of the model coordinate system is offered as a snap point (DidSnapToAbsoluteZero, setting "Snap.SnapGlobalOrigin").
public bool SnapGlobalOrigin
Field Value
SnapLocalOrigin
If true, the origin of the drawing plane is offered as a snap point (DidSnapToLocalZero, setting "Snap.SnapLocalOrigin").
public bool SnapLocalOrigin
Field Value
SnapMode
The combination of SnapPointFinder.SnapModes to apply; the SnapToXxx properties test its individual flags.
public SnapPointFinder.SnapModes SnapMode
Field Value
SnapPoint
The result: the snapped point in model coordinates. Before any snapping it holds the mouse position on the drawing plane, so it is valid even when DidSnap is DidNotSnap.
public GeoPoint SnapPoint
Field Value
SnapPointIndex
Reserved for the index of the snap point within BestObject. It is reset to 0 by Init(Point, Projection, SnapModes, int) and not set by the current snap implementations.
public int SnapPointIndex
Field Value
SourceBeam
The line perpendicular to the screen through the mouse position, in model coordinates. Snap points are searched close to this line, and surfaces are intersected with it for SnapToFaceSurface.
public Axis SourceBeam
Field Value
SourcePoint
Postition of the source point on the projection plane
public GeoPoint2D SourcePoint
Field Value
faceDist
For SnapToFaceSurface: the position along the SourceBeam of the closest surface found so far. Faces (and bitmaps) use it to keep only the frontmost surface under the cursor.
public double faceDist
Field Value
pickArea
The pick area (a small square around the mouse position, extruded along the view direction) used to find the objects close to the mouse. Its size is given by the pixel distance passed to Init(Point, Projection, SnapModes, int).
public Projection.PickArea pickArea
Field Value
Properties
AdjustOrtho
True if AdjustOrtho is set in SnapMode. Requires a valid BasePoint.
public bool AdjustOrtho { get; }
Property Value
SnapToDropPoint
True if SnapToDropPoint is set in SnapMode. Requires a valid BasePoint.
public bool SnapToDropPoint { get; }
Property Value
SnapToFaceSurface
True if SnapToFaceSurface is set in SnapMode.
public bool SnapToFaceSurface { get; }
Property Value
SnapToGridPoint
True if SnapToGridPoint is set in SnapMode.
public bool SnapToGridPoint { get; }
Property Value
SnapToIntersectionPoint
True if SnapToIntersectionPoint is set in SnapMode.
public bool SnapToIntersectionPoint { get; }
Property Value
SnapToObjectCenter
True if SnapToObjectCenter is set in SnapMode.
public bool SnapToObjectCenter { get; }
Property Value
SnapToObjectPoint
True if SnapToObjectPoint is set in SnapMode.
public bool SnapToObjectPoint { get; }
Property Value
SnapToObjectSnapPoint
True if SnapToObjectSnapPoint is set in SnapMode.
public bool SnapToObjectSnapPoint { get; }
Property Value
SnapToTangentPoint
True if SnapToTangentPoint is set in SnapMode. Requires a valid BasePoint.
public bool SnapToTangentPoint { get; }
Property Value
SnapToZero
True if SnapToZero is set in SnapMode.
public bool SnapToZero { get; }
Property Value
SourcePoint3D
The source point (the mouse position on the projection plane, see SourcePoint) as a 3d point in model coordinates. Together with the direction of the projection it defines the line perpendicular to the screen through the mouse position, along which snap points are searched.
public GeoPoint SourcePoint3D { get; }
Property Value
- GeoPoint
The mouse position as a 3d point on the projection plane.
Methods
Accept(IGeoObject)
Tests whether toTest may take part in the snap search according to FilterList.
public bool Accept(IGeoObject toTest)
Parameters
toTestIGeoObjectThe object to test
Returns
- bool
true if there is no filter list or the filter list accepts the object
Check(GeoPoint, IGeoObject, DidSnapModes)
The IGeoObject obj offers the point p as a snappoint in the given mode. This method checks whether to use this point as the closest snap point. This method is typically called by GeoObjects from the FindSnapPoint(SnapPointFinder) method.
public void Check(GeoPoint p, IGeoObject obj, SnapPointFinder.DidSnapModes mode)
Parameters
pGeoPointobjIGeoObjectmodeSnapPointFinder.DidSnapModes
Init(Point, Projection, SnapModes, int)
Prepares the finder for a snap search at the mouse position SourcePoint: resets the result
(SnapPoint is the mouse position on the drawing plane, DidSnap is
DidNotSnap), computes SourceBeam, pickArea and
MaxDist and sets the snap modes. No base point is defined, so the modes that need one have no effect.
public void Init(Point SourcePoint, Projection projection, SnapPointFinder.SnapModes SnapMode, int MaxDist)
Parameters
SourcePointPointThe mouse position in pixels of the view
projectionProjectionThe projection of the view
SnapModeSnapPointFinder.SnapModesThe snap modes to apply
MaxDistintMaximum distance in pixels between the mouse position and an accepted snap point
Init(Point, Projection, SnapModes, int, GeoPoint)
Same as Init(Point, Projection, SnapModes, int), but additionally defines the BasePoint needed for SnapToDropPoint, SnapToTangentPoint and AdjustOrtho.
public void Init(Point SourcePoint, Projection projection, SnapPointFinder.SnapModes SnapMode, int MaxDist, GeoPoint BasePoint)
Parameters
SourcePointPointThe mouse position in pixels of the view
projectionProjectionThe projection of the view
SnapModeSnapPointFinder.SnapModesThe snap modes to apply
MaxDistintMaximum distance in pixels between the mouse position and an accepted snap point
BasePointGeoPointThe base point in model coordinates
SnapHierarchy(DidSnapModes)
Returns the priority of a snap mode: 1 for intersection points and object snap points, 2 for tangent points and perpendicular foot points, 3 for object centers, 4 for arbitrary object points, 5 for grid points, 6 for the orthogonal adjustment and 7 for everything else (including DidNotSnap). Check(GeoPoint, IGeoObject, DidSnapModes) replaces the current snap point only by one with a lower or equal value.
public int SnapHierarchy(SnapPointFinder.DidSnapModes mode)
Parameters
modeSnapPointFinder.DidSnapModesThe snap mode to rate
Returns
- int
The priority; lower values win