G4ModelCmdApplyStringColour< M > Class Template Reference

#include <G4ModelApplyCommandsT.hh>

Inheritance diagram for G4ModelCmdApplyStringColour< M >:

G4VModelCommand< M > G4UImessenger G4ModelCmdSetStringColour< M >

Public Member Functions

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

Protected Member Functions

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

Detailed Description

template<typename M>
class G4ModelCmdApplyStringColour< M >

Definition at line 51 of file G4ModelApplyCommandsT.hh.


Constructor & Destructor Documentation

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

Definition at line 77 of file G4ModelApplyCommandsT.hh.

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

00078   :G4VModelCommand<M>(model, placement)
00079 {
00080   //Set variable colour through a string
00081   G4String dir = placement+"/"+model->Name()+"/"+cmdName;
00082   G4UIparameter* param(0);
00083 
00084   fpStringCmd = new G4UIcommand(dir, this);
00085   fpStringCmd->SetGuidance("Set variable colour through a string");   
00086   
00087   param = new G4UIparameter("Variable", 's', false);
00088   fpStringCmd->SetParameter(param);
00089 
00090   param = new G4UIparameter("Value", 's', false);
00091   fpStringCmd->SetParameter(param);
00092 
00093   //Set variable colour through RGBA components
00094   G4String componentDir = dir+"RGBA";
00095   
00096   fpComponentCmd = new G4UIcommand(componentDir, this);
00097   fpComponentCmd->SetGuidance("Set variable colour through red, green, blue and alpha components");   
00098   param = new G4UIparameter("Variable", 's', false);
00099   fpComponentCmd->SetParameter(param);
00100 
00101   param = new G4UIparameter("Red component", 'd', false);
00102   fpComponentCmd->SetParameter(param);
00103 
00104   param = new G4UIparameter("Green component", 'd', false);
00105   fpComponentCmd->SetParameter(param);
00106 
00107   param = new G4UIparameter("Blue component", 'd', false);
00108   fpComponentCmd->SetParameter(param);
00109 
00110   param = new G4UIparameter("Alpha component", 'd', false);
00111   fpComponentCmd->SetParameter(param);
00112 } 

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

Definition at line 115 of file G4ModelApplyCommandsT.hh.

00116 { 
00117   delete fpStringCmd;
00118   delete fpComponentCmd;
00119 }


Member Function Documentation

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

Implemented in G4ModelCmdSetStringColour< M >.

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

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

Definition at line 67 of file G4ModelApplyCommandsT.hh.

00067 {return fpComponentCmd;}

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

Reimplemented from G4UImessenger.

Definition at line 122 of file G4ModelApplyCommandsT.hh.

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

00123 {
00124   G4Colour myColour;
00125   G4String parameter;
00126   
00127   if (cmd == fpStringCmd) {
00128     G4String colour;
00129     std::istringstream is (newValue);
00130     is >> parameter >> colour;
00131     
00132     // Colour key should exist
00133     if (!G4Colour::GetColour(colour, myColour)) {
00134       G4ExceptionDescription ed;
00135       ed << "G4Colour with key "<<colour<<" does not exist ";
00136       G4Exception
00137         ("G4ModelCmdApplyStringColour<M>::SetNewValue",
00138          "modeling0106", JustWarning, ed);
00139       return;
00140     }
00141   }
00142   
00143   if (cmd == fpComponentCmd) {
00144     G4double red(0), green(0), blue(0), alpha(0);
00145     std::istringstream is (newValue);
00146     is >> parameter >> red >> green >> blue >> alpha;
00147     
00148     G4Colour colour(red, green, blue, alpha);
00149     myColour = colour;
00150   }
00151 
00152   Apply(parameter, myColour);
00153   G4VVisManager* visManager = G4VVisManager::GetConcreteInstance();
00154   if (visManager) visManager->NotifyHandlers();
00155 }

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

Definition at line 66 of file G4ModelApplyCommandsT.hh.

00066 {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