← Back to team overview

yade-dev team mailing list archive

Re: drawing a color legend

 

> Hello.
> I want to draw a color legend from ColorizedVelocityFilter engine.
>   
:-) there is duplicated code, see Shop::scalarOnColorScale, which uses
the algorithm from matplotlib.
> How to draw from engine? Is there such mechanism?
>   
I recently added GL locking which should make it possible, but I give no
warranties. You _must_ get a GLLock before manipulating GL, otherwise
you get error/crash/hardlock (depending on graphics card and driver). I
don't know however, if you will get the scale painted after the whole
scene of just before the scene, maybe it is undefined.

I was thinking once of using openscenegraph for GL stuff, since we're
already got bunch of low-level hacks to get relatively decent 3d. One
more hack could be to draw the scale in GLViewer::postDraw, but you must
carefully think were you store min/max values (in the engine? and the
GLViewer will have to search engines every time? Or in the GLViewer? But
what if there is no GLViewer? And so on). If someone needs, god forbid,
two scales or three scales, we're lost...
> Currently, I see an possibility to do so by adding a body with an appropriate GeometricalModel...
>   
It would be subject to 3d manipulation of the scene (GL functors for
bodies are in local coordinates), whereas here you need something that
is bound to the 2d view; maybe do the inverse glMatrix to get to global
space. You could also use special kind of interaction, since those are
GL-drawn in global space. But the constitutive law must skip such
interaction then. Still you need to find camera glMatrix and use its
inverse to get from global space to the view space. Eh, ugly.

What about creating special kind of objects just for this (like
MetaBody::planarWidgets ;-) ), like grid, time displays etc, that would
be drawn in the 2d space and add those to the OpenGLRenderingEngine?

V.




References