Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIQt Class Reference

#include <G4UIQt.hh>

Inheritance diagram for G4UIQt:

Public Member Functions

 G4UIQt (G4int, char **)
G4UIsessionSessionStart () override
void AddMenu (const char *, const char *) override
void AddButton (const char *, const char *, const char *) override
void AddIcon (const char *userLabel, const char *iconFile, const char *command, const char *file_name="") override
void SetOutputStyle (const char *destination, const char *style) override
void NativeMenu (G4bool aVal) override
void ClearMenu () override
void DefaultIcons (G4bool aVal) override
G4bool AddTabWidget (QWidget *, QString)
QTabWidget * GetViewerTabWidget ()
QWidget * GetSceneTreeWidget ()
QWidget * GetViewerPropertiesWidget ()
QWidget * GetPickInfosWidget ()
G4bool IsSplitterReleased ()
G4bool IsIconMoveSelected ()
G4bool IsIconRotateSelected ()
G4bool IsIconPickSelected ()
G4bool IsIconZoomInSelected ()
G4bool IsIconZoomOutSelected ()
void SetIconMoveSelected ()
void SetIconRotateSelected ()
void TogglePickSelection ()
void SetIconZoomInSelected ()
void SetIconZoomOutSelected ()
void SetIconHLHSRSelected ()
void SetIconHLRSelected ()
void SetIconSolidSelected ()
void SetIconWireframeSelected ()
void SetIconCoudPointSelected ()
void SetIconPerspectiveSelected ()
void SetIconOrthoSelected ()
QMainWindow * GetMainWindow ()
QPixmap * getSearchIcon ()
QPixmap * getClearIcon ()
void SetStartPage (const std::string &)
QWidget * GetCoutWidget ()
G4UIDockWidgetGetCoutDockWidget ()
G4UIDockWidgetGetUserInterfaceWidget ()
QTabWidget * GetUITabWidget ()
QWidget * GetHistoryWidget ()
QWidget * GetHelpWidget ()
G4bool AddViewerTab (QWidget *w, std::string title)
G4bool AddViewerTabFromFile (std::string fileName, std::string title)
void UpdateSceneTree (const G4SceneTreeItem &) override
void UpdateDrawingStyle (G4int style) override
void UpdateProjectionStyle (G4int style) override
void UpdateTransparencySlider (G4double depth, G4int option) override
 ~G4UIQt () override
void Prompt (const G4String &)
void SessionTerminate ()
void PauseSessionStart (const G4String &) override
G4int ReceiveG4debug (const G4String &) override
G4int ReceiveG4cout (const G4String &) override
G4int ReceiveG4cerr (const G4String &) override
Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 ~G4VBasicShell () override
Public Member Functions inherited from G4UIsession
 G4UIsession ()
 G4UIsession (G4int iBatch)
 ~G4UIsession () override
G4int ReceiveG4debug (const G4String &debugString) override
G4int ReceiveG4cout (const G4String &coutString) override
G4int ReceiveG4cerr (const G4String &cerrString) override
G4int GetLastReturnCode () const
Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
virtual ~G4coutDestination ()=default
void AddDebugTransformer (const Transformer &t)
void AddDebugTransformer (Transformer &&t)
void AddCoutTransformer (const Transformer &t)
void AddCoutTransformer (Transformer &&t)
void AddCerrTransformer (const Transformer &t)
void AddCerrTransformer (Transformer &&t)
virtual void ResetTransformers ()
G4int ReceiveG4debug_ (const G4String &msg)
G4int ReceiveG4cout_ (const G4String &msg)
G4int ReceiveG4cerr_ (const G4String &msg)
Public Member Functions inherited from G4VInteractiveSession
 G4VInteractiveSession ()
virtual ~G4VInteractiveSession ()
void AddInteractor (G4String, G4Interactor)
G4Interactor GetInteractor (const G4String &)
const std::map< G4String, OutputStyle > & GetOutputStyles () const

Additional Inherited Members

Public Types inherited from G4coutDestination
using Transformer = std::function<G4bool(G4String&)>
Static Public Member Functions inherited from G4UIsession
static G4int InSession ()
Protected Member Functions inherited from G4VBasicShell
G4String ModifyToFullPathCommand (const char *aCommandLine) const
G4String GetCurrentWorkingDirectory () const
G4bool ChangeDirectory (const char *newDir)
G4UIcommandTreeFindDirectory (const char *dirName) const
G4UIcommandFindCommand (const char *commandName) const
G4String Complete (const G4String &)
G4String FindMatchingPath (G4UIcommandTree *, const G4String &)
virtual void ExecuteCommand (const G4String &)
void ApplyShellCommand (const G4String &, G4bool &, G4bool &)
void ShowCurrent (const G4String &) const
void ChangeDirectoryCommand (const G4String &)
void ListDirectory (const G4String &) const
void TerminalHelp (const G4String &)
Protected Member Functions inherited from G4VInteractiveSession
void SetStyleUtility (const G4String &destination, const G4String &style)
Protected Attributes inherited from G4UIsession
G4int ifBatch = 0
G4int lastRC = 0
Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersDebug
std::vector< TransformertransformersCout
std::vector< TransformertransformersCerr
Protected Attributes inherited from G4VInteractiveSession
std::map< G4String, OutputStylefOutputStyles
Static Protected Attributes inherited from G4UIsession
static G4ICOMS_DLL G4int inSession = 0
Static Protected Attributes inherited from G4coutDestination
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr

Detailed Description

Definition at line 124 of file G4UIQt.hh.

Constructor & Destructor Documentation

◆ G4UIQt()

G4UIQt::G4UIQt ( G4int argc,
char ** argv )

Build a Qt window with a menubar, output area and promt area

   +-----------------------+
   |exit menu|             |
   |                       |
   | +-------------------+ |
   | |                   | |
   | |  Output area      | |
   | |                   | |
   | +-------------------+ |
   |      | clear |        |
   | +-------------------+ |
   | |  promt history    | |
   | +-------------------+ |
   | +-------------------+ |
   | |> promt area       | |
   | +-------------------+ |
   +-----------------------+

Definition at line 125 of file G4UIQt.cc.

126 : fMainWindow(nullptr),
127 fCommandLabel(nullptr),
128 fCommandArea(nullptr),
129 fCoutTBTextArea(nullptr),
130 fUITabWidget(nullptr),
131 fCoutFilter(nullptr),
132 fCompleter(nullptr),
133 fDefaultIcons(true),
134 fHistoryTBTableList(nullptr),
135 fHelpTreeWidget(nullptr),
136 fHelpTBWidget(nullptr),
137 fTimeWindowWidget(nullptr),
138 fHistoryTBWidget(nullptr),
139 fCoutDockWidget(nullptr),
140 fUIDockWidget(nullptr),
141 fSceneTreeWidget(nullptr),
142 fNewSceneTreeWidget(nullptr),
143 fNewSceneTreeItemTreeWidget(nullptr),
144 fMaxPVDepth(0),
145 fNewSceneTreeSlider(nullptr),
146 fUnwrapButtonWidget(nullptr),
147 fFadeButtonWidget(nullptr),
148 fXrayButtonWidget(nullptr),
149 fViewerPropertiesWidget(nullptr),
150 fPickInfosWidget(nullptr),
151 fHelpLine(nullptr),
152 fViewerTabWidget(nullptr),
153 fCoutText("Output"),
154 fStartPage(nullptr),
155 fHelpVSplitter(nullptr),
156 fParameterHelpLabel(nullptr),
157 fParameterHelpTable(nullptr),
158 fToolbarApp(nullptr),
159 fToolbarUser(nullptr),
160 fStringSeparator("__$$$@%%###__"),
161 fLastOpenPath(""),
162 fSearchIcon(nullptr),
163 fClearIcon(nullptr),
164 fSaveIcon(nullptr),
165 fOpenIcon(nullptr),
166 fMoveIcon(nullptr),
167 fRotateIcon(nullptr),
168 fPickIcon(nullptr),
169 fZoomInIcon(nullptr),
170 fZoomOutIcon(nullptr),
171 fWireframeIcon(nullptr),
172 fSolidIcon(nullptr),
173 fPointCloudIcon(nullptr),
174 fHiddenLineRemovalIcon(nullptr),
175 fHiddenLineAndSurfaceRemovalIcon(nullptr),
176 fPerspectiveIcon(nullptr),
177 fOrthoIcon(nullptr),
178 fCommandIcon(nullptr),
179 fDirIcon(nullptr),
180 fRunIcon(nullptr),
181 fParamIcon(nullptr),
182 fPickTargetIcon(nullptr),
183 fExitIcon(nullptr),
184 fResetCameraIcon(nullptr),
185 fResetTargetPointIcon(nullptr)
186#ifdef G4MULTITHREADED
187 ,
188 fThreadsFilterComboBox(nullptr)
189#endif
190 ,
191 fDefaultViewerFirstPageHTMLText(""),
192 fViewerPropertiesDialog(nullptr),
193 fPickInfosDialog(nullptr),
194 fLastCompleteCommand(""),
195 fMoveSelected(false),
196 fRotateSelected(true),
197 fPickSelected(false),
198 fZoomInSelected(false),
199 fZoomOutSelected(false)
200{
201 G4Qt* interactorManager = G4Qt::getInstance(argc, argv, (char*)"Qt");
202 if ((QApplication*)interactorManager->GetMainInteractor() == nullptr) {
203 G4UImanager* UImanager = G4UImanager::GetUIpointer();
204 G4int verbose = UImanager->GetVerboseLevel();
205
206 if (verbose >= 2) {
207 G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
208 }
209 }
210
211 G4UImanager* UI = G4UImanager::GetUIpointer();
212 if (UI != nullptr) UI->SetSession(this);
213 if (UI != nullptr) UI->SetG4UIWindow(this);
214
215 // Check if already define in external app QMainWindow
216 G4bool found = false;
217 Q_FOREACH (QWidget* widget, QApplication::allWidgets()) {
218 if ((!found) && (widget->inherits("QMainWindow"))) {
219 found = true;
220 }
221 }
222
223 if (found) {
224 G4UImanager* UImanager = G4UImanager::GetUIpointer();
225 G4int verbose = UImanager->GetVerboseLevel();
226
227 if (verbose >= 2) {
228 G4cout << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted"
229 << G4endl;
230 }
231 return;
232 }
233 CreateIcons();
234
235 fMainWindow = new QMainWindow();
236 fMainWindow->setAttribute(Qt::WA_DeleteOnClose);
237
238 fMainWindow->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
239 fMainWindow->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
240 fMainWindow->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
241 fMainWindow->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
242
243 CreateViewerWidget();
244 fMainWindow->addDockWidget(Qt::LeftDockWidgetArea, CreateUITabWidget());
245 fMainWindow->addDockWidget(Qt::BottomDockWidgetArea, CreateCoutTBWidget());
246
247 CreateNewSceneTreeWidget();
248
249 // add defaults icons
250 SetDefaultIconsToolbar();
251
252 if (UI != nullptr) UI->SetCoutDestination(this); // TO KEEP
253
254#ifdef G4MULTITHREADED
255 // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
257#endif
258
259 fMainWindow->setWindowTitle(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
260
261 // force the size at be correct at the beggining
262 // because the widget is not realized yet, the size of the main window is not up to date. But
263 // we need it in order to add some viewer inside
264 int width = QGuiApplication::primaryScreen()->geometry().size().width() * 0.9;
265 int height = QGuiApplication::primaryScreen()->geometry().size().height() * 0.9;
266 fMainWindow->resize(width, height);
267 fMainWindow->move((QGuiApplication::primaryScreen()->geometry().size().width() - width) / 2,
268 (QGuiApplication::primaryScreen()->geometry().size().height() - height) / 4);
269
270 // set last focus on command line
271 fCommandArea->setFocus(Qt::TabFocusReason);
272
273 // Allow QTextCursor to be called by another thread :
274 // http://qt-project.org/doc/qt-4.8/qmetatype.html#qRegisterMetaType
275 qRegisterMetaType<QTextCursor>("QTextCursor");
276
277 // add some tips
278 AddTabWidget(fStartPage, "Useful tips");
279
280 // Set not visible until session start
281 fMainWindow->setVisible(false);
282}
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4Qt * getInstance()
Definition G4Qt.cc:61
G4bool AddTabWidget(QWidget *, QString)
Definition G4UIQt.cc:3215
void SetCoutDestination(G4UIsession *const value)
G4int GetVerboseLevel() const
static G4UImanager * GetUIpointer()
void SetSession(G4UIsession *const value)
void SetG4UIWindow(G4UIsession *const value)
static G4MTGLOB_DLL G4coutDestination * masterG4coutDestination

◆ ~G4UIQt()

G4UIQt::~G4UIQt ( )
override

Definition at line 284 of file G4UIQt.cc.

285{
286 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
287 if (UI != nullptr) { // TO KEEP
288 UI->SetSession(nullptr); // TO KEEP
289 UI->SetG4UIWindow(nullptr);
290 UI->SetCoutDestination(nullptr); // TO KEEP
291#ifdef G4MULTITHREADED
292 masterG4coutDestination = nullptr; // set to cout when UI is deleted
293#endif
294 }
295}

Member Function Documentation

◆ AddButton()

void G4UIQt::AddButton ( const char * aMenu,
const char * aLabel,
const char * aCommand )
overridevirtual

Add a new button to a menu

Parameters
aMenu: parent menu
aLabel: label to display
aCommand: command to execute as a callback

Reimplemented from G4VInteractiveSession.

Definition at line 3772 of file G4UIQt.cc.

3773{
3774 if (aMenu == nullptr) return; // TO KEEP
3775 if (aLabel == nullptr) return; // TO KEEP
3776 if (aCommand == nullptr) return; // TO KEEP
3777
3778 QMenu* parentTmp = (QMenu*)GetInteractor(aMenu);
3779
3780 if (parentTmp == nullptr) {
3781 G4UImanager* UImanager = G4UImanager::GetUIpointer();
3782 G4int verbose = UImanager->GetVerboseLevel();
3783
3784 if (verbose >= 2) {
3785 G4cout << "Menu name " << aMenu << " does not exist, please define it before using it."
3786 << G4endl;
3787 }
3788 return;
3789 }
3790
3791 // Find the command in the command tree
3792 G4UImanager* UI = G4UImanager::GetUIpointer();
3793 if (UI == nullptr) return;
3794 G4UIcommandTree* treeTop = UI->GetTree();
3795
3796 G4String cmd = aCommand;
3797 std::size_t cmdEndPos = cmd.find_first_of(" \t");
3798 if (cmdEndPos != std::string::npos) {
3799 cmd.erase(cmdEndPos);
3800 }
3801
3802 if (treeTop->FindPath(cmd) == nullptr) {
3803 if (cmd != "ls" && cmd.substr(0, 3) != "ls " && cmd != "pwd" && cmd != "cd" &&
3804 cmd.substr(0, 3) != "cd " && cmd != "help" && cmd.substr(0, 5) != "help " &&
3805 cmd[0] != '?' && cmd != "hist" && cmd != "history" && cmd[0] != '!' && cmd != "exit" &&
3806 cmd != "cont" && cmd != "continue")
3807 {
3808 G4UImanager* UImanager = G4UImanager::GetUIpointer();
3809 G4int verbose = UImanager->GetVerboseLevel();
3810
3811 if (verbose >= 2) {
3812 G4cout << "Warning: command '" << cmd
3813 << "' does not exist, please define it before using it." << G4endl;
3814 }
3815 }
3816 }
3817
3818 QString cmd_tmp = QString(aCommand);
3819 parentTmp->addAction(aLabel, this, [this, cmd_tmp]() { this->ButtonCallback(cmd_tmp); });
3820}
G4UIcommand * FindPath(const char *commandPath) const
G4UIcommandTree * GetTree() const
G4Interactor GetInteractor(const G4String &)

◆ AddIcon()

void G4UIQt::AddIcon ( const char * aLabel,
const char * aIconFile,
const char * aCommand,
const char * aFileName = "" )
overridevirtual

special case for the "open" icon. It will open a file selector and map the return file to the given command.

Reimplemented from G4VInteractiveSession.

Definition at line 3826 of file G4UIQt.cc.

3828{
3829 if (aLabel == nullptr) return; // TO KEEP
3830 // special case, aCommand could be NULL if aIconFile is not user_icon
3831 if (aCommand == nullptr) {
3832 if (std::string(aIconFile) == "user_icon") {
3833 return; // TO KEEP
3834 }
3835 }
3836 QPixmap* pix;
3837 G4bool userToolBar = false;
3838
3839 if (! fDefaultIcons) {
3840 userToolBar = true;
3841 }
3842 if (std::string(aIconFile) == "user_icon") {
3843 // try to open a file
3844 G4UImanager* UImanager = G4UImanager::GetUIpointer();
3845 pix = new QPixmap(UImanager->FindMacroPath(aFileName).data());
3846 if (pix->isNull()) {
3847 G4int verbose = UImanager->GetVerboseLevel();
3848
3849 if (verbose >= 2) {
3850 G4cout << "Warning: file '" << aFileName
3851 << "' is incorrect or does not exist, this command will not be build" << G4endl;
3852 }
3853 return;
3854 }
3855 }
3856 else if (std::string(aIconFile) == "open") {
3857 pix = fOpenIcon;
3858 }
3859 else if (std::string(aIconFile) == "save") {
3860 pix = fSaveIcon;
3861 }
3862 else if (std::string(aIconFile) == "move") {
3863 pix = fMoveIcon;
3864 }
3865 else if (std::string(aIconFile) == "rotate") {
3866 pix = fRotateIcon;
3867 }
3868 else if (std::string(aIconFile) == "pick") {
3869 pix = fPickIcon;
3870 }
3871 else if (std::string(aIconFile) == "zoom_in") {
3872 pix = fZoomInIcon;
3873 }
3874 else if (std::string(aIconFile) == "zoom_out") {
3875 pix = fZoomOutIcon;
3876 }
3877 else if (std::string(aIconFile) == "wireframe") {
3878 pix = fWireframeIcon;
3879 }
3880 else if (std::string(aIconFile) == "solid") {
3881 pix = fSolidIcon;
3882 }
3883 else if (std::string(aIconFile) == "point_cloud") {
3884 pix = fPointCloudIcon;
3885 }
3886 else if (std::string(aIconFile) == "hidden_line_removal") {
3887 pix = fHiddenLineRemovalIcon;
3888 }
3889 else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
3890 pix = fHiddenLineAndSurfaceRemovalIcon;
3891 }
3892 else if (std::string(aIconFile) == "perspective") {
3893 pix = fPerspectiveIcon;
3894 }
3895 else if (std::string(aIconFile) == "ortho") {
3896 pix = fOrthoIcon;
3897 }
3898 else if (std::string(aIconFile) == "runBeamOn") {
3899 pix = fRunIcon;
3900 }
3901 else if (std::string(aIconFile) == "exit") {
3902 pix = fExitIcon;
3903 }
3904 else if (std::string(aIconFile) == "reset_camera") {
3905 pix = fResetCameraIcon;
3906 }
3907 else if (std::string(aIconFile) == "resetTargetPoint") {
3908 pix = fResetTargetPointIcon;
3909 }
3910 else {
3911 G4UImanager* UImanager = G4UImanager::GetUIpointer();
3912 G4int verbose = UImanager->GetVerboseLevel();
3913
3914 if (verbose >= 2) {
3915 G4cout << "Parameter" << aIconFile << " not defined" << G4endl;
3916 }
3917 return;
3918 }
3919 QToolBar* currentToolbar = nullptr;
3920 if (userToolBar) {
3921 if (fToolbarUser == nullptr) {
3922 fToolbarUser = new QToolBar();
3923 fToolbarUser->setIconSize(QSize(20, 20));
3924 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
3925 }
3926 currentToolbar = fToolbarUser;
3927 }
3928 else {
3929 if (fToolbarApp == nullptr) {
3930 fToolbarApp = new QToolBar();
3931 fToolbarApp->setIconSize(QSize(20, 20));
3932 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
3933 }
3934 currentToolbar = fToolbarApp;
3935 }
3936
3937 // Check if already present
3938
3939 QList<QAction*> list = currentToolbar->actions();
3940
3941 for (auto i : list) {
3942 if (i->text() == QString(aLabel)) {
3943 G4UImanager* UI = G4UImanager::GetUIpointer();
3944 if (UI == nullptr) return;
3945 G4int verbose = UI->GetVerboseLevel();
3946 if (verbose >= 2) {
3947 G4cout << "Warning: A toolBar icon \"" << aLabel << "\" already exists with the same name!"
3948 << G4endl;
3949 }
3950 }
3951 }
3952
3953 // special cases :"open"
3954 if (std::string(aIconFile) == "open") {
3955 QString txt = aCommand + fStringSeparator + aLabel;
3956 currentToolbar->addAction(
3957 QIcon(*pix), aIconFile, this, [this, txt]() { this->OpenIconCallback(txt); });
3958
3959 // special cases :"save"
3960 }
3961 else if (std::string(aIconFile) == "save") {
3962 QString txt = aCommand + fStringSeparator + aLabel;
3963 currentToolbar->addAction(
3964 QIcon(*pix), aIconFile, this, [this, txt]() { this->SaveIconCallback(txt); });
3965 // special cases : cursor style
3966 }
3967 else if ((std::string(aIconFile) == "move") || (std::string(aIconFile) == "rotate") ||
3968 (std::string(aIconFile) == "pick") || (std::string(aIconFile) == "zoom_out") ||
3969 (std::string(aIconFile) == "zoom_in"))
3970 {
3971 QString txt = QString(aIconFile);
3972 QAction* action = currentToolbar->addAction(
3973 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeCursorAction(txt); });
3974 action->setCheckable(true);
3975 action->setChecked(false);
3976 action->setData(aIconFile);
3977
3978 if (std::string(aIconFile) == "rotate") {
3980 }
3981
3982 // special case : surface style
3983 }
3984 else if ((std::string(aIconFile) == "hidden_line_removal") ||
3985 (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
3986 (std::string(aIconFile) == "solid") ||
3987 (std::string(aIconFile) == "wireframe") ||
3988 (std::string(aIconFile) == "point_cloud"))
3989 {
3990 QString txt = QString(aIconFile);
3991 QAction* action = currentToolbar->addAction(
3992 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeSurfaceStyle(txt); });
3993 action->setCheckable(true);
3994 action->setChecked(true);
3995 action->setData(aIconFile);
3996
3997 /*if (std::string(aIconFile) == "hidden_line_removal") {
3998 SetIconHLRSelected();
3999 }
4000 if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
4001 SetIconHLHSRSelected();
4002 }*/
4003 if (std::string(aIconFile) == "solid") {
4005 }
4006 /*if (std::string(aIconFile) == "wireframe") {
4007 SetIconWireframeSelected();
4008 }
4009 if (std::string(aIconFile) == "point_cloud") {
4010 SetIconWireframeSelected();
4011 }*/
4012
4013 // special case : perspective/ortho
4014 }
4015 else if ((std::string(aIconFile) == "perspective") || (std::string(aIconFile) == "ortho")) {
4016 QString txt = QString(aIconFile);
4017 QAction* action = currentToolbar->addAction(
4018 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangePerspectiveOrtho(txt); });
4019 action->setCheckable(true);
4020 action->setChecked(true);
4021 action->setData(aIconFile);
4022
4023 if (std::string(aIconFile) == "perspective") {
4025 }
4026 if (std::string(aIconFile) == "ortho") {
4028 }
4029 // special cases :"resetCamera"
4030 }
4031 else if (std::string(aIconFile) == "reset_camera") {
4032 currentToolbar->addAction(QIcon(*pix), aIconFile, this, [this]() { this->ResetCameraCallback(); });
4033 }
4034 else {
4035 // Find the command in the command tree
4036 G4UImanager* UI = G4UImanager::GetUIpointer();
4037 if (UI == nullptr) return;
4038 G4UIcommandTree* treeTop = UI->GetTree();
4039 if (aCommand != nullptr) {
4040 std::string str = aCommand;
4041 std::string::size_type pos = str.find(' ');
4042 if (pos != std::string::npos) {
4043 str = str.substr(0, pos).c_str();
4044 }
4045 if (treeTop->FindPath(str.c_str()) == nullptr) {
4046 G4UImanager* UImanager = G4UImanager::GetUIpointer();
4047 G4int verbose = UImanager->GetVerboseLevel();
4048
4049 if (verbose >= 2) {
4050 G4cout << "Warning: command '" << aCommand
4051 << "' does not exist, please define it before using it." << G4endl;
4052 }
4053 }
4054 }
4055 QString txt = QString(aCommand);
4056 currentToolbar->addAction(QIcon(*pix), aCommand, this,
4057 [this, txt]() { this->ButtonCallback(txt); });
4058 }
4059}
void SetIconOrthoSelected()
Definition G4UIQt.cc:6386
void SetIconPerspectiveSelected()
Definition G4UIQt.cc:6365
void SetIconSolidSelected()
Definition G4UIQt.cc:6213
void SetIconRotateSelected()
Definition G4UIQt.cc:6106
G4String FindMacroPath(const G4String &fname) const

◆ AddMenu()

void G4UIQt::AddMenu ( const char * aName,
const char * aLabel )
overridevirtual

Add a new menu to the menu bar

Parameters
aNamename of menu
aLabellabel to display

Reimplemented from G4VInteractiveSession.

Definition at line 3755 of file G4UIQt.cc.

3756{
3757 if (aName == nullptr) return;
3758 if (aLabel == nullptr) return;
3759
3760 auto fileMenu = new QMenu(aLabel);
3761 fMainWindow->menuBar()->addMenu(fileMenu);
3762
3763 AddInteractor(aName, (G4Interactor)fileMenu);
3764}
void * G4Interactor
void AddInteractor(G4String, G4Interactor)

◆ AddTabWidget()

G4bool G4UIQt::AddTabWidget ( QWidget * aWidget,
QString name )

Add a new tab widget. Create the tab if it was not done

Definition at line 3215 of file G4UIQt.cc.

3216{
3217#if QT_VERSION < 0x060000
3218 if (fViewerTabWidget == nullptr) {
3219 CreateViewerWidget();
3220 }
3221#endif
3222
3223 if (aWidget == nullptr) {
3224 return false;
3225 }
3226#if QT_VERSION < 0x060000
3227 // Has to be added before we put it into the fViewerTabWidget widget
3228 aWidget->setParent(fViewerTabWidget); // Will create in some cases widget outside
3229 // of UI for a really short moment
3230
3231 fViewerTabWidget->addTab(aWidget, name);
3232
3233 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count() - 1);
3234
3235 // Set visible
3236 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
3237#else
3238 //G.Barrand: disconnect temporarily the signal/slot on UpdateTabWidget(), else
3239 // if adding a viewer, the UpdateTabWidget/Apply("vis/viewer/select") will
3240 // issue an ERROR message since the viewer is not yet declared to the G4VisManager
3241 // at this moment (see the logic in G4VisManager::CreateViewer()).
3242 QObject::disconnect(fViewerTabWidget, SIGNAL(currentChanged(int)), this, SLOT(UpdateTabWidget(int)));
3243 fViewerTabWidget->addTab(aWidget, name);
3244 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count() - 1);
3245 QObject::connect(fViewerTabWidget, SIGNAL(currentChanged(int)), this, SLOT(UpdateTabWidget(int)));
3246#endif
3247
3248 // Not the good solution, but ensure that the help tree is correctly build when launching a viewer
3249 // It should be done by a notification when adding a command, but that's nit done yet
3250 // (Geant4.10.1)
3251 FillHelpTree();
3252
3253 return true;
3254}

Referenced by G4VtkQtViewer::CreateMainWindow(), G4UIQt(), and G4RTQtScanner::GetQtWindow().

◆ AddViewerTab()

G4bool G4UIQt::AddViewerTab ( QWidget * aWidget,
std::string title )

Add a new tab in the viewer

Definition at line 3175 of file G4UIQt.cc.

3176{
3177 if (fViewerTabWidget == nullptr) {
3178 return false;
3179 }
3180 fViewerTabWidget->addTab(aWidget, title.c_str());
3181
3182 return true;
3183}

◆ AddViewerTabFromFile()

G4bool G4UIQt::AddViewerTabFromFile ( std::string fileName,
std::string title )

Add a new tab in the viewer

Definition at line 3187 of file G4UIQt.cc.

3188{
3189 if (fViewerTabWidget == nullptr) {
3190 return false;
3191 }
3192
3193 G4UImanager* UI = G4UImanager::GetUIpointer();
3194 if (UI == nullptr) return false;
3195 std::ifstream file(UI->FindMacroPath(fileName.c_str()).data());
3196 if (file) {
3197 std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
3198
3199 auto text = new QTextEdit();
3200 text->setAcceptRichText(true);
3201 text->setContentsMargins(5, 5, 5, 5);
3202 text->setText(QString("<pre>") + content.c_str() + "</pre>");
3203 text->setReadOnly(true);
3204 fViewerTabWidget->addTab(text, title.c_str());
3205 }
3206 else {
3207 return false;
3208 }
3209 return true;
3210}

◆ ClearMenu()

void G4UIQt::ClearMenu ( )
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 4078 of file G4UIQt.cc.

4078{ fMainWindow->menuBar()->clear(); }

◆ DefaultIcons()

void G4UIQt::DefaultIcons ( G4bool aVal)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 297 of file G4UIQt.cc.

298{
299 fDefaultIcons = aVal;
300
301 if (! fMainWindow->isVisible()) {
302 return;
303 }
304
305 if (fToolbarApp != nullptr) {
306 if (aVal) {
307 fToolbarApp->setVisible(true);
308 }
309 else {
310 // Set not visible until session start
311 fToolbarApp->setVisible(false);
312 }
313 }
314}

◆ getClearIcon()

QPixmap * G4UIQt::getClearIcon ( )
inline

Definition at line 214 of file G4UIQt.hh.

214{ return fClearIcon; };

◆ GetCoutDockWidget()

G4UIDockWidget * G4UIQt::GetCoutDockWidget ( )
inline

Definition at line 225 of file G4UIQt.hh.

225{ return fCoutDockWidget; };

◆ GetCoutWidget()

QWidget * G4UIQt::GetCoutWidget ( )
inline

Definition at line 222 of file G4UIQt.hh.

222{ return fCoutDockWidget->widget(); };

◆ GetHelpWidget()

QWidget * G4UIQt::GetHelpWidget ( )
inline

Definition at line 237 of file G4UIQt.hh.

237{ return fHelpTBWidget; }

◆ GetHistoryWidget()

QWidget * G4UIQt::GetHistoryWidget ( )
inline

Definition at line 234 of file G4UIQt.hh.

234{ return fHistoryTBWidget; }

◆ GetMainWindow()

QMainWindow * G4UIQt::GetMainWindow ( )
inline

Definition at line 208 of file G4UIQt.hh.

208{ return fMainWindow; };

◆ GetPickInfosWidget()

QWidget * G4UIQt::GetPickInfosWidget ( )

Get the Pick Widget

Definition at line 3165 of file G4UIQt.cc.

3166{
3167 if (fPickInfosDialog == nullptr) {
3168 CreatePickInfosDialog();
3169 }
3170 return fPickInfosWidget;
3171}

◆ GetSceneTreeWidget()

QWidget * G4UIQt::GetSceneTreeWidget ( )

Get the ViewerComponents ToolBox Widget

Definition at line 3151 of file G4UIQt.cc.

3151{ return fSceneTreeWidget; }

◆ getSearchIcon()

QPixmap * G4UIQt::getSearchIcon ( )
inline

Definition at line 211 of file G4UIQt.hh.

211{ return fSearchIcon; };

◆ GetUITabWidget()

QTabWidget * G4UIQt::GetUITabWidget ( )
inline

Definition at line 231 of file G4UIQt.hh.

231{ return fUITabWidget; }

◆ GetUserInterfaceWidget()

G4UIDockWidget * G4UIQt::GetUserInterfaceWidget ( )
inline

Definition at line 228 of file G4UIQt.hh.

228{ return fUIDockWidget; };

◆ GetViewerPropertiesWidget()

QWidget * G4UIQt::GetViewerPropertiesWidget ( )

Get the Viewer properties Widget

Definition at line 3155 of file G4UIQt.cc.

3156{
3157 if (fViewerPropertiesDialog == nullptr) {
3158 CreateViewerPropertiesDialog();
3159 }
3160 return fViewerPropertiesWidget;
3161}

◆ GetViewerTabWidget()

QTabWidget * G4UIQt::GetViewerTabWidget ( )
inline

Definition at line 175 of file G4UIQt.hh.

175{ return fViewerTabWidget; };

◆ IsIconMoveSelected()

G4bool G4UIQt::IsIconMoveSelected ( )
inline

Definition at line 188 of file G4UIQt.hh.

188{ return fMoveSelected; };

◆ IsIconPickSelected()

G4bool G4UIQt::IsIconPickSelected ( )
inline

Definition at line 190 of file G4UIQt.hh.

190{ return fPickSelected; };

◆ IsIconRotateSelected()

G4bool G4UIQt::IsIconRotateSelected ( )
inline

Definition at line 189 of file G4UIQt.hh.

189{ return fRotateSelected; };

◆ IsIconZoomInSelected()

G4bool G4UIQt::IsIconZoomInSelected ( )
inline

Definition at line 191 of file G4UIQt.hh.

191{ return fZoomInSelected; };

◆ IsIconZoomOutSelected()

G4bool G4UIQt::IsIconZoomOutSelected ( )
inline

Definition at line 192 of file G4UIQt.hh.

192{ return fZoomOutSelected; };

◆ IsSplitterReleased()

G4bool G4UIQt::IsSplitterReleased ( )

◆ NativeMenu()

void G4UIQt::NativeMenu ( G4bool aVal)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 4070 of file G4UIQt.cc.

4071{
4072 if (fMainWindow->menuBar()->isNativeMenuBar() == aVal) return; // already in this state
4073
4074 // Menu become empty when goin from Qt to Native Bar
4075 fMainWindow->menuBar()->setNativeMenuBar(aVal);
4076}

◆ PauseSessionStart()

void G4UIQt::PauseSessionStart ( const G4String & aState)
overridevirtual

Called by intercoms/src/G4UImanager.cc
Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument
It have to pause the session command terminal.
Call SecondaryLoop to wait for exit event

Parameters
aState
See also
: G4VisCommandReviewKeptEvents::SetNewValue

Implements G4VBasicShell.

Definition at line 3380 of file G4UIQt.cc.

3381{
3382 if (aState == nullptr) return;
3383
3384 if (aState == "G4_pause> ") { // TO KEEP
3385 SecondaryLoop("Pause, type continue to exit this state"); // TO KEEP
3386 } // TO KEEP
3387
3388 if (aState == "EndOfEvent") { // TO KEEP
3389 // Picking with feed back in event data Done here !!!
3390 SecondaryLoop("End of event, type continue to exit this state"); // TO KEEP
3391 } // TO KEEP
3392}

◆ Prompt()

void G4UIQt::Prompt ( const G4String & aPrompt)

Display the prompt in the prompt area

Parameters
aPrompt: string to display as the promt label

Definition at line 3358 of file G4UIQt.cc.

3359{
3360 if (aPrompt == nullptr) return;
3361
3362 fCommandLabel->setText((char*)aPrompt.data());
3363}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIQt::ReceiveG4cerr ( const G4String & aString)
overridevirtual

Receive a cerr from Geant4. We have to display it in the cout zone

Parameters
aString: label to add in the display area
Returns
0

Reimplemented from G4coutDestination.

Definition at line 3616 of file G4UIQt.cc.

3617{
3618 if (aString.empty()) return 0;
3619
3620#ifdef G4MULTITHREADED
3621 G4AutoLock al(&ReceiveMutex);
3622#endif
3623
3624 // A workaround so that output is not lost after crash or G4Exception.
3625 // The "workaround" is to make sure all flushed output appears on
3626 // the terminal after a crash, because even flushed output can
3627 // get lost in the Qt UI system.
3628 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
3629 // so limit this to the master thread
3630#ifdef G4MULTITHREADED
3632#endif
3633 std::cerr << aString << std::flush;
3634
3635 G4String aStringWithStyle;
3636 // aString has a \n on the end (maybe it comes from G4endl or from the
3637 // Enter key on the command line) - ignore it. That’s why
3638 // i < aString.length() - 1
3639 // But other \n need to be translated to an HTML newline.
3640 // Similarly, spaces need to be translated to an HTML "non-breaking space".
3641 // Tabs (\t) are more tricky since the number of equivalent spaces depends
3642 // on how many characters precede it. Probably needs an HTML table. For now
3643 // we replace \t with four spaces.
3644 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
3645 if (aString[i] == '\n') {
3646 aStringWithStyle += "<br>";
3647 }
3648 else if (aString[i] == ' ') {
3649 aStringWithStyle += "&nbsp;";
3650 }
3651 else if (aString[i] == '\t') {
3652 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
3653 }
3654 else if (aString[i] == '<') {
3655 aStringWithStyle += "&lt;";
3656 }
3657 else {
3658 aStringWithStyle += aString[i];
3659 }
3660 }
3661 if (fOutputStyles["cerr"].fixed) {
3662 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
3663 }
3664 else {
3665 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
3666 }
3667
3668 // Add to string
3669
3670 G4UIOutputString txt =
3671 G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(), GetThreadPrefix(), "error");
3672 fG4OutputString.push_back(txt);
3673
3674#ifdef G4MULTITHREADED
3675 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
3676#else
3677 QString result = FilterOutput(txt, "", fCoutFilter->text());
3678#endif
3679 if (result.isEmpty()) {
3680 return 0;
3681 }
3682
3683 // Suppress space, \n,\t,\r...
3684 if (QString(aString.data()).trimmed() != "") {
3685 if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
3686 (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit))
3687 {
3688 // In case of Abort or Quit, the useful error message should be in the last error message !
3689 fLastErrMessage += "\n" + aString;
3690 QString criticalMessage = fLastErrMessage.data();
3691 criticalMessage = criticalMessage.toHtmlEscaped();
3692 QMessageBox::critical(fMainWindow, "Error", QString(fLastErrMessage));
3693 }
3694 }
3695 fCoutTBTextArea->append(QString("<font color=\"Red\">") + result + QString("</font>"));
3696 fCoutTBTextArea->ensureCursorVisible();
3697
3698 if (QString(aString.data()).trimmed() != "") {
3699 fLastErrMessage += aString;
3700 }
3701#ifdef G4MULTITHREADED
3702 UpdateCoutThreadFilter();
3703#endif
3704 return 0;
3705}
@ G4State_Quit
@ G4State_Abort
G4TemplateAutoLock< G4Mutex > G4AutoLock
static G4StateManager * GetStateManager()
std::map< G4String, OutputStyle > fOutputStyles
G4bool IsMasterThread()

Referenced by ReceiveG4cout().

◆ ReceiveG4cout()

G4int G4UIQt::ReceiveG4cout ( const G4String & aString)
overridevirtual

Receive a cout from Geant4. We have to display it in the cout zone

Parameters
aString: label to add in the display area
Returns
0

Reimplemented from G4coutDestination.

Definition at line 3515 of file G4UIQt.cc.

3516{
3517 if (aString.empty()) return 0;
3518
3519 // Try to be smart :
3520 // "*** This is just a warning message. ***"
3521 if (G4StrUtil::contains(aString, "*** This is just a warning message. ***")) {
3522 return ReceiveG4cerr(aString);
3523 }
3524
3525#ifdef G4MULTITHREADED
3526 G4AutoLock al(&ReceiveMutex);
3527#endif
3528
3529 // A workaround so that output is not lost after crash or G4Exception.
3530 // The "workaround" is to make sure all flushed output appears on
3531 // the terminal after a crash, because even flushed output can
3532 // get lost in the Qt UI system.
3533 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
3534 // so limit this to the master thread
3535#ifdef G4MULTITHREADED
3537#endif
3538 std::cout << aString << std::flush;
3539
3540 G4String aStringWithStyle;
3541 // aString has a \n on the end (maybe it comes from G4endl or from the
3542 // Enter key on the command line) - ignore it. That’s why
3543 // i < aString.length() - 1
3544 // But other \n need to be translated to an HTML newline.
3545 // Similarly, spaces need to be translated to an HTML "non-breaking space".
3546 // Tabs (\t) are more tricky since the number of equivalent spaces depends
3547 // on how many characters precede it. Probably needs an HTML table. For now
3548 // we replace \t with four spaces.
3549 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
3550 if (aString[i] == '\n') {
3551 aStringWithStyle += "<br>";
3552 }
3553 else if (aString[i] == ' ') {
3554 aStringWithStyle += "&nbsp;";
3555 }
3556 else if (aString[i] == '\t') {
3557 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
3558 }
3559 else if (aString[i] == '<') {
3560 aStringWithStyle += "&lt;";
3561 }
3562 else {
3563 aStringWithStyle += aString[i];
3564 }
3565 }
3566 if (fOutputStyles["cout"].fixed) {
3567 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
3568 }
3569 else {
3570 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
3571 }
3572
3573 // Add to string
3574 G4UIOutputString txt =
3575 G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
3576 fG4OutputString.push_back(txt);
3577
3578#ifdef G4MULTITHREADED
3579 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
3580#else
3581 QString result = FilterOutput(txt, "", fCoutFilter->text());
3582#endif
3583
3584 if (result.isEmpty()) {
3585 return 0;
3586 }
3587
3588 G4UImanager* UI = G4UImanager::GetUIpointer();
3589 if (fOutputStyles["cout"].highlight) {
3590 if (! UI->IsLastCommandOutputTreated()) {
3591 QPalette pal;
3592 result = QString("<span style='background:") + pal.link().color().name() +
3593 ";'>&nbsp;</span>" + "<span style='background:" + pal.highlight().color().name() +
3594 ";'> " + result + "</span>";
3595 }
3596 }
3598
3599 fCoutTBTextArea->append(result);
3600 fCoutTBTextArea->ensureCursorVisible();
3601
3602#ifdef G4MULTITHREADED
3603 UpdateCoutThreadFilter();
3604#endif
3605
3606 // reset error stack
3607 fLastErrMessage = aString;
3608 return 0;
3609}
G4int ReceiveG4cerr(const G4String &) override
Definition G4UIQt.cc:3616
bool IsLastCommandOutputTreated()
void SetLastCommandOutputTreated()
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

◆ ReceiveG4debug()

G4int G4UIQt::ReceiveG4debug ( const G4String & aString)
overridevirtual

Receive a debug log message from Geant4. We have to display it in the cout zone

Parameters
aString: label to add in the display area
Returns
0

Reimplemented from G4coutDestination.

Definition at line 3426 of file G4UIQt.cc.

3427{
3428 if (aString.empty()) return 0;
3429
3430#ifdef G4MULTITHREADED
3431 G4AutoLock al(&ReceiveMutex);
3432#endif
3433
3434 // A workaround so that output is not lost after crash or G4Exception.
3435 // The "workaround" is to make sure all flushed output appears on
3436 // the terminal after a crash, because even flushed output can
3437 // get lost in the Qt UI system.
3438 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
3439 // so limit this to the master thread
3440#ifdef G4MULTITHREADED
3442#endif
3443 std::cout << aString << std::flush;
3444
3445 G4String aStringWithStyle;
3446 // aString has a \n on the end (maybe it comes from G4endl or from the
3447 // Enter key on the command line) - ignore it. That’s why
3448 // i < aString.length() - 1
3449 // But other \n need to be translated to an HTML newline.
3450 // Similarly, spaces need to be translated to an HTML "non-breaking space".
3451 // Tabs (\t) are more tricky since the number of equivalent spaces depends
3452 // on how many characters precede it. Probably needs an HTML table. For now
3453 // we replace \t with four spaces.
3454 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
3455 if (aString[i] == '\n') {
3456 aStringWithStyle += "<br>";
3457 }
3458 else if (aString[i] == ' ') {
3459 aStringWithStyle += "&nbsp;";
3460 }
3461 else if (aString[i] == '\t') {
3462 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
3463 }
3464 else if (aString[i] == '<') {
3465 aStringWithStyle += "&lt;";
3466 }
3467 else {
3468 aStringWithStyle += aString[i];
3469 }
3470 }
3471 if (fOutputStyles["debug"].fixed) {
3472 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
3473 }
3474 else {
3475 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
3476 }
3477
3478 // Add to string
3479 G4UIOutputString txt =
3480 G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
3481 fG4OutputString.push_back(txt);
3482
3483#ifdef G4MULTITHREADED
3484 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
3485#else
3486 QString result = FilterOutput(txt, "", fCoutFilter->text());
3487#endif
3488
3489 if (result.isEmpty()) {
3490 return 0;
3491 }
3492
3493 if (fOutputStyles["debug"].highlight) {
3494 QPalette pal;
3495 result = QString("<span style='background:") + pal.link().color().name() + ";'>&nbsp;</span>" +
3496 "<span style='background: Pink;'> " + result + "</span>";
3497 }
3498 result = QString("<font color=\"Green\">") + result + QString("</font>");
3499
3500 fCoutTBTextArea->append(result);
3501 fCoutTBTextArea->ensureCursorVisible();
3502
3503#ifdef G4MULTITHREADED
3504 UpdateCoutThreadFilter();
3505#endif
3506
3507 return 0;
3508}

◆ SessionStart()

G4UIsession * G4UIQt::SessionStart ( )
overridevirtual

Start the Qt main loop

Implements G4VBasicShell.

Definition at line 3317 of file G4UIQt.cc.

3318{
3319 G4Qt* interactorManager = G4Qt::getInstance();
3320 Prompt("Session :");
3321 exitSession = false;
3322
3323 QCoreApplication::sendPostedEvents();
3324
3325 fMainWindow->setVisible(true);
3326
3327 if (fDefaultIcons) {
3328 fToolbarApp->setVisible(true);
3329 }
3330 else {
3331 // Set not visible until session start
3332 fToolbarApp->setVisible(false);
3333 }
3334 // Rebuild help tree (new command could be registered)
3335 FillHelpTree();
3336
3337 // Rebuild command completion (new command could be registered)
3338 UpdateCommandCompleter();
3339
3340 // Set event filters
3341 fHistoryTBTableList->installEventFilter(this);
3342 fCommandArea->installEventFilter(this);
3343
3344 // Focus on command line
3345 fCommandArea->setFocus();
3346
3347 interactorManager->DisableSecondaryLoop(); // TO KEEP
3348 if ((QApplication*)interactorManager->GetMainInteractor() != nullptr)
3349 ((QApplication*)interactorManager->GetMainInteractor())->exec();
3350
3351 interactorManager->EnableSecondaryLoop();
3352 return this;
3353}
void Prompt(const G4String &)
Definition G4UIQt.cc:3358

◆ SessionTerminate()

void G4UIQt::SessionTerminate ( )

Definition at line 3365 of file G4UIQt.cc.

3366{
3367 G4Qt* interactorManager = G4Qt::getInstance();
3368 fMainWindow->close();
3369 ((QApplication*)interactorManager->GetMainInteractor())->exit();
3370}

◆ SetIconCoudPointSelected()

void G4UIQt::SetIconCoudPointSelected ( )

Definition at line 6334 of file G4UIQt.cc.

6335{
6336 // Theses actions should be in the app toolbar
6337
6338 QToolBar* toolbar = fToolbarApp;
6339 if (!fDefaultIcons) {
6340 toolbar = fToolbarUser;
6341 }
6342 if (toolbar == nullptr) return;
6343
6344 QList<QAction*> list = toolbar->actions();
6345 for (auto i : list) {
6346 if (i->data().toString() == "point_cloud") {
6347 i->setChecked(true);
6348 }
6349 else if (i->data().toString() == "wireframe") {
6350 i->setChecked(false);
6351 }
6352 else if (i->data().toString() == "hidden_line_removal") {
6353 i->setChecked(false);
6354 }
6355 else if (i->data().toString() == "hidden_line_and_surface_removal") {
6356 i->setChecked(false);
6357 }
6358 else if (i->data().toString() == "solid") {
6359 i->setChecked(false);
6360 }
6361
6362 }
6363}

Referenced by UpdateDrawingStyle().

◆ SetIconHLHSRSelected()

void G4UIQt::SetIconHLHSRSelected ( )

Definition at line 6303 of file G4UIQt.cc.

6304{
6305 // Theses actions should be in the app toolbar
6306
6307 QToolBar* toolbar = fToolbarApp;
6308 if (! fDefaultIcons) {
6309 toolbar = fToolbarUser;
6310 }
6311
6312 if (toolbar == nullptr) return;
6313
6314 QList<QAction*> list = toolbar->actions();
6315 for (auto i : list) {
6316 if (i->data().toString() == "hidden_line_and_surface_removal") {
6317 i->setChecked(true);
6318 }
6319 else if (i->data().toString() == "solid") {
6320 i->setChecked(false);
6321 }
6322 else if (i->data().toString() == "hidden_line_removal") {
6323 i->setChecked(false);
6324 }
6325 else if (i->data().toString() == "wireframe") {
6326 i->setChecked(false);
6327 }
6328 else if (i->data().toString() == "point_cloud") {
6329 i->setChecked(false);
6330 }
6331 }
6332}

Referenced by UpdateDrawingStyle().

◆ SetIconHLRSelected()

void G4UIQt::SetIconHLRSelected ( )

Definition at line 6273 of file G4UIQt.cc.

6274{
6275 // Theses actions should be in the app toolbar
6276
6277 QToolBar* toolbar = fToolbarApp;
6278 if (! fDefaultIcons) {
6279 toolbar = fToolbarUser;
6280 }
6281 if (toolbar == nullptr) return;
6282
6283 QList<QAction*> list = toolbar->actions();
6284 for (auto i : list) {
6285 if (i->data().toString() == "hidden_line_removal") {
6286 i->setChecked(true);
6287 }
6288 else if (i->data().toString() == "solid") {
6289 i->setChecked(false);
6290 }
6291 else if (i->data().toString() == "hidden_line_and_surface_removal") {
6292 i->setChecked(false);
6293 }
6294 else if (i->data().toString() == "wireframe") {
6295 i->setChecked(false);
6296 }
6297 else if (i->data().toString() == "point_cloud") {
6298 i->setChecked(false);
6299 }
6300 }
6301}

Referenced by UpdateDrawingStyle().

◆ SetIconMoveSelected()

void G4UIQt::SetIconMoveSelected ( )

Definition at line 6080 of file G4UIQt.cc.

6081{
6082 // Theses actions should be in the app toolbar
6083 fMoveSelected = true;
6084 fRotateSelected = false;
6085 fZoomInSelected = false;
6086 fZoomOutSelected = false;
6087
6088 if (fToolbarApp == nullptr) return;
6089 QList<QAction*> list = fToolbarApp->actions();
6090 for (auto i : list) {
6091 if (i->data().toString() == "move") {
6092 i->setChecked(true);
6093 }
6094 else if (i->data().toString() == "rotate") {
6095 i->setChecked(false);
6096 }
6097 else if (i->data().toString() == "zoom_in") {
6098 i->setChecked(false);
6099 }
6100 else if (i->data().toString() == "zoom_out") {
6101 i->setChecked(false);
6102 }
6103 }
6104}

◆ SetIconOrthoSelected()

void G4UIQt::SetIconOrthoSelected ( )

Definition at line 6386 of file G4UIQt.cc.

6387{
6388 // Theses actions should be in the app toolbar
6389
6390 QToolBar* toolbar = fToolbarApp;
6391 if (! fDefaultIcons) {
6392 toolbar = fToolbarUser;
6393 }
6394
6395 if (toolbar == nullptr) return;
6396
6397 QList<QAction*> list = toolbar->actions();
6398 for (auto i : list) {
6399 if (i->data().toString() == "ortho") {
6400 i->setChecked(true);
6401 }
6402 else if (i->data().toString() == "perspective") {
6403 i->setChecked(false);
6404 }
6405 }
6406}

Referenced by AddIcon(), and UpdateProjectionStyle().

◆ SetIconPerspectiveSelected()

void G4UIQt::SetIconPerspectiveSelected ( )

Definition at line 6365 of file G4UIQt.cc.

6366{
6367 // Theses actions should be in the app toolbar
6368
6369 QToolBar* toolbar = fToolbarApp;
6370 if (! fDefaultIcons) {
6371 toolbar = fToolbarUser;
6372 }
6373 if (toolbar == nullptr) return;
6374
6375 QList<QAction*> list = toolbar->actions();
6376 for (auto i : list) {
6377 if (i->data().toString() == "perspective") {
6378 i->setChecked(true);
6379 }
6380 else if (i->data().toString() == "ortho") {
6381 i->setChecked(false);
6382 }
6383 }
6384}

Referenced by AddIcon(), and UpdateProjectionStyle().

◆ SetIconRotateSelected()

void G4UIQt::SetIconRotateSelected ( )

Definition at line 6106 of file G4UIQt.cc.

6107{
6108 // Theses actions should be in the app toolbar
6109 fRotateSelected = true;
6110 fMoveSelected = false;
6111 fZoomInSelected = false;
6112 fZoomOutSelected = false;
6113
6114 if (fToolbarApp == nullptr) return;
6115 QList<QAction*> list = fToolbarApp->actions();
6116 for (auto i : list) {
6117 if (i->data().toString() == "rotate") {
6118 i->setChecked(true);
6119 }
6120 else if (i->data().toString() == "move") {
6121 i->setChecked(false);
6122 }
6123 else if (i->data().toString() == "zoom_in") {
6124 i->setChecked(false);
6125 }
6126 else if (i->data().toString() == "zoom_out") {
6127 i->setChecked(false);
6128 }
6129 }
6130}

Referenced by AddIcon().

◆ SetIconSolidSelected()

void G4UIQt::SetIconSolidSelected ( )

Definition at line 6213 of file G4UIQt.cc.

6214{
6215 // Theses actions should be in the app toolbar
6216
6217 QToolBar* toolbar = fToolbarApp;
6218 if (! fDefaultIcons) {
6219 toolbar = fToolbarUser;
6220 }
6221 if (toolbar == nullptr) return;
6222
6223 QList<QAction*> list = toolbar->actions();
6224 for (auto i : list) {
6225 if (i->data().toString() == "solid") {
6226 i->setChecked(true);
6227 }
6228 else if (i->data().toString() == "hidden_line_removal") {
6229 i->setChecked(false);
6230 }
6231 else if (i->data().toString() == "hidden_line_and_surface_removal") {
6232 i->setChecked(false);
6233 }
6234 else if (i->data().toString() == "wireframe") {
6235 i->setChecked(false);
6236 }
6237 else if (i->data().toString() == "point_cloud") {
6238 i->setChecked(false);
6239 }
6240 }
6241}

Referenced by AddIcon(), and UpdateDrawingStyle().

◆ SetIconWireframeSelected()

void G4UIQt::SetIconWireframeSelected ( )

Definition at line 6243 of file G4UIQt.cc.

6244{
6245 // Theses actions should be in the app toolbar
6246
6247 QToolBar* toolbar = fToolbarApp;
6248 if (! fDefaultIcons) {
6249 toolbar = fToolbarUser;
6250 }
6251 if (toolbar == nullptr) return;
6252
6253 QList<QAction*> list = toolbar->actions();
6254 for (auto i : list) {
6255 if (i->data().toString() == "wireframe") {
6256 i->setChecked(true);
6257 }
6258 else if (i->data().toString() == "hidden_line_removal") {
6259 i->setChecked(false);
6260 }
6261 else if (i->data().toString() == "hidden_line_and_surface_removal") {
6262 i->setChecked(false);
6263 }
6264 else if (i->data().toString() == "solid") {
6265 i->setChecked(false);
6266 }
6267 else if (i->data().toString() == "point_cloud") {
6268 i->setChecked(false);
6269 }
6270 }
6271}

Referenced by UpdateDrawingStyle().

◆ SetIconZoomInSelected()

void G4UIQt::SetIconZoomInSelected ( )

Definition at line 6151 of file G4UIQt.cc.

6152{
6153 // Theses actions should be in the app toolbar
6154 fZoomInSelected = true;
6155 fMoveSelected = false;
6156 fRotateSelected = false;
6157 fZoomOutSelected = false;
6158
6159 QToolBar* toolbar = fToolbarApp;
6160 if (! fDefaultIcons) {
6161 toolbar = fToolbarUser;
6162 }
6163 if (toolbar == nullptr) return;
6164
6165 QList<QAction*> list = toolbar->actions();
6166 for (auto i : list) {
6167 if (i->data().toString() == "zoom_in") {
6168 i->setChecked(true);
6169 }
6170 else if (i->data().toString() == "move") {
6171 i->setChecked(false);
6172 }
6173 else if (i->data().toString() == "rotate") {
6174 i->setChecked(false);
6175 }
6176 else if (i->data().toString() == "zoom_out") {
6177 i->setChecked(false);
6178 }
6179 }
6180}

◆ SetIconZoomOutSelected()

void G4UIQt::SetIconZoomOutSelected ( )

Definition at line 6182 of file G4UIQt.cc.

6183{
6184 // Theses actions should be in the app toolbar
6185 fZoomOutSelected = true;
6186 fMoveSelected = false;
6187 fRotateSelected = false;
6188 fZoomInSelected = false;
6189
6190 QToolBar* toolbar = fToolbarApp;
6191 if (! fDefaultIcons) {
6192 toolbar = fToolbarUser;
6193 }
6194 if (toolbar == nullptr) return;
6195
6196 QList<QAction*> list = toolbar->actions();
6197 for (auto i : list) {
6198 if (i->data().toString() == "zoom_out") {
6199 i->setChecked(true);
6200 }
6201 else if (i->data().toString() == "move") {
6202 i->setChecked(false);
6203 }
6204 else if (i->data().toString() == "rotate") {
6205 i->setChecked(false);
6206 }
6207 else if (i->data().toString() == "zoom_in") {
6208 i->setChecked(false);
6209 }
6210 }
6211}

◆ SetOutputStyle()

void G4UIQt::SetOutputStyle ( const char * destination,
const char * style )
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 4061 of file G4UIQt.cc.

4062{
4063 // Specify an output style
4064 // First argument destination ("cout" etc or "all")
4065 // Second argument is the required style - see guidance
4066
4067 SetStyleUtility(destination, style);
4068}
void SetStyleUtility(const G4String &destination, const G4String &style)

◆ SetStartPage()

void G4UIQt::SetStartPage ( const std::string & text)

Definition at line 3256 of file G4UIQt.cc.

3257{
3258 if (! text.empty()) {
3259 fDefaultViewerFirstPageHTMLText = text;
3260 }
3261 if (fStartPage == nullptr) {
3262 fStartPage = new QTextBrowser();
3263 fStartPage->setContentsMargins(5, 5, 5, 5);
3264 fStartPage->setReadOnly(true);
3265 }
3266 fStartPage->setOpenExternalLinks(true);
3267 fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
3268}

◆ TogglePickSelection()

void G4UIQt::TogglePickSelection ( )

Definition at line 6132 of file G4UIQt.cc.

6133{
6134 // Theses actions should be in the app toolbar
6135 fPickSelected = !fPickSelected;
6136
6137 QToolBar* toolbar = fToolbarApp;
6138 if (! fDefaultIcons) {
6139 toolbar = fToolbarUser;
6140 }
6141 if (toolbar == nullptr) return;
6142
6143 QList<QAction*> list = toolbar->actions();
6144 for (auto i : list) {
6145 if (i->data().toString() == "pick") {
6146 i->setChecked(fPickSelected);
6147 }
6148 }
6149 }

◆ UpdateDrawingStyle()

void G4UIQt::UpdateDrawingStyle ( G4int style)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 1761 of file G4UIQt.cc.

1761 {
1762 // Surface style
1763 switch (style) {
1764 case 0:
1766 break;
1767 case 1:
1768 this->SetIconHLRSelected();
1769 break;
1770 case 2:
1771 this->SetIconSolidSelected();
1772 break;
1773 case 3:
1774 this->SetIconHLHSRSelected();
1775 break;
1776 case 4:
1778 break;
1779 default:
1780 return;
1781 }
1782}
void SetIconHLRSelected()
Definition G4UIQt.cc:6273
void SetIconCoudPointSelected()
Definition G4UIQt.cc:6334
void SetIconWireframeSelected()
Definition G4UIQt.cc:6243
void SetIconHLHSRSelected()
Definition G4UIQt.cc:6303

◆ UpdateProjectionStyle()

void G4UIQt::UpdateProjectionStyle ( G4int style)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 1784 of file G4UIQt.cc.

1784 {
1785 if (style == 0.) { // ortho
1786 this->SetIconOrthoSelected();
1787 } else {
1789 }
1790}

◆ UpdateSceneTree()

void G4UIQt::UpdateSceneTree ( const G4SceneTreeItem & root)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 1707 of file G4UIQt.cc.

1708{
1709 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree summary\n";
1710 // root.DumpTree(G4debug); // Verbosity = 0 (one line per item)
1711 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree dump\n";
1712 // root.DumpTree(G4debug,1); // Verbosity = 1 (higher levels available)
1713
1714 // Clear the existing GUI-side tree
1715 fNewSceneTreeItemTreeWidget->clear();
1716 // (I think this deletes everything - the top level items and their children.)
1717 fMaxPVDepth = 0;
1718
1719 // Build a new GUI-side tree
1720 fNewSceneTreeItemTreeWidget->setHeaderLabel (root.GetDescription().c_str());
1721 for (const auto& model : root.GetChildren()) {
1722
1723 auto item = new QTreeWidgetItem(fNewSceneTreeItemTreeWidget);
1724
1725 // Add this GUI-side representation of the model as a child of the top widget
1726 fNewSceneTreeItemTreeWidget->insertTopLevelItem(0,item);
1727
1728 // Add text that appears in the scene tree
1729 item->setText(0, model.GetModelType().c_str());
1730
1731 // Load with info from model
1732 // There may be a way to add data as a QVariant, or a list of QVariants,
1733 // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1734 // does not seem to be a way of adding a pointer directly.)
1735 std::ostringstream oss; oss << std::hex << &model;
1736 auto data = QVariant(oss.str().c_str());
1737 item->setData(0, Qt::UserRole, data);
1738
1739 // Load a tooltip
1740 G4String toolTipMessage = model.GetModelDescription();
1741 if (!model.GetFurtherInfo().empty()) {
1742 toolTipMessage += "\n " + model.GetFurtherInfo();
1743 }
1744 item->setToolTip(0, toolTipMessage.c_str());
1745
1746 // Set the check state
1747 item->setCheckState
1748 (0, model.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1749
1750 // Set the expand state
1751 item->setExpanded(model.IsExpanded());
1752
1753 if (model.GetType() == G4SceneTreeItem::pvmodel) {
1754 thisSceneTreePVDepth = -1; // First item is the model - touchables hang from it
1755 BuildPVQTree(model,item);
1756 }
1757 }
1758}
const G4String & GetDescription() const
const std::list< G4SceneTreeItem > & GetChildren() const

◆ UpdateTransparencySlider()

void G4UIQt::UpdateTransparencySlider ( G4double depth,
G4int option )
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 1792 of file G4UIQt.cc.

1792 {
1793 fNewSceneTreeSlider->blockSignals(true);
1794 fNewSceneTreeSlider->setValue(depth * maxInherentSliderValue / fMaxPVDepth);
1795 fNewSceneTreeSlider->blockSignals(false);
1796 if (option == 1) {
1797 fUnwrapButtonWidget->blockSignals(true);
1798 fUnwrapButtonWidget->setChecked(true);
1799 fUnwrapButtonWidget->blockSignals(false);
1800 }
1801 else if (option == 2) {
1802 fFadeButtonWidget->blockSignals(true);
1803 fFadeButtonWidget->setChecked(true);
1804 fFadeButtonWidget->blockSignals(false);
1805 }
1806 else if (option == 3) {
1807 fXrayButtonWidget->blockSignals(true);
1808 fXrayButtonWidget->setChecked(true);
1809 fXrayButtonWidget->blockSignals(false);
1810 }
1811}

The documentation for this class was generated from the following files: