This pull request adds the arrow line annotation tool to the viewer app. To implement this functionality, I used the SVG line shape and added an arrowhead to the end of this line. This was done using the marker-end attribute that can be added to the <line /> tag. In the marker-end attribute the URL of an SVG definition needs to be given. So, we create an SVG marker definition for the arrowhead, add it to the SVG definitions - defs tag and reference the URL for this in the line attribute.
Changes
Created arrowline.js to add the functionality of the new tool.
mview.html: Loading the arrowline.js script
base.js: Made changes to handle the marker-end attribute. It needs to be added only for the arrow line annotation type.
annotation-svg.js: Added the code to add marker definition to the annotation SVG, changing the colour of the arrowhead on stroke change, parsing the saved arrow line annotations correctly and creating the corresponding marker SVG definitions for matching the stroke colours of the loaded arrow lines.
annotation-group.js: Added the arrow line annotation type case.
annotation-tool.js: HTML code changes to render the arrow line option in the tool and other arrow line case changes.
Misc
The PR might show other file changes, but those are due to the formatting being updated for the files. The exact lines for code changes are below:
mview.html: Loading the arrow line script.
arrowline.js: Created the entire file for the new annotation tool.
Implementation
This pull request adds the arrow line annotation tool to the viewer app. To implement this functionality, I used the SVG line shape and added an arrowhead to the end of this line. This was done using the
marker-end
attribute that can be added to the<line />
tag. In themarker-end
attribute the URL of an SVG definition needs to be given. So, we create an SVGmarker
definition for the arrowhead, add it to the SVG definitions -defs
tag and reference the URL for this in the line attribute.Changes
arrowline.js
to add the functionality of the new tool.mview.html
: Loading the arrowline.js scriptbase.js
: Made changes to handle themarker-end
attribute. It needs to be added only for the arrow line annotation type.annotation-svg.js
: Added the code to add marker definition to the annotation SVG, changing the colour of the arrowhead on stroke change, parsing the saved arrow line annotations correctly and creating the corresponding marker SVG definitions for matching the stroke colours of the loaded arrow lines.annotation-group.js
: Added the arrow line annotation type case.annotation-tool.js
: HTML code changes to render the arrow line option in the tool and other arrow line case changes.Misc The PR might show other file changes, but those are due to the formatting being updated for the files. The exact lines for code changes are below: