Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4InteractorMessenger Class Reference

#include <G4InteractorMessenger.hh>

Inheritance diagram for G4InteractorMessenger:

Public Member Functions

 G4InteractorMessenger (G4VInteractiveSession *session)
 ~G4InteractorMessenger () override
void SetNewValue (G4UIcommand *command, G4String newValue) override
Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual ~G4UImessenger ()
virtual G4String GetCurrentValue (G4UIcommand *command)
G4bool CommandsShouldBeInMaster () const

Additional Inherited Members

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 (const 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)
Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
G4String baseDirName = ""
G4bool commandsShouldBeInMaster = false

Detailed Description

Definition at line 37 of file G4InteractorMessenger.hh.

Constructor & Destructor Documentation

◆ G4InteractorMessenger()

G4InteractorMessenger::G4InteractorMessenger ( G4VInteractiveSession * session)

Definition at line 49 of file G4InteractorMessenger.cc.

50{
51 session = a_session;
52
53 G4UIparameter* parameter;
54
55 // gui commands should *not* be broadcast to workers
56 G4bool propagateToWorkers;
57 interactorDirectory = new G4UIdirectory("/gui/", propagateToWorkers = false);
58 interactorDirectory->SetGuidance("UI interactors commands.");
59
60 // /gui/addMenu :
61 addMenu = new G4UIcommand("/gui/addMenu", this);
62 addMenu->SetGuidance("Add a menu to menu bar.");
63 parameter = new G4UIparameter("Name", 's', false);
64 parameter->SetDefaultValue("dummy");
65 addMenu->SetParameter(parameter);
66 parameter = new G4UIparameter("Label", 's', false);
67 parameter->SetDefaultValue("dummy");
68 addMenu->SetParameter(parameter);
69
70 // /gui/addButton :
71 addButton = new G4UIcommand("/gui/addButton", this);
72 addButton->SetGuidance("Add a button to menu.");
73 parameter = new G4UIparameter("Menu", 's', false);
74 parameter->SetDefaultValue("dummy");
75 addButton->SetParameter(parameter);
76 parameter = new G4UIparameter("Label", 's', false);
77 parameter->SetDefaultValue("dummy");
78 addButton->SetParameter(parameter);
79 parameter = new G4UIparameter("Command", 's', false);
80 parameter->SetDefaultValue("");
81 addButton->SetParameter(parameter);
82
83 // /gui/defaultIcons :
84 defaultIcons = new G4UIcommand("/gui/defaultIcons", this);
85 defaultIcons->SetGuidance("Set the Geant4 defaults icons in Qt driver.");
86 defaultIcons->SetGuidance("By default, Geant4 icons are enable.");
87
88 parameter = new G4UIparameter("bool", 'b', true);
89 parameter->SetDefaultValue("true");
90 defaultIcons->SetParameter(parameter);
91
92 // /gui/addIcon :
93 addIcon = new G4UIcommand("/gui/addIcon", this);
94 addIcon->SetGuidance("Add a non-checkable icon to the Icon toolbar.");
95 addIcon->SetGuidance(
96 "If the Icon parameter is set to \"user_icon\", you should provide the icon file in xpm "
97 "format, otherwise you have to choose one of the candidate icons");
98 addIcon->SetGuidance(
99 "A command given without parameters will display a window that will allow one to choose the "
100 "parameters (if needed) for this command.");
101 addIcon->SetGuidance(
102 "E.g: /gui/addIcon \"Change background color\" user_icon /vis/viewer/set/background "
103 "../Images/background.xpm");
104 addIcon->SetGuidance("Special cases for the Icon parameter:");
105 addIcon->SetGuidance(
106 " - open: Open an open-file-selector that can run the Command with File as argument.");
107 addIcon->SetGuidance(
108 " - save: Open a save-file-selector that can run the Command with File as argument.");
109 addIcon->SetGuidance(
110 " - move/rotate/pick/zoom_in/zoom_out: Theses icons are radio-button icons that can change "
111 "cursor action.");
112 addIcon->SetGuidance(
113 " - wireframe/solid/hidden_line_removal/hidden_line_and_surface_removal: These icons are "
114 "radio-button icons that can change drawing style.");
115 addIcon->SetGuidance(
116 " - perspective/ortho: These icons are radio-button icons that can change projection style.");
117
118 parameter = new G4UIparameter("Label", 's', false);
119 parameter->SetDefaultValue("");
120 addIcon->SetParameter(parameter);
121
122 parameter = new G4UIparameter("Icon", 's', false);
123 parameter->SetDefaultValue("");
124 parameter->SetParameterCandidates(
125 "open save move rotate pick zoom_in zoom_out wireframe solid hidden_line_removal "
126 "hidden_line_and_surface_removal perspective ortho exit user_icon");
127 addIcon->SetParameter(parameter);
128
129 parameter = new G4UIparameter("Command", 's', true);
130 parameter->SetDefaultValue("no_command");
131 addIcon->SetParameter(parameter);
132
133 parameter = new G4UIparameter("File", 's', true);
134 parameter->SetDefaultValue("no_file");
135 addIcon->SetParameter(parameter);
136
137 // /gui/system :
138 sys = new G4UIcommand("/gui/system", this);
139 sys->SetGuidance("Send a command to the system.");
140 parameter = new G4UIparameter("Command", 's', false);
141 parameter->SetDefaultValue("");
142 sys->SetParameter(parameter);
143
144 // /gui/outputStyle :
145 outputStyle = new G4UIcommand("/gui/outputStyle", this);
146 outputStyle->SetGuidance("Set output style.");
147 outputStyle->SetGuidance("First parameter: destination stream.");
148 outputStyle->SetGuidance("Second parameter: style.");
149 outputStyle->SetGuidance(
150 "Note that highlight for cout refers only to echoed commands, i.e.,"
151 "\ncommands echoed by \"/control/verbose 2\".");
152 outputStyle->SetGuidance("Note also that plain resets both highlight and bold.");
153 parameter = new G4UIparameter("destination", 's', true); // Omitable
154 const auto& outputStyles = session->GetOutputStyles();
155 G4String candidates;
156 for (const auto& style : outputStyles) {
157 candidates += style.first + ' ';
158 }
159 candidates += "all";
160 parameter->SetParameterCandidates(candidates);
161 parameter->SetDefaultValue("all");
162 outputStyle->SetParameter(parameter);
163 parameter = new G4UIparameter("style", 's', true); // Omitable
164 parameter->SetParameterCandidates("fixed proportional bold plain highlight");
165 parameter->SetDefaultValue("fixed");
166 outputStyle->SetParameter(parameter);
167
168 // /gui/nativeMenuBar :
169 nativeMenu = new G4UIcommand("/gui/nativeMenuBar", this);
170 nativeMenu->SetGuidance("Allow native menu bar in Geant4 Qt driver.");
171 nativeMenu->SetGuidance("By default, enable.");
172
173 parameter = new G4UIparameter("bool", 'b', true);
174 parameter->SetDefaultValue("true");
175 nativeMenu->SetParameter(parameter);
176 // /gui/clearMenu
177 clearMenu = new G4UIcommand("/gui/clearMenu", this);
178 clearMenu->SetGuidance("Clear menu bar, remove all user defined menu entries.");
179}
bool G4bool
Definition G4Types.hh:86
void SetDefaultValue(const char *theDefaultValue)
void SetParameterCandidates(const char *theString)

◆ ~G4InteractorMessenger()

G4InteractorMessenger::~G4InteractorMessenger ( )
override

Definition at line 181 of file G4InteractorMessenger.cc.

182{
183 delete clearMenu;
184 delete nativeMenu;
185 delete outputStyle;
186 delete sys;
187 delete defaultIcons;
188 delete addIcon;
189 delete addButton;
190 delete addMenu;
191 delete interactorDirectory;
192}

Member Function Documentation

◆ SetNewValue()

void G4InteractorMessenger::SetNewValue ( G4UIcommand * command,
G4String newValue )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 194 of file G4InteractorMessenger.cc.

195{
196 const auto paramn = command->GetParameterEntries();
197 auto params = new G4String[paramn];
198 if (GetValues(newValue, (G4int)paramn, params)) {
199 if (command == addMenu) {
200 session->AddMenu((const char*)params[0], (const char*)params[1]);
201 }
202 else if (command == addButton) {
203 session->AddButton((const char*)params[0], (const char*)params[1], (const char*)params[2]);
204 }
205 else if (command == addIcon) {
206 session->AddIcon((const char*)params[0], (const char*)params[1], (const char*)params[2],
207 (const char*)params[3]);
208 }
209 else if (command == defaultIcons) {
210 session->DefaultIcons(command->ConvertToBool(newValue));
211 }
212 else if (command == sys) {
213 G4int rc = system((const char*)params[0]);
214 if (rc < 0) {
215 }
216 }
217 else if (command == outputStyle) {
218 session->SetOutputStyle((const char*)params[0], (const char*)params[1]);
219 }
220 else if (command == nativeMenu) {
221 session->NativeMenu(command->ConvertToBool(newValue));
222 }
223 else if (command == clearMenu) {
224 session->ClearMenu();
225 }
226 }
227 delete[] params;
228}
int G4int
Definition G4Types.hh:85
std::size_t GetParameterEntries() const
static G4bool ConvertToBool(const char *st)

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