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) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSCOLOURS_H
20#define BDSCOLOURS_H
21
22#include "globals.hh"
23
24#include <map>
25#include <tuple>
26
27class G4Colour;
28
34{
35public:
36 typedef std::tuple<G4double, G4double, G4double, G4double> BDSColourKey;
37
38 static BDSColours* Instance();
39
41
43 G4Colour* GetColour(G4double red,
44 G4double green,
45 G4double blue,
46 G4double alpha = 1);
47
49 G4Colour* GetColour(const G4String& type,
50 G4bool normaliseTo255 = true);
51
53 void DefineColour(const G4String& name,
54 G4double red,
55 G4double green,
56 G4double blue,
57 G4double alpha = 1,
58 G4bool normaliseTo255 = true);
59
62 void Print();
63
64private:
65 BDSColours();
66 static BDSColours* instance;
67
70 std::map<G4int, G4String> magnetName;
71
73 std::map<G4String, G4Colour*> colours;
74
78 std::map<BDSColourKey, G4Colour*> anonymousColours;
79};
80
81#endif
Colour class that holds all colours used in BDSIM.
Definition BDSColours.hh:34
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:78
static BDSColours * Instance()
singleton pattern
Definition BDSColours.cc:33
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:45
void Print()
std::map< G4int, G4String > magnetName
Definition BDSColours.hh:70
std::map< G4String, G4Colour * > colours
A map of the colour for each type or component by name.
Definition BDSColours.hh:73