70000009 I would like oSnaps added in vectordraw web control

Article 70000009
Type Wish
Product WebJS
Version 6027
Date Added 5/12/2014 12:00:00 AM
Fixed (5/20/2014 12:00:00 AM)
Submitted by Martin Poynter

Summary

I would like oSnaps added in vectordraw web control.

Solution

New osnap funcionality was added in version 7001 of the web library.

The user can select between various oSnap modes. More specifically the available modes are None, Endpoint,Midpoint, Centerpoint, Insertion, Nearest, Node, Quadratic and All. Also subsets of the available modes canbe used easily.
Also, the user can define the size and color of the oSnap mark. They maximum distance around the cursor where the oSnaps are enable is defined by the PickSize property of the vdcanvas object.

The use of the oSnap functionality is performed using the following functions.

SetOsnapMode(Integer) is used to set the appropriate oSnap mode. The oSnap mode is defined by an integer.
GetOsnapMode() returns the active oSnap mode.
EnableOsnapMode(Boolean) enables or disables the functionality of oSnaps, according to the bollean parameter passed. If set to disabled the osnap mode is not cleared, so when enabled again the same oSnaps will be active as before.


SetActionOsnapColor(object) is used to set the color of the oSnap mark. The parameter passed is a three dimensional array defining the red, green and blue values of the color.
SetActionOsnapSize(Integer) is used to define the size of the oSnap mark in pixels.

Not all entities support every available snapmode.
The endpoint snap is supported by the vdRect, vdLine, vdPolyLine, vdPolyface, vd3dFace, vdArc, vdEllipse and vdImage.
The midpoint snap is supported by the vdRect, vdLine, vdPolyLine, vdPolyface, vd3dFace, vdArc, vdEllipse and vdImage
The centerpoint snap is supported by the vdCircle, vdArc and vdEllipse
The insertion snap is supported by the vdRect, vdImage and vdText
The nearest snap is supported by all the entities
The node snap is supported by the vdPoint
The quadratic snap is supported by the vdCircle

Use example
//Setting the desired oSnap mode
function vdrawInitPageLoad() {

    vdmanager.AttachCanvas('display');900, 640, new Array(255,255,255));
    var vdcanvas = vdmanager.vdrawObject('display');

    //This defines the line width of the entities used during the Actions (e.g. the rubber line).
    vdcanvas.SetActionLineWidth(2);
    //This defines the osnap size in pixels.
    vdcanvas.SetActionOsnapSize(20);
    //This defines the color of the entities used during the Actions (e.g. the rubber line).
    vdcanvas.SetActionOsnapColor(new Array(255,0,0));
    //The pick size is used both in the select and osnap operations.
    vdcanvas.PickSize = 25;

    //We set the Endpoint and Centerpoint osnaps active.
    var oSnapmode = vdConst.OsnapMode_END + vdConst.OsnapMode_CEN;
    e.target.SetOsnapMode(oSnapmode);
    //This command enables the osnaps.
    e.target.EnableOsnapMode(true);

}

Send comments on this topic.