G4ModelCmdApplyColour< M > Class Template Reference

#include <G4ModelApplyCommandsT.hh>

Inheritance diagram for G4ModelCmdApplyColour< M >:

G4VModelCommand< M > G4UImessenger G4ModelCmdSetAuxPtsColour< M > G4ModelCmdSetDefaultColour< M > G4ModelCmdSetLineColour< M > G4ModelCmdSetStepPtsColour< M >

Public Member Functions

 G4ModelCmdApplyColour (M *model, const G4String &placement, const G4String &cmdName)
virtual ~G4ModelCmdApplyColour ()
void SetNewValue (G4UIcommand *command, G4String newValue)

Protected Member Functions

virtual void Apply (const G4Colour &)=0
G4UIcommandStringCommand ()
G4UIcommandComponentCommand ()

Detailed Description

template<typename M>
class G4ModelCmdApplyColour< M >

Definition at line 160 of file G4ModelApplyCommandsT.hh.


Constructor & Destructor Documentation

template<typename M>
G4ModelCmdApplyColour< M >::G4ModelCmdApplyColour ( M *  model,
const G4String placement,
const G4String cmdName 
)

Definition at line 186 of file G4ModelApplyCommandsT.hh.

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

00187   :G4VModelCommand<M>(model, placement)
00188 {
00189   //Set colour through a string
00190   G4String dir = placement+"/"+model->Name()+"/"+cmdName;
00191   G4UIparameter* param(0);
00192 
00193   fpStringCmd = new G4UIcommand(dir, this);
00194   fpStringCmd->SetGuidance("Set colour through a string");   
00195   
00196   param = new G4UIparameter("Variable", 's', false);
00197   fpStringCmd->SetParameter(param);
00198 
00199   //Set colour through RGBA components
00200   G4String componentDir = dir+"RGBA";
00201   
00202   fpComponentCmd = new G4UIcommand(componentDir, this);
00203   fpComponentCmd->SetGuidance("Set colour through red, green, blue and alpha components");   
00204   fpComponentCmd->SetGuidance("Four inputs are expected.");
00205 
00206   param = new G4UIparameter("Red component", 'd', false);
00207   fpComponentCmd->SetParameter(param);
00208 
00209   param = new G4UIparameter("Green component", 'd', false);
00210   fpComponentCmd->SetParameter(param);
00211 
00212   param = new G4UIparameter("Blue component", 'd', false);
00213   fpComponentCmd->SetParameter(param);
00214 
00215   param = new G4UIparameter("Alpha component", 'd', false);
00216   fpComponentCmd->SetParameter(param);
00217 } 

template<typename M>
G4ModelCmdApplyColour< M >::~G4ModelCmdApplyColour (  )  [virtual]

Definition at line 220 of file G4ModelApplyCommandsT.hh.

00221 { 
00222   delete fpStringCmd;
00223   delete fpComponentCmd;
00224 }


Member Function Documentation

template<typename M>
virtual void G4ModelCmdApplyColour< M >::Apply ( const G4Colour  )  [protected, pure virtual]

Implemented in G4ModelCmdSetDefaultColour< M >, G4ModelCmdSetAuxPtsColour< M >, G4ModelCmdSetStepPtsColour< M >, and G4ModelCmdSetLineColour< M >.

Referenced by G4ModelCmdApplyColour< M >::SetNewValue().

template<typename M>
G4UIcommand* G4ModelCmdApplyColour< M >::ComponentCommand (  )  [inline, protected]

Definition at line 176 of file G4ModelApplyCommandsT.hh.

00176 {return fpComponentCmd;}

template<typename M>
void G4ModelCmdApplyColour< M >::SetNewValue ( G4UIcommand command,
G4String  newValue 
) [virtual]

Reimplemented from G4UImessenger.

Definition at line 227 of file G4ModelApplyCommandsT.hh.

References G4InuclParticleNames::alpha, G4ModelCmdApplyColour< M >::Apply(), G4Exception(), G4Colour::GetColour(), G4VVisManager::GetConcreteInstance(), JustWarning, and G4VVisManager::NotifyHandlers().

00228 {
00229   G4Colour myColour;
00230 
00231   if (cmd == fpStringCmd) {
00232     G4String colour;
00233     std::istringstream is (newValue);
00234     is >> colour;
00235     
00236     // Colour key should exist
00237     if (!G4Colour::GetColour(colour, myColour)) {
00238       G4ExceptionDescription ed;
00239       ed << "G4Colour with key "<<colour<<" does not exist ";
00240       G4Exception
00241         ("G4ModelCmdApplyColour<M>::SetNewValue",
00242          "modeling0107", JustWarning, ed);
00243       return;
00244     }
00245   }
00246 
00247   if (cmd == fpComponentCmd) {
00248     G4double red(0), green(0), blue(0), alpha(0);
00249     std::istringstream is (newValue);
00250     is >> red >> green >> blue >> alpha;
00251     
00252     G4Colour colour(red, green, blue, alpha);
00253     myColour = colour;
00254   }
00255 
00256   Apply(myColour);
00257   G4VVisManager* visManager = G4VVisManager::GetConcreteInstance();
00258   if (visManager) visManager->NotifyHandlers();
00259 }

template<typename M>
G4UIcommand* G4ModelCmdApplyColour< M >::StringCommand (  )  [inline, protected]

Definition at line 175 of file G4ModelApplyCommandsT.hh.

00175 {return fpStringCmd;}


The documentation for this class was generated from the following file:
Generated on Mon May 27 17:52:29 2013 for Geant4 by  doxygen 1.4.7