Skip to content

Improve Context2D labeled isolines

  • Fix label orientations under conditions when the viewport is not square (i.e. when it has aspect ratio far from 1.0).

  • Also remove the rendering of the background quad, as that is already done for us by the DrawString api method, so we were getting two quads drawn behind each label, and the one we drew manually suffered from stretching and skewing under the viewport conditions described above.

  • Additionally fix the computation in display coords of the corners of each label bbox, which was resulting in label overlap testing not catching too many labels in the same neighborhood.

  • Finally, remove some code that is not being used. This code was initially copied from the 3D labeled contour mapper, and some parts were left in place at the time even though they are not needed in a 2D coordinate system. There are still cleanups that remain to be done along these lines, but this is a step in the right direction.

In the image below, the contoured wavelet is shown in three different viewports. While everything is fine in the square viewport, the label backgrounds are stretched misshapen in the other two.

before-fixes

In the image below, the same script has generated nice-looking labels in all viewports. Also notice that the label colors are brighter (or at least more saturated) in the image above. This is because the color is set to red, the opacity set to 0.5, and the old code drew an extra quad behind the one the OpenGL2 device is already drawing for us with each label.

after-fixes

The image below shows some similar issues with label contours before this fix. The vertical white strips are actually the extra label backgrounds, and it's clear the labels aren't being culled when they overlap. Also, the label orientations do not seem to match very well the direction of the underlying lines.

wk_figure3_before

The image below shows the same plot, but with the fixes from this topic.

wk_figure3_after

Edited by Scott Wittenburg

Merge request reports