Table of Contents

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

GeoPoint

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

bool

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

double

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

IGeoObject

DidSnap

The result: the snap mode that produced the current SnapPoint, or DidNotSnap.

public SnapPointFinder.DidSnapModes DidSnap

Field Value

SnapPointFinder.DidSnapModes

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

FilterList

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

GeoObjectList

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

double

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

Projection

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

bool

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

bool

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

bool

SnapLocalOrigin

If true, the origin of the drawing plane is offered as a snap point (DidSnapToLocalZero, setting "Snap.SnapLocalOrigin").

public bool SnapLocalOrigin

Field Value

bool

SnapMode

The combination of SnapPointFinder.SnapModes to apply; the SnapToXxx properties test its individual flags.

public SnapPointFinder.SnapModes SnapMode

Field Value

SnapPointFinder.SnapModes

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

GeoPoint

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

int

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

Axis

SourcePoint

Postition of the source point on the projection plane

public GeoPoint2D SourcePoint

Field Value

GeoPoint2D

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

double

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

Projection.PickArea

Properties

AdjustOrtho

True if AdjustOrtho is set in SnapMode. Requires a valid BasePoint.

public bool AdjustOrtho { get; }

Property Value

bool

SnapToDropPoint

True if SnapToDropPoint is set in SnapMode. Requires a valid BasePoint.

public bool SnapToDropPoint { get; }

Property Value

bool

SnapToFaceSurface

True if SnapToFaceSurface is set in SnapMode.

public bool SnapToFaceSurface { get; }

Property Value

bool

SnapToGridPoint

True if SnapToGridPoint is set in SnapMode.

public bool SnapToGridPoint { get; }

Property Value

bool

SnapToIntersectionPoint

True if SnapToIntersectionPoint is set in SnapMode.

public bool SnapToIntersectionPoint { get; }

Property Value

bool

SnapToObjectCenter

True if SnapToObjectCenter is set in SnapMode.

public bool SnapToObjectCenter { get; }

Property Value

bool

SnapToObjectPoint

True if SnapToObjectPoint is set in SnapMode.

public bool SnapToObjectPoint { get; }

Property Value

bool

SnapToObjectSnapPoint

True if SnapToObjectSnapPoint is set in SnapMode.

public bool SnapToObjectSnapPoint { get; }

Property Value

bool

SnapToTangentPoint

True if SnapToTangentPoint is set in SnapMode. Requires a valid BasePoint.

public bool SnapToTangentPoint { get; }

Property Value

bool

SnapToZero

True if SnapToZero is set in SnapMode.

public bool SnapToZero { get; }

Property Value

bool

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

toTest IGeoObject

The 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

p GeoPoint
obj IGeoObject
mode SnapPointFinder.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

SourcePoint Point

The mouse position in pixels of the view

projection Projection

The projection of the view

SnapMode SnapPointFinder.SnapModes

The snap modes to apply

MaxDist int

Maximum distance in pixels between the mouse position and an accepted snap point

Init(Point, Projection, SnapModes, int, GeoPoint)

public void Init(Point SourcePoint, Projection projection, SnapPointFinder.SnapModes SnapMode, int MaxDist, GeoPoint BasePoint)

Parameters

SourcePoint Point

The mouse position in pixels of the view

projection Projection

The projection of the view

SnapMode SnapPointFinder.SnapModes

The snap modes to apply

MaxDist int

Maximum distance in pixels between the mouse position and an accepted snap point

BasePoint GeoPoint

The 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

mode SnapPointFinder.DidSnapModes

The snap mode to rate

Returns

int

The priority; lower values win