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::G4Colour ( G4double  r = 1.,
G4double  g = 1.,
G4double  b = 1.,
G4double  a = 1. 
)

Definition at line 34 of file G4Colour.cc.

References G4InuclParticleNames::alpha.

Referenced by Black(), Blue(), Brown(), Cyan(), Gray(), Green(), Grey(), Magenta(), Red(), White(), and Yellow().

00034                                                                   :
00035 red (r), green (gr), blue (b), alpha (a)
00036 {
00037   if( red   > 1.0 ){red   = 1.0;} if( red   < 0.0 ){red   = 0.0;}
00038   if( green > 1.0 ){green = 1.0;} if( green < 0.0 ){green = 0.0;}
00039   if( blue  > 1.0 ){blue  = 1.0;} if( blue  < 0.0 ){blue  = 0.0;}
00040   if( alpha > 1.0 ){alpha = 1.0;} if( alpha < 0.0 ){alpha = 0.0;}
00041 }

G4Colour::G4Colour ( G4ThreeVector   ) 

Definition at line 43 of file G4Colour.cc.

00043                                   :
00044 red (v.x()), green (v.y()), blue (v.z()), alpha (1.)
00045 {
00046   if( red   > 1.0 ){red   = 1.0;} if( red   < 0.0 ){red   = 0.0;}
00047   if( green > 1.0 ){green = 1.0;} if( green < 0.0 ){green = 0.0;}
00048   if( blue  > 1.0 ){blue  = 1.0;} if( blue  < 0.0 ){blue  = 0.0;}
00049 }


Member Function Documentation

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

Definition at line 86 of file G4Colour.cc.

References G4endl, G4Exception(), JustWarning, and G4String::toLower().

00087 {
00088   // Convert to lower case since colour map is case insensitive
00089   G4String myKey(key);
00090   myKey.toLower();
00091 
00092   std::map<G4String, G4Colour>::iterator iter = fColourMap.find(myKey);
00093   
00094   if (iter == fColourMap.end()) fColourMap[myKey] = colour;  
00095   else {
00096     G4ExceptionDescription ed; 
00097     ed << "G4Colour with key "<<myKey<<" already exists."<<G4endl;
00098     G4Exception
00099       ("G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
00100        "greps0001", JustWarning, ed,
00101        "Colour key exists");
00102   }
00103 }

G4Colour G4Colour::Black (  )  [inline, static]

Definition at line 145 of file G4Colour.hh.

References G4Colour().

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

G4Colour G4Colour::Blue (  )  [inline, static]

Definition at line 149 of file G4Colour.hh.

References G4Colour().

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

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

G4Colour G4Colour::Brown (  )  [inline, static]

Definition at line 146 of file G4Colour.hh.

References G4Colour().

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

G4Colour G4Colour::Cyan (  )  [inline, static]

Definition at line 150 of file G4Colour.hh.

References G4Colour().

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

G4double G4Colour::GetAlpha (  )  const [inline]

Definition at line 141 of file G4Colour.hh.

Referenced by G4TheRayTracer::Attenuate(), G4ViewParameters::CameraAndLightingCommands(), G4PhysicalVolumeModel::DescribeAndDescend(), G4TheRayTracer::GetMixedColour(), G4TheRayTracer::GetSurfaceColour(), and G4ViewParameters::TouchableCommands().

00141 {return alpha;}

G4double G4Colour::GetBlue (  )  const [inline]

Definition at line 140 of file G4Colour.hh.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4GMocrenFileSceneHandler::AddPrimitive(), G4TheRayTracer::Attenuate(), G4ViewParameters::CameraAndLightingCommands(), G4TheRayTracer::CreateBitMap(), G4TheRayTracer::GetMixedColour(), G4TheRayTracer::GetSurfaceColour(), G4VisCommandsViewerSet::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandSetTextColour::SetNewValue(), G4VisCommandSetColour::SetNewValue(), G4VisCommandGeometrySetColour::SetNewValue(), and G4ViewParameters::TouchableCommands().

00140 {return blue;}

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

Definition at line 123 of file G4Colour.cc.

References G4String::toLower().

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

00124 {
00125   if (false == fInitColourMap) {
00126     fInitColourMap = true;
00127     // Add standard colours to map
00128     InitialiseColourMap();
00129   }
00130  
00131   G4String myKey(key);
00132   myKey.toLower();
00133  
00134   std::map<G4String, G4Colour>::iterator iter = fColourMap.find(myKey);
00135 
00136   // Don't modify "result" if colour was not found in map
00137   if (iter == fColourMap.end()) return false;
00138   
00139   result = iter->second;
00140 
00141   return true;
00142 }

G4double G4Colour::GetGreen (  )  const [inline]

Definition at line 139 of file G4Colour.hh.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4GMocrenFileSceneHandler::AddPrimitive(), G4TheRayTracer::Attenuate(), G4ViewParameters::CameraAndLightingCommands(), G4TheRayTracer::CreateBitMap(), G4TheRayTracer::GetMixedColour(), G4TheRayTracer::GetSurfaceColour(), G4VisCommandsViewerSet::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandSetTextColour::SetNewValue(), G4VisCommandSetColour::SetNewValue(), G4VisCommandGeometrySetColour::SetNewValue(), and G4ViewParameters::TouchableCommands().

00139 {return green;}

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

Definition at line 144 of file G4Colour.cc.

Referenced by operator<<().

00145 {
00146   if (false == fInitColourMap) {
00147     fInitColourMap = true;
00148     // Add standard colours to map
00149     InitialiseColourMap();
00150   }
00151  
00152   return fColourMap;
00153 }

G4double G4Colour::GetRed (  )  const [inline]

Definition at line 138 of file G4Colour.hh.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4GMocrenFileSceneHandler::AddPrimitive(), G4TheRayTracer::Attenuate(), G4ViewParameters::CameraAndLightingCommands(), G4TheRayTracer::CreateBitMap(), G4TheRayTracer::GetMixedColour(), G4TheRayTracer::GetSurfaceColour(), G4VisCommandsViewerSet::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandSetTextColour::SetNewValue(), G4VisCommandSetColour::SetNewValue(), G4VisCommandGeometrySetColour::SetNewValue(), and G4ViewParameters::TouchableCommands().

00138 {return red;}

G4Colour G4Colour::Gray (  )  [inline, static]

Definition at line 143 of file G4Colour.hh.

References G4Colour().

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

G4Colour G4Colour::Green (  )  [inline, static]

Definition at line 148 of file G4Colour.hh.

References G4Colour().

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

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

G4Colour G4Colour::Grey (  )  [inline, static]

Definition at line 144 of file G4Colour.hh.

References G4Colour().

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

G4Colour G4Colour::Magenta (  )  [inline, static]

Definition at line 151 of file G4Colour.hh.

References G4Colour().

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

G4Colour::operator G4ThreeVector (  ) 

Definition at line 51 of file G4Colour.cc.

00051                                  {
00052   return G4ThreeVector(red,green,blue);
00053 }

G4bool G4Colour::operator!= ( const G4Colour c  )  const

Definition at line 71 of file G4Colour.cc.

References alpha, G4InuclParticleNames::alpha, blue, green, and red.

Referenced by operator==().

00071                                                      {
00072   if (
00073       (red   != c.red)   ||
00074       (green != c.green) ||
00075       (blue  != c.blue)  ||
00076       (alpha != c.alpha)
00077       )
00078     return true;
00079   return false;
00080 }

G4bool G4Colour::operator== ( const G4Colour c  )  const [inline]

Definition at line 100 of file G4Colour.hh.

References operator!=().

00100 {return !(operator != (c));}

G4Colour G4Colour::Red (  )  [inline, static]

Definition at line 147 of file G4Colour.hh.

References G4Colour().

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

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

G4Colour G4Colour::White (  )  [inline, static]

Definition at line 142 of file G4Colour.hh.

References G4Colour().

Referenced by G4TrajectoryDrawByParticleID::SetDefault().

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

G4Colour G4Colour::Yellow (  )  [inline, static]

Definition at line 152 of file G4Colour.hh.

References G4Colour().

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


Friends And Related Function Documentation

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

Definition at line 55 of file G4Colour.cc.

00055                                                             {
00056   os << '(' << c.red << ',' << c.green << ',' << c.blue
00057             << ',' << c.alpha << ')';
00058   const std::map<G4String, G4Colour>& colourMap = G4Colour::GetMap();
00059   // Reverse iterator to pick up English spelling of grey!!  :)
00060   std::map<G4String, G4Colour>::const_reverse_iterator ri;
00061   for (ri = colourMap.rbegin(); ri != colourMap.rend(); ++ri) {
00062     if (c == ri->second) {
00063       os << " (" << ri->first << ')';
00064       break;
00065     }
00066   }
00067   
00068   return os;
00069 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:41 2013 for Geant4 by  doxygen 1.4.7