Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UIQt.hh
이 파일의 문서화 페이지로 가기
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: G4UIQt.hh 108356 2018-02-08 09:11:28Z gcosmo $
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"
37 #include "G4VInteractiveSession.hh"
38 
39 #include <qobject.h>
40 #include <qmap.h>
41 #include <qstringlist.h>
42 #include <qtabwidget.h>
43 #include <qdockwidget.h>
44 #include <qdialog.h>
45 
46 class QMainWindow;
47 class QLineEdit;
48 class G4UIsession;
49 class QListWidget;
50 class QTreeWidget;
51 class QTreeWidgetItem;
52 class QTextEdit;
53 class QLabel;
54 class QResizeEvent;
55 class QTabWidget;
56 class QStringList;
57 class QSplitter;
58 class QToolBar;
59 class QTableWidget;
60 class QPixmap;
61 class QComboBox;
62 class QCompleter;
63 class QtGlobal;
64 class QStandardItemModel;
65 class QToolButton;
66 
67 // Class description :
68 //
69 // G4UIQt : class to handle a Qt interactive session.
70 // G4UIQt is the Qt version of G4UIterminal.
71 //
72 // A command box is at disposal for entering/recalling Geant4 commands.
73 // A menubar could be customized through the AddMenu, AddButton, AddIcon methods.
74 // Note that there are corresponding Geant4 commands to add a
75 // menus in the menubar and add buttons in a menu.
76 // Ex :
77 // /gui/addMenu test Test
78 // /gui/addButton test Init /run/initialize
79 // /gui/addButton test "Set gun" "/control/execute gun.g4m"
80 // /gui/addButton test "Run one event" "/run/beamOn 1"
81 //
82 // Command completion, by typing "tab" key, is available on the
83 // command line.
84 //
85 // Class description - end :
86 
87 class G4QTabWidget : public QTabWidget {
88 public :
89  G4QTabWidget();
90  G4QTabWidget(QWidget* aParent, int sizeX, int sizeY);
91  void paintEvent ( QPaintEvent * event );
92  inline void setTabSelected(bool a) { fTabSelected = a; };
93  inline void setLastTabCreated(int a) { fLastCreated = a; };
94  inline bool isTabSelected() { return fTabSelected; };
95  bool fTabSelected;
96  int fLastCreated;
97  int fPreferedSizeX;
98  int fPreferedSizeY;
99  inline void setPreferredSize(QSize s) {
100  fPreferedSizeX = s.width() + 6; // tab label height + margin left+right
101  fPreferedSizeY = s.height() + 58; // margin left+right
102  }
103  inline QSize sizeHint () const {
104  return QSize(fPreferedSizeX, fPreferedSizeY);
105  }
106 };
107 
108 class G4UIOutputString {
109  public :
110  G4UIOutputString(QString text,G4String thread = "",G4String outputstream= "info");
111  inline QString GetOutputList() { return " all info warning error ";};
112  QString fText;
113  G4String fThread;
114  G4String fOutputStream; // Error, Warning, Info
115 };
116 
117 
118 class G4UIDockWidget : public QDockWidget {
119 public:
120  G4UIDockWidget(QString txt);
121  void closeEvent(QCloseEvent *);
122 };
123 
124 
125 class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
126  Q_OBJECT
127 
128 public: // With description
129  G4UIQt(int,char**);
130  // (argv, argc) or (0, NULL) had to be given.
132  // To enter interactive X loop ; waiting/executing command,...
133  void AddMenu(const char*,const char*);
134  // To add a pulldown menu in the menu bar.
135  // First argument is the name of the menu.
136  // Second argument is the label of the cascade button.
137  // Ex : AddMenu("my_menu","My menu")
138  void AddButton(const char*,const char*,const char*);
139  // To add a push button in a pulldown menu.
140  // First argument is the name of the menu.
141  // Second argument is the label of the button.
142  // Third argument is the Geant4 command executed when the button is fired.
143  // Ex : AddButton("my_menu","Run","/run/beamOn 1");
144  void AddIcon(const char* userLabel, const char* iconFile, const char* command, const char* file_name="");
145  // To add a icon in the toolbar
146  // First argument is the label of the icon.
147  // Second argument is the selected icon type (open save move rotate pick zoom_in zoom_out wireframe solid hidden_line_removal hidden_line_and_surface_removal perspective ortho user_icon).
148  // Third argument is the Geant4 command executed when the button is fired.
149  // Fourth argument is the path to the icon file if "user_icon" selected
150  // Ex : AddButton("change background color","../background.xpm"," /vis/viewer/set/background");
151 
152  void DefaultIcons(bool aVal);
153  // Enable/Disable the default icon ToolBar in Qt
154 
155  bool AddTabWidget(QWidget*,QString);
156  // To add a tab for vis openGL Qt driver
157 
158  inline QTabWidget* GetViewerTabWidget() {
159  return fViewerTabWidget;
160  };
161 
162  QWidget* GetSceneTreeWidget();
163  // Get the scene tree component
164 
165  QWidget* GetViewerPropertiesWidget();
166  // Get the Viewer Properties Widget
167 
168  QWidget* GetPickInfosWidget();
169  // Get the Pick Widget
170 
171  bool IsSplitterReleased();
172 
173  inline bool IsIconMoveSelected() {
174  return fMoveSelected;
175  };
176  inline bool IsIconRotateSelected() {
177  return fRotateSelected;
178  };
179  inline bool IsIconPickSelected() {
180  return fPickSelected;
181  };
182  inline bool IsIconZoomInSelected() {
183  return fZoomInSelected;
184  };
185  inline bool IsIconZoomOutSelected() {
186  return fZoomOutSelected;
187  };
188 
189  void SetIconMoveSelected();
190  void SetIconRotateSelected();
191  void SetIconPickSelected();
192  void SetIconZoomInSelected();
193  void SetIconZoomOutSelected();
194  void SetIconHLHSRSelected();
195  void SetIconHLRSelected();
196  void SetIconSolidSelected();
197  void SetIconWireframeSelected();
198  void SetIconPerspectiveSelected();
199  void SetIconOrthoSelected();
200 
201  inline QMainWindow * GetMainWindow() {
202  return fMainWindow;
203  };
204  // Return the main window
205 
206  inline QPixmap* getSearchIcon() { return fSearchIcon;};
207  // return the "search" icon pixmap
208  inline QPixmap* getClearIcon() { return fClearIcon;};
209  // return the "clear" icon pixmap
210 
211  void SetStartPage(const std::string&);
212  // Set the text on the first page of the viewer. If "", will take the last value as default
213  // Note: Qt Rich text format could be used, see link for example :
214  // https://qt-project.org/doc/qt-4.8/richtext-html-subset.html#table-cell-attributes
215 
216  inline QWidget* GetCoutWidget() {
217  return fCoutDockWidget->widget();
218  };
219  // Return the G4cout widget with filters
220 
221  inline G4UIDockWidget* GetCoutDockWidget() {
222  return fCoutDockWidget;
223  };
224  // Return the cout dockable widget as a QDockWidget
225 
226  inline G4UIDockWidget* GetUserInterfaceWidget() {
227  return fUIDockWidget;
228  };
229  // Return the UserInterface widget (including scene tree, help and History widgets)
230 
231  inline QTabWidget* GetUITabWidget() {
232  return fUITabWidget;
233  }
234  // return the viewer widget including all viewers
235 
236  inline QWidget* GetHistoryWidget() {
237  return fHistoryTBWidget;
238  }
239  // return the history widget
240 
241  inline QWidget* GetHelpWidget() {
242  return fHelpTBWidget;
243  }
244  // return the help widget
245 
246  bool AddViewerTab(QWidget* w, std::string title);
247  // Add a new tab in the viewer, could be used to add your own component
248 
249  bool AddViewerTabFromFile(std::string fileName, std::string title);
250  // Add a new tab in the viewer containing the content of the file in a QLabel
251 
252 public:
253  ~G4UIQt();
254  void Prompt(G4String);
255  void SessionTerminate();
256  virtual void PauseSessionStart(const G4String&);
257  virtual G4int ReceiveG4cout(const G4String&);
258  virtual G4int ReceiveG4cerr(const G4String&);
259  // G4String GetCommand(Widget);
260 
261 private:
262  void SecondaryLoop(G4String); // a VIRER
263  void CreateHelpWidget();
264  void InitHelpTreeAndVisParametersWidget();
265  void FillHelpTree();
266  void UpdateCommandCompleter();
267  void CreateIcons();
268  virtual void ExitHelp() const;
269  void SetDefaultIconsToolbar();
270 
271  void CreateHelpTree(QTreeWidgetItem*,G4UIcommandTree*);
272  QTreeWidgetItem* FindTreeItem(QTreeWidgetItem *,const QString&);
273 
274  QString GetCommandList(const G4UIcommand*);
275  void updateHelpArea(const G4UIcommand*);
276  virtual G4bool GetHelpChoice(G4int&);// have to be implemeted because we heritate from G4VBasicShell
277  bool eventFilter(QObject*,QEvent*);
278  void ActivateCommand(G4String);
279  QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
280 
281  QWidget* CreateVisParametersTBWidget();
282  QWidget* CreateHelpTBWidget();
283  G4UIDockWidget* CreateCoutTBWidget();
284  QWidget* CreateHistoryTBWidget();
285  G4UIDockWidget* CreateUITabWidget();
286  QWidget* CreateSceneTreeWidget();
287  void CreateViewerWidget();
288  void OpenHelpTreeOnCommand(const QString &);
289  QString GetShortCommandPath(QString);
290  QString GetLongCommandPath(QTreeWidgetItem*);
291  G4bool IsGUICommand(const G4UIcommand*);
292  bool CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool isDialog);
293  bool CreateCommandWidget(G4UIcommand* command, QWidget* parent, bool isDialog);
294  void CreateViewerPropertiesDialog();
295  void CreatePickInfosDialog();
296 #ifdef G4MULTITHREADED
297  void UpdateCoutThreadFilter();
298 #endif
299  void FilterAllOutputTextArea();
300  QString FilterOutput(const G4UIOutputString&,const QString&,const QString&);
301  G4String GetThreadPrefix();
302  bool CheckG4EnvironmentVariable(char* txt, char* version);
303  QStandardItemModel* CreateCompleterModel(G4String aCmd);
304  void CreateEmptyViewerPropertiesWidget();
305  void CreateEmptyPickInfosWidget();
306 private:
307 
308  QMainWindow * fMainWindow;
309  QLabel *fCommandLabel;
310  QLineEdit * fCommandArea;
311  QTextEdit *fCoutTBTextArea;
312  QTabWidget* fUITabWidget;
313  std::vector <G4UIOutputString> fG4OutputString;
314  QLineEdit * fCoutFilter;
315  QCompleter* fCompleter;
316  bool fDefaultIcons;
317 
318  QListWidget *fHistoryTBTableList;
319  QTreeWidget *fHelpTreeWidget;
320  QWidget* fHelpTBWidget;
321  QWidget* fHistoryTBWidget;
322  G4UIDockWidget* fCoutDockWidget;
323  G4UIDockWidget* fUIDockWidget;
324  QWidget* fSceneTreeWidget;
325  QWidget* fViewerPropertiesWidget;
326  QWidget* fPickInfosWidget;
327  QLineEdit* fHelpLine;
328  G4QTabWidget* fViewerTabWidget;
329  QString fCoutText;
330  QTextEdit *fStartPage;
331  QSplitter * fHelpVSplitter;
332  QTextEdit* fParameterHelpLabel;
333  QTableWidget* fParameterHelpTable;
334 
335  QToolBar *fToolbarApp;
336  QToolBar *fToolbarUser;
337  QString fStringSeparator;
338  G4String fLastErrMessage;
339  QString fLastOpenPath;
340  QToolButton* fViewModePopupButton;
341  QToolButton* fSurfaceModePopupButton;
342 
343  QPixmap* fSearchIcon;
344  QPixmap* fClearIcon;
345  QPixmap* fSaveIcon;
346  QPixmap* fOpenIcon;
347  QPixmap* fMoveIcon;
348  QPixmap* fRotateIcon;
349  QPixmap* fPickIcon;
350  QPixmap* fZoomInIcon;
351  QPixmap* fZoomOutIcon;
352  QPixmap* fWireframeIcon;
353  QPixmap* fSolidIcon;
354  QPixmap* fHiddenLineRemovalIcon;
355  QPixmap* fHiddenLineAndSurfaceRemovalIcon;
356  QPixmap* fPerspectiveIcon;
357  QPixmap* fOrthoIcon;
358  QPixmap* fCommandIcon;
359  QPixmap* fDirIcon;
360  QPixmap* fRunIcon;
361  QPixmap* fParamIcon;
362  QPixmap* fPickTargetIcon;
363 
364 #ifdef G4MULTITHREADED
365  QComboBox* fThreadsFilterComboBox;
366 #endif
367  std::string fDefaultViewerFirstPageHTMLText;
368 
369  QDialog* fViewerPropertiesDialog;
370  QDialog* fPickInfosDialog;
371  QString fLastCompleteCommand;
372  bool fMoveSelected;
373  bool fRotateSelected;
374  bool fPickSelected;
375  bool fZoomInSelected;
376  bool fZoomOutSelected;
377 
378 private Q_SLOTS :
379  void ExitSession();
380  void ClearButtonCallback();
381  void SaveOutputCallback();
382  void CommandEnteredCallback();
383  void CommandEditedCallback(const QString & text);
384  void ButtonCallback(const QString&);
385  void HelpTreeClicCallback();
386  void HelpTreeDoubleClicCallback();
387  void ShowHelpCallback();
388  void CommandHistoryCallback();
389  void LookForHelpStringCallback();
390  void UpdateTabWidget(int);
391  void ResizeTabWidget( QResizeEvent* );
392  void CoutFilterCallback(const QString&);
393  void ThreadComboBoxCallback(int);
394  void TabCloseCallback(int);
395  void ToolBoxActivated(int);
396  void VisParameterCallback(QWidget*);
397  void ChangeColorCallback(QWidget*);
398  void ChangeCursorAction(const QString&);
399  void ChangeSurfaceStyle(const QString&);
400  void OpenIconCallback(const QString&);
401  void SaveIconCallback(const QString&);
402  void ViewerPropertiesIconCallback(int);
403  void ChangePerspectiveOrtho(const QString&);
404 };
405 
406 #endif
407 
408 #endif
409 
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
virtual void DefaultIcons(bool)
const XML_Char * s
Definition: expat.h:262
bool G4bool
Definition: G4Types.hh:79
virtual void PauseSessionStart(const G4String &Prompt)=0
virtual void ExitHelp() const =0
virtual G4int ReceiveG4cout(const G4String &coutString)
Definition: G4UIsession.cc:50
const XML_Char * version
Definition: expat.h:187
int G4int
Definition: G4Types.hh:78
virtual G4int ReceiveG4cerr(const G4String &cerrString)
Definition: G4UIsession.cc:56
virtual G4UIsession * SessionStart()=0
virtual G4bool GetHelpChoice(G4int &)=0
virtual void AddButton(const char *, const char *, const char *)
virtual void AddMenu(const char *, const char *)
virtual void AddIcon(const char *, const char *, const char *, const char *)