Geant4 11.2.2
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 ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Protected Member Functions

virtual void Apply (const G4Colour &)=0
 
G4UIcommandStringCommand ()
 
G4UIcommandComponentCommand ()
 
- Protected Member Functions inherited from G4VModelCommand< M >
MModel ()
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

template<typename M>
class G4ModelCmdApplyColour< M >

Definition at line 159 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 185 of file G4ModelApplyCommandsT.hh.

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

◆ ~G4ModelCmdApplyColour()

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

Definition at line 219 of file G4ModelApplyCommandsT.hh.

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

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 175 of file G4ModelApplyCommandsT.hh.

175{return fpComponentCmd;}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 226 of file G4ModelApplyCommandsT.hh.

227{
228 G4Colour myColour;
229
230 if (cmd == fpStringCmd) {
231 G4String colour;
232 std::istringstream is (newValue);
233 is >> colour;
234
235 // Colour key should exist
236 if (!G4Colour::GetColour(colour, myColour)) {
238 ed << "G4Colour with key "<<colour<<" does not exist ";
240 ("G4ModelCmdApplyColour<M>::SetNewValue",
241 "modeling0107", JustWarning, ed);
242 return;
243 }
244 }
245
246 if (cmd == fpComponentCmd) {
247 G4double red(0), green(0), blue(0), alpha(0);
248 std::istringstream is (newValue);
249 is >> red >> green >> blue >> alpha;
250
251 G4Colour colour(red, green, blue, alpha);
252 myColour = colour;
253 }
254
255 Apply(myColour);
257 if (visManager) visManager->NotifyHandlers();
258}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition G4Colour.cc:155
virtual void Apply(const G4Colour &)=0
virtual void NotifyHandlers()
static G4VVisManager * GetConcreteInstance()

◆ StringCommand()

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

Definition at line 174 of file G4ModelApplyCommandsT.hh.

174{return fpStringCmd;}

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