37#define STRDUP(str) ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : (char*)NULL)
38#define STRDEL(str) {if((str)!=NULL) {free(str);str=NULL;}}
52 interactorDirectory =
new G4UIdirectory(
"/gui/",propagateToWorkers=
false);
53 interactorDirectory->
SetGuidance(
"UI interactors commands.");
79 defaultIcons =
new G4UIcommand(
"/gui/defaultIcons",
this);
80 defaultIcons->
SetGuidance(
"Set the Geant4 defaults icons in Qt driver.");
81 defaultIcons->
SetGuidance(
"By default, Geant4 icons are enable.");
90 (
"Add a non-checkable icon to the Icon toolbar.");
92 (
"If the Icon parameter is set to \"user_icon\", you should provide the icon file in xpm format, otherwise you have to choose one of the candidate icons");
94 (
"A command given without parameters will display a window that will allow one to choose the parameters (if needed) for this command.");
96 (
"E.g: /gui/addIcon \"Change background color\" user_icon /vis/viewer/set/background ../Images/background.xpm");
98 (
"Special cases for the Icon parameter:");
100 (
" - open: Open an open-file-selector that can run the Command with File as argument.");
102 (
" - save: Open a save-file-selector that can run the Command with File as argument.");
104 (
" - move/rotate/pick/zoom_in/zoom_out: Theses icons are radio-button icons that can change cursor action.");
106 (
" - wireframe/solid/hidden_line_removal/hidden_line_and_surface_removal: These icons are radio-button icons that can change drawing style.");
108 (
" - perspective/ortho: These icons are radio-button icons that can change projection style.");
117 (
"open save move rotate pick zoom_in zoom_out wireframe solid hidden_line_removal hidden_line_and_surface_removal perspective ortho exit user_icon");
136 outputStyle =
new G4UIcommand(
"/gui/outputStyle",
this);
138 outputStyle->
SetGuidance(
"Highlights commands if requested and if /control/verbose > 0.");
153 nativeMenu =
new G4UIcommand(
"/gui/nativeMenuBar",
this);
154 nativeMenu->
SetGuidance(
"Allow native menu bar in Geant4 Qt driver.");
161 clearMenu =
new G4UIcommand(
"/gui/clearMenu",
this);
162 clearMenu->
SetGuidance(
"Clear menu bar, remove all user defined menu entries.");
175 delete interactorDirectory;
185 if(GetValues(newValue,paramn,params)==
true) {
186 if(command==addMenu) {
187 session->AddMenu((
const char*)params[0],(
const char*)params[1]);
188 }
else if(command==addButton) {
189 session->AddButton((
const char*)params[0],(
const char*)params[1],(
const char*)params[2]);
190 }
else if(command==addIcon) {
191 session->AddIcon((
const char*)params[0],(
const char*)params[1],(
const char*)params[2],(
const char*)params[3]);
192 }
else if(command==defaultIcons) {
194 }
else if(command==sys) {
195 G4int rc = system((
const char*)params[0]);
197 }
else if(command==outputStyle) {
198 session->OutputStyle((
const char*)params[0],(
const char*)params[1],(
const char*)params[2]);
199 }
else if(command==nativeMenu) {
201 }
else if(command==clearMenu) {
213 char* value =
STRDUP(newValue.data());
214 if(value==NULL)
return false;
215 char* tok = strtok(value,
" ");
216 for(
G4int i=0; i<paramn; ++i ) {
222 if( token[0]==
'"' ) {
223 while( token.back() !=
'"' ) {
224 tok = strtok(NULL,
" ");
225 if( (tok==NULL) || (*tok==
'\0')) {
234 if( token.empty() ) {
240 tok = strtok(NULL,
" ");
void SetNewValue(G4UIcommand *command, G4String newValue)
G4InteractorMessenger(G4VInteractiveSession *session)
virtual ~G4InteractorMessenger()
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)
void strip(G4String &str, char ch=' ')
Remove leading and trailing characters from string.