]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliColourStore.cxx
Add const to SolenoidField() method for correct overwriting from the parent class
[u/mrichter/AliRoot.git] / AliGeant4 / AliColourStore.cxx
CommitLineData
676fb573 1// $Id$
2// Category: visualization
3//
ad42298e 4// Author: I. Hrivnacova
5//
6// Class AliColourStore
7// --------------------
676fb573 8// See the class description in the header file.
9
10#include "AliColourStore.h"
11#include "AliGlobals.h"
12
676fb573 13// static data members
14
78ca1e9c 15//_____________________________________________________________________________
676fb573 16AliColourStore* AliColourStore::fgInstance = 0;
17
78ca1e9c 18//_____________________________________________________________________________
476fd655 19AliColourStore::AliColourStore()
20{
21 // fill predefined colours
22 G4int id0 = 1000;
23
24 fColours.push_back(TColor(id0 + 0, 0.99, 0.99, 0.99, "White"));
25 fColours.push_back(TColor(id0 + 1, 0.00, 0.00, 0.00, "Black"));
26 fColours.push_back(TColor(id0 + 2, 0.99, 0.00, 0.00, "Red"));
27 fColours.push_back(TColor(id0 + 3, 0.99, 0.50, 0.00, "Red2"));
28 fColours.push_back(TColor(id0 + 4, 0.00, 0.00, 0.99, "Green"));
29 fColours.push_back(TColor(id0 + 5, 0.00, 0.50, 0.99, "Green2"));
30 fColours.push_back(TColor(id0 + 6, 0.50, 0.00, 0.99, "Green3"));
31 fColours.push_back(TColor(id0 + 7, 0.00, 0.99, 0.00, "Blue"));
32 fColours.push_back(TColor(id0 + 8, 0.00, 0.99, 0.99, "Blue2"));
33 fColours.push_back(TColor(id0 + 9, 0.00, 0.99, 0.50, "Blue3"));
34 fColours.push_back(TColor(id0 + 10, 0.99, 0.00, 0.99, "Yellow"));
35 fColours.push_back(TColor(id0 + 11, 0.99, 0.99, 0.00, "Magenta"));
36 fColours.push_back(TColor(id0 + 12, 0.50, 0.99, 0.00, "Magenta2"));
37 fColours.push_back(TColor(id0 + 13, 0.99, 0.00, 0.50, "Brown"));
38 fColours.push_back(TColor(id0 + 14, 0.30, 0.30, 0.30, "Gray"));
676fb573 39}
40
78ca1e9c 41//_____________________________________________________________________________
676fb573 42AliColourStore::AliColourStore(const AliColourStore& right) {
43//
44 AliGlobals::Exception(
45 "Attempt to copy AliColourStore singleton.");
46}
47
78ca1e9c 48//_____________________________________________________________________________
676fb573 49AliColourStore::~AliColourStore() {
50//
51}
52
53// operators
54
78ca1e9c 55//_____________________________________________________________________________
676fb573 56AliColourStore& AliColourStore::operator=(const AliColourStore& right)
57{
58 // check assignement to self
59 if (this == &right) return *this;
60
61 AliGlobals::Exception(
62 "Attempt to assign AliColourStore singleton.");
63
64 return *this;
65}
66
67// static methods
68
78ca1e9c 69//_____________________________________________________________________________
676fb573 70AliColourStore* AliColourStore::Instance()
71{
72// Returns the singleton instance.
73// Creates the instance if it does not exist.
74// ---
75
ad42298e 76 if (fgInstance == 0 )
676fb573 77 fgInstance = new AliColourStore();
676fb573 78
79 return fgInstance;
80}
81
82// public methods
83
78ca1e9c 84//_____________________________________________________________________________
476fd655 85G4Colour AliColourStore::GetColour(const G4String& name) const
676fb573 86{
87// Retrieves the colour by name.
88// ---
89
ad42298e 90 ColourConstIterator it;
91 for (it = fColours.begin(); it != fColours.end(); it++)
476fd655 92 if (name == (*it).GetName()) return GetColour(*it);
676fb573 93
94 G4String text = "Colour " + name + " is not defined.";
95 AliGlobals::Exception(text);
96 return 0;
97}
98
476fd655 99//_____________________________________________________________________________
100G4Colour AliColourStore::GetColour(const TColor& color) const
101{
102// Converts TColor to G4Colour.
103// ---
104
105 return G4Colour(color.GetRed(), color.GetBlue(), color.GetGreen());
106}
107
78ca1e9c 108//_____________________________________________________________________________
676fb573 109G4String AliColourStore::GetColoursList() const
110{
111// Returns the list of all defined colours names.
112// ---
113
114 G4String list = "";
ad42298e 115 ColourConstIterator it;
116
117 for (it = fColours.begin(); it != fColours.end(); it++) {
118 list += (*it).GetName();
676fb573 119 list += " ";
ad42298e 120 }
121
676fb573 122 return list;
123}
124
78ca1e9c 125//_____________________________________________________________________________
676fb573 126G4String AliColourStore::GetColoursListWithCommas() const
127{
128// Returns the list of all defined colours names
129// with commas.
130// ---
131
132 G4String list = "";
ad42298e 133 G4int i = 0;
134 ColourConstIterator it;
135
136 for (it = fColours.begin(); it != fColours.end(); it++) {
137 list += (*it).GetName();
138 if (i++ < fColours.size()-1) list += ", ";
139 }
140
676fb573 141 return list;
142}