Article | 70002174 |
Type | Wish |
Product | WebJS |
Version | 9003 |
Date Added | 3/9/2022 12:00:00 AM |
Fixed | 10.1001.0.1 (3/12/2022 12:00:00 AM) |
Submitted by | Brendan Fry |
Summary
Add Window Polygon and Crossing Polygon select on WebCntrol.
Solution
In version 1001.0.1 new methods was added to vdcanvas object
GetEntitiesInWindowPolygon(pts, coordSystem)
A window polygon selection that
returns an array of vdraw entities that lie entirely inside the specified closed polygon.
Even if a small part of an entity lies outside the polygon, the entity is ignored.
pts:An array of points
coordSystem:The coordinate system of the passed pts
It can get the following values:
0 -or- false -or- undefined for pts are in pixels.
1 -or- true for pts are in WorldCS.
2 for pts are in current View.
and
GetEntitiesFromPolygon(pts, coordSystem)
A crossing polygon selection that
returns an array of vdraw entities that cross the specified closed polygon.
Even if a small part of an entity lies inside the polygon, it is added in the array.
pts: An array of points
coordSystem:The coordinate system of the passed pts
It can get the following values:
0 -or- false -or- undefined for pts are in pixels.
1 -or- true for pts are in WorldCS.
2 for pts are in current View.
Example
Prompt the user to select a polyline and make a polygon selection from selected polyline boundary vdcanvas.GetUserPoint(_onActiongetPointEntitySelection); function _onActiongetPointEntitySelection5(action, status) { var vdcanvas = action.vdrawOwner(); if (status == 'start') { vdcanvas.Prompt('pick an polyline that defines a close polygon for selection'); } else if (status == 'end') { vdcanvas.Prompt(''); if (!action.IsCanceled()) { var pt = vdcanvas.WorldToPixel([action.ResValue[X], action.ResValue[Y], 0]); var entity = vdcanvas.GetEntityFromPoint(pt[X], pt[Y]); //scan for an entity under the pick point if (!entity || entity._t !== vdConst.vdPolyline_code) return; //check if entity exist and is a polyline type var pts = vdcanvas.GetEntitySamplePoints(entity); //get the points of selected curve in world coordinate system var ents = vdcanvas.GetEntitiesFromPolygon(pts, 1); //for crossing polyon select //var ents = vdcanvas.GetEntitiesInWindowPolygon(pts, 1); //for window polygon select if (ents) { for (var i = 0; i < ents.length; i++) ents[i].HighLight = true; //highlight the selected figures setTimeout(vdcanvas.redraw); //post a redraw } } } }