How can I implement a lasso or selection tool? Will this tool be able to scale, and rotate the selected strokes?
I see that there is a selection tool in your MyScriptATK_1.3 but nothing regarding it in iink.
Indeed, we do not have a lasso tool available out of the box in the API.
Basicall to develop a lasso, you should get the position of your lasso. You can then get the strokes inside of it. Once done, you can transform the strokes as you prefer (do a rotation, re-scale...), and also do the recognition if necessary!
basically, you normally have the cordinates of your lasso.
Once you have it, you need to export the content of your editor as JIIX. This way, you can process all the X and Y coordinates of your lasso, and determine if it is inside your lasso.
For each point of the JIIX, first transform it as follows (x_model and y_model are the coordinates from the JIIX):
auto transform = mEditorWidget->getEditor()->getRenderer()->getViewTransform();
auto point = transform.apply(x_model, y_model);
float x = point.x;
float y = point.y;
Then we use a isPointInsidePolygon function to determine if a point is inside the lasso (polygon is basically the lasso):
bool isPointInsidePolygon(float x, float y, const QList<QPoint>& polygon)
bool inside = false;
for (int i = 0, j = polygon.size() - 1; i < polygon.size(); j = i++)
float xi = (float)polygon[i].x(), yi = (float)polygon[i].y();
float xj = (float)polygon[j].x(), yj = (float)polygon[j].y();
bool intersect = ((yi > y) != (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
inside = !inside;
You can then determine the strokes inside of a lasso, and use these according to your needs.