]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliColourStore.cxx
updated commands description
[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"
c97337f9 11#include "AliColour.h"
676fb573 12#include "AliGlobals.h"
13
14#include <G4Element.hh>
15
16// static data members
17
78ca1e9c 18//_____________________________________________________________________________
676fb573 19AliColourStore* AliColourStore::fgInstance = 0;
20
21// lifecycle
22
78ca1e9c 23//_____________________________________________________________________________
676fb573 24AliColourStore::AliColourStore() {
25//
ad42298e 26 fColours.push_back(AliColour("White", 1.0, 1.0, 1.0));
27 fColours.push_back(AliColour("Black", 0.0, 0.0, 0.0));
28 fColours.push_back(AliColour("Red", 1.0, 0.0, 0.0));
29 fColours.push_back(AliColour("RoseDark", 1.0, 0.0, 0.5));
30 fColours.push_back(AliColour("Green", 0.0, 1.0, 0.0));
31 fColours.push_back(AliColour("Green2", 0.0, 1.0, 0.5));
32 fColours.push_back(AliColour("GreenClair",0.5, 1.0, 0.0));
33 fColours.push_back(AliColour("Yellow", 1.0, 1.0, 0.0));
34 fColours.push_back(AliColour("BlueDark", 0.0, 0.0, 1.0));
35 fColours.push_back(AliColour("BlueClair", 0.0, 1.0, 1.0));
36 fColours.push_back(AliColour("BlueClair2",0.0, 0.5, 1.0));
37 fColours.push_back(AliColour("Magenta", 1.0, 0.0, 1.0));
38 fColours.push_back(AliColour("Magenta2", 0.5, 0.0, 1.0));
39 fColours.push_back(AliColour("BrownClair",1.0, 0.5, 0.0));
40 fColours.push_back(AliColour("Gray", 0.3, 0.3, 0.3));
41 fColours.push_back(AliColour("GrayClair", 0.6, 0.6, 0.6));
676fb573 42}
43
78ca1e9c 44//_____________________________________________________________________________
676fb573 45AliColourStore::AliColourStore(const AliColourStore& right) {
46//
47 AliGlobals::Exception(
48 "Attempt to copy AliColourStore singleton.");
49}
50
78ca1e9c 51//_____________________________________________________________________________
676fb573 52AliColourStore::~AliColourStore() {
53//
54}
55
56// operators
57
78ca1e9c 58//_____________________________________________________________________________
676fb573 59AliColourStore& AliColourStore::operator=(const AliColourStore& right)
60{
61 // check assignement to self
62 if (this == &right) return *this;
63
64 AliGlobals::Exception(
65 "Attempt to assign AliColourStore singleton.");
66
67 return *this;
68}
69
70// static methods
71
78ca1e9c 72//_____________________________________________________________________________
676fb573 73AliColourStore* AliColourStore::Instance()
74{
75// Returns the singleton instance.
76// Creates the instance if it does not exist.
77// ---
78
ad42298e 79 if (fgInstance == 0 )
676fb573 80 fgInstance = new AliColourStore();
676fb573 81
82 return fgInstance;
83}
84
85// public methods
86
78ca1e9c 87//_____________________________________________________________________________
676fb573 88G4Colour AliColourStore::GetColour(G4String name) const
89{
90// Retrieves the colour by name.
91// ---
92
ad42298e 93 ColourConstIterator it;
94 for (it = fColours.begin(); it != fColours.end(); it++)
95 if (name == (*it).GetName()) return (*it).GetColour();
676fb573 96
97 G4String text = "Colour " + name + " is not defined.";
98 AliGlobals::Exception(text);
99 return 0;
100}
101
78ca1e9c 102//_____________________________________________________________________________
676fb573 103G4String AliColourStore::GetColoursList() const
104{
105// Returns the list of all defined colours names.
106// ---
107
108 G4String list = "";
ad42298e 109 ColourConstIterator it;
110
111 for (it = fColours.begin(); it != fColours.end(); it++) {
112 list += (*it).GetName();
676fb573 113 list += " ";
ad42298e 114 }
115
676fb573 116 return list;
117}
118
78ca1e9c 119//_____________________________________________________________________________
676fb573 120G4String AliColourStore::GetColoursListWithCommas() const
121{
122// Returns the list of all defined colours names
123// with commas.
124// ---
125
126 G4String list = "";
ad42298e 127 G4int i = 0;
128 ColourConstIterator it;
129
130 for (it = fColours.begin(); it != fColours.end(); it++) {
131 list += (*it).GetName();
132 if (i++ < fColours.size()-1) list += ", ";
133 }
134
676fb573 135 return list;
136}