Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
 
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() [1/2]

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

Definition at line 34 of file G4Colour.cc.

34 :
35red (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}

◆ G4Colour() [2/2]

G4Colour::G4Colour ( G4ThreeVector  v)

Definition at line 43 of file G4Colour.cc.

43 :
44red (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 z() const
double x() const
double y() const

Member Function Documentation

◆ AddToMap()

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

Definition at line 86 of file G4Colour.cc.

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

◆ Black()

G4Colour G4Colour::Black ( )
inlinestatic

Definition at line 145 of file G4Colour.hh.

145{return G4Colour(0.0, 0.0, 0.0);}

◆ Blue()

G4Colour G4Colour::Blue ( )
inlinestatic

Definition at line 149 of file G4Colour.hh.

149{return G4Colour(0.0, 0.0, 1.0);}

Referenced by G4AxesModel::G4AxesModel(), and G4TrajectoryDrawByCharge::G4TrajectoryDrawByCharge().

◆ Brown()

G4Colour G4Colour::Brown ( )
inlinestatic

Definition at line 146 of file G4Colour.hh.

146{return G4Colour(0.45,0.25,0.0);}

◆ Cyan()

G4Colour G4Colour::Cyan ( )
inlinestatic

Definition at line 150 of file G4Colour.hh.

150{return G4Colour(0.0, 1.0, 1.0);}

◆ GetAlpha()

◆ GetBlue()

◆ GetColour()

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

Definition at line 123 of file G4Colour.cc.

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

Referenced by G4AxesModel::G4AxesModel(), G4ModelColourMap< T >::Set(), G4TrajectoryDrawByOriginVolume::SetDefault(), G4TrajectoryDrawByParticleID::SetDefault(), G4VisCommandGeometrySetColour::SetNewValue(), G4VisCommandSetColour::SetNewValue(), G4VisCommandSetTextColour::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandsViewerSet::SetNewValue(), G4ModelCmdApplyStringColour< M >::SetNewValue(), and G4ModelCmdApplyColour< M >::SetNewValue().

◆ GetGreen()

◆ GetMap()

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

Definition at line 144 of file G4Colour.cc.

145{
146 if (false == fInitColourMap) {
147 fInitColourMap = true;
148 // Add standard colours to map
149 InitialiseColourMap();
150 }
151
152 return fColourMap;
153}

◆ GetRed()

◆ Gray()

G4Colour G4Colour::Gray ( )
inlinestatic

Definition at line 143 of file G4Colour.hh.

143{return G4Colour(0.5, 0.5, 0.5);}

◆ Green()

G4Colour G4Colour::Green ( )
inlinestatic

Definition at line 148 of file G4Colour.hh.

148{return G4Colour(0.0, 1.0, 0.0);}

Referenced by G4AxesModel::G4AxesModel(), and G4TrajectoryDrawByCharge::G4TrajectoryDrawByCharge().

◆ Grey()

G4Colour G4Colour::Grey ( )
inlinestatic

Definition at line 144 of file G4Colour.hh.

144{return G4Colour(0.5, 0.5, 0.5);}

◆ Magenta()

G4Colour G4Colour::Magenta ( )
inlinestatic

Definition at line 151 of file G4Colour.hh.

151{return G4Colour(1.0, 0.0, 1.0);}

◆ operator G4ThreeVector()

G4Colour::operator G4ThreeVector ( )

Definition at line 51 of file G4Colour.cc.

51 {
52 return G4ThreeVector(red,green,blue);
53}
CLHEP::Hep3Vector G4ThreeVector

◆ operator!=()

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}

Referenced by operator==().

◆ operator==()

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

◆ Red()

G4Colour G4Colour::Red ( )
inlinestatic

◆ White()

G4Colour G4Colour::White ( )
inlinestatic

Definition at line 142 of file G4Colour.hh.

142{return G4Colour(1.0, 1.0, 1.0);}

Referenced by G4TrajectoryDrawByParticleID::SetDefault().

◆ Yellow()

G4Colour G4Colour::Yellow ( )
inlinestatic

Definition at line 152 of file G4Colour.hh.

152{return G4Colour(1.0, 1.0, 0.0);}

Friends And Related Function Documentation

◆ operator<<

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:144

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