G4VisCommandSetColour Class Reference

#include <G4VisCommandsSet.hh>

Inheritance diagram for G4VisCommandSetColour:

G4VVisCommand G4UImessenger

Public Member Functions

 G4VisCommandSetColour ()
virtual ~G4VisCommandSetColour ()
G4String GetCurrentValue (G4UIcommand *command)
void SetNewValue (G4UIcommand *command, G4String newValue)

Detailed Description

Definition at line 42 of file G4VisCommandsSet.hh.


Constructor & Destructor Documentation

G4VisCommandSetColour::G4VisCommandSetColour (  ) 

Definition at line 43 of file G4VisCommandsSet.cc.

References G4UIparameter::SetDefaultValue(), G4UIparameter::SetGuidance(), G4UIcommand::SetGuidance(), and G4UIcommand::SetParameter().

00044 {
00045   G4bool omitable;
00046   fpCommand = new G4UIcommand("/vis/set/colour", this);
00047   fpCommand->SetGuidance
00048     ("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
00049   fpCommand->SetGuidance
00050     ("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
00051   fpCommand->SetGuidance("Default: white and opaque.");
00052   G4UIparameter* parameter;
00053   parameter = new G4UIparameter ("red", 's', omitable = true);
00054   parameter->SetGuidance
00055     ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
00056   parameter->SetDefaultValue ("1.");
00057   fpCommand->SetParameter (parameter);
00058   parameter = new G4UIparameter ("green", 'd', omitable = true);
00059   parameter->SetDefaultValue (1.);
00060   fpCommand->SetParameter (parameter);
00061   parameter = new G4UIparameter ("blue", 'd', omitable = true);
00062   parameter->SetDefaultValue (1.);
00063   fpCommand->SetParameter (parameter);
00064   parameter = new G4UIparameter ("alpha", 'd', omitable = true);
00065   parameter->SetDefaultValue (1.);
00066   parameter->SetGuidance ("Opacity");
00067   fpCommand->SetParameter (parameter);
00068 }

G4VisCommandSetColour::~G4VisCommandSetColour (  )  [virtual]

Definition at line 70 of file G4VisCommandsSet.cc.

00071 {
00072   delete fpCommand;
00073 }


Member Function Documentation

G4String G4VisCommandSetColour::GetCurrentValue ( G4UIcommand command  )  [virtual]

Reimplemented from G4UImessenger.

Definition at line 75 of file G4VisCommandsSet.cc.

00076 {
00077   return G4String();
00078 }

void G4VisCommandSetColour::SetNewValue ( G4UIcommand command,
G4String  newValue 
) [virtual]

Reimplemented from G4UImessenger.

Definition at line 80 of file G4VisCommandsSet.cc.

References G4VisManager::confirmations, G4UIcommand::ConvertToDouble(), G4VVisCommand::fCurrentColour, G4VVisCommand::fpVisManager, G4cout, G4endl, G4Colour::GetBlue(), G4Colour::GetColour(), G4Colour::GetGreen(), G4Colour::GetRed(), G4VisManager::GetVerbosity(), and G4VisManager::warnings.

00081 {
00082   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00083 
00084   G4String redOrString;
00085   G4double green, blue, opacity;
00086   std::istringstream iss(newValue);
00087   iss >> redOrString >> green >> blue >> opacity;
00088 
00089   G4Colour colour(1,1,1,1);  // Default white and opaque.
00090   if (std::isalpha(redOrString(0))) {
00091     if (!G4Colour::GetColour(redOrString, colour)) {
00092       if (verbosity >= G4VisManager::warnings) {
00093         G4cout << "WARNING: Colour \"" << redOrString
00094                << "\" not found.  Defaulting to white and opaque."
00095                << G4endl;
00096       }
00097     }
00098   } else {
00099     colour = G4Colour
00100       (G4UIcommand::ConvertToDouble(redOrString), green, blue);
00101   }
00102   // Add opacity
00103   fCurrentColour = G4Colour
00104     (colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
00105 
00106   if (verbosity >= G4VisManager::confirmations) {
00107     G4cout <<
00108       "Colour for future \"/vis/scene/add/\" commands has been set to "
00109            << fCurrentColour <<
00110       ".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)"
00111            << G4endl;
00112   }
00113 }


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