source: trunk/source/interfaces/basic/include/G4UIQt.hh @ 1236

Last change on this file since 1236 was 1236, checked in by garnier, 15 years ago

debug mode

  • Property svn:mime-type set to text/cpp
File size: 6.8 KB
RevLine 
[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//
[1228]27// $Id: G4UIQt.hh,v 1.17 2010/01/06 14:13:08 lgarnier Exp $
28// GEANT4 tag $Name: laurent-QtUI_with_tabs_v1 $
[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]45class QMainWindow;
46class QLineEdit;
[481]47class G4UIsession;
[603]48#if QT_VERSION < 0x040000
49class QListView;
50class QListViewItem;
51#else
[593]52class QListWidget;
[603]53class QTreeWidget;
54class QTreeWidgetItem;
55#endif
[593]56class QTextEdit;
57class QLabel;
[1223]58class QResizeEvent;
59class QToolBox;
[1224]60class QStringList;
[1236]61class 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]83class G4QTabWidget : public QTabWidget {
84public :
85  G4QTabWidget();
86  G4QTabWidget(QSplitter*&);
87  void paintEvent  ( QPaintEvent * event );
88  inline void setTabSelected() { tabSelected = true; };
89  inline void unselectTab() { tabSelected = false; };
90  inline bool isTabSelected() { return tabSelected; };
91  bool tabSelected;
92};
93
[490]94class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
95  Q_OBJECT
[488]96
[481]97public: // With description
[874]98  G4UIQt(int,char**);
[481]99  // (argv, argc) or (0, NULL) had to be given.
100  G4UIsession* SessionStart();
101  // To enter interactive X loop ; waiting/executing command,...
102  void AddMenu(const char*,const char*);
103  // To add a pulldown menu in the menu bar.
104  // First argument is the name of the menu.
105  // Second argument is the label of the cascade button.
106  // Ex : AddMenu("my_menu","My menu")
107  void AddButton(const char*,const char*,const char*);
108  // To add a push button in a pulldown menu.
109  // First argument is the name of the menu.
110  // Second argument is the label of the button.
111  // Third argument is the Geant4 command executed when the button is fired.
112  // Ex : AddButton("my_menu","Run","/run/beamOn 1");
[1158]113
[1232]114  bool AddTabWidget(QWidget*,QString,int,int);
[1158]115  // To add a tab for vis openGL Qt driver
[1232]116 
117  bool IsSplitterReleased();
[1158]118
[481]119public:
120  ~G4UIQt();
121  void Prompt(G4String);
122  void SessionTerminate();
123  void PauseSessionStart(G4String);
124  G4int ReceiveG4cout(G4String);
125  G4int ReceiveG4cerr(G4String);
[516]126  //   G4String GetCommand(Widget);
127
[481]128private:
[506]129  void SecondaryLoop(G4String); // a VIRER
[1223]130  void CreateHelpWidget();
[603]131#if QT_VERSION < 0x040000
[697]132  QListView * CreateHelpTree();
133#else
134  QTreeWidget * CreateHelpTree();
135#endif
[1224]136  void ExitHelp();
[697]137
138#if QT_VERSION < 0x040000
[603]139  void CreateChildTree(QListViewItem*,G4UIcommandTree*);
140  QListViewItem* FindTreeItem(QListViewItem *,const QString&);
141#else
[514]142  void CreateChildTree(QTreeWidgetItem*,G4UIcommandTree*);
[527]143  QTreeWidgetItem* FindTreeItem(QTreeWidgetItem *,const QString&);
[603]144#endif
[524]145
[527]146  QString GetCommandList(const G4UIcommand*);
[506]147
[517]148  G4bool GetHelpChoice(G4int&) ;// have to be implemeted because we heritate from G4VBasicShell
[528]149  bool eventFilter(QObject*,QEvent*);
[695]150  void ActivateCommand(G4String);
[697]151  QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
[514]152
[1224]153  void CreateVisParametersTBWidget();
154  void CreateViewComponentsTBWidget();
155  void CreateHelpTBWidget();
156  void CreateCoutTBWidget();
157  void CreateHistoryTBWidget();
[1226]158  void OpenHelpTreeOnCommand(const QString &);
[695]159
[481]160private:
[488]161
[481]162  //  Widget form,shell,command,menuBar,text;
[504]163  //  std::map<QAction*,G4String, std::less<QAction*> > commands;
[481]164  //  static void commandEnteredCallback(Widget,XtPointer,XtPointer);
165  //  static void keyHandler(Widget,XtPointer,XEvent*,Boolean*);
[494]166  QMainWindow * fMainWindow;
167  QLabel *fCommandLabel;
168  QLineEdit * fCommandArea;
[1224]169  QTextEdit *fCoutTBTextArea;
[509]170  QTextEdit *fHelpArea;
[1223]171  QToolBox* fToolBox;
[1224]172  QStringList fG4cout;
173  QLineEdit * fCoutFilter;
[1223]174
[603]175#if QT_VERSION < 0x040000
[1224]176  QListView *fHistoryTBTableList;
[603]177  QListView *fHelpTreeWidget;
178#else
[1224]179  QListWidget *fHistoryTBTableList;
[512]180  QTreeWidget *fHelpTreeWidget;
[603]181#endif
[1224]182  QWidget* fHelpTBWidget;
183  QWidget* fHistoryTBWidget;
184  QWidget* fCoutTBWidget;
185  QWidget* fVisParametersTBWidget;
186  QWidget* fViewComponentsTBWidget;
187  QLineEdit* helpLine;
[1236]188  G4QTabWidget* fTabWidget;
[1163]189  QString fCoutText;
190
[504]191signals :
[1236]192  void refreshTab(const QString &text);
[504]193
[491]194private slots :
[608]195  void ExitSession();
[526]196  void ClearButtonCallback();
197  void CommandEnteredCallback();
198  void ButtonCallback(const QString&);
[575]199  void HelpTreeClicCallback();
[648]200  void HelpTreeDoubleClicCallback();
[526]201  void ShowHelpCallback();
202  void CommandHistoryCallback();
[1226]203  void LookForHelpStringCallback();
[1163]204  void UpdateTabWidget(int);
[1223]205  void ResizeTabWidget( QResizeEvent* );
[1224]206  void CoutFilterCallback(const QString&);
[1236]207  void RefreshTabCallback (const QString&);
208
[481]209};
210
[1236]211
[490]212#endif
[481]213
214#endif
215
Note: See TracBrowser for help on using the repository browser.