Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions
G4ModelCmdApplyColour< M > Class Template Referenceabstract

#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)
 
- Public Member Functions inherited from G4VModelCommand< M >
 G4VModelCommand (M *model, const G4String &placement="")
 
virtual ~G4VModelCommand ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
G4String Placement ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 

Protected Member Functions

virtual void Apply (const G4Colour &)=0
 
G4UIcommandStringCommand ()
 
G4UIcommandComponentCommand ()
 
- Protected Member Functions inherited from G4VModelCommand< M >
M * Model ()
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 

Additional Inherited Members

- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

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().

187  :G4VModelCommand<M>(model, placement)
188 {
189  //Set colour through a string
190  G4String dir = placement+"/"+model->Name()+"/"+cmdName;
191  G4UIparameter* param(0);
192 
193  fpStringCmd = new G4UIcommand(dir, this);
194  fpStringCmd->SetGuidance("Set colour through a string");
195 
196  param = new G4UIparameter("Variable", 's', false);
197  fpStringCmd->SetParameter(param);
198 
199  //Set colour through RGBA components
200  G4String componentDir = dir+"RGBA";
201 
202  fpComponentCmd = new G4UIcommand(componentDir, this);
203  fpComponentCmd->SetGuidance("Set colour through red, green, blue and alpha components");
204  fpComponentCmd->SetGuidance("Four inputs are expected.");
205 
206  param = new G4UIparameter("Red component", 'd', false);
207  fpComponentCmd->SetParameter(param);
208 
209  param = new G4UIparameter("Green component", 'd', false);
210  fpComponentCmd->SetParameter(param);
211 
212  param = new G4UIparameter("Blue component", 'd', false);
213  fpComponentCmd->SetParameter(param);
214 
215  param = new G4UIparameter("Alpha component", 'd', false);
216  fpComponentCmd->SetParameter(param);
217 }
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
const XML_Char XML_Content * model
template<typename M >
G4ModelCmdApplyColour< M >::~G4ModelCmdApplyColour ( )
virtual

Definition at line 220 of file G4ModelApplyCommandsT.hh.

221 {
222  delete fpStringCmd;
223  delete fpComponentCmd;
224 }

Member Function Documentation

template<typename M >
virtual void G4ModelCmdApplyColour< M >::Apply ( const G4Colour )
protectedpure virtual
template<typename M >
G4UIcommand* G4ModelCmdApplyColour< M >::ComponentCommand ( )
inlineprotected

Definition at line 176 of file G4ModelApplyCommandsT.hh.

176 {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 blue, G4Exception(), G4Colour::GetColour(), G4VVisManager::GetConcreteInstance(), JustWarning, G4VVisManager::NotifyHandlers(), and red.

228 {
229  G4Colour myColour;
230 
231  if (cmd == fpStringCmd) {
232  G4String colour;
233  std::istringstream is (newValue);
234  is >> colour;
235 
236  // Colour key should exist
237  if (!G4Colour::GetColour(colour, myColour)) {
239  ed << "G4Colour with key "<<colour<<" does not exist ";
241  ("G4ModelCmdApplyColour<M>::SetNewValue",
242  "modeling0107", JustWarning, ed);
243  return;
244  }
245  }
246 
247  if (cmd == fpComponentCmd) {
248  G4double red(0), green(0), blue(0), alpha(0);
249  std::istringstream is (newValue);
250  is >> red >> green >> blue >> alpha;
251 
252  G4Colour colour(red, green, blue, alpha);
253  myColour = colour;
254  }
255 
256  Apply(myColour);
258  if (visManager) visManager->NotifyHandlers();
259 }
char cmd[1024]
Definition: tracer.cxx:25
Definition: test07.cc:36
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4VVisManager * GetConcreteInstance()
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:126
Definition: test07.cc:36
virtual void NotifyHandlers()
virtual void Apply(const G4Colour &)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
template<typename M >
G4UIcommand* G4ModelCmdApplyColour< M >::StringCommand ( )
inlineprotected

Definition at line 175 of file G4ModelApplyCommandsT.hh.

175 {return fpStringCmd;}

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