BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSColours.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSCOLOURS_H
19#define BDSCOLOURS_H
20
21#include "globals.hh"
22
23#include <map>
24#include <tuple>
25
26class G4Colour;
27
33{
34public:
35 typedef std::tuple<G4double, G4double, G4double, G4double> BDSColourKey;
36
37 static BDSColours* Instance();
38
40
42 G4Colour* GetColour(G4double red,
43 G4double green,
44 G4double blue,
45 G4double alpha = 1);
46
48 G4Colour* GetColour(const G4String& type,
49 G4bool normaliseTo255 = true);
50
52 void DefineColour(const G4String& name,
53 G4double red,
54 G4double green,
55 G4double blue,
56 G4double alpha = 1,
57 G4bool normaliseTo255 = true);
58
61 void Print();
62
63private:
64 BDSColours();
65 static BDSColours* instance;
66
69 std::map<G4int, G4String> magnetName;
70
72 std::map<G4String, G4Colour*> colours;
73
77 std::map<BDSColourKey, G4Colour*> anonymousColours;
78};
79
80#endif
Colour class that holds all colours used in BDSIM.
Definition BDSColours.hh:33
G4Colour * GetColour(G4double red, G4double green, G4double blue, G4double alpha=1)
Get a cached anonymous colour by values.
std::map< BDSColourKey, G4Colour * > anonymousColours
Definition BDSColours.hh:77
static BDSColours * Instance()
singleton pattern
Definition BDSColours.cc:32
void DefineColour(const G4String &name, G4double red, G4double green, G4double blue, G4double alpha=1, G4bool normaliseTo255=true)
Define a new colour.
BDSColours()
Private constructor as singleton.
Definition BDSColours.cc:44
void Print()
std::map< G4int, G4String > magnetName
Definition BDSColours.hh:69
std::map< G4String, G4Colour * > colours
A map of the colour for each type or component by name.
Definition BDSColours.hh:72