[989] | 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 | // $Id: G4UIWt.hh,v 1.12 2008/03/10 17:03:16 lgarnier Exp $ |
---|
| 28 | // GEANT4 tag $Name: HEAD $ |
---|
| 29 | // |
---|
| 30 | #ifndef G4UIWt_h |
---|
| 31 | #define G4UIWt_h |
---|
| 32 | |
---|
| 33 | //#define G4UI_BUILD_WT_SESSION |
---|
| 34 | |
---|
| 35 | #if defined(G4UI_BUILD_WT_SESSION) || defined(G4UI_USE_WT) |
---|
| 36 | |
---|
| 37 | #include <map> |
---|
| 38 | |
---|
| 39 | #include "G4VBasicShell.hh" |
---|
| 40 | #include "G4VInteractiveSession.hh" |
---|
| 41 | |
---|
| 42 | // Undef the wt SLOT if already define |
---|
| 43 | #ifdef SLOT |
---|
| 44 | # undef SLOT |
---|
| 45 | # undef signals |
---|
| 46 | # undef slots |
---|
| 47 | #endif |
---|
| 48 | |
---|
| 49 | #include <qobject.h> |
---|
| 50 | |
---|
| 51 | namespace Wt { |
---|
| 52 | class WString; |
---|
| 53 | class WComboBox; |
---|
| 54 | class WTree; |
---|
| 55 | class WTreeNode; |
---|
| 56 | class WTreeTable; |
---|
| 57 | class WTextEdit; |
---|
| 58 | class WLabel; |
---|
| 59 | class WDialog; |
---|
| 60 | class WEnvironment; |
---|
| 61 | namespace Ext { |
---|
| 62 | class Panel; |
---|
| 63 | class ToolBar; |
---|
| 64 | class LineEdit; |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | class G4UIsession; |
---|
| 69 | class QEvent; |
---|
| 70 | // #if WT_VERSION < 0x040000 |
---|
| 71 | // class WListView; |
---|
| 72 | // class WListViewItem; |
---|
| 73 | // #else |
---|
| 74 | // #endif |
---|
| 75 | |
---|
| 76 | // Class description : |
---|
| 77 | // |
---|
| 78 | // G4UIWt : class to handle a Motif interactive session. |
---|
| 79 | // G4UIWt is the Motif version of G4UIterminal. |
---|
| 80 | // |
---|
| 81 | // A command box is at disposal for entering/recalling Geant4 commands. |
---|
| 82 | // A menubar could be customized through the AddMenu, AddButton methods. |
---|
| 83 | // Note that there are corresponding Geant4 commands to add a |
---|
| 84 | // menus in the menubar and add buttons in a menu. |
---|
| 85 | // Ex : |
---|
| 86 | // /gui/addMenu test Test |
---|
| 87 | // /gui/addButton test Init /run/initialize |
---|
| 88 | // /gui/addButton test "Set gun" "/control/execute gun.g4m" |
---|
| 89 | // /gui/addButton test "Run one event" "/run/beamOn 1" |
---|
| 90 | // |
---|
| 91 | // Command completion, by typing "tab" key, is available on the |
---|
| 92 | // command line. |
---|
| 93 | // |
---|
| 94 | // Class description - end : |
---|
| 95 | |
---|
| 96 | class G4UIWt : public QObject, public G4VBasicShell, public G4VInteractiveSession { |
---|
| 97 | Q_OBJECT |
---|
| 98 | |
---|
| 99 | public: // With description |
---|
| 100 | G4UIWt( const Wt::WEnvironment& env); |
---|
| 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"); |
---|
| 115 | public: |
---|
| 116 | ~G4UIWt(); |
---|
| 117 | void Prompt(G4String); |
---|
| 118 | void SessionTerminate(); |
---|
| 119 | void PauseSessionStart(G4String); |
---|
| 120 | G4int ReceiveG4cout(G4String); |
---|
| 121 | G4int ReceiveG4cerr(G4String); |
---|
| 122 | // G4String GetCommand(Widget); |
---|
| 123 | |
---|
| 124 | private: |
---|
| 125 | void SecondaryLoop(G4String); // a VIRER |
---|
| 126 | void TerminalHelp(G4String); |
---|
| 127 | // #if WT_VERSION < 0x040000 |
---|
| 128 | // WListView * CreateHelpTree(); |
---|
| 129 | // #else |
---|
| 130 | Wt::WTreeTable* CreateHelpTree(); |
---|
| 131 | // #endif |
---|
| 132 | |
---|
| 133 | // #if WT_VERSION < 0x040000 |
---|
| 134 | // void CreateChildTree(WListViewItem*,G4UIcommandTree*); |
---|
| 135 | // WListViewItem* FindTreeItem(WListViewItem *,const WString&); |
---|
| 136 | // #else |
---|
| 137 | void CreateChildTree(Wt::WTreeNode*,G4UIcommandTree*); |
---|
| 138 | Wt::WTreeNode* FindTreeItem(Wt::WTreeNode *,const Wt::WString &); |
---|
| 139 | // #endif |
---|
| 140 | |
---|
| 141 | Wt::WString GetCommandList(const G4UIcommand*); |
---|
| 142 | |
---|
| 143 | G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell |
---|
| 144 | void ExitHelp();// have to be implemeted because we heritate from G4VBasicShell |
---|
| 145 | bool eventFilter(QObject*,QEvent*); |
---|
| 146 | void ActivateCommand(G4String); |
---|
| 147 | std::map<int,Wt::WString> LookForHelpStringInChildTree(G4UIcommandTree *,const Wt::WString&); |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | private: |
---|
| 151 | |
---|
| 152 | // Widget form,shell,command,menuBar,text; |
---|
| 153 | // std::map<WAction*,G4String, std::less<WAction*> > commands; |
---|
| 154 | // static void commandEnteredCallback(Widget,XtPointer,XtPointer); |
---|
| 155 | // static void keyHandler(Widget,XtPointer,XEvent*,Boolean*); |
---|
| 156 | Wt::Ext::Panel* fMainWindow; |
---|
| 157 | Wt::WLabel *fCommandLabel; |
---|
| 158 | Wt::Ext::LineEdit * fCommandArea; |
---|
| 159 | Wt::WTextEdit *fTextArea; |
---|
| 160 | Wt::WTextEdit *fHelpArea; |
---|
| 161 | // #if WT_VERSION < 0x040000 |
---|
| 162 | // WListView *fCommandHistoryArea; |
---|
| 163 | // WListView *fHelpTreeWidget; |
---|
| 164 | // #else |
---|
| 165 | Wt::WComboBox *fCommandHistoryArea; |
---|
| 166 | Wt::WTreeTable *fHelpTreeWidget; |
---|
| 167 | // #endif |
---|
| 168 | Wt::Ext::Panel *fHelpDialog; |
---|
| 169 | Wt::Ext::LineEdit *fHelpLine; |
---|
| 170 | Wt::Ext::ToolBar *fToolBar; |
---|
| 171 | |
---|
| 172 | signals : |
---|
| 173 | void myClicked(const Wt::WString &text); |
---|
| 174 | |
---|
| 175 | private slots : |
---|
| 176 | void ExitSession(); |
---|
| 177 | void ClearButtonCallback(); |
---|
| 178 | void CommandEnteredCallback(); |
---|
| 179 | void ButtonCallback(const Wt::WString&); |
---|
| 180 | void HelpTreeClicCallback(); |
---|
| 181 | void HelpTreeDoubleClicCallback(); |
---|
| 182 | void ShowHelpCallback(); |
---|
| 183 | void CommandHistoryCallback(); |
---|
| 184 | void lookForHelpStringCallback(); |
---|
| 185 | }; |
---|
| 186 | |
---|
| 187 | #endif |
---|
| 188 | |
---|
| 189 | #endif |
---|
| 190 | |
---|