Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIQt.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// L. Garnier
29
30#include "G4Types.hh"
31
32#include <string.h>
33
34#include "G4UIQt.hh"
35#include "G4UImanager.hh"
36#include "G4UIcommand.hh"
37#include "G4StateManager.hh"
38#include "G4UIcommandTree.hh"
39#include "G4UIcommandStatus.hh"
41#include "G4Qt.hh"
42
43#include <qapplication.h>
44#include <qmessagebox.h>
45#include <qlineedit.h>
46#include <qwidget.h>
47#include <qmenubar.h>
48#include <qlayout.h>
49#include <qpushbutton.h>
50#include <qlabel.h>
51#include <qsplitter.h>
52#include <qscrollbar.h>
53#include <qdialog.h>
54#include <qevent.h>
55#include <qtextedit.h>
56#include <qtextbrowser.h>
57#if QT_VERSION < 0x050600
58#include <qsignalmapper.h>
59#endif
60#include <qtabwidget.h>
61#include <qtabbar.h>
62#include <qstringlist.h>
63#include <qtextstream.h>
64
65#include <qmainwindow.h>
66#include <qmenu.h>
67#include <qlistwidget.h>
68#include <qtreewidget.h>
69#include <qheaderview.h>
70#include <qgroupbox.h>
71#include <qscrollarea.h>
72#include <qtoolbox.h>
73#include <qradiobutton.h>
74#include <qbuttongroup.h>
75#include <qcombobox.h>
76#include <qpainter.h>
77#include <qcolordialog.h>
78#include <qtoolbar.h>
79#include <qfiledialog.h>
80#include <qdesktopwidget.h>
81#include <qtablewidget.h>
82#include <qcompleter.h>
83#include <qstandarditemmodel.h>
84#include <qboxlayout.h>
85#include <stdlib.h>
86
87#ifndef G4GMAKE
88#include "moc_G4UIQt.cpp"
89#endif
90
91// Pourquoi Static et non variables de classe ?
92static G4bool exitSession = true;
93static G4bool exitPause = true;
94
95/** Build a Qt window with a menubar, output area and promt area<br>
96<pre>
97 +-----------------------+
98 |exit menu| |
99 | |
100 | +-------------------+ |
101 | | | |
102 | | Output area | |
103 | | | |
104 | +-------------------+ |
105 | | clear | |
106 | +-------------------+ |
107 | | promt history | |
108 | +-------------------+ |
109 | +-------------------+ |
110 | |> promt area | |
111 | +-------------------+ |
112 +-----------------------+
113</pre>
114*/
116 G4int argc
117,char** argv
118)
119:fMainWindow(NULL)
120,fCommandLabel(NULL)
121,fCommandArea(NULL)
122,fCoutTBTextArea(NULL)
123,fUITabWidget(NULL)
124,fCoutFilter(NULL)
125,fCompleter(NULL)
126,fDefaultIcons(true)
127,fHistoryTBTableList(NULL)
128,fHelpTreeWidget(NULL)
129,fHelpTBWidget(NULL)
130,fHistoryTBWidget(NULL)
131,fCoutDockWidget(NULL)
132,fUIDockWidget(NULL)
133,fSceneTreeWidget(NULL)
134,fViewerPropertiesWidget(NULL)
135,fPickInfosWidget(NULL)
136,fHelpLine(NULL)
137,fViewerTabWidget(NULL)
138,fCoutText("Output")
139,fStartPage(NULL)
140,fHelpVSplitter(NULL)
141,fParameterHelpLabel(NULL)
142,fParameterHelpTable(NULL)
143,fToolbarApp(NULL)
144,fToolbarUser(NULL)
145,fStringSeparator("__$$$@%%###__")
146,fLastOpenPath("")
147,fSearchIcon(NULL)
148,fClearIcon(NULL)
149,fSaveIcon(NULL)
150,fOpenIcon(NULL)
151,fMoveIcon(NULL)
152,fRotateIcon(NULL)
153,fPickIcon(NULL)
154,fZoomInIcon(NULL)
155,fZoomOutIcon(NULL)
156,fWireframeIcon(NULL)
157,fSolidIcon(NULL)
158,fHiddenLineRemovalIcon(NULL)
159,fHiddenLineAndSurfaceRemovalIcon(NULL)
160,fPerspectiveIcon(NULL)
161,fOrthoIcon(NULL)
162,fCommandIcon(NULL)
163,fDirIcon(NULL)
164,fRunIcon(NULL)
165,fParamIcon(NULL)
166,fPickTargetIcon(NULL)
167#ifdef G4MULTITHREADED
168,fThreadsFilterComboBox(NULL)
169#endif
170,fDefaultViewerFirstPageHTMLText("")
171,fViewerPropertiesDialog(NULL)
172,fPickInfosDialog(NULL)
173,fLastCompleteCommand("")
174,fMoveSelected(false)
175,fRotateSelected(true)
176,fPickSelected(false)
177,fZoomInSelected(false)
178,fZoomOutSelected(false)
179{
180
181 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
182 if (!(QApplication*)interactorManager->GetMainInteractor()) {
184 G4int verbose = UImanager->GetVerboseLevel();
185
186 if (verbose >= 2) {
187 G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
188 }
189 }
190
192 if(UI!=NULL) UI->SetSession(this);
193 if(UI!=NULL) UI->SetG4UIWindow(this);
194
195 // Check if already define in external app QMainWindow
196 G4bool found = false;
197 Q_FOREACH (QWidget *widget, QApplication::allWidgets()) {
198 if ((found== false) && (widget->inherits("QMainWindow"))) {
199 found = true;
200 }
201 }
202
203 if (found) {
205 G4int verbose = UImanager->GetVerboseLevel();
206
207 if (verbose >= 2) {
208 G4cout << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
209 }
210 return ;
211 }
212 CreateIcons();
213
214 // Set default output styles
215 for (const auto& destination: {"cout","cerr","warnings","errors"}) {
216 G4UIQtStyle defaultStyle;
217 defaultStyle.fixed = true;
218 defaultStyle.highlight = true;
219 fOutputStyles[destination] = defaultStyle;
220 }
221
222 fMainWindow = new QMainWindow();
223 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
224
225 fMainWindow->setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
226 fMainWindow->setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
227 fMainWindow->setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
228 fMainWindow->setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
229
230 CreateViewerWidget();
231 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
232 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
233
234
235 // add defaults icons
236 SetDefaultIconsToolbar();
237
238 if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
239
240#ifdef G4MULTITHREADED
241 // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
243#endif
244
245 fMainWindow->setWindowTitle(QFileInfo( QCoreApplication::applicationFilePath() ).fileName());
246 fMainWindow->move(QPoint(50,50));
247
248 // force the size at be correct at the beggining
249 // because the widget is not realized yet, the size of the main window is not up to date. But
250 // we need it in order to add some viewer inside
251 fMainWindow->resize(fUIDockWidget->width()+fCoutDockWidget->width()+20,
252 fUIDockWidget->height()+fCoutDockWidget->height()+20);
253
254 // set last focus on command line
255 fCommandArea->setFocus(Qt::TabFocusReason);
256
257 // Allow QTextCursor to be called by another thread :
258 // http://qt-project.org/doc/qt-4.8/qmetatype.html#qRegisterMetaType
259 qRegisterMetaType<QTextCursor>("QTextCursor");
260
261 // add some tips
262 AddTabWidget(fStartPage,"Useful tips");
263
264 // Set not visible until session start
265 #if QT_VERSION < 0x040200
266 fMainWindow->hide();
267 #else
268 fMainWindow->setVisible(false);
269 #endif
270}
271
272
273
275)
276{
277 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
278 if(UI!=NULL) { // TO KEEP
279 UI->SetSession(NULL); // TO KEEP
280 UI->SetG4UIWindow(NULL);
281 UI->SetCoutDestination(0); // TO KEEP
282#ifdef G4MULTITHREADED
283 masterG4coutDestination = 0; // set to cout when UI is deleted
284#endif
285 }
286}
287
288
290{
291 fDefaultIcons = aVal;
292
293#if QT_VERSION < 0x040200
294 if (!fMainWindow->isHidden()) {
295#else
296 if (!fMainWindow->isVisible()) {
297#endif
298 return;
299 }
300
301 if (fToolbarApp) {
302 if (aVal) {
303#if QT_VERSION < 0x040200
304 fToolbarApp->show();
305#else
306 fToolbarApp->setVisible(true);
307#endif
308 } else {
309 // Set not visible until session start
310#if QT_VERSION < 0x040200
311 fToolbarApp->hide();
312#else
313 fToolbarApp->setVisible(false);
314#endif
315 }
316 }
317}
318
319
320void G4UIQt::SetDefaultIconsToolbar(
321) {
322
323 if (fDefaultIcons) {
324 if (fToolbarApp == NULL) {
325 fToolbarApp = new QToolBar();
326 fToolbarApp->setIconSize (QSize(20,20));
327 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
328 }
329
330 // Open/Save Icons
331 AddIcon("Open macro file","open", "/control/execute");
332 AddIcon("Save viewer state", "save", "/vis/viewer/save");
333
334 // View parameters
335#if QT_VERSION < 0x050600
336 QSignalMapper *signalMapperViewerProperties = new QSignalMapper(this);
337 QAction *actionViewerProperties = fToolbarApp->addAction(QIcon(*fParamIcon),"Viewer properties", signalMapperViewerProperties, SLOT(map()));
338 connect(signalMapperViewerProperties, SIGNAL(mapped(G4int)),this, SLOT(ViewerPropertiesIconCallback(G4int)));
339 G4int intVP = 0;
340 signalMapperViewerProperties->setMapping(actionViewerProperties, intVP);
341#else
342 fToolbarApp->addAction(QIcon(*fParamIcon),"Viewer properties", this, [this](){ this->ViewerPropertiesIconCallback(0); });
343#endif
344
345 // Cursors style icons
346 AddIcon("Move", "move", "");
347 AddIcon("Pick", "pick", "");
348 AddIcon("Zoom out", "zoom_out", "");
349 AddIcon("Zoom in", "zoom_in", "");
350 AddIcon("Rotate", "rotate", "");
351
352 // Surface Style icons
353 AddIcon("Hidden line removal", "hidden_line_removal", "");
354 AddIcon("Hidden line and hidden surface removal", "hidden_line_and_surface_removal", "");
355 AddIcon("Surfaces", "solid", "");
356 AddIcon("Wireframe", "wireframe", "");
357
358 // Perspective/Ortho icons
359 AddIcon("Perspective", "perspective","");
360 AddIcon("Orthographic", "ortho","");
361 AddIcon("Run beam on", "runBeamOn","/run/beamOn 1");
362 AddIcon("Exit Application", "exit","exit");
363 }
364}
365
366
367void G4UIQt::CreateIcons(
368)
369{
370 const char * const save[]={
371 "32 32 24 1",
372 " c None",
373 "+ c #000200",
374 "@ c #141E43",
375 "# c #000C56",
376 "$ c #494A47",
377 "% c #636662",
378 "& c #312F2A",
379 "* c #191B19",
380 "= c #002992",
381 "- c #003DFF",
382 "; c #041DA5",
383 "> c #A8A9A3",
384 ", c #FDFFFC",
385 "' c #DDE0DD",
386 ") c #818783",
387 "! c #C9CBC8",
388 "~ c #0116C3",
389 "{ c #C5C8FA",
390 "] c #6596FC",
391 "^ c #A0B4F9",
392 "/ c #0B2AFD",
393 "( c #799BE3",
394 "_ c #5F4826",
395 ": c #D5D8D5",
396 " ",
397 " ",
398 " +++++++++++++++++++++++++ ",
399 " +@##+$%%%%%%%%%%%%%%%&*$%&+ ",
400 " +=-;@>,,''',,,,,,,',,)&!,)+ ",
401 " +;-~@>,,,,,,,,,,,,,,,>$!,)+ ",
402 " +=-~@>,,,,,{]]]]]^,,,>*&$&+ ",
403 " +=-~@>,,,,,'{^{^^{,,,>*#=#+ ",
404 " +=-~@>,,,,,,,,,,,,,,,>@~/=+ ",
405 " +=-~@>,,,{{{''''{',,,>@~-=+ ",
406 " +=-~@>,,'^]]]]]]({,,,>@~-=+ ",
407 " +=-~@>,,,{{{{{{{{{,,,>@~-=+ ",
408 " +=-~@>,,,,,'{^{{^{,,,>@~-=+ ",
409 " +=-~@>,,,,,]]]]]]],,,>@~-=+ ",
410 " +=-~*>,,,,,,,,,,,,,,,>@~-=+ ",
411 " +=-~@>,,,,,,,,,,,,,,,>@~-=+ ",
412 " +=-/=$%%%%%%%%%%%%%%%$=/-=+ ",
413 " +=---;###############;---=+ ",
414 " +=---////////////////----=+ ",
415 " +=----------------///----=+ ",
416 " +=---=@##############@#--=+ ",
417 " +=---@+++++++++++*%))_+~-=+ ",
418 " +=---#+++++++++++&:,,>@~-=+ ",
419 " +=---#+++++++++++$',,>@~-=+ ",
420 " +=---#+++++++++++&!,,>@~-=+ ",
421 " +=/--#+++++++++++&',,>@~-=+ ",
422 " @;--#+++++++++++$',,>@~-=+ ",
423 " @;;@+++++++++++*)!>%@=;#+ ",
424 " @++++++++++++++*&**++@++ ",
425 " ",
426 " ",
427 " "}
428 ;
429 fSaveIcon = new QPixmap(save);
430
431 const char * const search[] = {
432 /* columns rows colors chars-per-pixel */
433 "19 19 8 1",
434 " c #5C5C5C",
435 ". c #7D7D7D",
436 "X c #9B9B9B",
437 "o c #C3C3C3",
438 "O c None",
439 "+ c #000000",
440 "@ c #000000",
441 "# c None",
442 /* pixels */
443 "OOOOOOOOOOOOOOOOOOO",
444 "OOOOOOOOOOOOOOOOOOO",
445 "OOOOOOOo. .oOOOOOO",
446 "OOOOOOX XOOOOO",
447 "OOOOOo XOOX oOOOO",
448 "OOOOO. XOOOOX .OOOO",
449 "OOOOO OOOOOO OOOO",
450 "OOOOO OOOOOO OOOO",
451 "OOOOO. XOOOOo .OOOO",
452 "OOOOOo oOOo oOOOO",
453 "OOOOOOX XOOOO",
454 "OOOOOOOo. . XOOO",
455 "OOOOOOOOOOOOO. XOO",
456 "OOOOOOOOOOOOOO. XOO",
457 "OOOOOOOOOOOOOOOoOOO",
458 "OOOOOOOOOOOOOOOOOOO",
459 "OOOOOOOOOOOOOOOOOOO",
460 "OOOOOOOOOOOOOOOOOOO",
461 "OOOOOOOOOOOOOOOOOOO"
462 };
463 fSearchIcon = new QPixmap(search);
464
465 const char * const clear[] = {
466 /* columns rows colors chars-per-pixel */
467 "20 20 8 1",
468 " c #020202",
469 ". c #202020",
470 "X c #2C2C2C",
471 "o c #797979",
472 "O c None",
473 "+ c #797979",
474 "@ c #797979",
475 "# c #797979",
476 /* pixels */
477 "OOOOOOOOOOOOOOOOOOOO",
478 "OOOOOOOo oOOOOOOO",
479 "OOOOOXX XXOOOOO",
480 "OOOOOOOOOOOOOOOOOOOO",
481 "OOOOOOOOOOOOOOOOOOOO",
482 "OOOO XXXXXXXXXX OOOO",
483 "OOO XOOOOOOOOOO OOO",
484 "OOOOXOooOooOooO OOOO",
485 "OOOOXOooOooOooO OOOO",
486 "OOOOXOooOooOooO OOOO",
487 "OOOOXOooOooOooO OOOO",
488 "OOOOXOooOooOooO OOOO",
489 "OOOOXOooOooOooO OOOO",
490 "OOOOXOooOooOooO OOOO",
491 "OOOOXOooOooOooO OOOO",
492 "OOOOXOooOooOooO OOOO",
493 "OOOOXOooOooOooO OOOO",
494 "OOOOXOOOOOOOOOO OOOO",
495 "OOOOOooooooooooOOOOO",
496 "OOOOOO........OOOOOO"
497 };
498
499 fClearIcon = new QPixmap(clear);
500
501
502 const char * const open[]={
503 "32 32 33 1",
504 " c None",
505 "+ c #09091E",
506 "@ c #191B18",
507 "# c #5F615F",
508 "$ c #777977",
509 "% c #AEB1AF",
510 "& c #929491",
511 "* c #515250",
512 "= c #858784",
513 "- c #333533",
514 "; c #000100",
515 "> c #272926",
516 ", c #424341",
517 "' c #696C6A",
518 ") c #5F4927",
519 "! c #583D18",
520 "~ c #6E6A5B",
521 "{ c #47351D",
522 "] c #E0A554",
523 "^ c #FFD67B",
524 "/ c #EFB465",
525 "( c #FDBF6C",
526 "_ c #FFCD76",
527 ": c #806238",
528 "< c #362611",
529 "[ c #0B0D0A",
530 "} c #68471B",
531 "| c #523E22",
532 "1 c #B78A51",
533 "2 c #A17B44",
534 "3 c #D6A45E",
535 "4 c #C29354",
536 "5 c #A1A3A0",
537 " ",
538 " ",
539 " +@@@# ",
540 " $% +& * ",
541 " #= $ -; ",
542 " %>;+ ",
543 " ,;;+ ",
544 " &#$''#' >;;;+ ",
545 " =)!)!!!!~ *#$'' ",
546 " {]^/((_({- %%%%%%%%%%% ",
547 " {(^_^^^^:<{{{{{{{{{{{{{[& ",
548 " {/_/(((((/]]]]]]]]]]]/]!# ",
549 " {/^(((((_^^^^^^^^^^^^^^:# ",
550 " {/^(((_^^____________^^}$ ",
551 " {/^(((((/////////////((!# ",
552 " {/^/^_:<|||||||||||||||@@****1 ",
553 " {/^/^(<[)||||||||||||||))!!}<; ",
554 " {/^_(:|234444444444444444432)1 ",
555 " {/_^/<)34444444444444444443}, ",
556 " {/^(2{:41111111111111111142|5 ",
557 " {3^3<:31111111111111111143}- ",
558 " {/^2<:31111111111111111441|' ",
559 " {_/<:41111111111111111143}, ",
560 " {(4<:31111111111111111144!# ",
561 " )4))44111111111111111144}, ",
562 " )2<:31111111111111111144{# ",
563 " @|:14444444444444444444}* ",
564 " ;@434444444444444444434<# ",
565 " ;[))))))))))))))))))))!~ ",
566 " ++++++++++++++++++++++;% ",
567 " ",
568 " "}
569 ;
570 fOpenIcon = new QPixmap(open);
571
572
573 const char * const move[]={
574 "32 32 16 1",
575 " c None",
576 ". c #F1F1F1",
577 "+ c #939393",
578 "@ c #282828",
579 "# c #787878",
580 "$ c #000000",
581 "% c #CCCCCC",
582 "& c #1A1A1A",
583 "* c #0D0D0D",
584 "= c #5D5D5D",
585 "- c #AEAEAE",
586 "; c #BBBBBB",
587 "> c #C9C9C9",
588 ", c #D6D6D6",
589 "' c #FFFFFF",
590 ") c #999999",
591 " ",
592 " ",
593 " ",
594 " ",
595 " .. ",
596 " ++ ",
597 " .@@. ",
598 " #$$# ",
599 " %&$$*% ",
600 " =$$$$= ",
601 " -**$$**- ",
602 " %;%&*>;% ",
603 " -% @& %- ",
604 " ,=*; @& ;*=, ",
605 " .#*$$> >$$*#. ",
606 " ')&$$$$*@@ @@*$$$$&)' ",
607 " ')&$$$$*@@ @@*$$$$&+' ",
608 " .#*$$> >$$*#. ",
609 " ,=*; @& ;*=, ",
610 " -% @& %- ",
611 " %;%&*>>% ",
612 " -**$$**- ",
613 " =$$$$= ",
614 " %&$$*% ",
615 " #$$# ",
616 " .@@. ",
617 " ++ ",
618 " .. ",
619 " ",
620 " ",
621 " ",
622 " "}
623 ;
624 fMoveIcon = new QPixmap(move);
625
626 const char * const rotate[]={
627 "32 32 27 1",
628 " c None",
629 ". c #003333",
630 "+ c #000066",
631 "@ c #1A1A1A",
632 "# c #003399",
633 "$ c #3333CC",
634 "% c #000033",
635 "& c #353535",
636 "* c #434343",
637 "= c #336699",
638 "- c #3399FF",
639 "; c #003366",
640 "> c #5D5D5D",
641 ", c #282828",
642 "' c #3399CC",
643 ") c #333333",
644 "! c #3366CC",
645 "~ c #333399",
646 "{ c #505050",
647 "] c #666666",
648 "^ c #333366",
649 "/ c #0033CC",
650 "( c #3366FF",
651 "_ c #336666",
652 ": c #787878",
653 "< c #868686",
654 "[ c #6B6B6B",
655 " .++@ ",
656 " #$$%&* ",
657 " =--; *>, ",
658 " '-= )>& ",
659 " !-', ,>* ",
660 " !!=--= >* ",
661 " =------!!~@&)@ ",
662 " --------!*{{{*&, ",
663 " -------=){*{{{>>{) ",
664 " ,!-----= ){& ,&{{@",
665 " ,*>!----= &>& )@",
666 " ){>)~---= *]) @",
667 " @*>, --! ,&@ ",
668 " @{* '! ,-!=~^,@ ",
669 " @& == {/(----!^ ",
670 " _ ]:;(----' ",
671 " ==_ >{+(----~ ",
672 " !-!!======!!(((---! ",
673 " ='--------------! ",
674 " =!!!!'!!=; !-! ",
675 " &<* !~ ",
676 " @. *[* ; ",
677 " ;+)>* ",
678 " @@ ",
679 " ",
680 " ",
681 " ",
682 " ",
683 " ",
684 " ",
685 " ",
686 " "}
687 ;
688 fRotateIcon = new QPixmap(rotate);
689
690 const char * const pick[]={
691 /* columns rows colors chars-per-pixel */
692 "20 20 12 1 ",
693 " c #050804",
694 ". c #222321",
695 "X c #3B3C3A",
696 "o c #4C4E4B",
697 "O c #616360",
698 "+ c #747673",
699 "@ c #8A8C89",
700 "# c #9FA19E",
701 "$ c #BABCB9",
702 "% c #CED0CD",
703 "& c #E4E6E3",
704 "* c None",
705 /* pixels */
706 "*********oo*********",
707 "*********oo*********",
708 "******$O. .O%******",
709 "****&o .O..O O*****",
710 "***&X @**oo**@ X****",
711 "***o $***oo***$ O***",
712 "**% @**********@ %**",
713 "**O.***********& +**",
714 "**.O*****@@*****o.**",
715 "oo .oo**@ #*&XX. oo",
716 "oo .oo**@ #*&oo. oO",
717 "**.O*****##*****oX**",
718 "**O ***********& +**",
719 "**% @****&&****+ &**",
720 "***O $***Xo***# +***",
721 "****X @&*Xo*&+ o****",
722 "*****O o..o +*****",
723 "******%+. X+&******",
724 "*********oo*********",
725 "*********oO*********"
726 };
727 fPickIcon = new QPixmap(pick);
728
729 const char * const zoom_in[]={
730 "32 32 11 1",
731 " c None",
732 ". c #C9CBC8",
733 "+ c #A8A9A3",
734 "@ c #818783",
735 "# c #D5D8D5",
736 "$ c #9BCCCC",
737 "% c #5FC7F4",
738 "& c #FDFFFC",
739 "* c #636662",
740 "= c #9599CE",
741 "- c #DDE0DD",
742 " ",
743 " ",
744 " ",
745 " ",
746 " ",
747 " .++@@++. ",
748 " +++..#.+++ ",
749 " .@+...++++#+@. ",
750 " @$.%%+&&&@%..@ ",
751 " ++.%%%+&&&*%%.++ ",
752 " .+#%%%%+&&&*%%.#+ ",
753 " ++..%%%+&&&*%%%.++ ",
754 " +#.+++++&&&*++++.+ ",
755 " @.+&&&&&&&&&&&&&+@ ",
756 " @#+&&&&&&&&&&&&&+@ ",
757 " @.+&&&&&&&&&&&&&+. ",
758 " +++@***+&&&****@+. ",
759 " ....++++&&&*++++.. ",
760 " ++.===+&&&*%=.++ ",
761 " @..==+&&&*=..@#& ",
762 " .@+#.+&&&@-+@@*@ ",
763 " +++.++++++ *+@* ",
764 " .+@@@++. @**+* ",
765 " .*@*+* ",
766 " .*@*+* ",
767 " +*@@* ",
768 " .**+ ",
769 " ",
770 " ",
771 " ",
772 " ",
773 " "}
774 ;
775 fZoomInIcon = new QPixmap(zoom_in);
776
777 const char * const zoom_out[]={
778 "32 32 11 1",
779 " c None",
780 ". c #C9CBC8",
781 "+ c #A8A9A3",
782 "@ c #818783",
783 "# c #D5D8D5",
784 "$ c #5FC7F4",
785 "% c #9BCCCC",
786 "& c #FDFFFC",
787 "* c #636662",
788 "= c #9599CE",
789 "- c #DDE0DD",
790 " ",
791 " ",
792 " ",
793 " ",
794 " ",
795 " .++@@++. ",
796 " +++..#.+++ ",
797 " .@+..$$$$.#+@. ",
798 " @%.$$$$$$$$..@ ",
799 " ++.$$$$$$$$$$.++ ",
800 " .+#$$$$$$$$$$$.#+ ",
801 " ++..$$$$$$$$$$$.++ ",
802 " +#.+++++++++++++.+ ",
803 " @.+&&&&&&&&&&&&&+@ ",
804 " @#+&&&&&&&&&&&&&+@ ",
805 " @.+&&&&&&&&&&&&&+. ",
806 " +++@***********@+. ",
807 " ....++++++++++++.. ",
808 " ++.===$$$$$$=.++ ",
809 " @..===$$$$=..@#& ",
810 " .@+#.$$$..-+@@*@ ",
811 " +++#--.+++ *+@* ",
812 " .+@@@++. @**+* ",
813 " .*@*+* ",
814 " .*@*+* ",
815 " +*@@* ",
816 " .**+ ",
817 " ",
818 " ",
819 " ",
820 " ",
821 " "}
822 ;
823 fZoomOutIcon = new QPixmap(zoom_out);
824
825 const char * const wireframe[]={
826 "32 32 24 1",
827 " c None",
828 "+ c #E4E4E4",
829 "@ c #D5D5D5",
830 "# c #E1E1E1",
831 "$ c #E7E7E7",
832 "% c #D8D8D8",
833 "& c #A7A7A7",
834 "* c #000000",
835 "= c #989898",
836 "- c #8A8A8A",
837 "; c #B5B5B5",
838 "> c #1B1B1B",
839 ", c #676767",
840 "' c #959595",
841 ") c #4A4A4A",
842 "! c #878787",
843 "~ c #D3D3D3",
844 "{ c #C4C4C4",
845 "] c #A4A4A4",
846 "^ c #5B5B5B",
847 "/ c #B3B3B3",
848 "( c #787878",
849 "_ c #C7C7C7",
850 ": c #585858",
851 " ",
852 " +@@# ",
853 " $%@@@@@&****=+ ",
854 " +&********&@-***; ",
855 " +@@@&**&@@@@@@$ @*-&>&+ ",
856 " +*****&+ %*@ ,**'# ",
857 " @***)!~ @*{&*****+ ",
858 " @*!]***&+ +-*^**'~!*@ ",
859 " @*~ +@&**&@@@@@@&****&+ ~*@ ",
860 " @*@ +&********&-*= @*@ ",
861 " @*@ $%@-*-@$ @*@ @*@ ",
862 " @*@ @*@ %*% @*@ ",
863 " @*@ %*% %*% @*@ ",
864 " @*@ %*% %*% @*@ ",
865 " @*@ %*% %*% @*@ ",
866 " @*@ %*% %*% @*@ ",
867 " @*@ %*% %*% @*@ ",
868 " @*@ @*@ %*% @*@ ",
869 " @*@ =*-+ @*@ @*@ ",
870 " @*@ $%@@&****&@-*-+ @*@ ",
871 " @*@ $@&*****&@@&******&~~!*@ ",
872 " @*{/***&@@%$ $@-*-&*****+ ",
873 " @*)*)(-~ @*@ ~)**] ",
874 " +*******&@@@@+ %*_+]**] ",
875 " +@@@@@&******&@%+_*^**]# ",
876 " $%@@@&****:**&+ ",
877 " +%@&**& ",
878 " ++ ",
879 " ",
880 " ",
881 " ",
882 " "}
883 ;
884 fWireframeIcon = new QPixmap(wireframe);
885
886 const char * const solid[]={
887 "32 32 33 1",
888 " c None",
889 "+ c #C2DEDE",
890 "@ c #B5D7DF",
891 "# c #ACD6E6",
892 "$ c #60C0EC",
893 "% c #4EB7EE",
894 "& c #53B9ED",
895 "* c #82CEEA",
896 "= c #CFDDDA",
897 "- c #94C9E8",
898 "; c #0960FF",
899 "> c #0943FF",
900 ", c #0949FF",
901 "' c #3CB3F0",
902 ") c #71C7EB",
903 "! c #73CBE5",
904 "~ c #D3DDDB",
905 "{ c #C4DDDE",
906 "] c #B7D5DF",
907 "^ c #2DACF5",
908 "/ c #59C1ED",
909 "( c #5FC0ED",
910 "_ c #85CEE9",
911 ": c #096BFF",
912 "< c #2AACF6",
913 "[ c #5CBEEC",
914 "} c #7ACAE4",
915 "| c #73CAEB",
916 "1 c #71C8E5",
917 "2 c #D1DDDA",
918 "3 c #CBDDD9",
919 "4 c #67C1EB",
920 "5 c #80CDEA",
921 " ",
922 " ",
923 " +@@@@@@#$%&*= ",
924 " +-;>>>>>>>>>,')!~ ",
925 " {]@@-;>>>>>>>>>>>>^/(_= ",
926 " {:>>>>>>>>>>>>>>>>><//[)!= ",
927 " ]>>>>>>>>>>>>>>>>>><////[)} ",
928 " @>>>>>>>>>>>>>>>>>><//////| ",
929 " @>>>>>>>>>>>>>>>>>><//////| ",
930 " @>>>>>>>>>>>>>>>>>><//////| ",
931 " @>>>>>>>>>>>>>>>>>><//////| ",
932 " @>>>>>>>>>>>>>>>>>><//////| ",
933 " @>>>>>>>>>>>>>>>>>><//////| ",
934 " @>>>>>>>>>>>>>>>>>><//////| ",
935 " @>>>>>>>>>>>>>>>>>><//////| ",
936 " @>>>>>>>>>>>>>>>>>><//////| ",
937 " @>>>>>>>>>>>>>>>>>><//////| ",
938 " @>>>>>>>>>>>>>>>>>><//////| ",
939 " @>>>>>>>>>>>>>>>>>><//////| ",
940 " @>>>>>>>>>>>>>>>>>><//////| ",
941 " @>>>>>>>>>>>>>>>>>><//////| ",
942 " @>>>>>>>>>>>>>>>>>></////[1 ",
943 " @>>>>>>>>>>>>>>>>>><////[*2 ",
944 " {:>>>>>>>>>>>>>>>>><//[)12 ",
945 " +@@@@@-;>>>>>>>>>><[)13 ",
946 " {]@@@-;>>>,'*3 ",
947 " +@@#452 ",
948 " ",
949 " ",
950 " ",
951 " ",
952 " "}
953 ;
954 fSolidIcon = new QPixmap(solid);
955
956 const char * const hidden_line_removal[]={
957 "32 32 15 1",
958 " c None",
959 "+ c #D5D5D5",
960 "@ c #C7C7C7",
961 "# c #9C9C9C",
962 "$ c #000000",
963 "% c #8E8E8E",
964 "& c #808080",
965 "* c #A9A9A9",
966 "= c #D8D8D8",
967 "- c #CACACA",
968 "; c #181818",
969 "> c #9F9F9F",
970 ", c #ACACAC",
971 "' c #B9B9B9",
972 ") c #555555",
973 " ",
974 " +@@+ ",
975 " +@@@@@@#$$$$%+ ",
976 " +#$$$$$$$$#@&$$$* ",
977 " =-@@#$$#@@@@@-= @$&#;>= ",
978 " =$$$$$#+ -$@ *$$%+ ",
979 " -$&@-= -$- #$$$= ",
980 " -$@ -$- +&$- ",
981 " @$@ @$@ @$@ ",
982 " @$@ @$@ @$@ ",
983 " @$@ @$@ @$@ ",
984 " @$@ @$@ @$@ ",
985 " @$@ @$@ @$@ ",
986 " @$@ @$@ @$@ ",
987 " @$@ @$@ @$@ ",
988 " @$@ @$@ @$@ ",
989 " @$@ @$@ @$@ ",
990 " @$@ @$@ @$@ ",
991 " @$@ @$@ @$@ ",
992 " @$@ @$@ @$@ ",
993 " @$@ @$@ @$@ ",
994 " @$@ @$@ #$= ",
995 " -$&@@@-= -$- =>;, ",
996 " =$$$$$$$#@@@-= -$'+#$$, ",
997 " =-@@@@#$$$$$$#@-+'$)$$#+ ",
998 " =-@@@#$$$$)$$#+ ",
999 " +@@#$$# ",
1000 " ++ ",
1001 " ",
1002 " ",
1003 " ",
1004 " "}
1005 ;
1006 fHiddenLineRemovalIcon = new QPixmap(hidden_line_removal);
1007
1008 const char * const hidden_line_and_surface_removal[]={
1009 "32 32 40 1",
1010 " c None",
1011 "+ c #FFFFFF",
1012 "@ c #89A2E9",
1013 "# c #5378E3",
1014 "$ c #A2B5ED",
1015 "% c #5379E3",
1016 "& c #5076E3",
1017 "* c #3E69E4",
1018 "= c #0C43F8",
1019 "- c #043FFE",
1020 "; c #CDD9ED",
1021 "> c #BDCDE9",
1022 ", c #FBFCFC",
1023 "' c #406AE4",
1024 ") c #0439FE",
1025 "! c #0137FF",
1026 "~ c #4F75E3",
1027 "{ c #9EB5E3",
1028 "] c #829FE0",
1029 "^ c #B6C6E7",
1030 "/ c #9DB4E3",
1031 "( c #7E9CE0",
1032 "_ c #B2C3E9",
1033 ": c #7E9AE0",
1034 "< c #86A2E1",
1035 "[ c #CAD6ED",
1036 "} c #5177E3",
1037 "| c #829CE0",
1038 "1 c #BCCCE9",
1039 "2 c #3A67E6",
1040 "3 c #0A43FA",
1041 "4 c #95ACE1",
1042 "5 c #BBCBE9",
1043 "6 c #A9BBE5",
1044 "7 c #96AFE1",
1045 "8 c #BDCBE9",
1046 "9 c #4067E4",
1047 "0 c #6485E5",
1048 "a c #E3EAF3",
1049 "b c #CAD6F3",
1050 " ",
1051 " ",
1052 " ++++ ",
1053 " ++++++++@#$+++ ",
1054 " ++@%####&*=-#+;>, ",
1055 " +++++@'=)))))))!)~+{]^++ ",
1056 " +$%&*=)!!!!!!!!!)~+/(]_+++ ",
1057 " +#-))!!!!!!!!!!!)~+/(::<[+ ",
1058 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1059 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1060 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1061 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1062 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1063 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1064 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1065 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1066 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1067 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1068 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1069 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1070 " +#)!!!!!!!!!!!!!!}+/::::{+ ",
1071 " +#)!!!!!!!!!!!!!!}+/:::|1+ ",
1072 " +$#}}~23!!!!!!!!)~+/(]45, ",
1073 " +++++++@#}}~23!!)~+678++ ",
1074 " ++++++@#~90+a++ ",
1075 " ++++b++ ",
1076 " ++ ",
1077 " ",
1078 " ",
1079 " ",
1080 " ",
1081 " "}
1082 ;
1083 fHiddenLineAndSurfaceRemovalIcon = new QPixmap(hidden_line_and_surface_removal);
1084
1085 const char * const perspective[]={
1086 "32 32 3 1",
1087 " c None",
1088 ". c #D5D8D5",
1089 "+ c #000000",
1090 " ",
1091 " ",
1092 " ",
1093 " ",
1094 " ",
1095 " ................ ",
1096 " ....+++++++++++++++. ",
1097 " ...++++..+.........+++. ",
1098 " ..++..............++..+. ",
1099 " .+++++++++++++++++.. .+. ",
1100 " .+...............+. .+. ",
1101 " .+. .+. .+. .+. ",
1102 " .+. .+. .+. .+. ",
1103 " .+. .+. .+. .+. ",
1104 " .+. .+. .+. .+. ",
1105 " .+. .+. .+. .+. ",
1106 " .+. .+. .+. .+. ",
1107 " .+. .+. .+. .+. ",
1108 " .+. .+. .+. .+. ",
1109 " .+. .+......+....+. ",
1110 " .+. ..++++++.+.++++. ",
1111 " .+. .++.......+...+.. ",
1112 " .+. .++. .+..++. ",
1113 " .+. ..+.. .+..+. ",
1114 " .+..++. .+.+. ",
1115 " .+.++. .+++. ",
1116 " .+++.............++. ",
1117 " .+++++++++++++++++. ",
1118 " ................... ",
1119 " ",
1120 " ",
1121 " "}
1122 ;
1123 fPerspectiveIcon = new QPixmap(perspective);
1124
1125 const char * const ortho[]={
1126 "32 32 3 1",
1127 " c None",
1128 ". c #D5D8D5",
1129 "@ c #000000",
1130 " ",
1131 " ",
1132 " ",
1133 " ................... ",
1134 " ..@@@@@@@@@@@@@@@@@. ",
1135 " ..@@@.............@@@. ",
1136 " ..@@.@. ..@..@. ",
1137 " ..@@ ..@. .@@...@. ",
1138 " ..@@..............@@.. .@. ",
1139 " .@@@@@@@@@@@@@@@@@.. .@. ",
1140 " .@...............@. .@. ",
1141 " .@. .@. .@. .@. ",
1142 " .@. .@. .@. .@. ",
1143 " .@. .@. .@. .@. ",
1144 " .@. .@. .@. .@. ",
1145 " .@. .@. .@. .@. ",
1146 " .@. .@. .@. .@. ",
1147 " .@. .@. .@. .@. ",
1148 " .@. .@. .@. .@. ",
1149 " .@. .@. .@. .@. ",
1150 " .@. .@. .@. .@. ",
1151 " .@. .@........@......@. ",
1152 " .@. .@@@@@@@@@.@.@@@@@@. ",
1153 " .@. .@@+........@....@@.. ",
1154 " .@...@. .@...@... ",
1155 " .@.@@. .@.@@ . ",
1156 " .@@@.............@@@.. ",
1157 " .@@@@@@@@@@@@@@@@@... ",
1158 " ................... ",
1159 " ",
1160 " ",
1161 " "}
1162 ;
1163 fOrthoIcon = new QPixmap(ortho);
1164
1165 const char * const commandIcon[]={
1166 "20 20 25 1 ",
1167 " c #4ED17F",
1168 ". c #4FD280",
1169 "X c #50D381",
1170 "o c #5BD181",
1171 "O c #5DD382",
1172 "+ c #59D48A",
1173 "@ c #66D68C",
1174 "# c #6FD895",
1175 "$ c #85DEA4",
1176 "% c #8CE0AC",
1177 "& c #96E4B8",
1178 "* c #9EE3B8",
1179 "= c #A8E5BB",
1180 "- c #A7E8C4",
1181 "; c #B2EAC8",
1182 ": c #B9ECD1",
1183 "> c #C2EDD3",
1184 ", c #CBF1DF",
1185 "< c #D4F3E3",
1186 "1 c #DDF4E5",
1187 "2 c #DBF5EC",
1188 "3 c #E5F7F0",
1189 "4 c #EDFAFB",
1190 "5 c #F6FBFE",
1191 "6 c #FEFFFC",
1192 /* pixels */
1193 "66666666666666666666",
1194 "66%++++++++++++++&56",
1195 "6$ o..o......o..o *6",
1196 "6+o...o*<441;@.o..+6",
1197 "6+..o@1553<354$..o+6",
1198 "6+..o<5<@ .*54#o.+6",
1199 "6+o.*52X :5-..@6",
1200 "6+..15% o$+o.+6",
1201 "6+.+55@ .o.+6",
1202 "6O.#54 .X.+6",
1203 "6O #54 .X.+6",
1204 "6O.+55@ .o.+6",
1205 "6+..25% @,*o.@6",
1206 "6+o.*52X :5>.o+6",
1207 "6+..O25<@ X=54#o.+6",
1208 "6+.o.@1553<354$...@6",
1209 "6+o..oo*<44<;@o..o+6",
1210 "6$ .o..o.....o..o *6",
1211 "66%+++++OOOO+++++*66",
1212 "66666666666666666666"
1213 };
1214 fCommandIcon = new QPixmap(commandIcon);
1215
1216 const char * const dirIcon[]={
1217 "20 20 25 1 ",
1218 " c #DF5959",
1219 ". c #DD5F5F",
1220 "X c #DE7370",
1221 "o c #E06360",
1222 "O c #E06467",
1223 "+ c #E06C6C",
1224 "@ c #E57979",
1225 "# c #E08886",
1226 "$ c #E18D91",
1227 "% c #E19D9B",
1228 "& c #E99B9D",
1229 "* c #E8A2A2",
1230 "= c #EEB2B0",
1231 "- c #EDBBBC",
1232 "; c #EDCBC7",
1233 ": c #E9CDD1",
1234 "> c #F1D5D6",
1235 ", c #F9DFE2",
1236 "< c #EFE8E7",
1237 "1 c #F3E3E4",
1238 "2 c #F8EEEC",
1239 "3 c #FCF6F4",
1240 "4 c #F6F3F9",
1241 "5 c #F2F8FC",
1242 "6 c #FEFFFD",
1243 /* pixels */
1244 "66666666666666666666",
1245 "66$oOOOOOOOOOOOOo%66",
1246 "6# %6",
1247 "6o +,666663:+ o6",
1248 "6o =635533666$ o6",
1249 "6o -65:+ +165X o6",
1250 "6o >6<. 36; O6",
1251 "6o 26- &6>. o6",
1252 "6. o56* @63. o6",
1253 "6. X56& o66. o6",
1254 "6. X56& +63. o6",
1255 "6. o56* @62. o6",
1256 "6o 26- =61 O6",
1257 "6o >6<. o36: o6",
1258 "6o -65:+ @265X o6",
1259 "6o =635543665# O6",
1260 "6o +1666662;+ o6",
1261 "6# %6",
1262 "66$OOOoo....OOOOo%66",
1263 "66666666666666666666"}
1264 ;
1265 fDirIcon = new QPixmap(dirIcon);
1266
1267
1268 const char * const runIcon[]={
1269 /* columns rows colors chars-per-pixel */
1270 "20 20 33 1 ",
1271 " c #5CA323",
1272 ". c #5EA03F",
1273 "X c #6DB620",
1274 "o c #66AD3F",
1275 "O c #70B73C",
1276 "+ c #7CC13F",
1277 "@ c #569B41",
1278 "# c #61A14E",
1279 "$ c #70A95D",
1280 "% c #7EB55C",
1281 "& c #85B94E",
1282 "* c #90BE49",
1283 "= c #81B669",
1284 "- c #81B370",
1285 "; c #95CA46",
1286 ": c #A1CD40",
1287 "> c #AED045",
1288 ", c #B3D558",
1289 "< c #9BC87E",
1290 "1 c #AED668",
1291 "2 c #A2D075",
1292 "3 c #C2DC73",
1293 "4 c #A5C98F",
1294 "5 c #C1DC9F",
1295 "6 c #CAE18E",
1296 "7 c #CCE39A",
1297 "8 c #C4DCB6",
1298 "9 c #E3ECBA",
1299 "0 c #EEF3D3",
1300 "q c #F0F7DE",
1301 "w c #F8FAE9",
1302 "e c #FCFFFB",
1303 "r c None",
1304 /* pixels */
1305 "rrrrrrrr%<<2rrrrrrrr",
1306 "rrrrr5=$$$$===rrrrrr",
1307 "rrrr<##$$$$$---&rrrr",
1308 "rrr=###$$$$-----%rrr",
1309 "rr=####$$$$------&rr",
1310 "r2@####7##$-------rr",
1311 "r.@####048$-------Or",
1312 "r.@####[email protected]",
1313 " .@@###w4eee5%$#@@@X",
1314 " .@@@..w4eeeeqo..@@X",
1315 " [email protected]<eeee7Oooo@X",
1316 " ..oooOe2eee6OOOooo ",
1317 "rOooOO+e2ew2+++++O+r",
1318 "r:oO+++e30,;;;;;++Or",
1319 "r :++;:9,>,,>>:;;1rr",
1320 "rr*1;:>,333333,>32rr",
1321 "rrr66,1367777637<rrr",
1322 "rrrr509799999905rrrr",
1323 "rrrrr=8wqwwww8-rrrrr",
1324 "rrrrrrrr4444rrrrrrrr"
1325 };
1326 fRunIcon = new QPixmap(runIcon);
1327
1328 const char * const paramIcon[]={
1329 /* columns rows colors chars-per-pixel */
1330 "20 20 35 1 ",
1331 " c #2E2525",
1332 ". c #403737",
1333 "X c #423A3A",
1334 "o c #443C3C",
1335 "O c #473F3F",
1336 "+ c #4C4444",
1337 "@ c #4F4848",
1338 "# c #514949",
1339 "$ c #544D4D",
1340 "% c #595252",
1341 "& c #625B5B",
1342 "* c #696262",
1343 "= c #6D6666",
1344 "- c #716B6B",
1345 "; c #726C6C",
1346 ": c #767171",
1347 "> c #7E7878",
1348 ", c #8B8787",
1349 "< c #8C8787",
1350 "1 c #8D8888",
1351 "2 c #918D8D",
1352 "3 c #928E8E",
1353 "4 c #948F8F",
1354 "5 c #9C9898",
1355 "6 c #9D9999",
1356 "7 c #D5D4D4",
1357 "8 c #D8D6D6",
1358 "9 c #DDDBDB",
1359 "0 c #EFEFEF",
1360 "q c #F6F6F6",
1361 "w c None",
1362 "e c None",
1363 "r c None",
1364 "t c gray99",
1365 "y c None",
1366 /* pixels */
1367 "wwwwwwww5 5wwwwwwww",
1368 "wwwwwwww, ,wwwwwwww",
1369 "www&;ww7+ +9ww=-www",
1370 "ww& O# OX *ww",
1371 "ww; >ww",
1372 "wwwO .%%X +www",
1373 "www# 3wwww3 Owww",
1374 "ww7 3wwwwww3 7ww",
1375 "5<+ .wwwwwww0. +<5",
1376 " %wwwwwwww$ ",
1377 " %wwwwwwww$ ",
1378 "5<+ .wwwwwww0X +<5",
1379 "ww9 4wwwwww1 9ww",
1380 "wwwO 30ww03 Owww",
1381 "wwwX X#$X @www",
1382 "ww= =ww",
1383 "ww- +O ++ :ww",
1384 "www*>ww7+ +7ww=:www",
1385 "wwwwwwww1 1wwwwwwww",
1386 "wwwwwwww5 5wwwwwwww"
1387 };
1388 fParamIcon = new QPixmap(paramIcon);
1389
1390 const char * const exitIcon[]={
1391 /* columns rows colors chars-per-pixel */
1392 "23 28 55 1 ",
1393 " c None",
1394 ". c #350505",
1395 "X c #3A0505",
1396 "o c #3C0605",
1397 "O c #3D0605",
1398 "+ c #430606",
1399 "@ c #440606",
1400 "# c #470706",
1401 "$ c #500707",
1402 "% c #510807",
1403 "& c #520807",
1404 "* c #530807",
1405 "= c #550808",
1406 "- c #570808",
1407 "; c #5C0908",
1408 ": c #5D0908",
1409 "> c #5F0908",
1410 ", c #630A08",
1411 "< c #640A09",
1412 "1 c #6B0A09",
1413 "2 c #6C0A09",
1414 "3 c #720B0A",
1415 "4 c #760B0A",
1416 "5 c #770B0A",
1417 "6 c #7A0B0B",
1418 "7 c #7D0C0B",
1419 "8 c #7F0C0B",
1420 "9 c #840D0B",
1421 "0 c #850D0C",
1422 "q c #880D0C",
1423 "w c #8D0E0C",
1424 "e c #900E0C",
1425 "r c #940E0D",
1426 "t c #950E0D",
1427 "y c #9C0F0E",
1428 "u c #9E100E",
1429 "i c #AA100E",
1430 "p c #AC100F",
1431 "a c #AD100F",
1432 "s c #AE110F",
1433 "d c #B31110",
1434 "f c #B51210",
1435 "g c #B61210",
1436 "h c #B71210",
1437 "j c #B91210",
1438 "k c #C01311",
1439 "l c #C21311",
1440 "z c #C81311",
1441 "x c #C91312",
1442 "c c #CC1412",
1443 "v c #CE1412",
1444 "b c #D01412",
1445 "n c #D11412",
1446 "m c #D31412",
1447 "M c #D51513",
1448 /* pixels */
1449 " ",
1450 " O= ",
1451 " :MMh ",
1452 " hMMM ",
1453 " jMMM ",
1454 " <x1 jMMM %xw ",
1455 " rMMM jMMM MMMk ",
1456 " rMMMM# jMMM MMMMx ",
1457 " OMMMMk jMMM 8MMMM9 ",
1458 " xMMMM jMMM pMMMM ",
1459 " MMMM jMMM xMMM8 ",
1460 "rMMM3 jMMM MMMM ",
1461 "MMMM hMMM MMMM ",
1462 "MMMM :MMh hMMM ",
1463 "MMMM O% 8MMM ",
1464 "MMMM pMMM ",
1465 "MMMM MMMM ",
1466 "wMMM3 MMMM ",
1467 ".MMMM xMMM9 ",
1468 " hMMMk wMMMM ",
1469 " MMMMMO hMMMM= ",
1470 " <MMMMMp: $rMMMMMp ",
1471 " yMMMMMMMMMMMMMMk ",
1472 " #MMMMMMMMMMMM3 ",
1473 " uMMMMMMMMk ",
1474 " #1wr3% ",
1475 " ",
1476 " "
1477 };
1478 fExitIcon= new QPixmap(exitIcon);
1479}
1480
1481
1482/** Create the History ToolBox Widget
1483 */
1484QWidget* G4UIQt::CreateHistoryTBWidget(
1485)
1486{
1487 fHistoryTBWidget = new QWidget();
1488
1489 QVBoxLayout *layoutHistoryTB = new QVBoxLayout();
1490 fHistoryTBTableList = new QListWidget();
1491 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
1492 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
1493
1494 layoutHistoryTB->addWidget(fHistoryTBTableList);
1495
1496 fHistoryTBWidget->setLayout(layoutHistoryTB);
1497 return fHistoryTBWidget;
1498}
1499
1500
1501/** Create the Help ToolBox Widget
1502 */
1503QWidget* G4UIQt::CreateHelpTBWidget(
1504)
1505{
1506 fHelpTBWidget = new QWidget();
1507
1508 QWidget *helpWidget = new QWidget();
1509 QHBoxLayout *helpLayout = new QHBoxLayout();
1510 QVBoxLayout *vLayout = new QVBoxLayout();
1511 fHelpVSplitter = new QSplitter(Qt::Vertical);
1512 fHelpLine = new QLineEdit();
1513 helpLayout->addWidget(new QLabel("Search :"));
1514 helpLayout->addWidget(fHelpLine);
1515 connect( fHelpLine, SIGNAL( editingFinished () ), this, SLOT( LookForHelpStringCallback() ) );
1516
1517 // Create Help tree
1518 FillHelpTree();
1519
1520 fParameterHelpLabel = new QTextEdit();
1521 fParameterHelpLabel->setReadOnly(true);
1522 fParameterHelpTable = new QTableWidget();
1523
1524 // Set layouts
1525
1526 if (fHelpTreeWidget) {
1527 fHelpVSplitter->addWidget(fHelpTreeWidget);
1528 }
1529 fHelpVSplitter->addWidget(fParameterHelpLabel);
1530 fHelpVSplitter->addWidget(fParameterHelpTable);
1531
1532 fParameterHelpLabel->setVisible(false);
1533 fParameterHelpTable->setVisible(false);
1534 QSizePolicy policy = QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
1535 policy.setVerticalStretch(4);
1536 if (fHelpTreeWidget) {
1537 fHelpTreeWidget->setSizePolicy(policy);
1538 }
1539 policy = QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
1540 policy.setVerticalStretch(1);
1541 fParameterHelpLabel->setSizePolicy(policy);
1542 fParameterHelpTable->setSizePolicy(policy);
1543
1544 vLayout->addWidget(helpWidget);
1545 vLayout->addWidget(fHelpVSplitter,1);
1546 vLayout->setContentsMargins(5,5,5,5);
1547
1548 helpWidget->setLayout(helpLayout);
1549 fHelpTBWidget->setLayout(vLayout);
1550
1551 return fHelpTBWidget;
1552}
1553
1554
1555/** Create the Cout ToolBox Widget
1556 */
1557G4UIDockWidget* G4UIQt::CreateCoutTBWidget(
1558)
1559{
1560 QWidget* coutTBWidget = new QWidget();
1561
1562 QVBoxLayout *layoutCoutTB = new QVBoxLayout();
1563
1564 fCoutTBTextArea = new QTextEdit();
1565
1566 fCoutFilter = new QLineEdit();
1567 fCoutFilter->setToolTip("Filter output by...");
1568
1569#if QT_VERSION > 0x050100
1570 fCoutFilter->addAction(*fSearchIcon,QLineEdit::TrailingPosition);
1571 fCoutFilter->setStyleSheet ("border-radius:7px;");
1572#else
1573 QPushButton *coutTBFilterButton = new QPushButton();
1574 coutTBFilterButton->setIcon(QIcon(*fSearchIcon));
1575 coutTBFilterButton->setStyleSheet ("padding-left: 0px; border:0px;");
1576 fCoutFilter->setStyleSheet ("padding-right: 0px;");
1577#endif
1578
1579 QPushButton *coutTBClearButton = new QPushButton();
1580 coutTBClearButton->setIcon(*fClearIcon);
1581 coutTBClearButton->setToolTip("Clear console output");
1582 coutTBClearButton->setStyleSheet ("border-radius:7px;");
1583 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
1584 connect(fCoutFilter, SIGNAL(textEdited ( const QString &)), SLOT(CoutFilterCallback( const QString &)));
1585
1586 QPushButton *coutTBSaveOutputButton = new QPushButton();
1587 coutTBSaveOutputButton->setIcon(*fSaveIcon);
1588 coutTBSaveOutputButton->setToolTip("Save console output");
1589 coutTBSaveOutputButton->setStyleSheet ("border-radius:7px;");
1590 connect(coutTBSaveOutputButton, SIGNAL(clicked()), SLOT(SaveOutputCallback()));
1591
1592 fCoutTBTextArea->setReadOnly(true);
1593
1594 QWidget* coutButtonWidget = new QWidget();
1595 QHBoxLayout* layoutCoutTBButtons = new QHBoxLayout();
1596
1597#ifdef G4MULTITHREADED
1598 // add all candidates to widget
1599 fThreadsFilterComboBox = new QComboBox();
1600 fThreadsFilterComboBox->setInsertPolicy(QComboBox::InsertAlphabetically);
1601 connect(fThreadsFilterComboBox, SIGNAL(activated(G4int)), this, SLOT(ThreadComboBoxCallback(G4int)));
1602
1603 UpdateCoutThreadFilter();
1604
1605 fThreadsFilterComboBox->setToolTip("Thread selection in output");
1606 layoutCoutTBButtons->addWidget(new QLabel(" Threads:"));
1607 layoutCoutTBButtons->addWidget(fThreadsFilterComboBox);
1608#endif
1609
1610 layoutCoutTBButtons->addWidget(fCoutFilter);
1611#if QT_VERSION <= 0x050100
1612 layoutCoutTBButtons->addWidget(coutTBFilterButton);
1613#endif
1614 layoutCoutTBButtons->addWidget(coutTBClearButton);
1615 layoutCoutTBButtons->addWidget(coutTBSaveOutputButton);
1616 coutButtonWidget->setLayout(layoutCoutTBButtons);
1617
1618 // reduce margins
1619 layoutCoutTBButtons->setContentsMargins(3,3,3,0);
1620
1621 layoutCoutTB->addWidget(coutButtonWidget);
1622 layoutCoutTB->addWidget(fCoutTBTextArea);
1623
1624 coutTBWidget->setLayout(layoutCoutTB);
1625
1626 fCoutTBTextArea->setMinimumSize(100,100);
1627
1628 // Command line :
1629 QWidget* commandLineWidget = new QWidget();
1630 QHBoxLayout *layoutCommandLine = new QHBoxLayout();
1631
1632 // fill them
1633
1634 fCommandLabel = new QLabel("");
1635 fCommandArea = new QLineEdit();
1636
1637 // The QCompleter will be append at SessionStart()
1638
1639 fCommandArea->activateWindow();
1640
1641 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
1642 fCommandArea->setFocus(Qt::TabFocusReason);
1643 fCommandArea->setToolTip("Apply command");
1644
1645
1646 layoutCommandLine->addWidget(fCommandLabel);
1647 layoutCommandLine->addWidget(fCommandArea);
1648
1649 // Connect signal
1650 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
1651 connect(fCommandArea, SIGNAL(textEdited(const QString &)), SLOT(CommandEditedCallback(const QString &)));
1652
1653
1654 commandLineWidget->setLayout(layoutCommandLine);
1655 commandLineWidget->setMinimumSize(50,50);
1656
1657 layoutCoutTB->addWidget(commandLineWidget);
1658
1659 fCoutDockWidget = new G4UIDockWidget ("Output");
1660 fCoutDockWidget->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1661
1662 fCoutDockWidget->setWidget(coutTBWidget);
1663 return fCoutDockWidget;
1664}
1665
1666
1667/** Create the VisParameters ToolBox Widget
1668 */
1669QWidget* G4UIQt::CreateVisParametersTBWidget(
1670)
1671{
1672 return NULL;
1673}
1674
1675
1676/** Create the VisParameters ToolBox Widget
1677 */
1678G4UIDockWidget* G4UIQt::CreateUITabWidget(
1679)
1680{
1681 fUITabWidget = new QTabWidget();
1682
1683 // the left dock
1684 fUITabWidget->addTab(CreateSceneTreeWidget(),"Scene tree");
1685 fUITabWidget->addTab(CreateHelpTBWidget(),"Help");
1686 fUITabWidget->addTab(CreateHistoryTBWidget(),"History");
1687 fUITabWidget->setCurrentWidget(fHelpTBWidget);
1688
1689 fUITabWidget->setTabToolTip (0,"Scene component tree. Only available in Stored mode");
1690 fUITabWidget->setTabToolTip (1,"Help widget");
1691 fUITabWidget->setTabToolTip (2,"All commands history");
1692 connect(fUITabWidget, SIGNAL(currentChanged(G4int)), SLOT(ToolBoxActivated(G4int)));
1693
1694 fUIDockWidget = new G4UIDockWidget ("Scene tree, Help, History");
1695 fUIDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1696
1697 fUIDockWidget->setWidget(fUITabWidget);
1698
1699 return fUIDockWidget;
1700}
1701
1702
1703QWidget* G4UIQt::CreateSceneTreeWidget(){
1704
1705 fSceneTreeWidget = new QWidget();
1706 QVBoxLayout* layout = new QVBoxLayout();
1707 fSceneTreeWidget->setLayout(layout);
1708
1709#if QT_VERSION < 0x040200
1710 fSceneTreeWidget->hide();
1711#else
1712 fSceneTreeWidget->setVisible(false);
1713#endif
1714
1715 return fSceneTreeWidget;
1716}
1717
1718
1719void G4UIQt::CreateViewerWidget(){
1720
1721 // Set layouts
1722
1723 SetStartPage(std::string("<table width='100%'><tr><td width='30%'></td><td><div ")+
1724 "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; padding-bottom: 0px; font-weight: normal'>Geant4: "+
1725 QApplication::applicationName ().toStdString()+
1726 "</div></td><td width='40%'>&nbsp;<br/><i>http://cern.ch/geant4/</i></td></tr></table>"+
1727 "<p>&nbsp;</p>"+
1728 "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
1729 "<li><b>Start a new viewer :</b><br />"+
1730 "<i>'/vis/open/...'<br />"+
1731 "For example '/vis/open OGL'</i></li>"+
1732 "<li><b>Execute a macro file :</b><br />"+
1733 "<i>'/control/execute my_macro_file'</i></li>"+
1734 "</ul></div>"+
1735
1736 "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
1737 "<li><b>Visualisation publication :</b><br />"+
1738 "<i><a href='http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011'>The Geant4 Visualization System - A Multi-Driver Graphics System</b><br />, Allison, J. et al., International Journal of Modeling, Simulation, and Scientific Computing, Vol. 4, Suppl. 1 (2013) 1340001</a>:<br/> http://www.worldscientific.com/doi/abs/10.1142/S1793962313400011</i></li>"+
1739 "</ul></div>"+
1740
1741 "<div style='background:#EEEEEE;'><b>Getting Help :</b><ul>"+
1742 "<li><b>If problems arise, try <a href='https://cern.ch/geant4-forum'>browsing the user forum</a> to see whether or not your problem has already been encountered.<br /> If it hasn't, you can post it and Geant4 developers will do their best to find a solution. This is also a good place to<br /> discuss Geant4 topics in general.</b> https://cern.ch/geant4-forum"+
1743 "<li><b>Get a look at <a href='http://cern.ch/geant4/support'>Geant4 User support pages</a>: <i>http://cern.ch/geant4/support</i></b></li>"+
1744 "</ul></div>"
1745 );
1746
1747
1748 // fill right splitter
1749 if (fViewerTabWidget == NULL) {
1750 fViewerTabWidget = new G4QTabWidget();
1751 fMainWindow->setCentralWidget(fViewerTabWidget);
1752#if QT_VERSION < 0x040500
1753#else
1754 fViewerTabWidget->setTabsClosable (true);
1755#endif
1756
1757#if QT_VERSION < 0x040200
1758#else
1759 fViewerTabWidget->setUsesScrollButtons (true);
1760#endif
1761
1762#if QT_VERSION < 0x040500
1763#else
1764 connect(fViewerTabWidget, SIGNAL(tabCloseRequested(G4int)), this, SLOT(TabCloseCallback(int)));
1765#endif
1766 connect(fViewerTabWidget, SIGNAL(currentChanged(G4int)), SLOT(UpdateTabWidget(G4int)));
1767 }
1768
1769// set the QGLWidget size policy
1770 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
1771 policy.setVerticalStretch(4);
1772 fViewerTabWidget->setSizePolicy(policy);
1773
1774 fViewerTabWidget->setMinimumSize(40,40);
1775}
1776
1777
1778/** Get the ViewerComponents ToolBox Widget
1779 */
1781)
1782{
1783 return fSceneTreeWidget;
1784}
1785
1786/** Get the Viewer properties Widget
1787 */
1789)
1790{
1791 if (!fViewerPropertiesDialog) {
1792 CreateViewerPropertiesDialog();
1793 }
1794 return fViewerPropertiesWidget;
1795}
1796
1797/** Get the Pick Widget
1798 */
1800)
1801{
1802 if (!fPickInfosDialog) {
1803 CreatePickInfosDialog();
1804 }
1805 return fPickInfosWidget;
1806}
1807
1808
1809/** Add a new tab in the viewer
1810 */
1812 QWidget* aWidget
1813 ,std::string title
1814 )
1815{
1816 if (fViewerTabWidget == NULL) {
1817 return false;
1818 }
1819 fViewerTabWidget->addTab(aWidget,title.c_str());
1820
1821 return true;
1822}
1823
1824
1825/** Add a new tab in the viewer
1826 */
1828 std::string fileName
1829 ,std::string title
1830 )
1831{
1832 if (fViewerTabWidget == NULL) {
1833 return false;
1834 }
1835
1837 if(UI==NULL) return 0;
1838 std::ifstream file(UI->FindMacroPath(fileName.c_str()).data());
1839 if (file) {
1840
1841 std::string content( (std::istreambuf_iterator<char>(file) ),
1842 (std::istreambuf_iterator<char>() ) );
1843
1844 QTextEdit* text = new QTextEdit();
1845 text->setAcceptRichText (true);
1846 text->setContentsMargins(5,5,5,5);
1847 text->setText(QString("<pre>")+content.c_str()+"</pre>");
1848 text->setReadOnly(true);
1849 fViewerTabWidget->addTab(text,title.c_str());
1850 } else {
1851 return false;
1852 }
1853 return true;
1854}
1855
1856
1857/** Add a new tab widget.
1858 Create the tab if it was not done
1859*/
1861 QWidget* aWidget
1862,QString name
1863)
1864{
1865 // Special case for Qt version between 5.0 and 5.1 on Mac OSX
1866 // Due to a bug in this Qt version, we can't put a OpenGL Widget inside the QTabWidget.
1867 // A work around is to put it outside. Returning false will fore the wiewer to put the QGLWidget
1868 // inside a new QWindow.
1869
1870#ifdef Q_OS_MAC
1871 #if QT_VERSION < 0x050100
1872 #if QT_VERSION >= 0x050000
1873 QString message = QString(
1874 "This Qt version [")+qVersion ()+"] has some issues with the OpenGL viewer.\n"+
1875 "To prevent problems, you are not allowed to open a Stored nor Immediate viewer.\n" +
1876 "\n" +
1877 "Please upgrade to Qt version >= 5.1\n";
1878
1879 QMessageBox::warning(fMainWindow, tr("Warning"),
1880 tr(message.toStdString().c_str()),
1881 QMessageBox::Ok);
1882 return false;
1883 #endif
1884 #endif
1885#endif
1886
1887 if (fViewerTabWidget == NULL) {
1888 CreateViewerWidget();
1889 }
1890
1891 if (!aWidget) {
1892 return false;
1893 }
1894// Has to be added before we put it into the fViewerTabWidget widget
1895 aWidget->setParent(fViewerTabWidget); // Will create in some cases widget outside
1896 // of UI for a really short moment
1897
1898 fViewerTabWidget->addTab(aWidget,name);
1899
1900 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
1901
1902 // Set visible
1903 #if QT_VERSION < 0x040200
1904 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1905 #else
1906 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
1907 #endif
1908
1909 // Not the good solution, but ensure that the help tree is correctly build when launching a viewer
1910 // It should be done by a notification when adding a command, but that's nit done yet (Geant4.10.1)␓
1911 FillHelpTree();
1912
1913 return true;
1914}
1915
1916
1918const std::string& text)
1919{
1920 if (text != "") {
1921 fDefaultViewerFirstPageHTMLText = text;
1922 }
1923 if (!fStartPage) {
1924 fStartPage = new QTextBrowser();
1925 fStartPage->setContentsMargins(5,5,5,5);
1926 fStartPage->setReadOnly(true);
1927 }
1928 fStartPage->setOpenExternalLinks(true);
1929 fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
1930}
1931
1932
1933void G4UIQt::UpdateTabWidget(G4int tabNumber) {
1934 if ( fViewerTabWidget == NULL) {
1935 fViewerTabWidget = new G4QTabWidget;
1936 }
1937
1938 fViewerTabWidget->setCurrentIndex(tabNumber);
1939
1940 // Send this signal to unblock graphic updates !
1941 fViewerTabWidget->setTabSelected(false);
1942
1943 #if QT_VERSION < 0x040200
1944 fViewerTabWidget->show();
1945 #else
1946 fViewerTabWidget->setVisible(true);
1947 #endif
1948
1949 // This will send a paintEvent to OGL Viewers
1950 fViewerTabWidget->setTabSelected(true);
1951}
1952
1953
1954/** Send resize event to all tabs
1955 */
1956void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
1957 if ( fViewerTabWidget) {
1958 for (G4int a=0;a<fViewerTabWidget->count() ;a++) {
1959 fViewerTabWidget->widget(a)->resize(e->size());
1960 }
1961 }
1962}
1963
1964
1965/** Start the Qt main loop
1966*/
1968)
1969{
1970 G4Qt* interactorManager = G4Qt::getInstance ();
1971 Prompt("Session :");
1972 exitSession = false;
1973
1974 QCoreApplication::sendPostedEvents () ;
1975
1976 #if QT_VERSION < 0x040200
1977 fMainWindow->show();
1978 #else
1979 fMainWindow->setVisible(true);
1980 #endif
1981
1982 if (fDefaultIcons) {
1983#if QT_VERSION < 0x040200
1984 fToolbarApp->show();
1985#else
1986 fToolbarApp->setVisible(true);
1987#endif
1988 } else {
1989 // Set not visible until session start
1990#if QT_VERSION < 0x040200
1991 fToolbarApp->hide();
1992#else
1993 fToolbarApp->setVisible(false);
1994#endif
1995 }
1996 // Rebuild help tree (new command could be registered)
1997 FillHelpTree();
1998
1999 // Rebuild command completion (new command could be registered)
2000 UpdateCommandCompleter();
2001
2002 // Set event filters
2003 fHistoryTBTableList->installEventFilter(this);
2004 fCommandArea->installEventFilter(this);
2005
2006 // Focus on command line
2007 fCommandArea->setFocus();
2008
2009 interactorManager->DisableSecondaryLoop (); // TO KEEP
2010 if ((QApplication*)interactorManager->GetMainInteractor())
2011 ((QApplication*)interactorManager->GetMainInteractor())->exec();
2012
2013 interactorManager->EnableSecondaryLoop ();
2014 return this;
2015}
2016
2017
2018/** Display the prompt in the prompt area
2019 @param aPrompt : string to display as the promt label
2020*/
2022 G4String aPrompt
2023)
2024{
2025 if (!aPrompt) return;
2026
2027 fCommandLabel->setText((char*)aPrompt.data());
2028}
2029
2030
2031
2033)
2034{
2035 G4Qt* interactorManager = G4Qt::getInstance ();
2036 fMainWindow->close();
2037 ((QApplication*)interactorManager->GetMainInteractor())->exit();
2038}
2039
2040
2041
2042/**
2043 Called by intercoms/src/G4UImanager.cc<br>
2044 Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
2045 It have to pause the session command terminal.<br>
2046 Call SecondaryLoop to wait for exit event<br>
2047 @param aState
2048 @see : G4VisCommandReviewKeptEvents::SetNewValue
2049*/
2051 const G4String& aState
2052)
2053{
2054 if (!aState) return;
2055
2056 if(aState=="G4_pause> ") { // TO KEEP
2057 SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
2058 } // TO KEEP
2059
2060 if(aState=="EndOfEvent") { // TO KEEP
2061 // Picking with feed back in event data Done here !!!
2062 SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
2063 } // TO KEEP
2064}
2065
2066
2067
2068/**
2069 Begin the secondary loop
2070 @param a_prompt : label to display as the prompt label
2071 */
2072void G4UIQt::SecondaryLoop (
2073 G4String aPrompt
2074)
2075{
2076 if (!aPrompt) return;
2077
2078 G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
2079 Prompt(aPrompt); // TO KEEP
2080 exitPause = false; // TO KEEP
2081 while(1) {
2082 ((QApplication*)interactorManager)->processEvents(QEventLoop::WaitForMoreEvents);
2083 if(exitPause==true) break; // TO KEEP
2084 } // TO KEEP
2085 Prompt("Session :"); // TO KEEP
2086}
2087
2088#ifdef G4MULTITHREADED
2089#include "G4Threading.hh"
2090#include "G4AutoLock.hh"
2091namespace {
2092 G4Mutex ReceiveG4coutMutex = G4MUTEX_INITIALIZER;
2093 G4Mutex ReceiveG4cerrMutex = G4MUTEX_INITIALIZER;
2094}
2095#endif
2096
2097/**
2098 Receive a cout from Geant4. We have to display it in the cout zone
2099 @param aString : label to add in the display area
2100 @return 0
2101*/
2103 const G4String& aString
2104 )
2105{
2106 if(aString.empty()) return 0;
2107
2108#ifdef G4MULTITHREADED
2109 G4AutoLock al(&ReceiveG4coutMutex);
2110#endif
2111
2112 // Try to be smart :
2113 // "*** This is just a warning message. ***"
2114 if (G4StrUtil::contains(aString, "*** This is just a warning message. ***")) {
2115 return ReceiveG4cerr(aString);
2116 }
2117
2118 // Workaround so that output is not lost after crash or G4Exception
2119 // It seems workers write to std::cout anyway, so limit this to the master
2120#ifdef G4MULTITHREADED
2122#endif
2123 std::cout << aString;
2124
2125 G4String aStringWithStyle;
2126 // aString has a \n on the end (maybe it comes from G4endl or from the
2127 // Enter key on the command line) - ignore it. That’s why
2128 // i < aString.length() - 1
2129 // But other \n need to be translated to an HTML newline.
2130 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2131 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2132 // on how many characters precede it. Probably needs an HTML table. For now
2133 // we replace \t with four spaces.
2134 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2135 if (aString[i] == '\n') {
2136 aStringWithStyle += "<br>";
2137 } else if (aString[i] == ' ') {
2138 aStringWithStyle += "&nbsp;";
2139 } else if (aString[i] == '\t') {
2140 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2141 } else if (aString[i] == '<') {
2142 aStringWithStyle += "&lt;";
2143 } else {
2144 aStringWithStyle += aString[i];
2145 }
2146 }
2147 if (fOutputStyles["cout"].fixed) {
2148 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2149 } else {
2150 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2151 }
2152
2153 // Add to string
2154 G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()),GetThreadPrefix());
2155 fG4OutputString.push_back(txt);
2156
2157#ifdef G4MULTITHREADED
2158 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2159#else
2160 QString result = FilterOutput(txt,"",fCoutFilter->text());
2161#endif
2162
2163 if (result.isEmpty()) {
2164 return 0;
2165 }
2166
2168 if (fOutputStyles["cout"].highlight) {
2169 if (!UI->IsLastCommandOutputTreated() ) {
2170 QPalette pal;
2171 result = QString("<span style='background:") + pal.link().color().name() + ";'>&nbsp;</span>"
2172 + "<span style='background:" + pal.highlight().color().name() +";'> " + result + "</span>";
2173 }
2174 }
2176
2177 fCoutTBTextArea->append(result);
2178 fCoutTBTextArea->ensureCursorVisible ();
2179
2180#ifdef G4MULTITHREADED
2181 UpdateCoutThreadFilter();
2182#endif
2183
2184 // reset error stack
2185 fLastErrMessage = aString;
2186 return 0;
2187}
2188
2189
2190/**
2191 Receive a cerr from Geant4. We have to display it in the cout zone
2192 @param aString : label to add in the display area
2193 @return 0
2194*/
2196 const G4String& aString
2197)
2198{
2199 if (aString.empty()) return 0;
2200
2201#ifdef G4MULTITHREADED
2202 G4AutoLock al(&ReceiveG4cerrMutex);
2203#endif
2204
2205 // Workaround so that output is not lost after crash or G4Exception
2206 // It seems workers write to std::cerr anyway, so limit this to the master
2207#ifdef G4MULTITHREADED
2209#endif
2210 std::cerr << aString;
2211
2212 G4String aStringWithStyle;
2213 // aString has a \n on the end (maybe it comes from G4endl or from the
2214 // Enter key on the command line) - ignore it. That’s why
2215 // i < aString.length() - 1
2216 // But other \n need to be translated to an HTML newline.
2217 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2218 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2219 // on how many characters precede it. Probably needs an HTML table. For now
2220 // we replace \t with four spaces.
2221 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2222 if (aString[i] == '\n') {
2223 aStringWithStyle += "<br>";
2224 } else if (aString[i] == ' ') {
2225 aStringWithStyle += "&nbsp;";
2226 } else if (aString[i] == '\t') {
2227 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2228 } else if (aString[i] == '<') {
2229 aStringWithStyle += "&lt;";
2230 } else {
2231 aStringWithStyle += aString[i];
2232 }
2233 }
2234 if (fOutputStyles["cerr"].fixed) {
2235 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2236 } else {
2237 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2238 }
2239
2240 // Add to string
2241
2242 G4UIOutputString txt = G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(),
2243 GetThreadPrefix(),
2244 "error");
2245 fG4OutputString.push_back(txt);
2246
2247#ifdef G4MULTITHREADED
2248 QString result = FilterOutput(txt,fThreadsFilterComboBox->currentText(),fCoutFilter->text());
2249#else
2250 QString result = FilterOutput(txt,"",fCoutFilter->text());
2251#endif
2252 if (result.isEmpty()) {
2253 return 0;
2254 }
2255
2256 // Suppress space, \n,\t,\r...
2257 if (QString(aString.data()).trimmed() != "") {
2258 if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
2259 (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit )) {
2260 // In case of Abort or Quit, the useful error message should be in the last error message !
2261 fLastErrMessage += "\n"+aString;
2262 QString criticalMessage = fLastErrMessage.data();
2263#if QT_VERSION < 0x050000
2264 criticalMessage = Qt::escape(criticalMessage);
2265#else
2266 criticalMessage = criticalMessage.toHtmlEscaped();
2267#endif
2268 QMessageBox::critical(fMainWindow, "Error",QString(fLastErrMessage));
2269 }
2270 }
2271 fCoutTBTextArea->append(QString("<font color=\"Red\">") +
2272 result + QString("</font>"));
2273 fCoutTBTextArea->ensureCursorVisible ();
2274
2275 if (QString(aString.data()).trimmed() != "") {
2276 fLastErrMessage += aString;
2277 }
2278#ifdef G4MULTITHREADED
2279 UpdateCoutThreadFilter();
2280#endif
2281 return 0;
2282}
2283
2284
2285G4String G4UIQt::GetThreadPrefix() {
2286 G4String threadPrefix = "";
2287#ifdef G4MULTITHREADED
2289 if(UI==NULL) return "";
2290 if (UI->GetThreadCout() != NULL) {
2291 threadPrefix = UI->GetThreadCout()->GetFullPrefixString().data();
2292 if (UI->GetThreadCout()->GetPrefixString() == G4String("G4VIS")) {
2293 return "G4VIS";
2294 }
2295 }
2296#endif
2297 return threadPrefix;
2298}
2299
2300
2301#ifdef G4MULTITHREADED
2302void G4UIQt::UpdateCoutThreadFilter() {
2304 if(UI==NULL) return;
2305
2306 // add "All" and "Master"
2307 if (fThreadsFilterComboBox->count() < 2) {
2308 if ( fThreadsFilterComboBox->findText("All", Qt::MatchExactly) == -1) {
2309 fThreadsFilterComboBox->addItem("All");
2310 }
2311 }
2312 if (fThreadsFilterComboBox->count() < 2) {
2313 if ( fThreadsFilterComboBox->findText("Master", Qt::MatchExactly) == -1) {
2314 fThreadsFilterComboBox->addItem("Master");
2315 }
2316 }
2317 // Add current Cout
2318 G4String prefix = GetThreadPrefix();
2319 if (prefix != "") {
2320 if ( fThreadsFilterComboBox->findText(prefix.data(), Qt::MatchExactly) == -1) {
2321 fThreadsFilterComboBox->addItem(prefix.data());
2322 }
2323 }
2324}
2325#endif
2326
2327
2328/**
2329 Add a new menu to the menu bar
2330 @param aName name of menu
2331 @param aLabel label to display
2332 */
2334 const char* aName
2335,const char* aLabel
2336)
2337{
2338 if (aName == NULL) return;
2339 if (aLabel == NULL) return;
2340
2341 QMenu *fileMenu = new QMenu(aLabel);
2342 fMainWindow->menuBar()->addMenu(fileMenu);
2343
2344 AddInteractor (aName,(G4Interactor)fileMenu);
2345}
2346
2347
2348/**
2349 Add a new button to a menu
2350 @param aMenu : parent menu
2351 @param aLabel : label to display
2352 @param aCommand : command to execute as a callback
2353 */
2355 const char* aMenu
2356,const char* aLabel
2357,const char* aCommand
2358)
2359{
2360 if(aMenu==NULL) return; // TO KEEP
2361 if(aLabel==NULL) return; // TO KEEP
2362 if(aCommand==NULL) return; // TO KEEP
2363
2364 QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
2365
2366 if(parentTmp==NULL) {
2368 G4int verbose = UImanager->GetVerboseLevel();
2369
2370 if (verbose >= 2) {
2371 G4cout << "Menu name " << aMenu<< " does not exist, please define it before using it."<< G4endl;
2372 }
2373 return;
2374 }
2375
2376 // Find the command in the command tree
2378 if(UI==NULL) return;
2379 G4UIcommandTree * treeTop = UI->GetTree();
2380
2381 G4String cmd = aCommand;
2382 std::size_t cmdEndPos = cmd.find_first_of(" \t");
2383 if(cmdEndPos!=std::string::npos) {
2384 cmd.erase(cmdEndPos);
2385 }
2386
2387 if(treeTop->FindPath(cmd) == NULL) {
2388 if(cmd != "ls" &&
2389 cmd.substr(0,3) != "ls " &&
2390 cmd != "pwd" &&
2391 cmd != "cd" &&
2392 cmd.substr(0,3) != "cd " &&
2393 cmd != "help" &&
2394 cmd.substr(0,5) != "help " &&
2395 cmd[0] != '?' &&
2396 cmd != "hist" &&
2397 cmd != "history" &&
2398 cmd[0] != '!' &&
2399 cmd != "exit" &&
2400 cmd != "cont" &&
2401 cmd != "continue"){
2403 G4int verbose = UImanager->GetVerboseLevel();
2404
2405 if (verbose >= 2) {
2406 G4cout << "Warning: command '"<< cmd <<"' does not exist, please define it before using it."<< G4endl;
2407 }
2408 }
2409 }
2410
2411#if QT_VERSION < 0x050600
2412 QSignalMapper *signalMapper = new QSignalMapper(this);
2413 QAction *action = parentTmp->addAction(aLabel, signalMapper, SLOT(map()));
2414
2415 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
2416 signalMapper->setMapping(action, QString(aCommand));
2417#else
2418 QString cmd_tmp = QString(aCommand);
2419 parentTmp->addAction(aLabel, this, [this, cmd_tmp](){ this->ButtonCallback(cmd_tmp); });
2420#endif
2421}
2422
2423
2424
2425
2426/**
2427 special case for the "open" icon. It will open a file selector and map the return file to the given command.
2428*/
2429void G4UIQt::AddIcon(const char* aLabel, const char* aIconFile, const char* aCommand, const char* aFileName){
2430 if(aLabel==NULL) return; // TO KEEP
2431 // special case, aCommand could be NULL if aIconFile is not user_icon
2432 if (aCommand==NULL) {
2433 if (std::string(aIconFile) == "user_icon") {
2434 return; // TO KEEP
2435 }
2436 }
2437 QPixmap* pix;
2438 G4bool userToolBar = false;
2439
2440 if (!fDefaultIcons) {
2441 userToolBar = true;
2442 }
2443 if (std::string(aIconFile) == "user_icon") {
2444 // try to open a file
2446 pix = new QPixmap(UImanager->FindMacroPath(aFileName).data());
2447 if (pix->isNull()) {
2448 G4int verbose = UImanager->GetVerboseLevel();
2449
2450 if (verbose >= 2) {
2451 G4cout << "Warning: file '"<< aFileName <<"' is incorrect or does not exist, this command will not be build"<< G4endl;
2452 }
2453 return;
2454 }
2455 } else if (std::string(aIconFile) == "open") {
2456 pix = fOpenIcon;
2457 } else if (std::string(aIconFile) == "save") {
2458 pix = fSaveIcon;
2459 } else if (std::string(aIconFile) == "move") {
2460 pix = fMoveIcon;
2461 } else if (std::string(aIconFile) == "rotate") {
2462 pix = fRotateIcon;
2463 } else if (std::string(aIconFile) == "pick") {
2464 pix = fPickIcon;
2465 } else if (std::string(aIconFile) == "zoom_in") {
2466 pix = fZoomInIcon;
2467 } else if (std::string(aIconFile) == "zoom_out") {
2468 pix = fZoomOutIcon;
2469 } else if (std::string(aIconFile) == "wireframe") {
2470 pix = fWireframeIcon;
2471 } else if (std::string(aIconFile) == "solid") {
2472 pix = fSolidIcon;
2473 } else if (std::string(aIconFile) == "hidden_line_removal") {
2474 pix = fHiddenLineRemovalIcon;
2475 } else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2476 pix = fHiddenLineAndSurfaceRemovalIcon;
2477 } else if (std::string(aIconFile) == "perspective") {
2478 pix = fPerspectiveIcon;
2479 } else if (std::string(aIconFile) == "ortho") {
2480 pix = fOrthoIcon;
2481 } else if (std::string(aIconFile) == "runBeamOn") {
2482 pix = fRunIcon;
2483 } else if (std::string(aIconFile) == "exit") {
2484 pix = fExitIcon;
2485 } else {
2487 G4int verbose = UImanager->GetVerboseLevel();
2488
2489 if (verbose >= 2) {
2490 G4cout << "Parameter"<< aIconFile <<" not defined"<< G4endl;
2491 }
2492 return;
2493 }
2494 QToolBar *currentToolbar = NULL;
2495 if (userToolBar) {
2496 if (fToolbarUser == NULL) {
2497 fToolbarUser = new QToolBar();
2498 fToolbarUser->setIconSize (QSize(20,20));
2499 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2500 }
2501 currentToolbar = fToolbarUser;
2502 } else {
2503 if (fToolbarApp == NULL) {
2504 fToolbarApp = new QToolBar();
2505 fToolbarApp->setIconSize (QSize(20,20));
2506 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2507 }
2508 currentToolbar = fToolbarApp;
2509 }
2510
2511 // Check if already present
2512
2513 QList<QAction*> list = currentToolbar->actions();
2514
2515 for (G4int i = 0; i < list.size(); ++i) {
2516 if (list.at(i)->text() == QString(aLabel)) {
2518 if(UI==NULL) return;
2519 G4int verbose = UI->GetVerboseLevel();
2520 if (verbose >= 2) {
2521 G4cout << "Warning: A toolBar icon \""<< aLabel<< "\" already exists with the same name!" << G4endl;
2522 }
2523 }
2524 }
2525
2526#if QT_VERSION < 0x050600
2527 QSignalMapper *signalMapper = new QSignalMapper(this);
2528 QAction *action = currentToolbar->addAction(QIcon(*pix),aLabel, signalMapper, SLOT(map()));
2529#endif
2530 // special cases :"open"
2531 if (std::string(aIconFile) == "open") {
2532 QString txt = aCommand + fStringSeparator + aLabel;
2533#if QT_VERSION < 0x050600
2534 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(OpenIconCallback(const QString &)));
2535 signalMapper->setMapping(action, QString(txt));
2536#else
2537 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->OpenIconCallback(txt); });
2538#endif
2539
2540 // special cases :"save"
2541 } else if (std::string(aIconFile) == "save") {
2542 QString txt = aCommand + fStringSeparator + aLabel;
2543#if QT_VERSION < 0x050600
2544 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(SaveIconCallback(const QString&)));
2545 signalMapper->setMapping(action, QString(txt));
2546#else
2547 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->SaveIconCallback(txt); });
2548#endif
2549
2550 // special cases : cursor style
2551 } else if ((std::string(aIconFile) == "move") ||
2552 (std::string(aIconFile) == "rotate") ||
2553 (std::string(aIconFile) == "pick") ||
2554 (std::string(aIconFile) == "zoom_out") ||
2555 (std::string(aIconFile) == "zoom_in")) {
2556#if QT_VERSION < 0x050600
2557 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangeCursorAction(const QString&)));
2558 signalMapper->setMapping(action, QString(aIconFile));
2559#else
2560 QString txt = QString(aIconFile);
2561 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangeCursorAction(txt); });
2562#endif
2563 action->setCheckable(TRUE);
2564 action->setChecked(TRUE);
2565 action->setData(aIconFile);
2566
2567 if (std::string(aIconFile) == "move") {
2569 }
2570 if (std::string(aIconFile) == "rotate") {
2572 }
2573 if (std::string(aIconFile) == "pick") {
2575 }
2576 if (std::string(aIconFile) == "zoom_in") {
2578 }
2579 if (std::string(aIconFile) == "zoom_out") {
2581 }
2582
2583 // special case : surface style
2584 } else if ((std::string(aIconFile) == "hidden_line_removal") ||
2585 (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
2586 (std::string(aIconFile) == "solid") ||
2587 (std::string(aIconFile) == "wireframe")) {
2588#if QT_VERSION < 0x050600
2589 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangeSurfaceStyle(const QString&)));
2590 signalMapper->setMapping(action, QString(aIconFile));
2591#else
2592 QString txt = QString(aIconFile);
2593 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangeSurfaceStyle(txt); });
2594#endif
2595 action->setCheckable(TRUE);
2596 action->setChecked(TRUE);
2597 action->setData(aIconFile);
2598
2599 if (std::string(aIconFile) == "hidden_line_removal") {
2601 }
2602 if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2604 }
2605 if (std::string(aIconFile) == "solid") {
2607 }
2608 if (std::string(aIconFile) == "wireframe") {
2610 }
2611
2612 // special case : perspective/ortho
2613 } else if ((std::string(aIconFile) == "perspective") ||
2614 (std::string(aIconFile) == "ortho")) {
2615#if QT_VERSION < 0x050600
2616 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ChangePerspectiveOrtho(const QString&)));
2617 signalMapper->setMapping(action, QString(aIconFile));
2618#else
2619 QString txt = QString(aIconFile);
2620 QAction* action = currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this, txt](){ this->ChangePerspectiveOrtho(txt); });
2621#endif
2622 action->setCheckable(TRUE);
2623 action->setChecked(TRUE);
2624 action->setData(aIconFile);
2625
2626 if (std::string(aIconFile) == "perspective") {
2628 }
2629 if (std::string(aIconFile) == "ortho") {
2631 }
2632
2633 } else {
2634
2635 // Find the command in the command tree
2637 if(UI==NULL) return;
2638 G4UIcommandTree * treeTop = UI->GetTree();
2639 if (aCommand != NULL) {
2640 std::string str = aCommand;
2641 std::string::size_type pos = str.find(" ");
2642 if (pos != std::string::npos)
2643 {
2644 str = str.substr(0,pos).c_str();
2645 }
2646 if(treeTop->FindPath(str.c_str()) == NULL) {
2648 G4int verbose = UImanager->GetVerboseLevel();
2649
2650 if (verbose >= 2) {
2651 G4cout << "Warning: command '"<< aCommand <<"' does not exist, please define it before using it."<< G4endl;
2652 }
2653 }
2654 }
2655
2656#if QT_VERSION < 0x050600
2657 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
2658 signalMapper->setMapping(action, QString(aCommand));
2659#else
2660 QString txt = QString(aCommand);
2661 currentToolbar->addAction(QIcon(*pix), aCommand, this, [this, txt](){ this->ButtonCallback(txt); });
2662#endif
2663 }
2664}
2665
2666
2667void G4UIQt::OutputStyle (const char* destination,const char* style,const char* highlight)
2668{
2669 // Specify an output style
2670 // First argument destination (cout cerr warnings errors all)
2671 // Second argument is the style (fixed proportional)
2672 // Third argument highlights commands if "highlight" (and if /control/verbose > 0)
2673 G4String uiQtDestination(destination);
2674 G4UIQtStyle uiQtStyle;
2675 if (G4String(style) == "fixed") uiQtStyle.fixed = true; else uiQtStyle.fixed = false;
2676 if (G4String(highlight) == "highlight") uiQtStyle.highlight = true; else uiQtStyle.highlight = false;
2677 if (uiQtDestination == "all") {
2678 for (auto& i: fOutputStyles) {
2679 i.second = uiQtStyle;
2680 }
2681 } else {
2682 fOutputStyles[uiQtDestination] = uiQtStyle;
2683 }
2684}
2685
2687{
2688 if ( fMainWindow->menuBar()->isNativeMenuBar() == aVal )
2689 return; // already in this state
2690
2691 // Menu become empty when goin from Qt to Native Bar
2692 fMainWindow->menuBar()->setNativeMenuBar(aVal);
2693}
2694
2696{
2697 fMainWindow->menuBar()->clear();
2698}
2699
2700void G4UIQt::ActivateCommand(
2701 G4String newCommand
2702)
2703{
2704 if (!fHelpTreeWidget) {
2705 return;
2706 }
2707 // Look for the choosen command "newCommand"
2708 std::size_t i = newCommand.find(" ");
2709 G4String targetCom ="";
2710 if( i != std::string::npos )
2711 {
2712 G4String newValue = newCommand.substr(i+1,newCommand.length()-(i+1));
2713 G4StrUtil::strip(newValue);
2714 targetCom = ModifyToFullPathCommand( newValue );
2715 }
2716 if (targetCom != "") {
2717 OpenHelpTreeOnCommand(targetCom.data());
2718 }
2719
2720 fUITabWidget->setCurrentWidget(fHelpTBWidget);
2721}
2722
2723
2724
2725/**
2726 Create the help tree widget
2727 @param parent : parent of tree widget
2728 @return the widget containing the tree or NULL if it could not have beeen created
2729 */
2730
2731void G4UIQt::InitHelpTreeAndVisParametersWidget()
2732{
2733
2734 if (! fHelpTreeWidget ) {
2735 fHelpTreeWidget = new QTreeWidget();
2736 }
2737
2738 // build widget
2739 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
2740 QStringList labels;
2741 labels << QString("Command");
2742 fHelpTreeWidget->setHeaderLabels(labels);
2743
2744
2745 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));
2746 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback()));
2747
2748}
2749/**
2750 Create the help tree widget
2751 @param parent : parent of tree widget
2752 @return the widget containing the tree or NULL if it could not have beeen created
2753 */
2754
2755void G4UIQt::FillHelpTree()
2756{
2757 if (! fHelpTreeWidget ) {
2758 InitHelpTreeAndVisParametersWidget();
2759 }
2760
2761 QString searchText = fHelpLine->text();
2762
2763 if (searchText =="") {
2764 // clear old help tree
2765 // fHelpTreeWidget->clear();
2766 } else {
2767 return;
2768 }
2769
2770 if (fParameterHelpLabel) {
2771 fParameterHelpLabel->setText("Choose a command in the command tree");
2772 fParameterHelpTable->setVisible(false);
2773 }
2774
2775 if (fHelpLine) {
2776#if QT_VERSION < 0x040200
2777 fHelpLine->clear();
2778#else
2779 fHelpLine->setText("");
2780#endif
2781 }
2782
2784 if(UI==NULL) return;
2785 G4UIcommandTree * treeTop = UI->GetTree();
2786
2787 G4int treeSize = treeTop->GetTreeEntry();
2788 QTreeWidgetItem * newItem = NULL;
2789 QString commandText = "";
2790 for (G4int a=0;a<treeSize;++a) {
2791 // Creating new item
2792 newItem = NULL;
2793
2794 commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed();
2795
2796 // if already exist, don't create it !
2797 for (G4int b=0;b<fHelpTreeWidget->topLevelItemCount();++b) {
2798 if (!newItem)
2799 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
2800 }
2801
2802 if (newItem == NULL) {
2803
2804 newItem = new QTreeWidgetItem();
2805 newItem->setText(0,GetShortCommandPath(commandText));
2806 fHelpTreeWidget->addTopLevelItem(newItem);
2807 }
2808
2809 // look for childs
2810 CreateHelpTree(newItem,treeTop->GetTree(a+1));
2811 }
2812
2813}
2814
2815
2816
2817/** Fill the Help Tree Widget
2818 @param aParent : parent item to fill
2819 @param aCommandTree : commandTree node associate with this part of the Tree
2820*/
2821void G4UIQt::CreateHelpTree(
2822 QTreeWidgetItem *aParent
2823,G4UIcommandTree *aCommandTree
2824)
2825{
2826 if (aParent == NULL) return;
2827 if (aCommandTree == NULL) return;
2828
2829
2830 // Creating new item
2831 QTreeWidgetItem * newItem;
2832
2833 QString commandText = "";
2834 // Get the Sub directories
2835 for (G4int a=0;a<aCommandTree->GetTreeEntry();++a) {
2836
2837 commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed();
2838
2839 // if already exist, don't create it !
2840 newItem = FindTreeItem(aParent,commandText);
2841 if (newItem == NULL) {
2842 newItem = new QTreeWidgetItem();
2843 newItem->setText(0,GetShortCommandPath(commandText));
2844 aParent->addChild(newItem);
2845 }
2846 CreateHelpTree(newItem,aCommandTree->GetTree(a+1));
2847 }
2848
2849 // Get the Commands
2850
2851 for (G4int a=0;a<aCommandTree->GetCommandEntry();++a) {
2852
2853 QStringList stringList;
2854 commandText = QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed();
2855
2856 // if already exist, don't create it !
2857 newItem = FindTreeItem(aParent,commandText);
2858 if (newItem == NULL) {
2859 newItem = new QTreeWidgetItem();
2860 newItem->setText(0,GetShortCommandPath(commandText));
2861 aParent->addChild(newItem);
2862
2863#if QT_VERSION < 0x040202
2864 fHelpTreeWidget->setItemExpanded(newItem,false);
2865#else
2866 newItem->setExpanded(false);
2867#endif
2868 }
2869 }
2870}
2871
2872
2873
2874
2875/**
2876 Add the following command to the corresponding groupbox
2877 If depthLevel is 1 : create ToolBox
2878 If depthLevel is 2 or more : create GroupBox
2879*/
2880G4bool G4UIQt::CreateVisCommandGroupAndToolBox(
2881 G4UIcommand* aCommand
2882,QWidget* aParent
2883,G4int aDepthLevel
2884,G4bool isDialog
2885)
2886{
2887 QString commandText = QString((char*)(aCommand->GetCommandPath().data())).section("/",-aDepthLevel);
2888
2889 if (commandText == NULL) {
2890 return false;
2891 }
2892
2893 // Look if groupBox is create
2894 // QGroupBox* gBoxCommandWidget;
2895 QWidget* newParentWidget = NULL;
2896 G4bool found = false;
2897 QString commandSection = commandText.left(commandText.indexOf("/"));
2898
2899 if (aDepthLevel == 1) {
2900 QToolBox* currentParent = dynamic_cast<QToolBox*>(aParent);
2901 if (currentParent != 0){
2902
2903 // already exists ?
2904 for (G4int a=0; a<currentParent->count(); ++a) {
2905 if (currentParent->itemText(a) == commandSection) {
2906 found = true;
2907 newParentWidget = currentParent->widget(a);
2908 }
2909 }
2910 }
2911 // Not found ? create it
2912 if (!found) {
2913 newParentWidget = new QGroupBox();
2914 newParentWidget->setLayout(new QVBoxLayout());
2915 if (currentParent != 0){
2916 currentParent->addItem(newParentWidget,commandSection);
2917 } else {
2918 if (!aParent->layout()) {
2919 aParent->setLayout(new QVBoxLayout());
2920 }
2921 aParent->layout()->addWidget(newParentWidget);
2922 }
2923
2924 if (commandText.indexOf("/") == -1) {
2925
2926 // Guidance
2927 QString guidance;
2928 G4int n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
2929 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2930 guidance += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
2931 }
2932 newParentWidget->setToolTip(guidance);
2933 }
2934
2935 QScrollArea* sc = dynamic_cast<QScrollArea*>(newParentWidget->parent()->parent());
2936 if (sc != 0) {
2937 sc->ensureWidgetVisible(newParentWidget);
2938
2939 }
2940 }
2941 } else {
2942
2943 // try to know if this level is already there
2944 QGroupBox* currentParent = dynamic_cast<QGroupBox*>(aParent);
2945 if (currentParent != 0){
2946
2947 // if depth==2, then we add a [more parameters inside] to the toolBoxItem parent
2948 // QGroupBox > QWidget > QScrollArea > QToolBox
2949 if (aDepthLevel == 2){
2950 QToolBox* parentToolBox = dynamic_cast<QToolBox*>(currentParent->parent()->parent()->parent());
2951 if (parentToolBox != 0) {
2952 // parentToolBox->setItemText(parentToolBox->indexOf(currentParent),"[more parameters inside]");
2953 }
2954 }
2955 for (G4int a=0; a<aParent->layout()->count(); ++a) {
2956 QGroupBox* gb = dynamic_cast<QGroupBox*>(aParent->layout()->itemAt(a)->widget());
2957 if (gb != 0) {
2958 if (gb->title() == commandSection) {
2959 found = true;
2960 newParentWidget = gb;
2961 }
2962 }
2963 }
2964 }
2965
2966 // Not found ? create it
2967 if (!found) {
2968 newParentWidget = new QGroupBox();
2969 newParentWidget->setLayout(new QVBoxLayout());
2970 if (!aParent->layout()) {
2971 aParent->setLayout(new QVBoxLayout());
2972 }
2973 aParent->layout()->addWidget(newParentWidget);
2974
2975 // set toolTip
2976 // Guidance
2977 QString guidance;
2978 G4int n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
2979 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
2980 guidance += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
2981 }
2982 newParentWidget->setToolTip(guidance);
2983 }
2984 }
2985
2986 // fill command groupbox
2987 if (commandText.indexOf("/") == -1) {
2988 if (CreateCommandWidget(aCommand, newParentWidget,isDialog)) {
2989 return true;
2990 }
2991 } else {
2992 CreateVisCommandGroupAndToolBox(aCommand,newParentWidget, aDepthLevel-1,isDialog);
2993 }
2994
2995 return true;
2996}
2997
2998
2999
3000/** Create a widget with the command parameters inside
3001 @param command: command line
3002 @parent : parent widget
3003 @isDialog : true if we want apply/cancel button and close at end, false if we want only apply
3004*/
3005G4bool G4UIQt::CreateCommandWidget(G4UIcommand* aCommand, QWidget* aParent, G4bool isDialog) {
3006
3007 if (aCommand == NULL) {
3008 return false;
3009 }
3010
3011
3012 // parameters
3013 G4int n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3014 if( n_parameterEntry > 0 ) {
3015 G4UIparameter *param;
3016
3017 // Re-implementation of G4UIparameter.cc
3018 QWidget* paramWidget = new QWidget();
3019 QGridLayout* gridLayout = new QGridLayout();
3020 paramWidget->setLayout(gridLayout);
3021
3022 // Special case for colour, try to display a color chooser if we found red/green/blue parameter
3023 unsigned int nbColorParameter = 0;
3024 G4bool isStillColorParameter = false;
3025 G4bool isColorDialogAdded = false;
3026 QLabel* redLabel = NULL;
3027 QLabel* greenLabel = NULL;
3028 QString redDefaultStr = "";
3029 QString greenDefaultStr = "";
3030 QString blueDefaultStr = "";
3031 QWidget* redInput = NULL;
3032 QWidget* greenInput = NULL;
3033
3034 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3035 QString txt;
3036 param = aCommand->GetParameter(i_thParameter);
3037 QLabel* label = new QLabel(QString((char*)(param->GetParameterName()).data()));
3038
3039 if ((label->text() == "red") || (label->text() == "red_or_string")){
3040 nbColorParameter ++;
3041 isStillColorParameter = true;
3042 } else if ((label->text() == "green") && isStillColorParameter) {
3043 nbColorParameter ++;
3044 } else if ((label->text() == "blue") && isStillColorParameter) {
3045 nbColorParameter ++;
3046 } else if (!isColorDialogAdded) {
3047
3048 // not following red/green/blue parameters ?
3049 if (nbColorParameter == 1) {
3050 gridLayout->addWidget(redLabel,i_thParameter-1,0);
3051 gridLayout->addWidget(redInput,i_thParameter-1,1);
3052 } else if (nbColorParameter == 2) {
3053 gridLayout->addWidget(redLabel,i_thParameter-2,0);
3054 gridLayout->addWidget(redInput,i_thParameter-2,1);
3055 gridLayout->addWidget(greenLabel,i_thParameter-1,0);
3056 gridLayout->addWidget(greenInput,i_thParameter-1,1);
3057 }
3058 nbColorParameter = 0;
3059 }
3060 // Check parameter type, could be NULL if not found
3061 QWidget* input = NULL;
3062 if ((QString(QChar(param->GetParameterType())) == "d") || (QString(QChar(param->GetParameterType())) == "i")) {
3063 input = new QLineEdit();
3064 // set default value
3065 dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3066
3067 if (((label->text() == "red") || (label->text() == "red_or_string")) && isStillColorParameter) {
3068 redDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3069 } else if ((label->text() == "green") && isStillColorParameter) {
3070 greenDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3071 } else if ((label->text() == "green") && isStillColorParameter) {
3072 blueDefaultStr = QString((char*)(param->GetDefaultValue()).data());
3073 }
3074
3075 } else if (QString(QChar(param->GetParameterType())) == "b") {
3076 input = new QWidget();
3077 QHBoxLayout* layout = new QHBoxLayout();
3078 input->setLayout(layout);
3079
3080 QButtonGroup* buttons = new QButtonGroup();
3081 QRadioButton* radioOff = new QRadioButton("0");
3082 QRadioButton* radioOn = new QRadioButton("1");
3083 buttons->addButton(radioOn);
3084 buttons->addButton(radioOff);
3085 layout->addWidget(radioOn);
3086 layout->addWidget(radioOff);
3087
3088 // set default value
3089 QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3090 if (defaultValue == "0") {
3091 radioOff->setChecked(true);
3092 } else if (defaultValue == "1") {
3093 radioOn->setChecked(true);
3094 }
3095 } else if ((QString(QChar(param->GetParameterType())) == "s") && (!param->GetParameterCandidates().empty())) {
3096 input = new QComboBox();
3097 QString candidates = QString((char*)(param->GetParameterCandidates()).data());
3098 QStringList list = candidates.split (" ");
3099
3100 // add all candidates to widget
3101 QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3102 for (int a=0; a<list.size(); a++) {
3103 dynamic_cast<QComboBox*>(input)->addItem(list.at(a));
3104 if (list.at(a) == defaultValue) {
3105 dynamic_cast<QComboBox*>(input)->setCurrentIndex(a);
3106 }
3107 }
3108
3109 } else if ((QString(QChar(param->GetParameterType())) == "s")) { // string
3110 input = new QLineEdit();
3111 // set default value
3112 dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3113
3114 } else if ((QString(QChar(param->GetParameterType())) == "c")) { // on/off
3115 input = new QWidget();
3116 QHBoxLayout* layout = new QHBoxLayout();
3117 input->setLayout(layout);
3118
3119 QButtonGroup* buttons = new QButtonGroup();
3120 QRadioButton* radioOff = new QRadioButton("off");
3121 QRadioButton* radioOn = new QRadioButton("on");
3122 buttons->addButton(radioOn);
3123 buttons->addButton(radioOff);
3124 layout->addWidget(radioOn);
3125 layout->addWidget(radioOff);
3126
3127 // set default value
3128 QString defaultValue = QString((char*)(param->GetDefaultValue()).data());
3129 if (defaultValue == "off") {
3130 radioOff->setChecked(true);
3131 } else if (defaultValue == "on") {
3132 radioOn->setChecked(true);
3133 }
3134
3135 } else {
3136 input = new QLineEdit();
3137 dynamic_cast<QLineEdit*>(input)->setText(QString((char*)(param->GetDefaultValue()).data()));
3138 }
3139
3140 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
3141 if( ! param->GetParameterGuidance().empty() )
3142 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
3143
3144 txt += " Parameter type : " + QString(QChar(param->GetParameterType())) + "\n";
3145 if(param->IsOmittable()){
3146 txt += " Omittable : True\n";
3147 } else {
3148 txt += " Omittable : False\n";
3149 }
3150 if( param->GetCurrentAsDefault() ) {
3151 txt += " Default value : taken from the current value\n";
3152 } else if( ! param->GetDefaultValue().empty() ) {
3153 txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
3154 }
3155 if( ! param->GetParameterRange().empty() ) {
3156 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
3157 }
3158 if( ! param->GetParameterCandidates().empty() ) {
3159 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
3160 }
3161
3162 if (isStillColorParameter && (nbColorParameter != 0)) {
3163 if ((label->text() == "red") || (label->text() == "red_or_string")) {
3164 redLabel = label;
3165 redInput = input;
3166 } else if (label->text() == "green") {
3167 greenLabel = label;
3168 greenInput = input;
3169 } else if (label->text() == "blue") {
3170
3171 // we have all, then add a color chooser
3172
3173 // Create a pixmap with the default color
3174 QColor qc;
3175 if ((redDefaultStr != "") && (redDefaultStr != "") && (redDefaultStr != "")) {
3176 qc.setRgbF(redDefaultStr.toDouble(),
3177 greenDefaultStr.toDouble(),
3178 blueDefaultStr.toDouble());
3179 }
3180 QPixmap pixmap = QPixmap(QSize(16, 16));
3181 pixmap.fill (qc);
3182 QPainter painter(&pixmap);
3183 painter.setPen(Qt::black);
3184 painter.drawRect(0,0,15,15); // Draw contour
3185
3186 input = new QPushButton("Change color");
3187 dynamic_cast<QPushButton*>(input)->setIcon(pixmap);
3188 dynamic_cast<QPushButton*>(input)->setAccessibleName(redDefaultStr+" "+greenDefaultStr+" "+blueDefaultStr);
3189 label = new QLabel("Choose color");
3190
3191 // less 1 because we have to add one to the row number
3192 nbColorParameter--;
3193 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
3194 input->setToolTip("Select the current color");
3195 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
3196
3197 // Connect pushButton to ColorDialog in callback
3198#if QT_VERSION < 0x050600
3199 QSignalMapper* signalMapper = new QSignalMapper(this);
3200 signalMapper->setMapping(input,input);
3201 connect(input, SIGNAL(clicked()), signalMapper, SLOT(map()));
3202 connect(signalMapper, SIGNAL(mapped(QWidget*)),this, SLOT(ChangeColorCallback(QWidget*)));
3203#else
3204 connect(dynamic_cast<QPushButton*>(input), &QPushButton::clicked , [this, input](){ this->ChangeColorCallback(input);});
3205#endif
3206 isColorDialogAdded = true;
3207 isStillColorParameter = false;
3208 }
3209 } else {
3210 gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
3211 input->setToolTip(txt);
3212 gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
3213 }
3214 }
3215 // add command name in hidden value at last line position 0
3216 QLabel* name = new QLabel(QString((char*)(aCommand->GetCommandPath().data())));
3217 name->hide();
3218 gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
3219
3220 QPushButton* applyButton = new QPushButton("Apply");
3221 if (!isDialog) {
3222
3223 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
3224
3225#if QT_VERSION < 0x050600
3226 QSignalMapper* signalMapper = new QSignalMapper(this);
3227 signalMapper->setMapping(applyButton, paramWidget);
3228 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
3229 connect(signalMapper, SIGNAL(mapped(QWidget*)),this, SLOT(VisParameterCallback(QWidget*)));
3230#else
3231 connect(applyButton, &QPushButton::clicked , [this, paramWidget](){ this->VisParameterCallback(paramWidget);});
3232#endif
3233 } else {
3234 // Apply/Cancel buttons
3235
3236 applyButton->setAutoDefault( TRUE );
3237 applyButton->setDefault( TRUE );
3238
3239 QPushButton* cancelButton = new QPushButton( tr( "&Cancel" ));
3240 cancelButton->setAutoDefault( TRUE );
3241 gridLayout->addWidget(cancelButton,n_parameterEntry-nbColorParameter,1);
3242 gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,0);
3243
3244#if QT_VERSION < 0x050600
3245 QSignalMapper* signalMapper = new QSignalMapper(this);
3246 signalMapper->setMapping(applyButton, paramWidget);
3247 connect(applyButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
3248 connect(signalMapper, SIGNAL(mapped(QWidget*)),this, SLOT(VisParameterCallback(QWidget*)));
3249#else
3250 connect(applyButton, &QPushButton::clicked , [this, paramWidget](){ this->VisParameterCallback(paramWidget);});
3251#endif
3252
3253 QWidget * parentCheck = aParent;
3254 QDialog* parentDialog = NULL;
3255 G4bool found = false;
3256 while ((parentCheck->parentWidget()) != NULL) {
3257 parentCheck = parentCheck->parentWidget();
3258 parentDialog = dynamic_cast<QDialog*>(parentCheck);
3259 if (parentDialog) {
3260 connect( applyButton, SIGNAL( clicked() ), parentDialog, SLOT( accept() ) );
3261 connect( cancelButton, SIGNAL( clicked() ), parentDialog, SLOT( reject() ) );
3262 found = true;
3263 }
3264 }
3265 if (!found) {
3266 return false;
3267 }
3268 }
3269
3270 if (!aParent->layout()) {
3271 aParent->setLayout(new QVBoxLayout());
3272 }
3273 aParent->layout()->addWidget(paramWidget);
3274 }
3275
3276 return true;
3277}
3278
3279
3280/** Find a treeItemWidget in the help tree
3281 @param aCommand item's String to look for
3282 @return item if found, NULL if not
3283*/
3284QTreeWidgetItem* G4UIQt::FindTreeItem(
3285 QTreeWidgetItem *aParent
3286,const QString& aCommand
3287)
3288{
3289 if (aParent == NULL) return NULL;
3290
3291 // Suppress last "/"
3292 QString myCommand = aCommand;
3293
3294 if (myCommand.lastIndexOf("/") == (myCommand.size()-1)) {
3295 myCommand = myCommand.left(myCommand.size()-1);
3296 }
3297
3298 if (GetLongCommandPath(aParent) == myCommand)
3299 return aParent;
3300
3301 QTreeWidgetItem * tmp = NULL;
3302 for (G4int a=0;a<aParent->childCount();++a) {
3303 if (!tmp)
3304 tmp = FindTreeItem(aParent->child(a),myCommand);
3305 }
3306 return tmp;
3307}
3308
3309
3310
3311/** Build the command list parameters in a QString<br>
3312 Reimplement partialy the G4UIparameter.cc
3313 @param aCommand : command to list parameters
3314 @see G4UIparameter::List()
3315 @see G4UIcommand::List()
3316 @return the command list parameters, or "" if nothing
3317 */
3318QString G4UIQt::GetCommandList (
3319 const G4UIcommand *aCommand
3320 )
3321{
3322
3323 QString txt ="";
3324 if (aCommand == NULL)
3325 return txt;
3326
3327 G4String commandPath = aCommand->GetCommandPath();
3328 G4String rangeString = aCommand->GetRange();
3329 G4int n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3330 G4int n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3331
3332 if ((commandPath == "") &&
3333 (rangeString == "") &&
3334 (n_guidanceEntry == 0) &&
3335 (n_parameterEntry == 0)) {
3336 return txt;
3337 }
3338
3339 if((commandPath.length()-1)!='/') {
3340 txt += "Command " + QString((char*)(commandPath).data()) + "\n";
3341 }
3342 txt += "Guidance :\n";
3343
3344 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3345 txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
3346 }
3347 if( ! rangeString.empty() ) {
3348 txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
3349 }
3350 if( n_parameterEntry > 0 ) {
3351 G4UIparameter *param;
3352
3353 // Re-implementation of G4UIparameter.cc
3354
3355 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3356 param = aCommand->GetParameter(i_thParameter);
3357 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
3358 if( ! param->GetParameterGuidance().empty() )
3359 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
3360 txt += " Parameter type : " + QString(QChar(param->GetParameterType())) + "\n";
3361 if(param->IsOmittable()){
3362 txt += " Omittable : True\n";
3363 } else {
3364 txt += " Omittable : False\n";
3365 }
3366 if( param->GetCurrentAsDefault() ) {
3367 txt += " Default value : taken from the current value\n";
3368 } else if( ! param->GetDefaultValue().empty() ) {
3369 txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
3370 }
3371 if( ! param->GetParameterRange().empty() ) {
3372 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
3373 }
3374 if( ! param->GetParameterCandidates().empty() ) {
3375 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
3376 }
3377 }
3378 }
3379 return txt;
3380}
3381
3382
3383/** Build the command list parameters in a QString with HTML<br>
3384 Reimplement partialy the G4UIparameter.cc
3385 @param aCommand : command to list parameters
3386 @see G4UIparameter::List()
3387 @see G4UIcommand::List()
3388 @return the command list parameters, or "" if nothing
3389*/
3390void G4UIQt::updateHelpArea (
3391 const G4UIcommand *aCommand
3392)
3393{
3394 if (!fParameterHelpLabel)
3395 return;
3396 if (!fParameterHelpTable)
3397 return;
3398
3399 fParameterHelpLabel->setTextInteractionFlags(Qt::NoTextInteraction);
3400 QString txt;
3401 if (aCommand == NULL)
3402 return;
3403
3404 G4String commandPath = aCommand->GetCommandPath();
3405 G4String rangeString = aCommand->GetRange();
3406 G4int n_guidanceEntry = (G4int)aCommand->GetGuidanceEntries();
3407 G4int n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3408
3409 if ((commandPath == "") &&
3410 (rangeString == "") &&
3411 (n_guidanceEntry == 0) &&
3412 (n_parameterEntry == 0)) {
3413 return;
3414 }
3415
3416 if((commandPath.length()-1)!='/') {
3417 txt += "<b>Command </b> " + QString((char*)(commandPath).data()) + "<br />";
3418 }
3419 txt += "<b>Guidance :</b> ";
3420 QString tmpGuidance = "";
3421 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3422 tmpGuidance = QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data());
3423#if QT_VERSION < 0x050000
3424 tmpGuidance = Qt::escape(tmpGuidance);
3425#else
3426 tmpGuidance = tmpGuidance.toHtmlEscaped();
3427#endif
3428 tmpGuidance.replace("\n","<br />");
3429 txt += tmpGuidance + "<br />";
3430 }
3431 if( ! rangeString.empty() ) {
3432 QString range = QString((char*)(rangeString).data());
3433#if QT_VERSION < 0x050000
3434 range = Qt::escape(range);
3435#else
3436 range = range.toHtmlEscaped();
3437#endif
3438
3439 txt += "<b>Range of parameters : </b> " + range + "<br />";
3440 } else {
3441 txt += "<br />";
3442 }
3443 fParameterHelpLabel->setHtml(txt);
3444
3445 if( n_parameterEntry > 0 ) {
3446 G4UIparameter *param;
3447
3448 // Re-implementation of G4UIparameter.cc
3449
3450 fParameterHelpTable->clear();
3451 fParameterHelpTable->setRowCount(n_parameterEntry);
3452 fParameterHelpTable->setColumnCount(8);
3453 fParameterHelpTable->setHorizontalHeaderLabels(QStringList() <<
3454 tr("") <<
3455 tr("Parameter") <<
3456 tr("Guidance") <<
3457 tr("Type") <<
3458 tr("Ommitable") <<
3459 tr("Default") <<
3460 tr("Range") <<
3461 tr("Candidate"));
3462 fParameterHelpTable->setColumnWidth(2,60);
3463
3464 fParameterHelpTable->verticalHeader()->setVisible(false);
3465 fParameterHelpTable->setAlternatingRowColors (true);
3466#if QT_VERSION < 0x050000
3467 fParameterHelpTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
3468 fParameterHelpTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
3469#else
3470 fParameterHelpTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
3471 fParameterHelpTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
3472#endif
3473 fParameterHelpTable->setWordWrap(true);
3474
3475 QTableWidgetItem* t = fParameterHelpTable->horizontalHeaderItem(1);
3476 QFont fnt = t->font();
3477 G4int size = fnt.pointSize();
3478 fnt.setPointSize(size-2);
3479
3480 for( G4int a=0; a<n_parameterEntry; a++ ) {
3481 param = aCommand->GetParameter(a);
3482 fParameterHelpTable->setItem(a, 0, new QTableWidgetItem(QString::number(a+1)));
3483
3484 fParameterHelpTable->setItem(a, 1, new QTableWidgetItem(QString((char*)(param->GetParameterName()).data())));
3485 if( ! param->GetParameterGuidance().empty() ) {
3486 fParameterHelpTable->setItem(a, 2, new QTableWidgetItem(QString((char*)(param->GetParameterGuidance()).data())));
3487 }
3488 fParameterHelpTable->setItem(a, 3, new QTableWidgetItem(QString(QChar(param->GetParameterType()))));
3489
3490 if(param->IsOmittable()){
3491 fParameterHelpTable->setItem(a, 4, new QTableWidgetItem(QString("True")));
3492 } else {
3493 fParameterHelpTable->setItem(a, 4, new QTableWidgetItem(QString("False")));
3494 }
3495 if( param->GetCurrentAsDefault() ) {
3496 fParameterHelpTable->setItem(a, 5, new QTableWidgetItem(QString("taken from the current value")));
3497 } else if( ! param->GetDefaultValue().empty() ) {
3498 fParameterHelpTable->setItem(a, 5, new QTableWidgetItem(QString((char*)(param->GetDefaultValue()).data())));
3499 }
3500 if( ! param->GetParameterRange().empty() ) {
3501 fParameterHelpTable->setItem(a, 6, new QTableWidgetItem(QString((char*)(param->GetParameterRange()).data())));
3502 }
3503 if( ! param->GetParameterCandidates().empty() ) {
3504 fParameterHelpTable->setItem(a, 7, new QTableWidgetItem(QString((char*)(param->GetParameterCandidates()).data())));
3505 }
3506 // tooltips
3507 for (G4int b=0; b<8; ++b) {
3508 QTableWidgetItem* tmp = fParameterHelpTable->item(a,b);
3509 if (tmp) {
3510 tmp->setToolTip(tmp->text());
3511 tmp->setFlags(Qt::NoItemFlags);
3512 }
3513 }
3514 fParameterHelpTable->resizeRowToContents(a);
3515 }
3516 for (G4int c=0; c<8; ++c) {
3517 if (c !=2) {
3518 fParameterHelpTable->resizeColumnToContents(c);
3519 }
3520 }
3521 fParameterHelpLabel->setVisible(true);
3522 fParameterHelpTable->setVisible(true);
3523
3524 }
3525}
3526
3527
3528/**
3529 Return true if this command takes almost a number (int, double, bool,
3530 string) as an input
3531 or a string with a candidate list
3532 */
3533G4bool G4UIQt::IsGUICommand(
3534 const G4UIcommand *aCommand
3535)
3536{
3537 if (aCommand == NULL)
3538 return false;
3539
3540 G4int n_parameterEntry = (G4int)aCommand->GetParameterEntries();
3541
3542 if( n_parameterEntry > 0 ) {
3543 G4UIparameter *param;
3544
3545 // Re-implementation of G4UIparameter.cc
3546
3547 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
3548 param = aCommand->GetParameter(i_thParameter);
3549 if (QString(QChar(param->GetParameterType())) == "d") {
3550 return true;
3551 }
3552 if (QString(QChar(param->GetParameterType())) == "b") {
3553 return true;
3554 }
3555 if (QString(QChar(param->GetParameterType())) == "i") {
3556 return true;
3557 }
3558 if (QString(QChar(param->GetParameterType())) == "s") {
3559 return true;
3560 }
3561 }
3562 }
3563 return false;
3564}
3565
3566
3567/** Implement G4VBasicShell vurtual function
3568 */
3569G4bool G4UIQt::GetHelpChoice(
3570 G4int&
3571)
3572{
3573 return true;
3574}
3575
3576
3577/** Event filter method. Every event from QtApplication goes here.<br/>
3578 We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
3579 is active. If this filter match, Up arrow we give the previous command<br/>
3580 and Down arrow will give the next if exist.<br/>
3581 @param obj Emitter of the event
3582 @param event Kind of event
3583*/
3584G4bool G4UIQt::eventFilter( // Should stay with a minuscule eventFilter because of Qt
3585 QObject *aObj
3586,QEvent *aEvent
3587)
3588{
3589 G4bool tabKeyPress = false;
3590 G4bool moveCommandCursor = false;
3591 if (aObj == NULL) return false;
3592 if (aEvent == NULL) return false;
3593
3594 if (aObj == fHistoryTBTableList) {
3595 if (aEvent->type() == QEvent::KeyPress) {
3596 fCommandArea->setFocus();
3597 }
3598 }
3599
3600 if (aObj == fCompleter->popup()) {
3601 if (aEvent->type() == QEvent::KeyPress) {
3602 QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
3603 if (e->key() == (Qt::Key_Tab)) {
3604 tabKeyPress = true;
3605 }
3606 } else if ( aEvent->type() == QEvent::Hide ) {
3607 // Store this value
3608 QString c = fCommandArea->text();
3609 fLastCompleteCommand = c.left(c.indexOf("<"));
3610 }
3611 }
3612
3613 if (aObj == fCommandArea) {
3614 if (aEvent->type() == QEvent::KeyPress) {
3615 QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
3616 if ((e->key() == (Qt::Key_Down)) ||
3617 (e->key() == (Qt::Key_PageDown)) ||
3618 (e->key() == (Qt::Key_Up)) ||
3619 (e->key() == (Qt::Key_PageUp))) {
3620 G4int selection = fHistoryTBTableList->currentRow();
3621 if (fHistoryTBTableList->count()) {
3622 if (selection == -1) {
3623 selection = fHistoryTBTableList->count()-1;
3624 } else {
3625 if (e->key() == (Qt::Key_Down)) {
3626 if (selection <(fHistoryTBTableList->count()-1))
3627 selection++;
3628 } else if (e->key() == (Qt::Key_PageDown)) {
3629 selection = fHistoryTBTableList->count()-1;
3630 } else if (e->key() == (Qt::Key_Up)) {
3631 if (selection >0)
3632 selection --;
3633 } else if (e->key() == (Qt::Key_PageUp)) {
3634 selection = 0;
3635 }
3636 }
3637 fHistoryTBTableList->clearSelection();
3638#if QT_VERSION < 0x040202
3639 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),true);
3640#else
3641 fHistoryTBTableList->item(selection)->setSelected(true);
3642#endif
3643 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
3644 }
3645 moveCommandCursor = true;
3646 } else if (e->key() == (Qt::Key_Tab)) {
3647 tabKeyPress = true;
3648 } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
3649 fCommandArea->home(false);
3650 return true;
3651 } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
3652 fCommandArea->end(false);
3653 return true;
3654 }
3655 } else if (aEvent->type() == QEvent::Paint) {
3656 if (fLastCompleteCommand != "") {
3657 fCommandArea->setText(fLastCompleteCommand);
3658 fLastCompleteCommand = "";
3659 }
3660 }
3661 }
3662 if (tabKeyPress == true) {
3663 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
3664 fCommandArea->setText((char*)(ss.data()));
3665 fCommandArea->setFocus();
3666 // do not pass by parent, it will disable widget tab focus !
3667 return true;
3668 // L.Garnier : MetaModifier is CTRL for MAC, but I don't want to put a MAC
3669 // specific #ifdef
3670 }
3671
3672 G4bool res= false;
3673 // change cursor position if needed
3674 if (moveCommandCursor == true) {
3675 fCommandArea->setCursorPosition ( fCommandArea->text().length() );
3676 fCommandArea->setCursorPosition (4);
3677 } else {
3678 // pass the event on to the parent class
3679 res = QObject::eventFilter(aObj, aEvent);
3680 }
3681 return res;
3682}
3683
3684
3685void G4UIQt::UpdateCommandCompleter() {
3686 if (!fCommandArea) return;
3687
3688 // remove previous one
3689 fCommandArea->setCompleter(NULL);
3690 if (fCompleter) {
3691 if (fCompleter->popup()) {
3692 fCompleter->popup()->removeEventFilter(this);
3693 }
3694 }
3695
3696 QStandardItemModel* model = CreateCompleterModel("/");
3697 fCompleter = new QCompleter(model);
3698
3699 // set all dir visibles in completion
3701 G4UIcommandTree * commandTreeTop = UI->GetTree();
3702 G4UIcommandTree* aTree = commandTreeTop->FindCommandTree("/");
3703 if (aTree) {
3704 int Ndir= aTree-> GetTreeEntry();
3705 fCompleter->setMaxVisibleItems(Ndir);
3706 }
3707 fCommandArea->setCompleter(fCompleter);
3708 fCompleter->popup()->installEventFilter(this);
3709}
3710
3711
3712QStandardItemModel* G4UIQt::CreateCompleterModel(G4String aCmd) {
3713
3714 QList< QStandardItem*> dirModelList;
3715 QList< QStandardItem*> commandModelList;
3716 QList< QStandardItem*> subDirModelList;
3717 QList< QStandardItem*> subCommandModelList;
3718
3719 G4String strtmp;
3720 G4int nMatch= 0;
3721
3722 G4String pName = aCmd;
3723 G4String remainingPath = aCmd;
3724 G4String empty = "";
3725 G4String matchingPath = empty;
3726
3727 // find the tree
3728 auto jpre= pName.rfind('/');
3729 if(jpre != G4String::npos) pName.erase(jpre+1);
3731 G4UIcommandTree * commandTreeTop = UI->GetTree();
3732 G4UIcommandTree* aTree = commandTreeTop->FindCommandTree(pName);
3733 if (aTree) {
3734 G4int Ndir= aTree-> GetTreeEntry();
3735 G4int Ncmd= aTree-> GetCommandEntry();
3736
3737 // directory ...
3738 for(G4int idir=1; idir<=Ndir; ++idir) {
3739 G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
3740 // matching test
3741 if( fpdir.find(remainingPath, 0) == 0) {
3742 if(nMatch==0) {
3743 matchingPath = fpdir;
3744 } else {
3745 matchingPath = aTree->GetFirstMatchedString(fpdir,matchingPath);
3746 }
3747 nMatch++;
3748
3749 // append to dir model list
3750 QStandardItem* item1 = new QStandardItem(fpdir.data());
3751 QIcon i = QIcon(*fDirIcon);
3752 item1->setData(1); // dir
3753 item1->setIcon(QIcon(*fDirIcon));
3754 dirModelList.append(item1);
3755
3756 // Go recursively
3757 QStandardItemModel* subModel = CreateCompleterModel(fpdir.data());
3758 for (G4int a=0; a< subModel->rowCount(); ++a) {
3759
3760 // copy item (an item could only be part of one model
3761 QStandardItem* tempItem = new QStandardItem(subModel->item(a)->text());
3762 tempItem->setIcon(subModel->item(a)->icon());
3763 tempItem->setToolTip(subModel->item(a)->toolTip());
3764 tempItem->setData(subModel->item(a)->data());
3765
3766 // dir
3767 if (tempItem->data() == 1) {
3768 subModel->item(a);
3769 subDirModelList.append(tempItem);
3770 }
3771 // command
3772 else if (tempItem->data() == 0) {
3773 subCommandModelList.append(tempItem);
3774 }
3775 }
3776 }
3777 }
3778
3779 // command ...
3780 G4int n_parameterEntry;
3781 G4String rangeString;
3782 G4int n_guidanceEntry;
3783 G4UIcommand * command;
3784 G4UIparameter *param;
3785 std::string tooltip;
3786 G4String params;
3787
3788 for(G4int icmd=1; icmd<=Ncmd; ++icmd){
3789 tooltip = "";
3790 params = " ";
3791 command = aTree-> GetCommand(icmd);
3792 G4String longCommandName= aTree-> GetPathName() +
3793 command -> GetCommandName();
3794 rangeString = command->GetRange();
3795 n_guidanceEntry = (G4int)command->GetGuidanceEntries();
3796 n_parameterEntry = (G4int)command->GetParameterEntries();
3797
3798
3799 // matching test
3800 if( longCommandName.find(remainingPath, 0) ==0) {
3801 if(nMatch==0) {
3802 matchingPath= longCommandName + " ";
3803 } else {
3804 strtmp= longCommandName + " ";
3805 matchingPath= aTree->GetFirstMatchedString(matchingPath, strtmp);
3806 }
3807
3808 // guidance
3809 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
3810 tooltip += std::string((command->GetGuidanceLine(i_thGuidance)).data());
3811 if (i_thGuidance < n_guidanceEntry-1 ) {
3812 tooltip += "\n";
3813 }
3814 }
3815
3816 // parameters
3817 for( G4int a=0; a<n_parameterEntry; a++ ) {
3818 param = command->GetParameter(a);
3819 if (param->IsOmittable()) {
3820 params += "[<" + param->GetParameterName()+">] ";
3821 } else {
3822 params += "<" + param->GetParameterName()+"> ";
3823 }
3824 }
3825 nMatch++;
3826
3827 // Append to command model list
3828 QStandardItem* item = new QStandardItem(G4String(longCommandName + params).data());
3829 item->setData(0); // command
3830 item->setIcon(QIcon(*fCommandIcon));
3831 item->setToolTip(tooltip.c_str());
3832
3833 commandModelList.append(item);
3834 }
3835 }
3836 }
3837
3838 QStandardItemModel* model = new QStandardItemModel();
3839 // initialize the model
3840 model->setColumnCount(1);
3841
3842 // concat models
3843 for (G4int a= 0; a< dirModelList.size(); ++a) {
3844 model->appendRow(dirModelList.at(a));
3845 }
3846 for (G4int a= 0; a< subDirModelList.size(); ++a) {
3847 model->appendRow(subDirModelList.at(a));
3848 }
3849 for (G4int a= 0; a< commandModelList.size(); ++a) {
3850 model->appendRow(commandModelList.at(a));
3851 }
3852 for (G4int a= 0; a< subCommandModelList.size(); ++a) {
3853 model->appendRow(subCommandModelList.at(a));
3854 }
3855
3856 return model;
3857}
3858
3859
3860/***************************************************************************/
3861//
3862// SLOTS DEFINITIONS
3863//
3864/***************************************************************************/
3865
3866/** Called when user give "help" command.
3867*/
3868void G4UIQt::ShowHelpCallback (
3869)
3870{
3871 TerminalHelp("");
3872}
3873
3874
3875/** Called when user click on clear button. Clear the text Output area
3876*/
3877void G4UIQt::ClearButtonCallback (
3878)
3879{
3880 fCoutTBTextArea->clear();
3881 fG4OutputString.clear();
3882}
3883
3884/** Called when user exit session
3885*/
3886void G4UIQt::ExitSession (
3887)
3888{
3890}
3891
3892void G4UIQt::ExitHelp(
3893) const
3894{
3895}
3896
3897/** Callback call when "click on a menu entry.<br>
3898 Send the associated command to geant4
3899*/
3900void G4UIQt::CommandEnteredCallback (
3901)
3902{
3903 // split by any new line character
3904 fCommandArea->setText(fCommandArea->text().trimmed());
3905#if QT_VERSION < 0x050F00
3906 // Before Qt5.15
3907 QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
3908#else
3909 // Qt5.15 and beyond
3910 QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),Qt::SkipEmptyParts);
3911#endif
3912
3913 // Apply for all commands
3914 for (G4int a=0; a< list.size(); ++a) {
3915 QString txt (list[a].trimmed());
3916 if (txt != "") {
3917 fHistoryTBTableList->addItem(txt);
3918 fHistoryTBTableList->clearSelection();
3919 fHistoryTBTableList->setCurrentItem(NULL);
3920 fCommandArea->setText("");
3921 G4Qt* interactorManager = G4Qt::getInstance ();
3922 if (interactorManager) {
3923 interactorManager->FlushAndWaitExecution();
3924 }
3925
3926 G4String command = txt.toStdString().c_str();
3927 if (command.substr(0,4) != "help") {
3928 ApplyShellCommand (command,exitSession,exitPause);
3929 } else {
3930 ActivateCommand(command);
3931 }
3932 }
3933 }
3934 // set the focus to the command line
3935 fCommandArea->setFocus();
3936
3937 // Rebuild help tree
3938 FillHelpTree();
3939
3940 // Rebuild command completion
3941 UpdateCommandCompleter();
3942
3943 if(exitSession==true)
3945}
3946
3947
3948/** Callback when the text in the line edit is changed.
3949 When a newline is inserted, trigger the Activate Command
3950 on this text end set unchanged the end of the line after the newline.
3951 */
3952void G4UIQt::CommandEditedCallback(const QString &)
3953{
3954#if QT_VERSION < 0x050F00
3955 // Before Qt5.15
3956 QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
3957#else
3958 // Qt5.15 and beyond
3959 QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),Qt::SkipEmptyParts);
3960#endif
3961
3962 if (list.size() > 1) { // trigger ActivateCommand
3963 for (G4int a=0; a<list.size()-1; ++a) {
3964 // set only the first part
3965 fCommandArea->setText(list[a]);
3966 // trigger callback
3967 CommandEnteredCallback();
3968 }
3969 // reset unfinished command
3970 fCommandArea->setText(list[list.size()-1]);
3971 }
3972}
3973
3974
3975/** Callback when one of the scene/vis parameters has changed
3976 */
3977void G4UIQt::VisParameterCallback(QWidget* widget){
3978 if (widget == NULL) {
3979 return;
3980 }
3981
3982 // Look in all the Grid layout, but only column 1 (0 is the parameter name)
3983 QGridLayout* grid = dynamic_cast<QGridLayout*>(widget->layout());
3984 if (grid == 0) {
3985 return;
3986 }
3987 QString command;
3988#if QT_VERSION < 0x040400
3989 QWidget* name = grid->itemAt(grid->columnCount()*(grid->rowCount()-2))->widget();
3990#else
3991 QWidget* name = grid->itemAtPosition(grid->rowCount()-1,0)->widget();
3992#endif
3993 if (dynamic_cast<QLabel*>(name) == 0) {
3994 return;
3995 }
3996 command += (dynamic_cast<QLabel*>(name))->text()+" ";
3997
3998 for (G4int a=0;a<grid->rowCount()-1; ++a) {
3999#if QT_VERSION < 0x040400
4000 QWidget* widgetTmp = grid->itemAt(a*grid->columnCount()+1)->widget();
4001#else
4002 QWidget* widgetTmp = grid->itemAtPosition(a,1)->widget();
4003#endif
4004
4005 // 4 kind of widgets : QLineEdit / QComboBox / radioButtonsGroup / QPushButton (color chooser)
4006 if (widgetTmp != NULL) {
4007
4008 if (dynamic_cast<QLineEdit*>(widgetTmp) != 0) {
4009 command += (dynamic_cast<QLineEdit*>(widgetTmp))->text()+" ";
4010
4011 } else if (dynamic_cast<QComboBox*>(widgetTmp) != 0){
4012 command += (dynamic_cast<QComboBox*>(widgetTmp))->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex())+" ";
4013
4014 // Color chooser
4015 } else if (dynamic_cast<QPushButton*>(widgetTmp) != 0){
4016 command += widgetTmp->accessibleName()+" ";
4017
4018 // Check for Button group
4019 } else if (dynamic_cast<QWidget*>(widgetTmp) != 0){
4020 if (widgetTmp->layout()->count() > 0){
4021 if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != 0) {
4022 QAbstractButton * checked = (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton();
4023 if (checked != 0) {
4024 command += (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()))->group()->checkedButton()->text()+" ";
4025 }
4026 }
4027 }
4028
4029 }
4030 }
4031 }
4032 if (command != "") {
4034 if(UI != NULL) {
4035 UI->ApplyCommand(command.toStdString().c_str());
4036 }
4037 }
4038}
4039
4040
4041/** Callback call when "enter" clicked on the command zone.<br>
4042 If command has no parameters :send the command to geant4
4043 Else, open a dialog for parameters input
4044 @param aCommand
4045*/
4046void G4UIQt::ButtonCallback (
4047 const QString& aCommand
4048)
4049{
4050 G4String ss = G4StrUtil::lstrip_copy(G4String(aCommand.toStdString().c_str()));
4051
4053 if(UI==NULL) return;
4054 G4UIcommandTree * treeTop = UI->GetTree();
4055
4056 G4UIcommand* command = treeTop->FindPath(ss);
4057
4058 if (command) {
4059 // if is GUI, then open a dialog
4060 if (IsGUICommand(command)) {
4061 QDialog* menuParameterDialog = new QDialog();
4062
4063 if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,true)) {
4064 menuParameterDialog->setWindowTitle (aCommand);
4065 menuParameterDialog->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
4066
4067 // exec this dialog, apply the command automaticaly, and return
4068 menuParameterDialog->exec();
4069 return;
4070 }
4071 delete menuParameterDialog;
4072 }
4073 }
4074
4075 ApplyShellCommand(ss,exitSession,exitPause);
4076
4077 // Rebuild help tree
4078 FillHelpTree();
4079
4080 if(exitSession==true)
4082}
4083
4084
4085
4086/** This callback is activated when user selected a item in the help tree
4087*/
4088void G4UIQt::HelpTreeClicCallback (
4089)
4090{
4091 QTreeWidgetItem* item = NULL;
4092 if (!fHelpTreeWidget)
4093 return ;
4094
4095 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
4096 if (list.isEmpty())
4097 return;
4098 item = list.first();
4099 if (!item)
4100 return;
4101
4103 if(UI==NULL) return;
4104 G4UIcommandTree * treeTop = UI->GetTree();
4105
4106 std::string itemText = GetLongCommandPath(item).toStdString();
4107
4108 // check if it is a command path
4109 if (item->childCount() > 0) {
4110 itemText +="/";
4111 }
4112 G4UIcommand* command = treeTop->FindPath(itemText.c_str());
4113
4114 if (command) {
4115 updateHelpArea(command);
4116 } else { // this is a command
4117 G4UIcommandTree* path = treeTop->FindCommandTree(itemText.c_str());
4118 if ( path) {
4119 // this is not a command, this is a sub directory
4120 // We display the Title
4121 fParameterHelpLabel->setVisible(true);
4122 fParameterHelpLabel->setText(path->GetTitle().data());
4123 fParameterHelpTable->setVisible(false);
4124 }
4125 }
4126}
4127
4128/** This callback is activated when user double clic on a item in the help tree
4129*/
4130void G4UIQt::HelpTreeDoubleClicCallback (
4131)
4132{
4133 HelpTreeClicCallback();
4134
4135 QTreeWidgetItem* item = NULL;
4136 if (!fHelpTreeWidget)
4137 return ;
4138
4139 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
4140 if (list.isEmpty())
4141 return;
4142 item = list.first();
4143 if (!item)
4144 return;
4145
4146 fCommandArea->clear();
4147 fCommandArea->setText(GetLongCommandPath(item));
4148}
4149
4150
4151/** Callback called when user select an old command in the command history<br>
4152 Give it to the command area.
4153*/
4154void G4UIQt::CommandHistoryCallback(
4155)
4156{
4157 QListWidgetItem* item = NULL;
4158 if (!fHistoryTBTableList)
4159 return ;
4160
4161
4162 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
4163 if (list.isEmpty())
4164 return;
4165 item = list.first();
4166 if (!item)
4167 return;
4168 fCommandArea->setText(item->text());
4169}
4170
4171
4172void G4UIQt::ThreadComboBoxCallback(G4int) {
4173 CoutFilterCallback("");
4174}
4175
4176
4177void G4UIQt::CoutFilterCallback(
4178const QString &) {
4179
4180 FilterAllOutputTextArea();
4181
4182 fCoutTBTextArea->repaint();
4183 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
4184
4185 }
4186
4187
4188void G4UIQt::SaveOutputCallback(){
4189 QString fileName = QFileDialog::getSaveFileName(fMainWindow, "Save console output as...", fLastOpenPath, "Save output as...");
4190 if (fileName != "") {
4191
4192 QFile data(fileName);
4193 if (data.open(QFile::WriteOnly | QFile::Truncate)) {
4194 QTextStream out(&data);
4195 out << fCoutTBTextArea->toPlainText();
4196 out.flush();
4197 }
4198 data.close();
4199 }
4200}
4201
4202
4203QString G4UIQt::FilterOutput(
4204 const G4UIOutputString& output
4205,const QString& currentThread
4206,const QString& filter
4207) {
4208
4209#ifdef G4MULTITHREADED
4210 if ((currentThread == "All") ||
4211 (currentThread == output.fThread)) {
4212#else
4213 if (currentThread == "") {
4214#endif
4215 if (output.fText.contains(QRegExp(filter))) {
4216 return output.fText;
4217 }
4218 }
4219 return "";
4220}
4221
4222
4223void G4UIQt::FilterAllOutputTextArea() {
4224
4225 QString currentThread = "";
4226#ifdef G4MULTITHREADED
4227 currentThread = fThreadsFilterComboBox->currentText();
4228 if (currentThread == "Master") {
4229 currentThread = "";
4230 }
4231#endif
4232 QString filter = fCoutFilter->text();
4233 G4String previousOutputStream = "";
4234
4235 QString pref = "";
4236 QString post = "";
4237
4238 fCoutTBTextArea->clear();
4239
4240 for (unsigned int a=0; a<fG4OutputString.size(); a++) {
4241 G4UIOutputString out = fG4OutputString[a];
4242 if (FilterOutput(out,currentThread,filter) != "") {
4243
4244 // changing color ?
4245 if (out.fOutputStream != previousOutputStream) {
4246 previousOutputStream = out.fOutputStream;
4247 if (out.fOutputStream == "info") {
4248 pref = "";
4249 post = "";
4250 } else if (out.fOutputStream == "warning") {
4251 pref = "<font color=\"DarkYellow\">";
4252 post = "</font>";
4253 } else {
4254 pref = "<font color=\"Red\">";
4255 post = "</font>";
4256 }
4257 }
4258 fCoutTBTextArea->append(pref + out.fText + post);
4259 }
4260 }
4261}
4262
4263
4264/** Callback called when user give a new string to look for<br>
4265 Display a list of matching commands descriptions. If no string is set,
4266 will display the complete help tree
4267*/
4268void G4UIQt::LookForHelpStringCallback(
4269)
4270{
4271 fHelpLine->setText(fHelpLine->text().trimmed());
4272 QString searchText = fHelpLine->text();
4273
4274 fParameterHelpLabel->setText("");
4275 fParameterHelpTable->setVisible(false);
4276 if (searchText =="") {
4277 // clear old help tree
4278 fHelpTreeWidget->clear();
4279
4280 FillHelpTree();
4281
4282 return;
4283 } else {
4284 OpenHelpTreeOnCommand(searchText);
4285 }
4286}
4287
4288
4289void G4UIQt::OpenHelpTreeOnCommand(
4290 const QString & searchText
4291)
4292{
4293 // the help tree
4295 if(UI==NULL) return;
4296 G4UIcommandTree * treeTop = UI->GetTree();
4297
4298 G4int treeSize = treeTop->GetTreeEntry();
4299
4300 // clear old help tree
4301 fHelpTreeWidget->clear();
4302
4303 // look for new items
4304
4305 int tmp = 0;
4306
4307#if QT_VERSION < 0x050F00
4308 // Before Qt5.15
4309 QMap<G4int,QString> commandResultMap;
4310 QMap<G4int,QString> commandChildResultMap;
4311 for (G4int a=0;a<treeSize;++a) {
4312 G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
4313 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
4314 if (tmp >0) {
4315 commandResultMap.insertMulti(tmp,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()));
4316 }
4317 // look for childs
4318 commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a+1),searchText);
4319 // insert new childs
4320 if (!commandChildResultMap.empty()) {
4321 QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
4322 while (i != commandChildResultMap.constEnd()) {
4323 commandResultMap.insertMulti(i.key(),i.value());
4324 i++;
4325 }
4326 commandChildResultMap.clear();
4327 }
4328 }
4329#else
4330 // Qt5.15 and beyond
4331 QMultiMap<G4int,QString> commandResultMap;
4332 QMultiMap<G4int,QString> commandChildResultMap;
4333 for (G4int a=0;a<treeSize;++a) {
4334 G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
4335 tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
4336 if (tmp >0) {
4337 commandResultMap.insert(tmp,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()));
4338 }
4339 // look for childs
4340 commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a+1),searchText);
4341 // insert new childs
4342 if (!commandChildResultMap.empty()) {
4343 QMap<G4int,QString>::const_iterator i = commandChildResultMap.constBegin();
4344 while (i != commandChildResultMap.constEnd()) {
4345 commandResultMap.insert(i.key(),i.value());
4346 ++i;
4347 }
4348 commandChildResultMap.clear();
4349 }
4350 }
4351#endif
4352
4353 // build new help tree
4354 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
4355 fHelpTreeWidget->setColumnCount(2);
4356 QStringList labels;
4357 labels << QString("Command") << QString("Match");
4358 fHelpTreeWidget->setHeaderLabels(labels);
4359
4360 if (commandResultMap.empty()) {
4361 fParameterHelpLabel->setText("No match found");
4362 fParameterHelpTable->setVisible(false);
4363 return;
4364 }
4365
4366 QMap<G4int,QString>::const_iterator i = commandResultMap.constEnd();
4367 i--;
4368 // 10 maximum progress values
4369 G4float multValue = 10.0/(G4float)(i.key());
4370 QString progressChar = "|";
4371 QString progressStr = "|";
4372
4373 QTreeWidgetItem * newItem;
4374 G4bool end = false;
4375 while (!end) {
4376 if (i == commandResultMap.constBegin()) {
4377 end = true;
4378 }
4379 for(G4int a=0;a<G4int(i.key()*multValue);++a) {
4380 progressStr += progressChar;
4381 }
4382 newItem = new QTreeWidgetItem();
4383 QString commandStr = i.value().trimmed();
4384
4385 if (commandStr.indexOf("/") == 0) {
4386 commandStr = commandStr.right(commandStr.size()-1);
4387 }
4388
4389 newItem->setText(0,commandStr);
4390 newItem->setText(1,progressStr);
4391 fHelpTreeWidget->addTopLevelItem(newItem);
4392#if QT_VERSION < 0x040200
4393#else
4394 newItem->setForeground ( 1, QBrush(Qt::blue) );
4395#endif
4396 progressStr = "|";
4397 i--;
4398 }
4399 fHelpTreeWidget->resizeColumnToContents (0);
4400 fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
4401 // fHelpTreeWidget->setColumnWidth(1,10);//resizeColumnToContents (1);
4402}
4403
4404#if QT_VERSION < 0x050F00
4405// Before Qt5.15
4406QMap<G4int,QString> G4UIQt::LookForHelpStringInChildTree(
4407 G4UIcommandTree *aCommandTree
4408,const QString & text
4409 )
4410{
4411 QMap<G4int,QString> commandResultMap;
4412 if (aCommandTree == NULL) return commandResultMap;
4413 // Get the Sub directories
4414 G4int tmp = 0;
4415 QMap<G4int,QString> commandChildResultMap;
4416 for (G4int a=0;a<aCommandTree->GetTreeEntry();++a) {
4417 const G4UIcommand* command = aCommandTree->GetGuidance();
4418 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4419 if (tmp >0) {
4420 commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
4421 }
4422 // look for childs
4423 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a+1),text);
4424 if (!commandChildResultMap.empty()) {
4425 // insert new childs
4426 QMap<G4int,QString>::const_iterator i = commandChildResultMap.constBegin();
4427 while (i != commandChildResultMap.constEnd()) {
4428 commandResultMap.insertMulti(i.key(),i.value());
4429 ++i;
4430 }
4431 commandChildResultMap.clear();
4432 }
4433 }
4434 // Get the Commands
4435 for (G4int a=0;a<aCommandTree->GetCommandEntry();++a) {
4436 const G4UIcommand* command = aCommandTree->GetCommand(a+1);
4437 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4438 if (tmp >0) {
4439 commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
4440 }
4441 }
4442 return commandResultMap;
4443}
4444#else
4445// Qt5.15 and beyond
4446QMultiMap<G4int,QString> G4UIQt::LookForHelpStringInChildTree(
4447 G4UIcommandTree *aCommandTree
4448,const QString & text
4449 )
4450{
4451 QMultiMap<G4int,QString> commandResultMap;
4452 if (aCommandTree == NULL) return commandResultMap;
4453 // Get the Sub directories
4454 G4int tmp = 0;
4455 QMultiMap<G4int,QString> commandChildResultMap;
4456 for (G4int a=0;a<aCommandTree->GetTreeEntry();++a) {
4457 const G4UIcommand* command = aCommandTree->GetGuidance();
4458 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4459 if (tmp >0) {
4460 commandResultMap.insert(tmp,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
4461 }
4462 // look for childs
4463 commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a+1),text);
4464 if (!commandChildResultMap.empty()) {
4465 // insert new childs
4466 QMap<G4int,QString>::const_iterator i = commandChildResultMap.constBegin();
4467 while (i != commandChildResultMap.constEnd()) {
4468 commandResultMap.insert(i.key(),i.value());
4469 ++i;
4470 }
4471 commandChildResultMap.clear();
4472 }
4473 }
4474 // Get the Commands
4475 for (G4int a=0;a<aCommandTree->GetCommandEntry();++a) {
4476 const G4UIcommand* command = aCommandTree->GetCommand(a+1);
4477 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
4478 if (tmp >0) {
4479 commandResultMap.insert(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
4480 }
4481 }
4482 return commandResultMap;
4483}
4484#endif
4485
4486
4487QString G4UIQt::GetShortCommandPath(
4488QString commandPath
4489)
4490{
4491 if (commandPath.indexOf("/") == 0) {
4492 commandPath = commandPath.right(commandPath.size()-1);
4493 }
4494
4495 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf("/",-2)-1);
4496
4497 if (commandPath.lastIndexOf("/") == (commandPath.size()-1)) {
4498 commandPath = commandPath.left(commandPath.size()-1);
4499 }
4500
4501 return commandPath;
4502}
4503
4504
4505QString G4UIQt::GetLongCommandPath(
4506 QTreeWidgetItem* item
4507)
4508{
4509 if (item == NULL) return "";
4510
4511 // rebuild path:
4512 QString itemText = "";
4513 itemText = item->text(0);
4514
4515 while (item->parent() != NULL) {
4516 itemText = item->parent()->text(0)+"/"+itemText;
4517 item = item->parent();
4518 }
4519 itemText = "/"+itemText;
4520
4521 return itemText;
4522}
4523
4524
4525void G4UIQt::ChangeColorCallback(QWidget* widget) {
4526 if (widget == NULL) {
4527 return;
4528 }
4529
4530 QPushButton* button = dynamic_cast<QPushButton*>(widget);
4531 if (button == 0) {
4532 return;
4533 }
4534 QString value = button->accessibleName();
4535
4536 QColor old;
4537 old.setRgbF(value.section(" ",0,1).toDouble(),
4538 value.section(" ",1,2).toDouble(),
4539 value.section(" ",2,3).toDouble());
4540#if QT_VERSION < 0x040500
4541 G4bool a;
4542 QColor color = QColor(QColorDialog::getRgba (old.rgba(),&a,fUITabWidget));
4543#else
4544 QColor color = QColorDialog::getColor(old,
4545 fUITabWidget,
4546 "Change color",
4547 QColorDialog::ShowAlphaChannel);
4548#endif
4549
4550
4551 if (color.isValid()) {
4552 // rebuild the widget icon
4553 QPixmap pixmap = QPixmap(QSize(16, 16));
4554 pixmap.fill (color);
4555 QPainter painter(&pixmap);
4556 painter.setPen(Qt::black);
4557 painter.drawRect(0,0,15,15); // Draw contour
4558
4559 button->setAccessibleName(QString::number(color.redF())+" "+
4560 QString::number(color.greenF())+" "+
4561 QString::number(color.blueF())+" "
4562 );
4563 button->setIcon(pixmap);
4564
4565
4566 }
4567}
4568
4569
4570void G4UIQt::ChangeCursorAction(const QString& action) {
4571
4572 // Theses actions should be in the app toolbar
4573
4574 fMoveSelected = true;
4575 fPickSelected = true;
4576 fRotateSelected = true;
4577 fZoomInSelected = true;
4578 fZoomOutSelected = true;
4579
4580 if (fToolbarApp == NULL) return;
4581 QList<QAction *> list = fToolbarApp->actions ();
4582 for (int i = 0; i < list.size(); ++i) {
4583 if (list.at(i)->data().toString () == action) {
4584 list.at(i)->setChecked(TRUE);
4585 if (list.at(i)->data().toString () == "pick") {
4586 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/picking true");
4587 CreatePickInfosDialog();
4588
4589 fPickInfosDialog->show();
4590 fPickInfosDialog->raise();
4591 fPickInfosDialog->activateWindow();
4592 }
4593 } else if (list.at(i)->data().toString () == "move") {
4594 fMoveSelected = false;
4595 list.at(i)->setChecked(FALSE);
4596 } else if (list.at(i)->data().toString () == "pick") {
4597 fPickSelected = false;
4598 list.at(i)->setChecked(FALSE);
4599 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/picking false");
4600 if (fPickInfosDialog) {
4601 fPickInfosDialog->hide();
4602 }
4603 } else if (list.at(i)->data().toString () == "rotate") {
4604 fRotateSelected = false;
4605 list.at(i)->setChecked(FALSE);
4606 } else if (list.at(i)->data().toString () == "zoom_in") {
4607 fZoomInSelected = false;
4608 list.at(i)->setChecked(FALSE);
4609 } else if (list.at(i)->data().toString () == "zoom_out") {
4610 fZoomOutSelected = false;
4611 list.at(i)->setChecked(FALSE);
4612 }
4613 }
4614 // FIXME : Should connect this to Vis
4615}
4616
4617
4618/* A little bit like "void G4OpenGLQtViewer::toggleDrawingAction(int aAction)"
4619 But for all viewers, not only Qt
4620
4621FIXME : Should be a feedback when changing viewer !
4622
4623 */
4624void G4UIQt::ChangeSurfaceStyle(const QString& action) {
4625
4626 // Theses actions should be in the app toolbar
4627
4628 if (fToolbarApp == NULL) return;
4629 QList<QAction *> list = fToolbarApp->actions ();
4630 for (G4int i = 0; i < list.size(); ++i) {
4631 if (list.at(i)->data().toString () == action) {
4632 list.at(i)->setChecked(TRUE);
4633 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
4634 list.at(i)->setChecked(FALSE);
4635 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
4636 list.at(i)->setChecked(FALSE);
4637 } else if (list.at(i)->data().toString () == "solid") {
4638 list.at(i)->setChecked(FALSE);
4639 } else if (list.at(i)->data().toString () == "wireframe") {
4640 list.at(i)->setChecked(FALSE);
4641 }
4642 }
4643 // FIXME : Should connect this to Vis
4644
4645 if (action == "hidden_line_removal") {
4646 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style w");
4647 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 1");
4648
4649 } else if (action == "hidden_line_and_surface_removal") {
4650 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style s");
4651 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 1");
4652
4653 } else if (action == "solid") {
4654 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style s");
4655 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 0");
4656
4657 } else if (action == "wireframe") {
4658 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/style w");
4659 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/hiddenEdge 0");
4660 }
4661}
4662
4663
4664void G4UIQt::OpenIconCallback(const QString& aParam) {
4665
4666 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4667 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4668
4669 QString nomFich = QFileDialog::getOpenFileName(fMainWindow, aLabel, fLastOpenPath, "Macro files (*.mac);;Geant4 files( *.mac *.g4* *.in);;All (*.*)");
4670 if (nomFich != "") {
4671 G4UImanager::GetUIpointer()->ApplyCommand((QString(aCommand)+ QString(" ")+ nomFich).toStdString().c_str());
4672 QDir dir;
4673 fLastOpenPath = dir.absoluteFilePath(nomFich);
4674 }
4675}
4676
4677
4678void G4UIQt::SaveIconCallback(const QString& aParam) {
4679
4680 QString aCommand = aParam.left(aParam.indexOf(fStringSeparator));
4681 QString aLabel = aParam.mid(aParam.indexOf(fStringSeparator)+fStringSeparator.length());
4682
4683 QString nomFich = QFileDialog::getSaveFileName(fMainWindow, aLabel, fLastOpenPath, "Macro files (*.mac)");
4684 if (nomFich != "") {
4685 G4UImanager::GetUIpointer()->ApplyCommand((QString(aCommand)+ QString(" ")+nomFich).toStdString().c_str());
4686 QDir dir;
4687 fLastOpenPath = dir.absoluteFilePath(nomFich);
4688 }
4689}
4690
4691
4692void G4UIQt::CreateViewerPropertiesDialog() {
4693
4694 if (fViewerPropertiesDialog != NULL) {
4695 return;
4696 }
4697 fViewerPropertiesDialog = new QDialog();
4698
4699 fViewerPropertiesDialog->setWindowTitle("Viewer properties");
4700 fViewerPropertiesDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4701
4702 if (!fViewerPropertiesWidget) {
4703 fViewerPropertiesWidget = new QWidget();
4704 QVBoxLayout* layoutPropertiesWidget = new QVBoxLayout();
4705 fViewerPropertiesWidget->setLayout(layoutPropertiesWidget);
4706
4707 CreateEmptyViewerPropertiesWidget();
4708 }
4709
4710 QVBoxLayout* layoutDialog = new QVBoxLayout();
4711
4712 layoutDialog->addWidget(fViewerPropertiesWidget);
4713 layoutDialog->setContentsMargins(0,0,0,0);
4714 fViewerPropertiesDialog->setLayout(layoutDialog);
4715}
4716
4717
4718void G4UIQt::CreatePickInfosDialog() {
4719
4720 if (fPickInfosDialog != NULL) {
4721 return;
4722 }
4723 fPickInfosDialog = new QDialog();
4724
4725 fPickInfosDialog->setWindowTitle("Pick infos");
4726 fPickInfosDialog->setSizePolicy (QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
4727
4728 if (!fPickInfosWidget) {
4729 fPickInfosWidget = new QWidget();
4730 QVBoxLayout* layoutPickInfos = new QVBoxLayout();
4731 fPickInfosWidget->setLayout(layoutPickInfos);
4732
4733 CreateEmptyPickInfosWidget();
4734 }
4735
4736 QVBoxLayout* layoutDialog = new QVBoxLayout();
4737
4738 layoutDialog->addWidget(fPickInfosWidget);
4739 layoutDialog->setContentsMargins(0,0,0,0);
4740 fPickInfosDialog->setLayout(layoutDialog);
4741 fPickInfosDialog->setWindowFlags(Qt::WindowStaysOnTopHint);
4742
4743}
4744
4745
4746void G4UIQt::CreateEmptyViewerPropertiesWidget() {
4747 if(!fViewerPropertiesWidget) return;
4748 if(!fViewerPropertiesWidget->layout()) return;
4749 QLayoutItem * wItem;
4750 if (fViewerPropertiesWidget->layout()->count()) {
4751 while ((wItem = fViewerPropertiesWidget->layout()->takeAt(0)) != 0) {
4752 delete wItem->widget();
4753 delete wItem;
4754 }
4755 }
4756 // Add empty one
4757 QLabel* label = new QLabel("No viewer - Please open a viewer first");
4758 fViewerPropertiesWidget->layout()->addWidget(label);
4759 fViewerPropertiesDialog->setWindowTitle("No viewer");
4760 fViewerPropertiesDialog->setVisible(false);
4761}
4762
4763
4764void G4UIQt::CreateEmptyPickInfosWidget() {
4765 QLayoutItem * wItem;
4766 if (fPickInfosWidget->layout()->count()) {
4767 while ((wItem = fPickInfosWidget->layout()->takeAt(0)) != 0) {
4768 delete wItem->widget();
4769 delete wItem;
4770 }
4771 }
4772 // Add empty one
4773 QLabel* label = new QLabel("Click on the object you want to pick");
4774 fPickInfosWidget->layout()->addWidget(label);
4775 fPickInfosDialog->setWindowTitle("Nothing to pick");
4776}
4777
4778
4779void G4UIQt::ViewerPropertiesIconCallback(G4int) {
4780
4781 CreateViewerPropertiesDialog();
4782
4783 fViewerPropertiesDialog->show();
4784 fViewerPropertiesDialog->raise();
4785 fViewerPropertiesDialog->activateWindow();
4786}
4787
4788
4789void G4UIQt::ChangePerspectiveOrtho(const QString& action) {
4790
4791 // Theses actions should be in the app toolbar
4792
4793 if (fToolbarApp == NULL) return;
4794 QList<QAction *> list = fToolbarApp->actions ();
4795 QString checked = "";
4796 for (G4int i = 0; i < list.size(); ++i) {
4797 if (list.at(i)->data().toString () == action) {
4798 list.at(i)->setChecked(TRUE);
4799 checked = list.at(i)->data().toString ();
4800 } else if (list.at(i)->data().toString () == "perspective") {
4801 list.at(i)->setChecked(FALSE);
4802 } else if (list.at(i)->data().toString () == "ortho") {
4803 list.at(i)->setChecked(FALSE);
4804 }
4805 }
4806
4807 if ((action == "ortho") && (checked == "ortho")) {
4808 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection o");
4809 } else if ((action == "perspective") && (checked == "perspective")) {
4810 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/set/projection p");
4811 }
4812}
4813
4814
4815
4817 // Theses actions should be in the app toolbar
4818 fMoveSelected = true;
4819 fRotateSelected = false;
4820 fPickSelected = false;
4821 fZoomInSelected = false;
4822 fZoomOutSelected = false;
4823
4824 if (fToolbarApp == NULL) return;
4825 QList<QAction *> list = fToolbarApp->actions ();
4826 for (G4int i = 0; i < list.size(); ++i) {
4827 if (list.at(i)->data().toString () == "move") {
4828 list.at(i)->setChecked(TRUE);
4829 } else if (list.at(i)->data().toString () == "rotate") {
4830 list.at(i)->setChecked(FALSE);
4831 } else if (list.at(i)->data().toString () == "pick") {
4832 list.at(i)->setChecked(FALSE);
4833 } else if (list.at(i)->data().toString () == "zoom_in") {
4834 list.at(i)->setChecked(FALSE);
4835 } else if (list.at(i)->data().toString () == "zoom_out") {
4836 list.at(i)->setChecked(FALSE);
4837 }
4838 }
4839}
4840
4841
4843 // Theses actions should be in the app toolbar
4844 fRotateSelected = true;
4845 fMoveSelected = false;
4846 fPickSelected = false;
4847 fZoomInSelected = false;
4848 fZoomOutSelected = false;
4849
4850 if (fToolbarApp == NULL) return;
4851 QList<QAction *> list = fToolbarApp->actions ();
4852 for (G4int i = 0; i < list.size(); ++i) {
4853 if (list.at(i)->data().toString () == "rotate") {
4854 list.at(i)->setChecked(TRUE);
4855 } else if (list.at(i)->data().toString () == "move") {
4856 list.at(i)->setChecked(FALSE);
4857 } else if (list.at(i)->data().toString () == "pick") {
4858 list.at(i)->setChecked(FALSE);
4859 } else if (list.at(i)->data().toString () == "zoom_in") {
4860 list.at(i)->setChecked(FALSE);
4861 } else if (list.at(i)->data().toString () == "zoom_out") {
4862 list.at(i)->setChecked(FALSE);
4863 }
4864 }
4865}
4866
4867
4869 // Theses actions should be in the app toolbar
4870 fPickSelected = true;
4871 fMoveSelected = false;
4872 fRotateSelected = false;
4873 fZoomInSelected = false;
4874 fZoomOutSelected = false;
4875
4876 QToolBar* bar = fToolbarApp;
4877 if (!fDefaultIcons) {
4878 bar = fToolbarUser;
4879 }
4880 if (!bar) return;
4881
4882 QList<QAction *> list = bar->actions ();
4883 for (G4int i = 0; i < list.size(); ++i) {
4884 if (list.at(i)->data().toString () == "pick") {
4885 list.at(i)->setChecked(TRUE);
4886 } else if (list.at(i)->data().toString () == "move") {
4887 list.at(i)->setChecked(FALSE);
4888 } else if (list.at(i)->data().toString () == "rotate") {
4889 list.at(i)->setChecked(FALSE);
4890 } else if (list.at(i)->data().toString () == "zoom_in") {
4891 list.at(i)->setChecked(FALSE);
4892 } else if (list.at(i)->data().toString () == "zoom_out") {
4893 list.at(i)->setChecked(FALSE);
4894 }
4895 }
4896}
4897
4898
4900 // Theses actions should be in the app toolbar
4901 fZoomInSelected = true;
4902 fMoveSelected = false;
4903 fRotateSelected = false;
4904 fPickSelected = false;
4905 fZoomOutSelected = false;
4906
4907 QToolBar* bar = fToolbarApp;
4908 if (!fDefaultIcons) {
4909 bar = fToolbarUser;
4910 }
4911 if (!bar) return;
4912
4913 QList<QAction *> list = bar->actions ();
4914 for (G4int i = 0; i < list.size(); ++i) {
4915 if (list.at(i)->data().toString () == "zoom_in") {
4916 list.at(i)->setChecked(TRUE);
4917 } else if (list.at(i)->data().toString () == "move") {
4918 list.at(i)->setChecked(FALSE);
4919 } else if (list.at(i)->data().toString () == "rotate") {
4920 list.at(i)->setChecked(FALSE);
4921 } else if (list.at(i)->data().toString () == "pick") {
4922 list.at(i)->setChecked(FALSE);
4923 } else if (list.at(i)->data().toString () == "zoom_out") {
4924 list.at(i)->setChecked(FALSE);
4925 }
4926 }
4927}
4928
4929
4931 // Theses actions should be in the app toolbar
4932 fZoomOutSelected = true;
4933 fMoveSelected = false;
4934 fRotateSelected = false;
4935 fPickSelected = false;
4936 fZoomInSelected = false;
4937
4938 QToolBar* bar = fToolbarApp;
4939 if (!fDefaultIcons) {
4940 bar = fToolbarUser;
4941 }
4942 if (!bar) return;
4943
4944 QList<QAction *> list = bar->actions ();
4945 for (G4int i = 0; i < list.size(); ++i) {
4946 if (list.at(i)->data().toString () == "zoom_out") {
4947 list.at(i)->setChecked(TRUE);
4948 } else if (list.at(i)->data().toString () == "move") {
4949 list.at(i)->setChecked(FALSE);
4950 } else if (list.at(i)->data().toString () == "rotate") {
4951 list.at(i)->setChecked(FALSE);
4952 } else if (list.at(i)->data().toString () == "pick") {
4953 list.at(i)->setChecked(FALSE);
4954 } else if (list.at(i)->data().toString () == "zoom_in") {
4955 list.at(i)->setChecked(FALSE);
4956 }
4957 }
4958}
4959
4960
4962 // Theses actions should be in the app toolbar
4963
4964 QToolBar* bar = fToolbarApp;
4965 if (!fDefaultIcons) {
4966 bar = fToolbarUser;
4967 }
4968 if (!bar) return;
4969
4970 QList<QAction *> list = bar->actions ();
4971 for (G4int i = 0; i < list.size(); ++i) {
4972 if (list.at(i)->data().toString () == "solid") {
4973 list.at(i)->setChecked(TRUE);
4974 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
4975 list.at(i)->setChecked(FALSE);
4976 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
4977 list.at(i)->setChecked(FALSE);
4978 } else if (list.at(i)->data().toString () == "wireframe") {
4979 list.at(i)->setChecked(FALSE);
4980 }
4981 }
4982}
4983
4984
4986 // Theses actions should be in the app toolbar
4987
4988 QToolBar* bar = fToolbarApp;
4989 if (!fDefaultIcons) {
4990 bar = fToolbarUser;
4991 }
4992 if (!bar) return;
4993
4994 QList<QAction *> list = bar->actions ();
4995 for (G4int i = 0; i < list.size(); ++i) {
4996 if (list.at(i)->data().toString () == "wireframe") {
4997 list.at(i)->setChecked(TRUE);
4998 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
4999 list.at(i)->setChecked(FALSE);
5000 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5001 list.at(i)->setChecked(FALSE);
5002 } else if (list.at(i)->data().toString () == "solid") {
5003 list.at(i)->setChecked(FALSE);
5004 }
5005 }
5006}
5007
5008
5010 // Theses actions should be in the app toolbar
5011
5012 QToolBar* bar = fToolbarApp;
5013 if (!fDefaultIcons) {
5014 bar = fToolbarUser;
5015 }
5016 if (!bar) return;
5017
5018
5019 QList<QAction *> list = bar->actions ();
5020 for (G4int i = 0; i < list.size(); ++i) {
5021 if (list.at(i)->data().toString () == "hidden_line_removal") {
5022 list.at(i)->setChecked(TRUE);
5023 } else if (list.at(i)->data().toString () == "solid") {
5024 list.at(i)->setChecked(FALSE);
5025 } else if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5026 list.at(i)->setChecked(FALSE);
5027 } else if (list.at(i)->data().toString () == "wireframe") {
5028 list.at(i)->setChecked(FALSE);
5029 }
5030 }
5031}
5032
5033
5035 // Theses actions should be in the app toolbar
5036
5037 QToolBar* bar = fToolbarApp;
5038 if (!fDefaultIcons) {
5039 bar = fToolbarUser;
5040 }
5041
5042 if (!bar) return;
5043
5044 QList<QAction *> list = bar->actions ();
5045 for (G4int i = 0; i < list.size(); ++i) {
5046 if (list.at(i)->data().toString () == "hidden_line_and_surface_removal") {
5047 list.at(i)->setChecked(TRUE);
5048 } else if (list.at(i)->data().toString () == "solid") {
5049 list.at(i)->setChecked(FALSE);
5050 } else if (list.at(i)->data().toString () == "hidden_line_removal") {
5051 list.at(i)->setChecked(FALSE);
5052 } else if (list.at(i)->data().toString () == "wireframe") {
5053 list.at(i)->setChecked(FALSE);
5054 }
5055 }
5056}
5057
5058
5060 // Theses actions should be in the app toolbar
5061
5062 QToolBar* bar = fToolbarApp;
5063 if (!fDefaultIcons) {
5064 bar = fToolbarUser;
5065 }
5066 if (!bar) return;
5067
5068
5069 QList<QAction *> list = bar->actions ();
5070 for (G4int i = 0; i < list.size(); ++i) {
5071 if (list.at(i)->data().toString () == "perspective") {
5072 list.at(i)->setChecked(TRUE);
5073 } else if (list.at(i)->data().toString () == "ortho") {
5074 list.at(i)->setChecked(FALSE);
5075 }
5076 }
5077}
5078
5079
5080
5082 // Theses actions should be in the app toolbar
5083
5084 QToolBar* bar = fToolbarApp;
5085 if (!fDefaultIcons) {
5086 bar = fToolbarUser;
5087 }
5088
5089 if (!bar) return;
5090
5091 QList<QAction *> list = bar->actions ();
5092 for (G4int i = 0; i < list.size(); ++i) {
5093 if (list.at(i)->data().toString () == "ortho") {
5094 list.at(i)->setChecked(TRUE);
5095 } else if (list.at(i)->data().toString () == "perspective") {
5096 list.at(i)->setChecked(FALSE);
5097 }
5098 }
5099}
5100
5101
5102
5104QWidget* aParent,
5105G4int sizeX,
5106G4int sizeY
5107):QTabWidget(aParent)
5108 ,fTabSelected(false)
5109 ,fLastCreated(-1)
5110,fPreferedSizeX(sizeX+6) // margin left+right
5111,fPreferedSizeY(sizeY+58) // tab label height + margin left+right
5112{
5113 setMinimumSize(100,100);
5114 QSizePolicy policy = QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
5115 setSizePolicy(policy);
5116}
5117
5119):QTabWidget()
5120 ,fTabSelected(false)
5121 ,fLastCreated(-1)
5122,fPreferedSizeX(0)
5123,fPreferedSizeY(0)
5124{
5125}
5126
5127
5129QString text,
5130G4String origine,
5131G4String outputStream
5132):
5133 fText(text)
5134,fThread(origine)
5135{
5136 if (!GetOutputList().contains(QString(" ")+outputStream+" ")) {
5137 fOutputStream = "info";
5138 } else {
5139 fOutputStream = outputStream;
5140 }
5141}
5142
5143
5144#if QT_VERSION < 0x040500
5145void G4UIQt::TabCloseCallback(G4int){
5146#else
5147void G4UIQt::TabCloseCallback(G4int a){
5148#endif
5149#if QT_VERSION < 0x040500
5150#else
5151 if (fViewerTabWidget == NULL) return;
5152
5153 // get the address of the widget
5154 QWidget* temp = fViewerTabWidget->widget(a);
5155 // remove the tab
5156 fViewerTabWidget->removeTab (a);
5157
5158 // if last QWidget : Add empty string
5159 G4bool lastTab = true;
5160 for (G4int c=0; c<fViewerTabWidget->count(); ++c) {
5161 if (fViewerTabWidget->tabText(c).contains("viewer")) {
5162 lastTab = false;
5163 }
5164 }
5165
5166 if (lastTab) {
5167 CreateEmptyViewerPropertiesWidget();
5168 }
5169 // delete the widget
5170 delete temp;
5171#endif
5172}
5173
5174
5175void G4UIQt::ToolBoxActivated(G4int a){
5176
5177 if (fUITabWidget->widget(a) == fHelpTBWidget) {
5178 // Rebuild the help tree
5179 FillHelpTree();
5180 } else if (fUITabWidget->widget(a) == fSceneTreeWidget) {
5181#if QT_VERSION < 0x040200
5182 fSceneTreeWidget->show();
5183#else
5184 fSceneTreeWidget->setVisible(true);
5185#endif
5186 }
5187}
5188
5189
5191QPaintEvent *
5192)
5193{
5194
5195 if (currentWidget()) {
5196
5197 if ( isTabSelected()) {
5198
5199 // QCoreApplication::sendPostedEvents () ;
5200
5201 QString text = tabText (currentIndex());
5202
5203 if (fLastCreated == -1) {
5204 QTextEdit* edit = dynamic_cast<QTextEdit*>(currentWidget());
5205 if (!edit){
5206 QString paramSelect = QString("/vis/viewer/select ")+text;
5208 if(UI != NULL) {
5209 UI->ApplyCommand(paramSelect.toStdString().c_str());
5210 }
5211 }
5212 } else {
5213 fLastCreated = -1;
5214 }
5215 setTabSelected(false);
5216 }
5217 }
5218}
5219
5220
5222 QDockWidget(txt)
5223{}
5224
5225
5226void G4UIDockWidget::closeEvent(QCloseEvent *aEvent) {
5227 setFloating (false);
5228
5229 //prevent from closing
5230 aEvent->ignore();
5231 // hide them instead
5232 hide();
5233}
@ G4State_Quit
@ G4State_Abort
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
float G4float
Definition: G4Types.hh:84
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void * G4Interactor
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4String GetFullPrefixString() const
G4String GetPrefixString() const
void setLastTabCreated(G4int a)
Definition: G4UIQt.hh:91
void setTabSelected(G4bool a)
Definition: G4UIQt.hh:90
void paintEvent(QPaintEvent *event)
Definition: G4UIQt.cc:5190
Definition: G4Qt.hh:49
static G4Qt * getInstance()
Definition: G4Qt.cc:51
void FlushAndWaitExecution()
Definition: G4Qt.cc:186
static G4StateManager * GetStateManager()
G4UIDockWidget(QString txt)
Definition: G4UIQt.cc:5221
void closeEvent(QCloseEvent *)
Definition: G4UIQt.cc:5226
G4String fOutputStream
Definition: G4UIQt.hh:112
QString fText
Definition: G4UIQt.hh:110
G4String fThread
Definition: G4UIQt.hh:111
G4UIOutputString(QString text, G4String thread="", G4String outputstream="info")
Definition: G4UIQt.cc:5128
QString GetOutputList()
Definition: G4UIQt.hh:109
void SetIconPickSelected()
Definition: G4UIQt.cc:4868
G4bool AddTabWidget(QWidget *, QString)
Definition: G4UIQt.cc:1860
QWidget * GetViewerPropertiesWidget()
Definition: G4UIQt.cc:1788
void SetIconOrthoSelected()
Definition: G4UIQt.cc:5081
void SetStartPage(const std::string &)
Definition: G4UIQt.cc:1917
G4bool AddViewerTabFromFile(std::string fileName, std::string title)
Definition: G4UIQt.cc:1827
virtual void PauseSessionStart(const G4String &)
Definition: G4UIQt.cc:2050
void SetIconZoomInSelected()
Definition: G4UIQt.cc:4899
QWidget * GetSceneTreeWidget()
Definition: G4UIQt.cc:1780
void SetIconZoomOutSelected()
Definition: G4UIQt.cc:4930
void SetIconHLRSelected()
Definition: G4UIQt.cc:5009
void SetIconPerspectiveSelected()
Definition: G4UIQt.cc:5059
virtual G4int ReceiveG4cout(const G4String &)
Definition: G4UIQt.cc:2102
virtual G4int ReceiveG4cerr(const G4String &)
Definition: G4UIQt.cc:2195
G4UIsession * SessionStart()
Definition: G4UIQt.cc:1967
QWidget * GetPickInfosWidget()
Definition: G4UIQt.cc:1799
void SetIconSolidSelected()
Definition: G4UIQt.cc:4961
void DefaultIcons(G4bool aVal)
Definition: G4UIQt.cc:289
void NativeMenu(G4bool aVal)
Definition: G4UIQt.cc:2686
void SetIconRotateSelected()
Definition: G4UIQt.cc:4842
void SessionTerminate()
Definition: G4UIQt.cc:2032
void AddButton(const char *, const char *, const char *)
Definition: G4UIQt.cc:2354
~G4UIQt()
Definition: G4UIQt.cc:274
void ClearMenu()
Definition: G4UIQt.cc:2695
void AddMenu(const char *, const char *)
Definition: G4UIQt.cc:2333
void AddIcon(const char *userLabel, const char *iconFile, const char *command, const char *file_name="")
Definition: G4UIQt.cc:2429
void Prompt(G4String)
Definition: G4UIQt.cc:2021
void SetIconWireframeSelected()
Definition: G4UIQt.cc:4985
void SetIconMoveSelected()
Definition: G4UIQt.cc:4816
G4bool AddViewerTab(QWidget *w, std::string title)
Definition: G4UIQt.cc:1811
G4UIQt(G4int, char **)
Definition: G4UIQt.cc:115
void SetIconHLHSRSelected()
Definition: G4UIQt.cc:5034
void OutputStyle(const char *, const char *, const char *)
Definition: G4UIQt.cc:2667
G4int GetCommandEntry() const
const G4UIcommand * GetGuidance() const
G4UIcommand * GetCommand(G4int i)
const G4String & GetPathName() const
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
G4UIcommandTree * FindCommandTree(const char *commandPath)
const G4String GetTitle() const
G4String GetFirstMatchedString(const G4String &, const G4String &) const
G4UIcommand * FindPath(const char *commandPath) const
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:139
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:133
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:140
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:137
std::size_t GetGuidanceEntries() const
Definition: G4UIcommand.hh:129
const G4String & GetRange() const
Definition: G4UIcommand.hh:128
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:747
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
bool IsLastCommandOutputTreated()
Definition: G4UImanager.hh:256
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:845
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4MTcoutDestination * GetThreadCout()
Definition: G4UImanager.hh:249
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:190
void SetG4UIWindow(G4UIsession *const value)
Definition: G4UImanager.hh:191
void SetLastCommandOutputTreated()
Definition: G4UImanager.hh:257
const G4String & GetParameterCandidates() const
const G4String & GetParameterGuidance() const
G4bool IsOmittable() const
const G4String & GetParameterRange() const
G4bool GetCurrentAsDefault() const
char GetParameterType() const
const G4String & GetParameterName() const
const G4String & GetDefaultValue() const
G4String ModifyToFullPathCommand(const char *aCommandLine) const
G4String Complete(const G4String &)
void TerminalHelp(const G4String &)
void ApplyShellCommand(const G4String &, G4bool &, G4bool &)
void AddInteractor(G4String, G4Interactor)
G4Interactor GetInteractor(G4String)
G4Interactor GetMainInteractor()
static G4MTGLOB_DLL G4coutDestination * masterG4coutDestination
#define TRUE
Definition: globals.hh:41
#define FALSE
Definition: globals.hh:38
const char * name(G4int ptype)
void strip(G4String &str, char ch=' ')
Remove leading and trailing characters from string.
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.
G4String lstrip_copy(G4String str, char ch=' ')
Return copy of string with leading characters removed.
G4bool IsMasterThread()
Definition: G4Threading.cc:124