00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4UIQt.hh,v 1.13 2006/06/29 19:09:33 gunter Exp $ 00028 // GEANT4 tag $Name: geant4-08-01 $ 00029 // 00030 #ifndef G4UIQt_h 00031 #define G4UIQt_h 00032 00033 #if defined(G4UI_BUILD_QT_SESSION) || defined(G4UI_USE_QT) 00034 00035 #include <map> 00036 00037 #include "G4VBasicShell.hh" 00038 #include "G4VInteractiveSession.hh" 00039 00040 #include <QtGui/qmainwindow.h> 00041 #include <QtGui/qlineedit.h> 00042 #include <QtGui/qlistwidget.h> 00043 #include <QtGui/qtextedit.h> 00044 #include <QtGui/qlabel.h> 00045 #include <QtGui/qtreewidget.h> 00046 #include <QSignalMapper.h> 00047 #include <QObject> 00048 00049 class G4UIsession; 00050 00051 00052 // Class description : 00053 // 00054 // G4UIQt : class to handle a Motif interactive session. 00055 // G4UIQt is the Motif version of G4UIterminal. 00056 // 00057 // A command box is at disposal for entering/recalling Geant4 commands. 00058 // A menubar could be customized through the AddMenu, AddButton methods. 00059 // Note that there are corresponding Geant4 commands to add a 00060 // menus in the menubar and add buttons in a menu. 00061 // Ex : 00062 // /gui/addMenu test Test 00063 // /gui/addButton test Init /run/initialize 00064 // /gui/addButton test "Set gun" "/control/execute gun.g4m" 00065 // /gui/addButton test "Run one event" "/run/beamOn 1" 00066 // 00067 // Command completion, by typing "tab" key, is available on the 00068 // command line. 00069 // 00070 // Class description - end : 00071 00072 class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession { 00073 Q_OBJECT 00074 00075 public: // With description 00076 G4UIQt(int,char**); 00077 // (argv, argc) or (0, NULL) had to be given. 00078 G4UIsession* SessionStart(); 00079 // To enter interactive X loop ; waiting/executing command,... 00080 void AddMenu(const char*,const char*); 00081 // To add a pulldown menu in the menu bar. 00082 // First argument is the name of the menu. 00083 // Second argument is the label of the cascade button. 00084 // Ex : AddMenu("my_menu","My menu") 00085 void AddButton(const char*,const char*,const char*); 00086 // To add a push button in a pulldown menu. 00087 // First argument is the name of the menu. 00088 // Second argument is the label of the button. 00089 // Third argument is the Geant4 command executed when the button is fired. 00090 // Ex : AddButton("my_menu","Run","/run/beamOn 1"); 00091 public: 00092 ~G4UIQt(); 00093 void Prompt(G4String); 00094 void SessionTerminate(); 00095 void PauseSessionStart(G4String); 00096 G4int ReceiveG4cout(G4String); 00097 G4int ReceiveG4cerr(G4String); 00098 // G4String GetCommand(Widget); 00099 00100 private: 00101 void SecondaryLoop(G4String); // a VIRER 00102 void TerminalHelp(G4String); 00103 void CreateChildTree(QTreeWidgetItem*,G4UIcommandTree*); 00104 QString GetCommandList(G4UIcommand*); 00105 00106 G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell 00107 void ExitHelp();// have to be implemeted because we heritate from G4VBasicShell 00108 bool eventFilter(QObject*,QEvent*); 00109 00110 private: 00111 00112 // Widget form,shell,command,menuBar,text; 00113 // std::map<QAction*,G4String, std::less<QAction*> > commands; 00114 // static void commandEnteredCallback(Widget,XtPointer,XtPointer); 00115 // static void keyHandler(Widget,XtPointer,XEvent*,Boolean*); 00116 QMainWindow * fMainWindow; 00117 QLabel *fCommandLabel; 00118 QLineEdit * fCommandArea; 00119 QTextEdit *fTextArea; 00120 QTextEdit *fHelpArea; 00121 QListWidget *fCommandHistoryArea; 00122 QSignalMapper *signalMapper ; 00123 QTreeWidget *fHelpTreeWidget; 00124 QDialog *fHelpDialog; 00125 00126 signals : 00127 void myClicked(const QString &text); 00128 00129 private slots : 00130 void clearButtonCallback(); 00131 void commandEnteredCallback(); 00132 void buttonCallback(const QString&); 00133 void helpTreeCallback(); 00134 void showHelpCallback(); 00135 void commandHistoryCallback(); 00136 }; 00137 00138 #endif 00139 00140 #endif 00141