Closed rastogi-bhavya closed 3 years ago
(changes to master branch)
Add a check in onMouseDragToDrawEnd
to see for which shape has this function been called. If it is Polygon
then call insertPointAtDrawEnd
, else follow the normal procedure.
The logic behind this approach is that, we are saving every SVG object on drawEnd
. We just need to make sure that when drawing a polygon
we don't remove the mouse tracker that polygon
until the user either de-selects the polygon or switches to a different tool.
De-Selecting tool
I have also added the feature to de-select an annotation tool.
Line Drawing
The line drawing part was similar to the other annotation tools, so I did not had to create any new flow for adding, saving and editing a line.
Polygon Drawing
Since a polygon has multiple edge, the user needs to drag the mouse pointer again to add a new edge. The new vertex will be added between the first and last vertices of the polygon, thus creating the new edge.
Mouse trackers are used to draw the SVG. They are added at the start of drawing and removed at the end of the drawing event.
To add a polygon I had to make changes to the how the drawing works
Old Code
onMouseDragToDrawEnd
was which deleted the mouse tracker -> saved the SVG -> added new mouse tracker for the same type of annotation toolNew Code
_currentDrawingEvent
.null
then I save the polygon SVG and remove its tracker. I dont have to add a new tracker for polygon because the stop drawing event is only called when a different annotation tool is selected or the polygon tool is de-selected.Synchronization Problem
The
drawingStop
&updateMode
are called in the same function (onClickChangeBtn
) inannotation-tool.js
. Both of these events work with tracker, i.e. drawingStop deletes them adn updateMode add them, given the right parameters. This caused the mouse tracker for a new annotation to be deleted by the previousdrawingStop
event.Current Solution
Added a set timeout for
updateMode
, this prevent the above problem. But this also creates a new problem i.e., the user cannot start drawing a new object before the timeout duration, as the new tracker has not been added.Other Issue
console.log
issue: #52