2 // Category: visualization
4 // Author: I. Hrivnacova
6 // Class AliColourStore
7 // --------------------
8 // See the class description in the header file.
10 #include "AliColourStore.h"
11 #include "AliGlobals.h"
13 // static data members
15 //_____________________________________________________________________________
16 AliColourStore* AliColourStore::fgInstance = 0;
18 //_____________________________________________________________________________
19 AliColourStore::AliColourStore()
21 // fill predefined colours
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"));
41 //_____________________________________________________________________________
42 AliColourStore::AliColourStore(const AliColourStore& right) {
44 AliGlobals::Exception(
45 "Attempt to copy AliColourStore singleton.");
48 //_____________________________________________________________________________
49 AliColourStore::~AliColourStore() {
55 //_____________________________________________________________________________
56 AliColourStore& AliColourStore::operator=(const AliColourStore& right)
58 // check assignement to self
59 if (this == &right) return *this;
61 AliGlobals::Exception(
62 "Attempt to assign AliColourStore singleton.");
69 //_____________________________________________________________________________
70 AliColourStore* AliColourStore::Instance()
72 // Returns the singleton instance.
73 // Creates the instance if it does not exist.
77 fgInstance = new AliColourStore();
84 //_____________________________________________________________________________
85 G4Colour AliColourStore::GetColour(const G4String& name) const
87 // Retrieves the colour by name.
90 ColourConstIterator it;
91 for (it = fColours.begin(); it != fColours.end(); it++)
92 if (name == (*it).GetName()) return GetColour(*it);
94 G4String text = "Colour " + name + " is not defined.";
95 AliGlobals::Exception(text);
99 //_____________________________________________________________________________
100 G4Colour AliColourStore::GetColour(const TColor& color) const
102 // Converts TColor to G4Colour.
105 return G4Colour(color.GetRed(), color.GetBlue(), color.GetGreen());
108 //_____________________________________________________________________________
109 G4String AliColourStore::GetColoursList() const
111 // Returns the list of all defined colours names.
115 ColourConstIterator it;
117 for (it = fColours.begin(); it != fColours.end(); it++) {
118 list += (*it).GetName();
125 //_____________________________________________________________________________
126 G4String AliColourStore::GetColoursListWithCommas() const
128 // Returns the list of all defined colours names
134 ColourConstIterator it;
136 for (it = fColours.begin(); it != fColours.end(); it++) {
137 list += (*it).GetName();
138 if (i++ < fColours.size()-1) list += ", ";