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

#include <G4ModelApplyCommandsT.hh>

+ Inheritance diagram for G4ModelCmdApplyStringColour< M >:

Public Member Functions

 G4ModelCmdApplyStringColour (M *model, const G4String &placement, const G4String &cmdName)
 
virtual ~G4ModelCmdApplyStringColour ()
 
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 ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Protected Member Functions

virtual void Apply (const G4String &, 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)
 
G4long StoL (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 = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

template<typename M>
class G4ModelCmdApplyStringColour< M >

Definition at line 50 of file G4ModelApplyCommandsT.hh.

Constructor & Destructor Documentation

◆ G4ModelCmdApplyStringColour()

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

Definition at line 76 of file G4ModelApplyCommandsT.hh.

77 :G4VModelCommand<M>(model, placement)
78{
79 //Set variable colour through a string
80 G4String dir = placement+"/"+model->Name()+"/"+cmdName;
81 G4UIparameter* param(0);
82
83 fpStringCmd = new G4UIcommand(dir, this);
84 fpStringCmd->SetGuidance("Set variable colour through a string");
85
86 param = new G4UIparameter("Variable", 's', false);
87 fpStringCmd->SetParameter(param);
88
89 param = new G4UIparameter("Value", 's', false);
90 fpStringCmd->SetParameter(param);
91
92 //Set variable colour through RGBA components
93 G4String componentDir = dir+"RGBA";
94
95 fpComponentCmd = new G4UIcommand(componentDir, this);
96 fpComponentCmd->SetGuidance("Set variable colour through red, green, blue and alpha components");
97 param = new G4UIparameter("Variable", 's', false);
98 fpComponentCmd->SetParameter(param);
99
100 param = new G4UIparameter("Red component", 'd', false);
101 fpComponentCmd->SetParameter(param);
102
103 param = new G4UIparameter("Green component", 'd', false);
104 fpComponentCmd->SetParameter(param);
105
106 param = new G4UIparameter("Blue component", 'd', false);
107 fpComponentCmd->SetParameter(param);
108
109 param = new G4UIparameter("Alpha component", 'd', false);
110 fpComponentCmd->SetParameter(param);
111}
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156

◆ ~G4ModelCmdApplyStringColour()

template<typename M >
G4ModelCmdApplyStringColour< M >::~G4ModelCmdApplyStringColour
virtual

Definition at line 114 of file G4ModelApplyCommandsT.hh.

115{
116 delete fpStringCmd;
117 delete fpComponentCmd;
118}

Member Function Documentation

◆ Apply()

template<typename M >
virtual void G4ModelCmdApplyStringColour< M >::Apply ( const G4String ,
const G4Colour  
)
protectedpure virtual

◆ ComponentCommand()

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

Definition at line 66 of file G4ModelApplyCommandsT.hh.

66{return fpComponentCmd;}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 121 of file G4ModelApplyCommandsT.hh.

122{
123 G4Colour myColour;
124 G4String parameter;
125
126 if (cmd == fpStringCmd) {
127 G4String colour;
128 std::istringstream is (newValue);
129 is >> parameter >> colour;
130
131 // Colour key should exist
132 if (!G4Colour::GetColour(colour, myColour)) {
134 ed << "G4Colour with key "<<colour<<" does not exist ";
136 ("G4ModelCmdApplyStringColour<M>::SetNewValue",
137 "modeling0106", JustWarning, ed);
138 return;
139 }
140 }
141
142 if (cmd == fpComponentCmd) {
143 G4double red(0), green(0), blue(0), alpha(0);
144 std::istringstream is (newValue);
145 is >> parameter >> red >> green >> blue >> alpha;
146
147 G4Colour colour(red, green, blue, alpha);
148 myColour = colour;
149 }
150
151 Apply(parameter, myColour);
153 if (visManager) visManager->NotifyHandlers();
154}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:162
virtual void Apply(const G4String &, const G4Colour &)=0
virtual void NotifyHandlers()
static G4VVisManager * GetConcreteInstance()

◆ StringCommand()

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

Definition at line 65 of file G4ModelApplyCommandsT.hh.

65{return fpStringCmd;}

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