| [481] | 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 | //
|
|---|
| [1252] | 27 | // $Id: G4UIQt.hh,v 1.20 2010/05/19 07:18:50 lgarnier Exp $
|
|---|
| [1248] | 28 | // GEANT4 tag $Name: $
|
|---|
| [481] | 29 | //
|
|---|
| 30 | #ifndef G4UIQt_h
|
|---|
| 31 | #define G4UIQt_h
|
|---|
| 32 |
|
|---|
| [1156] | 33 | #if defined(G4UI_BUILD_QT_SESSION) || defined(G4UI_USE_QT)
|
|---|
| [481] | 34 |
|
|---|
| 35 | #include <map>
|
|---|
| 36 |
|
|---|
| 37 | #include "G4VBasicShell.hh"
|
|---|
| 38 | #include "G4VInteractiveSession.hh"
|
|---|
| 39 |
|
|---|
| [595] | 40 | #include <qobject.h>
|
|---|
| [697] | 41 | #include <qmap.h>
|
|---|
| [1224] | 42 | #include <qstringlist.h>
|
|---|
| [1236] | 43 | #include <qtabwidget.h>
|
|---|
| [490] | 44 |
|
|---|
| [593] | 45 | class QMainWindow;
|
|---|
| 46 | class QLineEdit;
|
|---|
| [481] | 47 | class G4UIsession;
|
|---|
| [603] | 48 | #if QT_VERSION < 0x040000
|
|---|
| 49 | class QListView;
|
|---|
| 50 | class QListViewItem;
|
|---|
| 51 | #else
|
|---|
| [593] | 52 | class QListWidget;
|
|---|
| [603] | 53 | class QTreeWidget;
|
|---|
| 54 | class QTreeWidgetItem;
|
|---|
| 55 | #endif
|
|---|
| [593] | 56 | class QTextEdit;
|
|---|
| 57 | class QLabel;
|
|---|
| [1223] | 58 | class QResizeEvent;
|
|---|
| 59 | class QToolBox;
|
|---|
| [1224] | 60 | class QStringList;
|
|---|
| [1236] | 61 | class QSplitter;
|
|---|
| [481] | 62 |
|
|---|
| 63 | // Class description :
|
|---|
| 64 | //
|
|---|
| [867] | 65 | // G4UIQt : class to handle a Qt interactive session.
|
|---|
| 66 | // G4UIQt is the Qt version of G4UIterminal.
|
|---|
| [481] | 67 | //
|
|---|
| 68 | // A command box is at disposal for entering/recalling Geant4 commands.
|
|---|
| 69 | // A menubar could be customized through the AddMenu, AddButton methods.
|
|---|
| 70 | // Note that there are corresponding Geant4 commands to add a
|
|---|
| 71 | // menus in the menubar and add buttons in a menu.
|
|---|
| 72 | // Ex :
|
|---|
| 73 | // /gui/addMenu test Test
|
|---|
| 74 | // /gui/addButton test Init /run/initialize
|
|---|
| 75 | // /gui/addButton test "Set gun" "/control/execute gun.g4m"
|
|---|
| 76 | // /gui/addButton test "Run one event" "/run/beamOn 1"
|
|---|
| 77 | //
|
|---|
| 78 | // Command completion, by typing "tab" key, is available on the
|
|---|
| 79 | // command line.
|
|---|
| 80 | //
|
|---|
| 81 | // Class description - end :
|
|---|
| 82 |
|
|---|
| [1236] | 83 | class G4QTabWidget : public QTabWidget {
|
|---|
| 84 | public :
|
|---|
| 85 | G4QTabWidget();
|
|---|
| 86 | G4QTabWidget(QSplitter*&);
|
|---|
| 87 | void paintEvent ( QPaintEvent * event );
|
|---|
| 88 | inline void setTabSelected() { tabSelected = true; };
|
|---|
| [1252] | 89 | inline void setLastTabCreated(int a) { lastCreated = a; };
|
|---|
| [1236] | 90 | inline void unselectTab() { tabSelected = false; };
|
|---|
| 91 | inline bool isTabSelected() { return tabSelected; };
|
|---|
| 92 | bool tabSelected;
|
|---|
| [1252] | 93 | int lastCreated;
|
|---|
| [1236] | 94 | };
|
|---|
| 95 |
|
|---|
| [490] | 96 | class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
|
|---|
| 97 | Q_OBJECT
|
|---|
| [488] | 98 |
|
|---|
| [481] | 99 | public: // With description
|
|---|
| [874] | 100 | G4UIQt(int,char**);
|
|---|
| [481] | 101 | // (argv, argc) or (0, NULL) had to be given.
|
|---|
| 102 | G4UIsession* SessionStart();
|
|---|
| 103 | // To enter interactive X loop ; waiting/executing command,...
|
|---|
| 104 | void AddMenu(const char*,const char*);
|
|---|
| 105 | // To add a pulldown menu in the menu bar.
|
|---|
| 106 | // First argument is the name of the menu.
|
|---|
| 107 | // Second argument is the label of the cascade button.
|
|---|
| 108 | // Ex : AddMenu("my_menu","My menu")
|
|---|
| 109 | void AddButton(const char*,const char*,const char*);
|
|---|
| 110 | // To add a push button in a pulldown menu.
|
|---|
| 111 | // First argument is the name of the menu.
|
|---|
| 112 | // Second argument is the label of the button.
|
|---|
| 113 | // Third argument is the Geant4 command executed when the button is fired.
|
|---|
| 114 | // Ex : AddButton("my_menu","Run","/run/beamOn 1");
|
|---|
| [1158] | 115 |
|
|---|
| [1232] | 116 | bool AddTabWidget(QWidget*,QString,int,int);
|
|---|
| [1158] | 117 | // To add a tab for vis openGL Qt driver
|
|---|
| [1232] | 118 |
|
|---|
| 119 | bool IsSplitterReleased();
|
|---|
| [1158] | 120 |
|
|---|
| [481] | 121 | public:
|
|---|
| 122 | ~G4UIQt();
|
|---|
| 123 | void Prompt(G4String);
|
|---|
| 124 | void SessionTerminate();
|
|---|
| 125 | void PauseSessionStart(G4String);
|
|---|
| 126 | G4int ReceiveG4cout(G4String);
|
|---|
| 127 | G4int ReceiveG4cerr(G4String);
|
|---|
| [516] | 128 | // G4String GetCommand(Widget);
|
|---|
| 129 |
|
|---|
| [481] | 130 | private:
|
|---|
| [506] | 131 | void SecondaryLoop(G4String); // a VIRER
|
|---|
| [1223] | 132 | void CreateHelpWidget();
|
|---|
| [1248] | 133 | void InitHelpTree();
|
|---|
| 134 | void FillHelpTree();
|
|---|
| [1224] | 135 | void ExitHelp();
|
|---|
| [697] | 136 |
|
|---|
| 137 | #if QT_VERSION < 0x040000
|
|---|
| [603] | 138 | void CreateChildTree(QListViewItem*,G4UIcommandTree*);
|
|---|
| 139 | QListViewItem* FindTreeItem(QListViewItem *,const QString&);
|
|---|
| 140 | #else
|
|---|
| [514] | 141 | void CreateChildTree(QTreeWidgetItem*,G4UIcommandTree*);
|
|---|
| [527] | 142 | QTreeWidgetItem* FindTreeItem(QTreeWidgetItem *,const QString&);
|
|---|
| [603] | 143 | #endif
|
|---|
| [524] | 144 |
|
|---|
| [527] | 145 | QString GetCommandList(const G4UIcommand*);
|
|---|
| [506] | 146 |
|
|---|
| [517] | 147 | G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell
|
|---|
| [528] | 148 | bool eventFilter(QObject*,QEvent*);
|
|---|
| [695] | 149 | void ActivateCommand(G4String);
|
|---|
| [697] | 150 | QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
|
|---|
| [514] | 151 |
|
|---|
| [1224] | 152 | void CreateVisParametersTBWidget();
|
|---|
| 153 | void CreateViewComponentsTBWidget();
|
|---|
| 154 | void CreateHelpTBWidget();
|
|---|
| 155 | void CreateCoutTBWidget();
|
|---|
| 156 | void CreateHistoryTBWidget();
|
|---|
| [1226] | 157 | void OpenHelpTreeOnCommand(const QString &);
|
|---|
| [1249] | 158 | QString GetShortCommandPath(QString);
|
|---|
| 159 | #if QT_VERSION < 0x040000
|
|---|
| 160 | QString GetLongCommandPath(QListViewItem*);
|
|---|
| 161 | #else
|
|---|
| 162 | QString GetLongCommandPath(QTreeWidgetItem*);
|
|---|
| 163 | #endif
|
|---|
| [695] | 164 |
|
|---|
| [481] | 165 | private:
|
|---|
| [488] | 166 |
|
|---|
| [481] | 167 | // Widget form,shell,command,menuBar,text;
|
|---|
| [504] | 168 | // std::map<QAction*,G4String, std::less<QAction*> > commands;
|
|---|
| [481] | 169 | // static void commandEnteredCallback(Widget,XtPointer,XtPointer);
|
|---|
| 170 | // static void keyHandler(Widget,XtPointer,XEvent*,Boolean*);
|
|---|
| [494] | 171 | QMainWindow * fMainWindow;
|
|---|
| 172 | QLabel *fCommandLabel;
|
|---|
| 173 | QLineEdit * fCommandArea;
|
|---|
| [1224] | 174 | QTextEdit *fCoutTBTextArea;
|
|---|
| [509] | 175 | QTextEdit *fHelpArea;
|
|---|
| [1223] | 176 | QToolBox* fToolBox;
|
|---|
| [1224] | 177 | QStringList fG4cout;
|
|---|
| 178 | QLineEdit * fCoutFilter;
|
|---|
| [1223] | 179 |
|
|---|
| [603] | 180 | #if QT_VERSION < 0x040000
|
|---|
| [1224] | 181 | QListView *fHistoryTBTableList;
|
|---|
| [603] | 182 | QListView *fHelpTreeWidget;
|
|---|
| 183 | #else
|
|---|
| [1224] | 184 | QListWidget *fHistoryTBTableList;
|
|---|
| [512] | 185 | QTreeWidget *fHelpTreeWidget;
|
|---|
| [603] | 186 | #endif
|
|---|
| [1224] | 187 | QWidget* fHelpTBWidget;
|
|---|
| 188 | QWidget* fHistoryTBWidget;
|
|---|
| 189 | QWidget* fCoutTBWidget;
|
|---|
| 190 | QWidget* fVisParametersTBWidget;
|
|---|
| 191 | QWidget* fViewComponentsTBWidget;
|
|---|
| [1239] | 192 | QLineEdit* fHelpLine;
|
|---|
| [1236] | 193 | G4QTabWidget* fTabWidget;
|
|---|
| [1163] | 194 | QString fCoutText;
|
|---|
| [1239] | 195 | QLabel *fEmptyViewerTabLabel;
|
|---|
| 196 | QSplitter * fMyVSplitter;
|
|---|
| [1248] | 197 | QSplitter * fHelpVSplitter;
|
|---|
| [1163] | 198 |
|
|---|
| [491] | 199 | private slots :
|
|---|
| [608] | 200 | void ExitSession();
|
|---|
| [526] | 201 | void ClearButtonCallback();
|
|---|
| 202 | void CommandEnteredCallback();
|
|---|
| 203 | void ButtonCallback(const QString&);
|
|---|
| [575] | 204 | void HelpTreeClicCallback();
|
|---|
| [648] | 205 | void HelpTreeDoubleClicCallback();
|
|---|
| [526] | 206 | void ShowHelpCallback();
|
|---|
| 207 | void CommandHistoryCallback();
|
|---|
| [1226] | 208 | void LookForHelpStringCallback();
|
|---|
| [1163] | 209 | void UpdateTabWidget(int);
|
|---|
| [1223] | 210 | void ResizeTabWidget( QResizeEvent* );
|
|---|
| [1224] | 211 | void CoutFilterCallback(const QString&);
|
|---|
| [1239] | 212 | void TabCloseCallback(int);
|
|---|
| [1248] | 213 | void ToolBoxActivated(int);
|
|---|
| [481] | 214 | };
|
|---|
| 215 |
|
|---|
| [490] | 216 | #endif
|
|---|
| [481] | 217 |
|
|---|
| 218 | #endif
|
|---|
| 219 |
|
|---|