Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4UIQt.hh
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// $Id$
28//
29#ifndef G4UIQt_h
30#define G4UIQt_h
31
32#if defined(G4UI_BUILD_QT_SESSION) || defined(G4UI_USE_QT)
33
34#include <map>
35
36#include "G4VBasicShell.hh"
38
39#include <qobject.h>
40#include <qmap.h>
41#include <qstringlist.h>
42#include <qtabwidget.h>
43
44class QMainWindow;
45class QLineEdit;
46class G4UIsession;
47class QListWidget;
48class QTreeWidget;
49class QTreeWidgetItem;
50class QTextEdit;
51class QLabel;
52class QResizeEvent;
53class QTabWidget;
54class QStringList;
55class QSplitter;
56class QToolBar;
57
58// Class description :
59//
60// G4UIQt : class to handle a Qt interactive session.
61// G4UIQt is the Qt version of G4UIterminal.
62//
63// A command box is at disposal for entering/recalling Geant4 commands.
64// A menubar could be customized through the AddMenu, AddButton, AddIcon methods.
65// Note that there are corresponding Geant4 commands to add a
66// menus in the menubar and add buttons in a menu.
67// Ex :
68// /gui/addMenu test Test
69// /gui/addButton test Init /run/initialize
70// /gui/addButton test "Set gun" "/control/execute gun.g4m"
71// /gui/addButton test "Run one event" "/run/beamOn 1"
72//
73// Command completion, by typing "tab" key, is available on the
74// command line.
75//
76// Class description - end :
77
78class G4QTabWidget : public QTabWidget {
79public :
80 G4QTabWidget();
81 G4QTabWidget(QSplitter*&);
82 void paintEvent ( QPaintEvent * event );
83 inline void setTabSelected(bool a) { tabSelected = a; };
84 inline void setLastTabCreated(int a) { lastCreated = a; };
85 inline bool isTabSelected() { return tabSelected; };
86 bool tabSelected;
87 int lastCreated;
88};
89
90class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
91 Q_OBJECT
92
93public: // With description
94 G4UIQt(int,char**);
95 // (argv, argc) or (0, NULL) had to be given.
97 // To enter interactive X loop ; waiting/executing command,...
98 void AddMenu(const char*,const char*);
99 // To add a pulldown menu in the menu bar.
100 // First argument is the name of the menu.
101 // Second argument is the label of the cascade button.
102 // Ex : AddMenu("my_menu","My menu")
103 void AddButton(const char*,const char*,const char*);
104 // To add a push button in a pulldown menu.
105 // First argument is the name of the menu.
106 // Second argument is the label of the button.
107 // Third argument is the Geant4 command executed when the button is fired.
108 // Ex : AddButton("my_menu","Run","/run/beamOn 1");
109 void AddIcon(const char* userLabel, const char* iconFile, const char* command, const char* file_name="");
110 // To add a icon in the toolbar
111 // First argument is the label of the icon.
112 // Second argument is the icon file.
113 // Third argument is the Geant4 command executed when the button is fired.
114 // Ex : AddButton("change background color","../background.xpm"," /vis/viewer/set/background");
115
116 bool AddTabWidget(QWidget*,QString,int,int);
117 // To add a tab for vis openGL Qt driver
118
119 QTabWidget* GetSceneTreeComponentsTBWidget();
120 // Get the viewComponent
121
122 bool IsSplitterReleased();
123
124 inline bool IsIconMoveSelected() {
125 return fMoveSelected;
126 };
127 inline bool IsIconRotateSelected() {
128 return fRotateSelected;
129 };
130 inline bool IsIconPickSelected() {
131 return fPickSelected;
132 };
133 inline bool IsIconZoomInSelected() {
134 return fZoomInSelected;
135 };
136 inline bool IsIconZoomOutSelected() {
137 return fZoomOutSelected;
138 };
139
140 void SetIconMoveSelected();
141 void SetIconRotateSelected();
142 void SetIconPickSelected();
143 void SetIconZoomInSelected();
144 void SetIconZoomOutSelected();
145 void SetIconHLHSRSelected();
146 void SetIconHLRSelected();
147 void SetIconSolidSelected();
148 void SetIconWireframeSelected();
149 void SetIconPerspectiveSelected();
150 void SetIconOrthoSelected();
151
152public:
153 ~G4UIQt();
154 void Prompt(G4String);
155 void SessionTerminate();
156 virtual void PauseSessionStart(const G4String&);
157 virtual G4int ReceiveG4cout(const G4String&);
158 virtual G4int ReceiveG4cerr(const G4String&);
159 // G4String GetCommand(Widget);
160
161private:
162 void SecondaryLoop(G4String); // a VIRER
163 void CreateHelpWidget();
164 void InitHelpTreeAndVisParametersWidget();
165 void FillHelpTree();
166 virtual void ExitHelp() const;
167
168 void CreateHelpTree(QTreeWidgetItem*,G4UIcommandTree*);
169 QTreeWidgetItem* FindTreeItem(QTreeWidgetItem *,const QString&);
170
171 QString GetCommandList(const G4UIcommand*);
172
173 virtual G4bool GetHelpChoice(G4int&);// have to be implemeted because we heritate from G4VBasicShell
174 bool eventFilter(QObject*,QEvent*);
175 void ActivateCommand(G4String);
176 QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
177
178 void CreateVisParametersTBWidget();
179 void CreateHelpTBWidget();
180 void CreateCoutTBWidget();
181 void CreateHistoryTBWidget();
182 void OpenHelpTreeOnCommand(const QString &);
183 QString GetShortCommandPath(QString);
184 QString GetLongCommandPath(QTreeWidgetItem*);
185 G4bool IsGUICommand(const G4UIcommand*);
186 bool CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool isDialog);
187 bool CreateCommandWidget(G4UIcommand* command, QWidget* parent, bool isDialog);
188
189private:
190
191 QMainWindow * fMainWindow;
192 QLabel *fCommandLabel;
193 QLineEdit * fCommandArea;
194 QTextEdit *fCoutTBTextArea;
195 QTextEdit *fHelpArea;
196 QTabWidget* fUITabWidget;
197 QStringList fG4cout;
198 QLineEdit * fCoutFilter;
199
200 QListWidget *fHistoryTBTableList;
201 QTreeWidget *fHelpTreeWidget;
202 QWidget* fHelpTBWidget;
203 QWidget* fHistoryTBWidget;
204 QWidget* fCoutTBWidget;
205 QTabWidget* fSceneTreeComponentsTBWidget;
206 QLineEdit* fHelpLine;
207 G4QTabWidget* fViewerTabWidget;
208 QString fCoutText;
209 QLabel *fEmptyViewerTabLabel;
210 QSplitter * fMainSplitterWidget;
211 QSplitter* fRightSplitterWidget;
212 QSplitter * fHelpVSplitter;
213 int fLastQTabSizeX;
214 int fLastQTabSizeY;
215
216 QToolBar *fToolbarApp;
217 QToolBar *fToolbarUser;
218
219 bool fMoveSelected;
220 bool fRotateSelected;
221 bool fPickSelected;
222 bool fZoomInSelected;
223 bool fZoomOutSelected;
224
225private Q_SLOTS :
226 void ExitSession();
227 void ClearButtonCallback();
228 void CommandEnteredCallback();
229 void ButtonCallback(const QString&);
230 void HelpTreeClicCallback();
231 void HelpTreeDoubleClicCallback();
232 void ShowHelpCallback();
233 void CommandHistoryCallback();
234 void LookForHelpStringCallback();
235 void UpdateTabWidget(int);
236 void ResizeTabWidget( QResizeEvent* );
237 void CoutFilterCallback(const QString&);
238 void TabCloseCallback(int);
239 void ToolBoxActivated(int);
240 void VisParameterCallback(QWidget*);
241 void ChangeColorCallback(QWidget*);
242 void ChangeCursorStyle(const QString&);
243 void ChangeSurfaceStyle(const QString&);
244 void OpenIconCallback(const QString&);
245 void SaveIconCallback(const QString&);
246 void ChangePerspectiveOrtho(const QString&);
247};
248
249#endif
250
251#endif
252
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
virtual G4int ReceiveG4cout(const G4String &coutString)
Definition: G4UIsession.cc:42
virtual G4int ReceiveG4cerr(const G4String &cerrString)
Definition: G4UIsession.cc:48
virtual void PauseSessionStart(const G4String &Prompt)=0
virtual G4UIsession * SessionStart()=0
virtual void ExitHelp() const =0
virtual G4bool GetHelpChoice(G4int &)=0
virtual void AddMenu(const char *, const char *)
virtual void AddIcon(const char *, const char *, const char *, const char *)
virtual void AddButton(const char *, const char *, const char *)