Drawing a Gradient Palette range in TEveManager

Hello again,

I made boxes to represent hits in an event viewer (using TEveBoxSet). The colour of each box represents a value (energy deposit for instance). I defined a gradient ColorPalette according to the code below but I would like to display an axis with the full range somehow in the viewer (something like a TPaletteAxis in a 2D histogram) so that we know e.g if dark blue is the highest or the lowest value.
See picture attached.

Is there a way to do this?

Thanks a lot,
Sebastien

ncolors=550

ColorPalette=np.array([0], dtype=np.int32)
NRGBs = 5
stops = np.array( [0.00, 0.34, 0.61, 0.84, 1.00] )
red = np.array( [0.00, 0.00, 0.87, 1.00, 0.51] )
green= np.array( [0.00, 0.81, 1.00, 0.20, 0.00] )
blue= np.array( [0.51, 1.00, 0.12, 0.00, 0.00] )
ncolors=550
FI=TColor.CreateGradientColorTable(NRGBs, stops, red, green, blue, ncolors)
for i in range(ncolors): ColorPalette=np.append(ColorPalette,FI+i)


ROOT 6.10/08 mac os 10.13.4


I think @matevz may have an idea.

Hi,

Look at tutorials/eve boxset.C and overlay_palette.C.

The idea is that you tell Digit/Quad/BoxSet about the palette and set DigitValue for each box. Then you get controls for the min/max values and choice what to do with overflow/underflow (and even plot histos from the second tab).

Matevz

ok perfect thanks looks like overlay_palette is what I need.

Hi again,
so all ok to set the colours of the TEVEBoxSet according to a TEveRGBAPalette (colours still not great need to work on this), however the overlay palette is nowhere to be found in the viewer. I tried playing with the position of the overlay palette at declaration tried to update the GLViewere in many different ways. See part of the code below and a snapshot.
Thanks,

pal=TEveRGBAPalette(0,100)
po=TEveRGBAPaletteOverlay(pal, 0, 0, 40, 500); #I tried playing with different positions height and width

#... not shown load gdml geometry ad it to TEVEmamanger

#... not shown loop on event and create TEVEBoxset, set the digit color and add it to TEve...

#now try to draw the palette in the viewer
f3DView=gEve.GetDefaultViewer()
f3DView.GetGLViewer().SetGuideState(ROOT.TGLUtil.kAxesOrigin, ROOT.kTRUE, ROOT.kFALSE, GuideRef)
f3DView.GetGLViewer().SetCurrentCamera(ROOT.TGLViewer.kCameraPerspYOZ)
f3DView.GetGLViewer().AddOverlayElement(po)
f3DView.GetGLViewer().UpdateScene()
f3DView.GetGLViewer().DoDraw()

gEve.GetViewers().SwitchColorSet()
gEve.FullRedraw3D(ROOT.kTRUE)
#Palette is not shown see drawing

It would be better to format your posts according to the rules described here:
https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292/2
It will make them more readable.

ok thanks for the comment. I added code tags, I think it is more readable now

Yes it is :slight_smile: Thanks

Grrr … indeed it does not show up. Will investigate later today. Sorry about that :frowning:

Adding SetupColorArray() call like this apparently fixes the problem.

TEveRGBAPalette *p = new TEveRGBAPalette(0, 100);
p->SetupColorArray();

If the palette is actually used by a DigitSet() this call should be made automatically before overlay rendering is reached in the GL viewer.

Indeed there it is thanks! (No way I would have found this myself :slight_smile: )

See also some comments about the rainbow color map:
https://root.cern.ch/rainbow-color-map

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.