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