This PR adds a visual scale bar in the lower right corner of the image.
In perspective projection, because of foreshortening, the scale bar refers to the distance between tick-marks displayed on the bounding box.
In orthographic projection, the scale bar is correctly proportional for all camera angles since there is no foreshortening for orthographic projections.
Most important files to look at:
ScaleBarTool.cpp (draws the actual scale bar)
Font.cpp (encapsulate a texture map with a rendered ttf font)
gesture.cpp (how to draw text as one aligned bitmap quad per character)
Util.cpp (how to draw tickmarks in 3d)
Nearly all the rest is "plumbing".
Code changes:
add handling of units to all file i/o. The reported VolumeDimensions now have a units string. There is no intelligence about units at all - they are just treated as plain strings.
add ScaleBarTool. responsible for calculating the size and drawing the scale bar
add code to render tickmarks along the bounding box
add a bitmapped font generator so that text can be easily displayed on the viewport without overlays . For simplicity, no special characters are allowed in units strings, so there is a small utility function to clean a couple of known unit characters. (angstrom and micron)
add stb_image and stb_font third party code for ttf font handling and image loading. No need to review the stb files; they are simply copy-pasted in.
add build infrastructure to distribute the .ttf file as a bundled data file and runtime code to find and load it at runtime
ensure that rendering is consistent between interactive viewport and rendered image
add scale bar support to python api, web api, and serialization
This PR adds a visual scale bar in the lower right corner of the image. In perspective projection, because of foreshortening, the scale bar refers to the distance between tick-marks displayed on the bounding box.
In orthographic projection, the scale bar is correctly proportional for all camera angles since there is no foreshortening for orthographic projections.
Most important files to look at:
Nearly all the rest is "plumbing".
Code changes:
Perspective mode:
Orthographic mode