getVWorldToImagePlate wrong on first canvas display
Hi,
I have a piece of code that puts a Canvas3D in a panel, and this one in a tabbed pane. The Java3D tab is not the one displayed when data is loaded, so to view the scene, tha user has to select the preview tab.
The preview panel as i call it, draws a series of polylines, each one having a text label beside its first point. As I want these texts to be sized so they are allways the same size in screen, I placed a TransformGroup with a scale Transform3D as parent of each text shape, to control its size.
To calculate the scale I use getLocaleToVWorld and getvWorldToImagePlate combined, to get to know the size of the text on screen, and having this, calculate a scale to turn it to be a constant value (say 1cm). When some change is made to the scene contents I recalculate the scale and update all transforms of the text shapes.
This works fine when some update occurs, but when I first select the preview tab and the Canvas3D is thus first displayed, the scale I get makes the texts very little. If right afterwards I make any change that forces to update the scale, I get one that makes the texts the right size.
The following is a secuence of scale calculations of my program, that show how the first scale greatly reduces the size, and the next one, which is forced by me on the setVisible method of the panel and provoked by selecting other tab and then again the preview tab, grows it to be the desired size:
// The calculated scale when data is loaded and the canvas is not visible
Image plate distance = 0.5301327278190269
Text scale = 0.028294800929778853
Previous scale = 1.0
Resulting scale = 0.028294800929778853
// The one calculated the first time it's made visible
Image plate distance = 0.0014393333718180712
Text scale = 10.42149115256946
Previous scale = 0.028294800929778853
Resulting scale = 0.2948740175534045
// The one when hidden and made visible again
Image plate distance = 0.014999999999999942
Text scale = 1.0000000000000038
Previous scale = 0.2948740175534045
Resulting scale = 0.2948740175534056
Regards

