38 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : (char*)NULL)
41 if ((str) != NULL) { \
57 interactorDirectory =
new G4UIdirectory(
"/gui/", propagateToWorkers =
false);
58 interactorDirectory->
SetGuidance(
"UI interactors commands.");
71 addButton =
new G4UIcommand(
"/gui/addButton",
this);
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.");
94 addIcon->
SetGuidance(
"Add a non-checkable icon to the Icon toolbar.");
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");
99 "A command given without parameters will display a window that will allow one to choose the "
100 "parameters (if needed) for this command.");
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:");
106 " - open: Open an open-file-selector that can run the Command with File as argument.");
108 " - save: Open a save-file-selector that can run the Command with File as argument.");
110 " - move/rotate/pick/zoom_in/zoom_out: Theses icons are radio-button icons that can change "
113 " - wireframe/solid/hidden_line_removal/hidden_line_and_surface_removal: These icons are "
114 "radio-button icons that can change drawing style.");
116 " - perspective/ortho: These icons are radio-button icons that can change projection style.");
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");
145 outputStyle =
new G4UIcommand(
"/gui/outputStyle",
this);
147 outputStyle->
SetGuidance(
"First parameter: destination stream.");
148 outputStyle->
SetGuidance(
"Second parameter: style.");
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.");
154 const auto& outputStyles =
session->GetOutputStyles();
156 for (
const auto& style : outputStyles) {
157 candidates += style.first +
' ';
169 nativeMenu =
new G4UIcommand(
"/gui/nativeMenuBar",
this);
170 nativeMenu->
SetGuidance(
"Allow native menu bar in Geant4 Qt driver.");
177 clearMenu =
new G4UIcommand(
"/gui/clearMenu",
this);
178 clearMenu->
SetGuidance(
"Clear menu bar, remove all user defined menu entries.");
191 delete interactorDirectory;
198 if (GetValues(newValue, (
G4int)paramn, params)) {
199 if (command == addMenu) {
200 session->AddMenu((
const char*)params[0], (
const char*)params[1]);
202 else if (command == addButton) {
203 session->AddButton((
const char*)params[0], (
const char*)params[1], (
const char*)params[2]);
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]);
209 else if (command == defaultIcons) {
212 else if (command == sys) {
213 G4int rc = system((
const char*)params[0]);
217 else if (command == outputStyle) {
218 session->SetOutputStyle((
const char*)params[0], (
const char*)params[1]);
220 else if (command == nativeMenu) {
223 else if (command == clearMenu) {
231 char* value =
STRDUP(newValue.data());
232 if (value ==
nullptr)
return false;
233 char* tok = strtok(value,
" ");
234 for (
G4int i = 0; i < paramn; ++i) {
235 if (tok ==
nullptr) {
240 if (token[0] ==
'"') {
241 while (token.back() !=
'"') {
242 tok = strtok(
nullptr,
" ");
243 if ((tok ==
nullptr) || (*tok ==
'\0')) {
250 G4StrUtil::strip(token,
'"');
259 tok = strtok(
nullptr,
" ");
~G4InteractorMessenger() override
G4InteractorMessenger(G4VInteractiveSession *session)
void SetNewValue(G4UIcommand *command, G4String newValue) override
std::size_t GetParameterEntries() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
static G4bool ConvertToBool(const char *st)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterCandidates(const char *theString)