Strategy object for assigning colors and transparency to geometry volumes.
Strategy class for assigning colors/transparency to geometry volumes.
This class is used by TGeoManager::DefaultColors(const TGeoColorScheme*) to assign visualization colors and transparency to geometry volumes, typically after GDML import where no color information is stored.
The default implementation combines:
This class is intended for runtime use only (not persistified). Users can extend or override the default behavior by:
Helper "strategy" class used by TGeoManager::DefaultColors() to assign visualization attributes (line color and optional transparency) to imported geometries (e.g. GDML), where the source format does not encode colors.
Example B: Override Z-fallback mapping (keep name overrides)
Example C: Full custom policy via subclassing (optional)
Definition at line 48 of file TGeoColorScheme.h.
Public Types | |
| using | ColorHook_t = std::function<Int_t(const TGeoVolume *)> |
| Type of user hook for overriding color assignment. | |
| using | TranspHook_t = std::function<Int_t(const TGeoVolume *)> |
| Type of user hook for overriding transparency assignment. | |
| using | ZFallbackHook_t = std::function<Int_t(Int_t , EGeoColorSet )> |
| Type of user hook for overriding the Z-based fallback coloring. | |
Public Member Functions | |
| TGeoColorScheme (EGeoColorSet set=EGeoColorSet::kNatural) | |
| Constructor. | |
| virtual | ~TGeoColorScheme () |
| Virtual destructor. | |
| virtual Int_t | Color (const TGeoVolume *vol) const |
| Compute the color for a given volume. | |
| virtual Int_t | ColorForZ (Int_t Z, EGeoColorSet set) const |
| Compute fallback color based on material effective Z. | |
| EGeoColorSet | GetSet () const |
| Get the active color set. | |
| void | SetColorHook (ColorHook_t h) |
| Set a user hook for color assignment. | |
| void | SetSet (EGeoColorSet s) |
| Set the active color set. | |
| void | SetTransparencyHook (TranspHook_t h) |
| Set a user hook for transparency assignment. | |
| void | SetZFallbackHook (ZFallbackHook_t h) |
| Set a user hook for Z-based fallback coloring. | |
| virtual Int_t | Transparency (const TGeoVolume *vol) const |
| Compute the transparency for a given volume. | |
Static Public Member Functions | |
| static const TGeoMaterial * | GetMaterial (const TGeoVolume *vol) |
| Retrieve the material associated with a geometry volume. | |
Private Attributes | |
| ColorHook_t | fColorHook = nullptr |
| Optional user hook for color assignment. | |
| EGeoColorSet | fSet |
| Active color set selection. | |
| TranspHook_t | fTranspHook = nullptr |
| Optional user hook for transparency. | |
| ZFallbackHook_t | fZFallbackHook = nullptr |
| Optional user hook for Z fallback. | |
#include <TGeoColorScheme.h>
| using TGeoColorScheme::ColorHook_t = std::function<Int_t(const TGeoVolume *)> |
Type of user hook for overriding color assignment.
Definition at line 51 of file TGeoColorScheme.h.
| using TGeoColorScheme::TranspHook_t = std::function<Int_t(const TGeoVolume *)> |
Type of user hook for overriding transparency assignment.
Definition at line 54 of file TGeoColorScheme.h.
| using TGeoColorScheme::ZFallbackHook_t = std::function<Int_t(Int_t , EGeoColorSet )> |
Type of user hook for overriding the Z-based fallback coloring.
Definition at line 57 of file TGeoColorScheme.h.
|
explicit |
Constructor.
| set | Initial color set selection (natural, flashy, high-contrast). |
Definition at line 358 of file TGeoColorScheme.cxx.
|
virtualdefault |
Virtual destructor.
|
virtual |
Compute the color for a given volume.
This method is called by TGeoManager::DefaultColors() for each volume. The default implementation:
| vol | Geometry volume to be colored. |
Definition at line 372 of file TGeoColorScheme.cxx.
|
virtual |
Compute fallback color based on material effective Z.
This method is used when no name-based material override applies. Users may override this behavior via SetZFallbackHook() or by subclassing and overriding this method.
| Z | Effective atomic number of the material. |
| set | Active color set selection. |
Definition at line 420 of file TGeoColorScheme.cxx.
|
static |
Retrieve the material associated with a geometry volume.
This helper performs all necessary pointer checks and may be safely used inside user hooks.
| vol | Geometry volume. |
Definition at line 362 of file TGeoColorScheme.cxx.
|
inline |
Get the active color set.
Definition at line 154 of file TGeoColorScheme.h.
|
inline |
Set a user hook for color assignment.
The hook is called before any built-in logic. Returning a value <0 delegates the decision to the default implementation.
| h | Color hook (set to nullptr to disable). |
Definition at line 127 of file TGeoColorScheme.h.
|
inline |
Set the active color set.
Definition at line 157 of file TGeoColorScheme.h.
|
inline |
Set a user hook for transparency assignment.
The hook is called before the default transparency logic. Returning a value <0 delegates the decision to the default implementation.
| h | Transparency hook (set to nullptr to disable). |
Definition at line 139 of file TGeoColorScheme.h.
|
inline |
Set a user hook for Z-based fallback coloring.
The hook is called before the built-in Z-binned lookup. Returning a value <0 delegates the decision to the default implementation.
| h | Z-fallback hook (set to nullptr to disable). |
Definition at line 151 of file TGeoColorScheme.h.
|
virtual |
Compute the transparency for a given volume.
The default implementation:
| vol | Geometry volume. |
Definition at line 398 of file TGeoColorScheme.cxx.
|
private |
Optional user hook for color assignment.
Definition at line 173 of file TGeoColorScheme.h.
|
private |
Active color set selection.
Definition at line 171 of file TGeoColorScheme.h.
|
private |
Optional user hook for transparency.
Definition at line 174 of file TGeoColorScheme.h.
|
private |
Optional user hook for Z fallback.
Definition at line 175 of file TGeoColorScheme.h.