Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ModelCmdApplyColour< M > Class Template Referenceabstract

#include <G4ModelApplyCommandsT.hh>

+ Inheritance diagram for G4ModelCmdApplyColour< 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)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
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)
 
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

◆ G4ModelCmdApplyColour()

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

Definition at line 186 of file G4ModelApplyCommandsT.hh.

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:147
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156

◆ ~G4ModelCmdApplyColour()

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

◆ Apply()

template<typename M >
virtual void G4ModelCmdApplyColour< M >::Apply ( const G4Colour )
protectedpure virtual

◆ ComponentCommand()

template<typename M >
G4UIcommand * G4ModelCmdApplyColour< M >::ComponentCommand ( )
inlineprotected

Definition at line 176 of file G4ModelApplyCommandsT.hh.

176{return fpComponentCmd;}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 227 of file G4ModelApplyCommandsT.hh.

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}
@ JustWarning
double G4double
Definition: G4Types.hh:64
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:123
virtual void Apply(const G4Colour &)=0
virtual void NotifyHandlers()
static G4VVisManager * GetConcreteInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

◆ StringCommand()

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: