Warning, file /include/Geant4/G4UIQt.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef G4UIQt_h
0029 #define G4UIQt_h
0030
0031 #include "G4VBasicShell.hh"
0032 #include "G4VInteractiveSession.hh"
0033 #include "G4SceneTreeItem.hh"
0034
0035 #include <qdialog.h>
0036 #include <qdockwidget.h>
0037 #include <qmap.h>
0038 #include <qobject.h>
0039 #include <qtabwidget.h>
0040 #include <qtreewidget.h>
0041
0042 class QMainWindow;
0043 class QLineEdit;
0044 class G4UIsession;
0045 class QListWidget;
0046 class QTreeWidgetItem;
0047 class QTextEdit;
0048 class QTextBrowser;
0049 class QLabel;
0050 class QResizeEvent;
0051 class QTabWidget;
0052 class QSplitter;
0053 class QToolBar;
0054 class QTableWidget;
0055 class QPixmap;
0056 class QComboBox;
0057 class QCompleter;
0058 class QtGlobal;
0059 class QStandardItemModel;
0060 class QToolButton;
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 #if QT_VERSION < 0x060000
0083 class G4QTabWidget : public QTabWidget
0084 {
0085 public:
0086 G4QTabWidget();
0087 G4QTabWidget(QWidget* aParent, G4int sizeX, G4int sizeY);
0088 void paintEvent(QPaintEvent* event) override;
0089 inline void setTabSelected(G4bool a) { fTabSelected = a; };
0090 inline void setLastTabCreated(G4int a) { fLastCreated = a; };
0091 inline bool isTabSelected() { return fTabSelected; };
0092 G4bool fTabSelected;
0093 G4int fLastCreated;
0094 G4int fPreferedSizeX;
0095 G4int fPreferedSizeY;
0096 inline void setPreferredSize(QSize s)
0097 {
0098 fPreferedSizeX = s.width() + 6;
0099 fPreferedSizeY = s.height() + 58;
0100 }
0101 inline QSize sizeHint() const override { return QSize(fPreferedSizeX, fPreferedSizeY); }
0102 };
0103 #endif
0104
0105 class G4UIOutputString
0106 {
0107 public:
0108 G4UIOutputString(const QString& text, const G4String& thread = "", const G4String& outputstream = "info");
0109 inline QString GetOutputList() { return " all info warning error "; };
0110 QString fText;
0111 G4String fThread;
0112 G4String fOutputStream;
0113 };
0114
0115 class G4UIDockWidget : public QDockWidget
0116 {
0117 public:
0118 G4UIDockWidget(const QString& txt);
0119 void closeEvent(QCloseEvent*) override;
0120 };
0121
0122 class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession
0123 {
0124 Q_OBJECT
0125
0126 public:
0127
0128 G4UIQt(G4int, char**);
0129
0130
0131 G4UIsession* SessionStart() override;
0132
0133
0134
0135
0136
0137 void AddMenu(const char*, const char*) override;
0138
0139
0140
0141
0142
0143
0144 void AddButton(const char*, const char*, const char*) override;
0145
0146
0147
0148
0149
0150
0151
0152
0153 void AddIcon(const char* userLabel, const char* iconFile, const char* command,
0154 const char* file_name = "") override;
0155
0156
0157
0158
0159 void SetOutputStyle(const char* destination, const char* style) override;
0160
0161
0162 void NativeMenu(G4bool aVal) override;
0163
0164
0165 void ClearMenu() override;
0166
0167
0168 void DefaultIcons(G4bool aVal) override;
0169
0170
0171 G4bool AddTabWidget(QWidget*, QString);
0172
0173 inline QTabWidget* GetViewerTabWidget() { return fViewerTabWidget; };
0174
0175
0176 QWidget* GetSceneTreeWidget();
0177
0178
0179 QWidget* GetViewerPropertiesWidget();
0180
0181
0182 QWidget* GetPickInfosWidget();
0183
0184 G4bool IsSplitterReleased();
0185
0186 inline G4bool IsIconMoveSelected() { return fMoveSelected; };
0187 inline G4bool IsIconRotateSelected() { return fRotateSelected; };
0188 inline G4bool IsIconPickSelected() { return fPickSelected; };
0189 inline G4bool IsIconZoomInSelected() { return fZoomInSelected; };
0190 inline G4bool IsIconZoomOutSelected() { return fZoomOutSelected; };
0191
0192 void SetIconMoveSelected();
0193 void SetIconRotateSelected();
0194 void SetIconPickSelected();
0195 void SetIconZoomInSelected();
0196 void SetIconZoomOutSelected();
0197 void SetIconHLHSRSelected();
0198 void SetIconHLRSelected();
0199 void SetIconSolidSelected();
0200 void SetIconWireframeSelected();
0201 void SetIconPerspectiveSelected();
0202 void SetIconOrthoSelected();
0203
0204
0205 inline QMainWindow* GetMainWindow() { return fMainWindow; };
0206
0207
0208 inline QPixmap* getSearchIcon() { return fSearchIcon; };
0209
0210
0211 inline QPixmap* getClearIcon() { return fClearIcon; };
0212
0213
0214
0215
0216 void SetStartPage(const std::string&);
0217
0218
0219 inline QWidget* GetCoutWidget() { return fCoutDockWidget->widget(); };
0220
0221
0222 inline G4UIDockWidget* GetCoutDockWidget() { return fCoutDockWidget; };
0223
0224
0225 inline G4UIDockWidget* GetUserInterfaceWidget() { return fUIDockWidget; };
0226
0227
0228 inline QTabWidget* GetUITabWidget() { return fUITabWidget; }
0229
0230
0231 inline QWidget* GetHistoryWidget() { return fHistoryTBWidget; }
0232
0233
0234 inline QWidget* GetHelpWidget() { return fHelpTBWidget; }
0235
0236
0237 G4bool AddViewerTab(QWidget* w, std::string title);
0238
0239
0240 G4bool AddViewerTabFromFile(std::string fileName, std::string title);
0241
0242
0243 void UpdateSceneTree(const G4SceneTreeItem&) override;
0244
0245 public:
0246 ~G4UIQt() override;
0247 void Prompt(const G4String&);
0248 void SessionTerminate();
0249 void PauseSessionStart(const G4String&) override;
0250 G4int ReceiveG4debug(const G4String&) override;
0251 G4int ReceiveG4cout(const G4String&) override;
0252 G4int ReceiveG4cerr(const G4String&) override;
0253
0254
0255 private:
0256 void SecondaryLoop(const G4String&);
0257 void CreateHelpWidget();
0258 void InitHelpTreeAndVisParametersWidget();
0259 void FillHelpTree();
0260 void UpdateCommandCompleter();
0261 void CreateIcons();
0262 void ExitHelp() const override;
0263 void SetDefaultIconsToolbar();
0264
0265 void CreateHelpTree(QTreeWidgetItem*, G4UIcommandTree*);
0266 QTreeWidgetItem* FindTreeItem(QTreeWidgetItem*, const QString&);
0267
0268
0269 QWidget* CreateSceneTreeWidget();
0270
0271
0272
0273
0274 void CreateNewSceneTreeWidget();
0275
0276 void BuildPVQTree(const G4SceneTreeItem& g4stItem, QTreeWidgetItem* qtwItem);
0277
0278 void SceneTreeItemClicked(QTreeWidgetItem*);
0279 void SceneTreeItemDoubleClicked(QTreeWidgetItem*);
0280 void SceneTreeItemExpanded(QTreeWidgetItem*);
0281 void SceneTreeItemCollapsed(QTreeWidgetItem*);
0282
0283 struct NewSceneTreeItemTreeWidget: public QTreeWidget {
0284 void mousePressEvent(QMouseEvent*) override;
0285 void ActWithoutParameter(const G4String& action, G4SceneTreeItem*);
0286 void ActWithABool(const G4String& action, G4SceneTreeItem*, G4bool);
0287 void ActWithAnInteger(const G4String& action, G4SceneTreeItem*);
0288 void ActWithADouble(const G4String& action, G4SceneTreeItem*);
0289 void ActWithAString(const G4String& action, G4SceneTreeItem*);
0290 };
0291
0292 QString GetCommandList(const G4UIcommand*);
0293 void updateHelpArea(const G4UIcommand*);
0294 G4bool GetHelpChoice(
0295 G4int&) override;
0296 bool eventFilter(QObject*, QEvent*) override;
0297 void ActivateCommand(G4String);
0298 #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
0299 QMap<G4int, QString> LookForHelpStringInChildTree(G4UIcommandTree*, const QString&);
0300 #else
0301 QMultiMap<G4int, QString> LookForHelpStringInChildTree(G4UIcommandTree*, const QString&);
0302 #endif
0303 QWidget* CreateVisParametersTBWidget();
0304 QWidget* CreateHelpTBWidget();
0305 G4UIDockWidget* CreateCoutTBWidget();
0306 QWidget* CreateHistoryTBWidget();
0307 G4UIDockWidget* CreateUITabWidget();
0308 void CreateViewerWidget();
0309 void OpenHelpTreeOnCommand(const QString&);
0310 QString GetShortCommandPath(QString&);
0311 QString GetLongCommandPath(QTreeWidgetItem*);
0312 G4bool IsGUICommand(const G4UIcommand*);
0313 G4bool CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, G4int, G4bool isDialog);
0314 G4bool CreateCommandWidget(G4UIcommand* command, QWidget* parent, G4bool isDialog);
0315 void CreateViewerPropertiesDialog();
0316 void CreatePickInfosDialog();
0317 #ifdef G4MULTITHREADED
0318 void UpdateCoutThreadFilter();
0319 #endif
0320 void FilterAllOutputTextArea();
0321 QString FilterOutput(const G4UIOutputString&, const QString&, const QString&);
0322 G4String GetThreadPrefix();
0323 G4bool CheckG4EnvironmentVariable(char* txt, char* version);
0324 QStandardItemModel* CreateCompleterModel(const G4String& aCmd);
0325 void CreateEmptyViewerPropertiesWidget();
0326 void CreateEmptyPickInfosWidget();
0327
0328 private:
0329 QMainWindow* fMainWindow;
0330 QLabel* fCommandLabel;
0331 QLineEdit* fCommandArea;
0332 QTextEdit* fCoutTBTextArea;
0333 QTabWidget* fUITabWidget;
0334 std::vector<G4UIOutputString> fG4OutputString;
0335 QLineEdit* fCoutFilter;
0336 QCompleter* fCompleter;
0337 G4bool fDefaultIcons;
0338
0339 QListWidget* fHistoryTBTableList;
0340 QTreeWidget* fHelpTreeWidget;
0341 QWidget* fHelpTBWidget;
0342 QWidget* fHistoryTBWidget;
0343 G4UIDockWidget* fCoutDockWidget;
0344 G4UIDockWidget* fUIDockWidget;
0345 QWidget* fSceneTreeWidget;
0346 QWidget* fNewSceneTreeWidget;
0347 NewSceneTreeItemTreeWidget* fNewSceneTreeItemTreeWidget;
0348 QWidget* fViewerPropertiesWidget;
0349 QWidget* fPickInfosWidget;
0350 QLineEdit* fHelpLine;
0351 #if QT_VERSION < 0x060000
0352 G4QTabWidget* fViewerTabWidget;
0353 #else
0354 QTabWidget* fViewerTabWidget;
0355 #endif
0356 QString fCoutText;
0357 QTextBrowser* fStartPage;
0358 QSplitter* fHelpVSplitter;
0359 QTextEdit* fParameterHelpLabel;
0360 QTableWidget* fParameterHelpTable;
0361
0362 QToolBar* fToolbarApp;
0363 QToolBar* fToolbarUser;
0364 QString fStringSeparator;
0365 G4String fLastErrMessage;
0366 QString fLastOpenPath;
0367
0368 QPixmap* fSearchIcon;
0369 QPixmap* fClearIcon;
0370 QPixmap* fSaveIcon;
0371 QPixmap* fOpenIcon;
0372 QPixmap* fMoveIcon;
0373 QPixmap* fRotateIcon;
0374 QPixmap* fPickIcon;
0375 QPixmap* fZoomInIcon;
0376 QPixmap* fZoomOutIcon;
0377 QPixmap* fWireframeIcon;
0378 QPixmap* fSolidIcon;
0379 QPixmap* fHiddenLineRemovalIcon;
0380 QPixmap* fHiddenLineAndSurfaceRemovalIcon;
0381 QPixmap* fPerspectiveIcon;
0382 QPixmap* fOrthoIcon;
0383 QPixmap* fCommandIcon;
0384 QPixmap* fDirIcon;
0385 QPixmap* fRunIcon;
0386 QPixmap* fParamIcon;
0387 QPixmap* fPickTargetIcon;
0388 QPixmap* fExitIcon;
0389
0390 #ifdef G4MULTITHREADED
0391 QComboBox* fThreadsFilterComboBox;
0392 #endif
0393 std::string fDefaultViewerFirstPageHTMLText;
0394
0395 QDialog* fViewerPropertiesDialog;
0396 QDialog* fPickInfosDialog;
0397 QString fLastCompleteCommand;
0398 G4bool fMoveSelected;
0399 G4bool fRotateSelected;
0400 G4bool fPickSelected;
0401 G4bool fZoomInSelected;
0402 G4bool fZoomOutSelected;
0403
0404 private Q_SLOTS:
0405 void ExitSession();
0406 void ClearButtonCallback();
0407 void SaveOutputCallback();
0408 void CommandEnteredCallback();
0409 void CommandEditedCallback(const QString& text);
0410 void ButtonCallback(const QString&);
0411 void HelpTreeClicCallback();
0412 void HelpTreeDoubleClicCallback();
0413 void ShowHelpCallback();
0414 void CommandHistoryCallback();
0415 void LookForHelpStringCallback();
0416 void UpdateTabWidget(int);
0417 void ResizeTabWidget(QResizeEvent*);
0418 void CoutFilterCallback(const QString&);
0419 void ThreadComboBoxCallback(int);
0420 void TabCloseCallback(int);
0421 void ToolBoxActivated(int);
0422 void VisParameterCallback(QWidget*);
0423 void ChangeColorCallback(QWidget*);
0424 void ChangeCursorAction(const QString&);
0425 void ChangeSurfaceStyle(const QString&);
0426 void OpenIconCallback(const QString&);
0427 void SaveIconCallback(const QString&);
0428 void ViewerPropertiesIconCallback(int);
0429 void ChangePerspectiveOrtho(const QString&);
0430 };
0431
0432 #endif