Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ModelCmdApplyStringColour< M > Class Template Referenceabstract

#include <G4ModelApplyCommandsT.hh>

Inheritance diagram for G4ModelCmdApplyStringColour< M >:
Collaboration 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 ()
 
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)
 
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
 
G4bool commandsShouldBeInMaster
 

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.

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

Here is the call graph for this function:

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

Definition at line 115 of file G4ModelApplyCommandsT.hh.

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

Member Function Documentation

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

Definition at line 67 of file G4ModelApplyCommandsT.hh.

67 {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.

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

Here is the call graph for this function:

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

Definition at line 66 of file G4ModelApplyCommandsT.hh.

66 {return fpStringCmd;}

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