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