Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Colour Class Reference

#include <G4Colour.hh>

Public Member Functions

 G4Colour (G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
 
 G4Colour (G4ThreeVector)
 
 operator G4ThreeVector ()
 
G4bool operator!= (const G4Colour &c) const
 
G4bool operator== (const G4Colour &c) const
 
G4Colouroperator+= (const G4Colour &)
 
G4double GetRed () const
 
G4double GetGreen () const
 
G4double GetBlue () const
 
G4double GetAlpha () const
 

Static Public Member Functions

static G4Colour White ()
 
static G4Colour Gray ()
 
static G4Colour Grey ()
 
static G4Colour Black ()
 
static G4Colour Brown ()
 
static G4Colour Red ()
 
static G4Colour Green ()
 
static G4Colour Blue ()
 
static G4Colour Cyan ()
 
static G4Colour Magenta ()
 
static G4Colour Yellow ()
 
static void AddToMap (const G4String &key, const G4Colour &colour)
 
static G4bool GetColour (const G4String &key, G4Colour &result)
 
static const std::map
< G4String, G4Colour > & 
GetMap ()
 

Friends

std::ostream & operator<< (std::ostream &, const G4Colour &)
 

Detailed Description

Definition at line 83 of file G4Colour.hh.

Constructor & Destructor Documentation

G4Colour::G4Colour ( G4double  r = 1.,
G4double  g = 1.,
G4double  b = 1.,
G4double  a = 1. 
)

Definition at line 34 of file G4Colour.cc.

34  :
35 red (r), green (gr), blue (b), alpha (a)
36 {
37  if( red > 1.0 ){red = 1.0;} if( red < 0.0 ){red = 0.0;}
38  if( green > 1.0 ){green = 1.0;} if( green < 0.0 ){green = 0.0;}
39  if( blue > 1.0 ){blue = 1.0;} if( blue < 0.0 ){blue = 0.0;}
40  if( alpha > 1.0 ){alpha = 1.0;} if( alpha < 0.0 ){alpha = 0.0;}
41 }
static const G4double alpha

Here is the caller graph for this function:

G4Colour::G4Colour ( G4ThreeVector  v)

Definition at line 43 of file G4Colour.cc.

43  :
44 red (v.x()), green (v.y()), blue (v.z()), alpha (1.)
45 {
46  if( red > 1.0 ){red = 1.0;} if( red < 0.0 ){red = 0.0;}
47  if( green > 1.0 ){green = 1.0;} if( green < 0.0 ){green = 0.0;}
48  if( blue > 1.0 ){blue = 1.0;} if( blue < 0.0 ){blue = 0.0;}
49 }
double x() const
double z() const
double y() const
static const G4double alpha

Member Function Documentation

void G4Colour::AddToMap ( const G4String key,
const G4Colour colour 
)
static

Definition at line 86 of file G4Colour.cc.

87 {
88  if (!fColourMap)
89  fColourMap = new std::map<G4String, G4Colour>;
90 
91  // Convert to lower case since colour map is case insensitive
92  G4String myKey(key);
93  myKey.toLower();
94 
95  std::map<G4String, G4Colour>::iterator iter = fColourMap->find(myKey);
96 
97  if (iter == fColourMap->end()) (*fColourMap)[myKey] = colour;
98  else {
100  ed << "G4Colour with key "<<myKey<<" already exists."<<G4endl;
102  ("G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
103  "greps0001", JustWarning, ed,
104  "Colour key exists");
105  }
106 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4Colour G4Colour::Black ( )
inlinestatic

Definition at line 146 of file G4Colour.hh.

146 {return G4Colour(0.0, 0.0, 0.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4Colour G4Colour::Blue ( )
inlinestatic

Definition at line 150 of file G4Colour.hh.

150 {return G4Colour(0.0, 0.0, 1.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

Here is the caller graph for this function:

G4Colour G4Colour::Brown ( )
inlinestatic

Definition at line 147 of file G4Colour.hh.

147 {return G4Colour(0.45,0.25,0.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4Colour G4Colour::Cyan ( )
inlinestatic

Definition at line 151 of file G4Colour.hh.

151 {return G4Colour(0.0, 1.0, 1.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4double G4Colour::GetAlpha ( ) const
inline

Definition at line 142 of file G4Colour.hh.

142 {return alpha;}
static const G4double alpha

Here is the caller graph for this function:

G4double G4Colour::GetBlue ( ) const
inline

Definition at line 141 of file G4Colour.hh.

141 {return blue;}

Here is the caller graph for this function:

bool G4Colour::GetColour ( const G4String key,
G4Colour result 
)
static

Definition at line 126 of file G4Colour.cc.

127 {
128  if (false == fInitColourMap) {
129  fInitColourMap = true;
130  // Add standard colours to map
131  InitialiseColourMap();
132  }
133 
134  G4String myKey(key);
135  myKey.toLower();
136 
137  std::map<G4String, G4Colour>::iterator iter = fColourMap->find(myKey);
138 
139  // Don't modify "result" if colour was not found in map
140  if (iter == fColourMap->end()) return false;
141 
142  result = iter->second;
143 
144  return true;
145 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4Colour::GetGreen ( ) const
inline

Definition at line 140 of file G4Colour.hh.

140 {return green;}

Here is the caller graph for this function:

const std::map< G4String, G4Colour > & G4Colour::GetMap ( )
static

Definition at line 147 of file G4Colour.cc.

148 {
149  if (false == fInitColourMap) {
150  fInitColourMap = true;
151  // Add standard colours to map
152  InitialiseColourMap();
153  }
154 
155  return *fColourMap;
156 }

Here is the caller graph for this function:

G4double G4Colour::GetRed ( ) const
inline

Definition at line 139 of file G4Colour.hh.

139 {return red;}

Here is the caller graph for this function:

G4Colour G4Colour::Gray ( )
inlinestatic

Definition at line 144 of file G4Colour.hh.

144 {return G4Colour(0.5, 0.5, 0.5);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4Colour G4Colour::Green ( )
inlinestatic

Definition at line 149 of file G4Colour.hh.

149 {return G4Colour(0.0, 1.0, 0.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

Here is the caller graph for this function:

G4Colour G4Colour::Grey ( )
inlinestatic

Definition at line 145 of file G4Colour.hh.

145 {return G4Colour(0.5, 0.5, 0.5);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4Colour G4Colour::Magenta ( )
inlinestatic

Definition at line 152 of file G4Colour.hh.

152 {return G4Colour(1.0, 0.0, 1.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

G4Colour::operator G4ThreeVector ( )

Definition at line 51 of file G4Colour.cc.

51  {
52  return G4ThreeVector(red,green,blue);
53 }
CLHEP::Hep3Vector G4ThreeVector
G4bool G4Colour::operator!= ( const G4Colour c) const

Definition at line 71 of file G4Colour.cc.

71  {
72  if (
73  (red != c.red) ||
74  (green != c.green) ||
75  (blue != c.blue) ||
76  (alpha != c.alpha)
77  )
78  return true;
79  return false;
80 }
static const G4double alpha

Here is the caller graph for this function:

G4Colour& G4Colour::operator+= ( const G4Colour )
inline

Definition at line 101 of file G4Colour.hh.

101 {return *this;} // Dummy
G4bool G4Colour::operator== ( const G4Colour c) const
inline

Definition at line 100 of file G4Colour.hh.

100 {return !(operator != (c));}
G4bool operator!=(const G4Colour &c) const
Definition: G4Colour.cc:71

Here is the call graph for this function:

G4Colour G4Colour::Red ( )
inlinestatic

Definition at line 148 of file G4Colour.hh.

148 {return G4Colour(1.0, 0.0, 0.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

Here is the caller graph for this function:

G4Colour G4Colour::White ( )
inlinestatic

Definition at line 143 of file G4Colour.hh.

143 {return G4Colour(1.0, 1.0, 1.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

Here is the caller graph for this function:

G4Colour G4Colour::Yellow ( )
inlinestatic

Definition at line 153 of file G4Colour.hh.

153 {return G4Colour(1.0, 1.0, 0.0);}
G4Colour(G4double r=1., G4double g=1., G4double b=1., G4double a=1.)
Definition: G4Colour.cc:34

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const G4Colour c 
)
friend

Definition at line 55 of file G4Colour.cc.

55  {
56  os << '(' << c.red << ',' << c.green << ',' << c.blue
57  << ',' << c.alpha << ')';
58  const std::map<G4String, G4Colour>& colourMap = G4Colour::GetMap();
59  // Reverse iterator to pick up English spelling of grey!! :)
60  std::map<G4String, G4Colour>::const_reverse_iterator ri;
61  for (ri = colourMap.rbegin(); ri != colourMap.rend(); ++ri) {
62  if (c == ri->second) {
63  os << " (" << ri->first << ')';
64  break;
65  }
66  }
67 
68  return os;
69 }
static const std::map< G4String, G4Colour > & GetMap()
Definition: G4Colour.cc:147

The documentation for this class was generated from the following files: