Setting colors with gui commands

Dear all,

This is most probably a dumb question to ask, but I seem not to be able to get it right.
I have a gdml file which I load into my Geant4 program. It’s loaded with no colour schemes, and for that I’m creating a macro assigning the colors for each of the volumes with “/vis/geometry/set/colour”. The thing is, I have colours as RGB vectors, e.g., 0.6038273572921753 0.6038273572921753 0.6038273572921753, for each of the volumes. But I see from “/vis/geometry/set/colour” command that it takes firstly a depth parameter (which I’m setting to zero), then a Red component, and then integers for green and blue? I’m somewhat confused on how to use a float/double red component followed by integers that represent green and blue? I’d expect to use either a vector as I presented, or vectors using the 255 scale.

I’m sure that this is a very simple question, but I’m hammering my head on this little thing. I’d appreciate if anyone has an answer to this one.

Thanks a lot in advance.

Br,
Leonardo.

Yes, sorry to confuse. The colour argument in question is “red or string”. (The command guidance explains quite well - have you looked at it?
) So you can type “0 1 0“ or “green”, say. Does that help?

The first argument is depth of propagation into the geometry hierarchy. 0 is appropriate if you don’t want to propagate the colour down the tree.

1 Like

Dear Alisson,

Thanks a lot for your fast response. I understand your explanation, but still don’t get how would I add different combinations of the rgb. I get how one adds the three integers for simple colours, but how would it work for a case like 0.603 0.200 0.450 for example? I’m looking for the exact colours as those from a CAD file. I can do such combination by coding with SetVisAttributes->G4Colour(redValue, greenValue, blueValue). I’d expect to be able to do something similar via gui.

And thanks again for the support.

That would be

/vis/geometry/set/colour <log-vol-name> 0 0.603 0.200 0.450
1 Like

Dear Alisson,

Thank you for the support. It works well now :slight_smile:

Br,
Leonardo.

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