Geant4 11.2.2
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 SetIconPickSelected ()
 
void SetIconZoomInSelected ()
 
void SetIconZoomOutSelected ()
 
void SetIconHLHSRSelected ()
 
void SetIconHLRSelected ()
 
void SetIconSolidSelected ()
 
void SetIconWireframeSelected ()
 
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
 
 ~G4UIQt () override
 
void Prompt (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 (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 120 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 118 of file G4UIQt.cc.

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

275{
276 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
277 if (UI != nullptr) { // TO KEEP
278 UI->SetSession(nullptr); // TO KEEP
279 UI->SetG4UIWindow(nullptr);
280 UI->SetCoutDestination(nullptr); // TO KEEP
281#ifdef G4MULTITHREADED
282 masterG4coutDestination = nullptr; // set to cout when UI is deleted
283#endif
284 }
285}

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 2810 of file G4UIQt.cc.

2811{
2812 if (aMenu == nullptr) return; // TO KEEP
2813 if (aLabel == nullptr) return; // TO KEEP
2814 if (aCommand == nullptr) return; // TO KEEP
2815
2816 QMenu* parentTmp = (QMenu*)GetInteractor(aMenu);
2817
2818 if (parentTmp == nullptr) {
2820 G4int verbose = UImanager->GetVerboseLevel();
2821
2822 if (verbose >= 2) {
2823 G4cout << "Menu name " << aMenu << " does not exist, please define it before using it."
2824 << G4endl;
2825 }
2826 return;
2827 }
2828
2829 // Find the command in the command tree
2831 if (UI == nullptr) return;
2832 G4UIcommandTree* treeTop = UI->GetTree();
2833
2834 G4String cmd = aCommand;
2835 std::size_t cmdEndPos = cmd.find_first_of(" \t");
2836 if (cmdEndPos != std::string::npos) {
2837 cmd.erase(cmdEndPos);
2838 }
2839
2840 if (treeTop->FindPath(cmd) == nullptr) {
2841 if (cmd != "ls" && cmd.substr(0, 3) != "ls " && cmd != "pwd" && cmd != "cd" &&
2842 cmd.substr(0, 3) != "cd " && cmd != "help" && cmd.substr(0, 5) != "help " &&
2843 cmd[0] != '?' && cmd != "hist" && cmd != "history" && cmd[0] != '!' && cmd != "exit" &&
2844 cmd != "cont" && cmd != "continue")
2845 {
2847 G4int verbose = UImanager->GetVerboseLevel();
2848
2849 if (verbose >= 2) {
2850 G4cout << "Warning: command '" << cmd
2851 << "' does not exist, please define it before using it." << G4endl;
2852 }
2853 }
2854 }
2855
2856 QString cmd_tmp = QString(aCommand);
2857 parentTmp->addAction(aLabel, this, [this, cmd_tmp]() { this->ButtonCallback(cmd_tmp); });
2858}
G4UIcommand * FindPath(const char *commandPath) const
G4UIcommandTree * GetTree() const
G4Interactor GetInteractor(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 2864 of file G4UIQt.cc.

2866{
2867 if (aLabel == nullptr) return; // TO KEEP
2868 // special case, aCommand could be NULL if aIconFile is not user_icon
2869 if (aCommand == nullptr) {
2870 if (std::string(aIconFile) == "user_icon") {
2871 return; // TO KEEP
2872 }
2873 }
2874 QPixmap* pix;
2875 G4bool userToolBar = false;
2876
2877 if (! fDefaultIcons) {
2878 userToolBar = true;
2879 }
2880 if (std::string(aIconFile) == "user_icon") {
2881 // try to open a file
2883 pix = new QPixmap(UImanager->FindMacroPath(aFileName).data());
2884 if (pix->isNull()) {
2885 G4int verbose = UImanager->GetVerboseLevel();
2886
2887 if (verbose >= 2) {
2888 G4cout << "Warning: file '" << aFileName
2889 << "' is incorrect or does not exist, this command will not be build" << G4endl;
2890 }
2891 return;
2892 }
2893 }
2894 else if (std::string(aIconFile) == "open") {
2895 pix = fOpenIcon;
2896 }
2897 else if (std::string(aIconFile) == "save") {
2898 pix = fSaveIcon;
2899 }
2900 else if (std::string(aIconFile) == "move") {
2901 pix = fMoveIcon;
2902 }
2903 else if (std::string(aIconFile) == "rotate") {
2904 pix = fRotateIcon;
2905 }
2906 else if (std::string(aIconFile) == "pick") {
2907 pix = fPickIcon;
2908 }
2909 else if (std::string(aIconFile) == "zoom_in") {
2910 pix = fZoomInIcon;
2911 }
2912 else if (std::string(aIconFile) == "zoom_out") {
2913 pix = fZoomOutIcon;
2914 }
2915 else if (std::string(aIconFile) == "wireframe") {
2916 pix = fWireframeIcon;
2917 }
2918 else if (std::string(aIconFile) == "solid") {
2919 pix = fSolidIcon;
2920 }
2921 else if (std::string(aIconFile) == "hidden_line_removal") {
2922 pix = fHiddenLineRemovalIcon;
2923 }
2924 else if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
2925 pix = fHiddenLineAndSurfaceRemovalIcon;
2926 }
2927 else if (std::string(aIconFile) == "perspective") {
2928 pix = fPerspectiveIcon;
2929 }
2930 else if (std::string(aIconFile) == "ortho") {
2931 pix = fOrthoIcon;
2932 }
2933 else if (std::string(aIconFile) == "runBeamOn") {
2934 pix = fRunIcon;
2935 }
2936 else if (std::string(aIconFile) == "exit") {
2937 pix = fExitIcon;
2938 }
2939 else {
2941 G4int verbose = UImanager->GetVerboseLevel();
2942
2943 if (verbose >= 2) {
2944 G4cout << "Parameter" << aIconFile << " not defined" << G4endl;
2945 }
2946 return;
2947 }
2948 QToolBar* currentToolbar = nullptr;
2949 if (userToolBar) {
2950 if (fToolbarUser == nullptr) {
2951 fToolbarUser = new QToolBar();
2952 fToolbarUser->setIconSize(QSize(20, 20));
2953 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
2954 }
2955 currentToolbar = fToolbarUser;
2956 }
2957 else {
2958 if (fToolbarApp == nullptr) {
2959 fToolbarApp = new QToolBar();
2960 fToolbarApp->setIconSize(QSize(20, 20));
2961 fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
2962 }
2963 currentToolbar = fToolbarApp;
2964 }
2965
2966 // Check if already present
2967
2968 QList<QAction*> list = currentToolbar->actions();
2969
2970 for (auto i : list) {
2971 if (i->text() == QString(aLabel)) {
2973 if (UI == nullptr) return;
2974 G4int verbose = UI->GetVerboseLevel();
2975 if (verbose >= 2) {
2976 G4cout << "Warning: A toolBar icon \"" << aLabel << "\" already exists with the same name!"
2977 << G4endl;
2978 }
2979 }
2980 }
2981
2982 // special cases :"open"
2983 if (std::string(aIconFile) == "open") {
2984 QString txt = aCommand + fStringSeparator + aLabel;
2985 currentToolbar->addAction(
2986 QIcon(*pix), aIconFile, this, [this, txt]() { this->OpenIconCallback(txt); });
2987
2988 // special cases :"save"
2989 }
2990 else if (std::string(aIconFile) == "save") {
2991 QString txt = aCommand + fStringSeparator + aLabel;
2992 currentToolbar->addAction(
2993 QIcon(*pix), aIconFile, this, [this, txt]() { this->SaveIconCallback(txt); });
2994 // special cases : cursor style
2995 }
2996 else if ((std::string(aIconFile) == "move") || (std::string(aIconFile) == "rotate") ||
2997 (std::string(aIconFile) == "pick") || (std::string(aIconFile) == "zoom_out") ||
2998 (std::string(aIconFile) == "zoom_in"))
2999 {
3000 QString txt = QString(aIconFile);
3001 QAction* action = currentToolbar->addAction(
3002 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeCursorAction(txt); });
3003 action->setCheckable(true);
3004 action->setChecked(true);
3005 action->setData(aIconFile);
3006
3007 if (std::string(aIconFile) == "move") {
3009 }
3010 if (std::string(aIconFile) == "rotate") {
3012 }
3013 if (std::string(aIconFile) == "pick") {
3015 }
3016 if (std::string(aIconFile) == "zoom_in") {
3018 }
3019 if (std::string(aIconFile) == "zoom_out") {
3021 }
3022
3023 // special case : surface style
3024 }
3025 else if ((std::string(aIconFile) == "hidden_line_removal") ||
3026 (std::string(aIconFile) == "hidden_line_and_surface_removal") ||
3027 (std::string(aIconFile) == "solid") || (std::string(aIconFile) == "wireframe"))
3028 {
3029 QString txt = QString(aIconFile);
3030 QAction* action = currentToolbar->addAction(
3031 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangeSurfaceStyle(txt); });
3032 action->setCheckable(true);
3033 action->setChecked(true);
3034 action->setData(aIconFile);
3035
3036 if (std::string(aIconFile) == "hidden_line_removal") {
3038 }
3039 if (std::string(aIconFile) == "hidden_line_and_surface_removal") {
3041 }
3042 if (std::string(aIconFile) == "solid") {
3044 }
3045 if (std::string(aIconFile) == "wireframe") {
3047 }
3048
3049 // special case : perspective/ortho
3050 }
3051 else if ((std::string(aIconFile) == "perspective") || (std::string(aIconFile) == "ortho")) {
3052 QString txt = QString(aIconFile);
3053 QAction* action = currentToolbar->addAction(
3054 QIcon(*pix), aIconFile, this, [this, txt]() { this->ChangePerspectiveOrtho(txt); });
3055 action->setCheckable(true);
3056 action->setChecked(true);
3057 action->setData(aIconFile);
3058
3059 if (std::string(aIconFile) == "perspective") {
3061 }
3062 if (std::string(aIconFile) == "ortho") {
3064 }
3065 }
3066 else {
3067 // Find the command in the command tree
3069 if (UI == nullptr) return;
3070 G4UIcommandTree* treeTop = UI->GetTree();
3071 if (aCommand != nullptr) {
3072 std::string str = aCommand;
3073 std::string::size_type pos = str.find(' ');
3074 if (pos != std::string::npos) {
3075 str = str.substr(0, pos).c_str();
3076 }
3077 if (treeTop->FindPath(str.c_str()) == nullptr) {
3079 G4int verbose = UImanager->GetVerboseLevel();
3080
3081 if (verbose >= 2) {
3082 G4cout << "Warning: command '" << aCommand
3083 << "' does not exist, please define it before using it." << G4endl;
3084 }
3085 }
3086 }
3087 QString txt = QString(aCommand);
3088 currentToolbar->addAction(
3089 QIcon(*pix), aCommand, this, [this, txt]() { this->ButtonCallback(txt); });
3090 }
3091}
void SetIconPickSelected()
Definition G4UIQt.cc:5149
void SetIconOrthoSelected()
Definition G4UIQt.cc:5384
void SetIconZoomInSelected()
Definition G4UIQt.cc:5184
void SetIconZoomOutSelected()
Definition G4UIQt.cc:5219
void SetIconHLRSelected()
Definition G4UIQt.cc:5308
void SetIconPerspectiveSelected()
Definition G4UIQt.cc:5363
void SetIconSolidSelected()
Definition G4UIQt.cc:5254
void SetIconRotateSelected()
Definition G4UIQt.cc:5119
void SetIconWireframeSelected()
Definition G4UIQt.cc:5281
void SetIconMoveSelected()
Definition G4UIQt.cc:5089
void SetIconHLHSRSelected()
Definition G4UIQt.cc:5335
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 2793 of file G4UIQt.cc.

2794{
2795 if (aName == nullptr) return;
2796 if (aLabel == nullptr) return;
2797
2798 auto fileMenu = new QMenu(aLabel);
2799 fMainWindow->menuBar()->addMenu(fileMenu);
2800
2801 AddInteractor(aName, (G4Interactor)fileMenu);
2802}
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 2283 of file G4UIQt.cc.

2284{
2285 if (fViewerTabWidget == nullptr) {
2286 CreateViewerWidget();
2287 }
2288
2289 if (aWidget == nullptr) {
2290 return false;
2291 }
2292 // Has to be added before we put it into the fViewerTabWidget widget
2293 aWidget->setParent(fViewerTabWidget); // Will create in some cases widget outside
2294 // of UI for a really short moment
2295
2296 fViewerTabWidget->addTab(aWidget, name);
2297
2298 fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count() - 1);
2299
2300 // Set visible
2301 fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
2302
2303 // Not the good solution, but ensure that the help tree is correctly build when launching a viewer
2304 // It should be done by a notification when adding a command, but that's nit done yet
2305 // (Geant4.10.1)
2306 FillHelpTree();
2307
2308 return true;
2309}
void setLastTabCreated(G4int a)
Definition G4UIQt.hh:89

Referenced by G4OpenInventorQtExaminerViewer::afterRealizeHook(), G4OpenGLQtViewer::CreateMainWindow(), G4VtkQtViewer::CreateMainWindow(), G4UIQt(), G4ToolsSGQtGLESViewer::Initialise(), and G4ToolsSGQtZBViewer::Initialise().

◆ AddViewerTab()

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

Add a new tab in the viewer

Definition at line 2243 of file G4UIQt.cc.

2244{
2245 if (fViewerTabWidget == nullptr) {
2246 return false;
2247 }
2248 fViewerTabWidget->addTab(aWidget, title.c_str());
2249
2250 return true;
2251}

◆ AddViewerTabFromFile()

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

Add a new tab in the viewer

Definition at line 2255 of file G4UIQt.cc.

2256{
2257 if (fViewerTabWidget == nullptr) {
2258 return false;
2259 }
2260
2262 if (UI == nullptr) return false;
2263 std::ifstream file(UI->FindMacroPath(fileName.c_str()).data());
2264 if (file) {
2265 std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
2266
2267 auto text = new QTextEdit();
2268 text->setAcceptRichText(true);
2269 text->setContentsMargins(5, 5, 5, 5);
2270 text->setText(QString("<pre>") + content.c_str() + "</pre>");
2271 text->setReadOnly(true);
2272 fViewerTabWidget->addTab(text, title.c_str());
2273 }
2274 else {
2275 return false;
2276 }
2277 return true;
2278}

◆ ClearMenu()

void G4UIQt::ClearMenu ( )
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 3110 of file G4UIQt.cc.

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

◆ DefaultIcons()

void G4UIQt::DefaultIcons ( G4bool aVal)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 287 of file G4UIQt.cc.

288{
289 fDefaultIcons = aVal;
290
291 if (! fMainWindow->isVisible()) {
292 return;
293 }
294
295 if (fToolbarApp != nullptr) {
296 if (aVal) {
297 fToolbarApp->setVisible(true);
298 }
299 else {
300 // Set not visible until session start
301 fToolbarApp->setVisible(false);
302 }
303 }
304}

◆ getClearIcon()

QPixmap * G4UIQt::getClearIcon ( )
inline

Definition at line 209 of file G4UIQt.hh.

209{ return fClearIcon; };

◆ GetCoutDockWidget()

G4UIDockWidget * G4UIQt::GetCoutDockWidget ( )
inline

Definition at line 220 of file G4UIQt.hh.

220{ return fCoutDockWidget; };

◆ GetCoutWidget()

QWidget * G4UIQt::GetCoutWidget ( )
inline

Definition at line 217 of file G4UIQt.hh.

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

◆ GetHelpWidget()

QWidget * G4UIQt::GetHelpWidget ( )
inline

Definition at line 232 of file G4UIQt.hh.

232{ return fHelpTBWidget; }

◆ GetHistoryWidget()

QWidget * G4UIQt::GetHistoryWidget ( )
inline

Definition at line 229 of file G4UIQt.hh.

229{ return fHistoryTBWidget; }

◆ GetMainWindow()

QMainWindow * G4UIQt::GetMainWindow ( )
inline

Definition at line 203 of file G4UIQt.hh.

203{ return fMainWindow; };

Referenced by G4ToolsSGQtGLESViewer::Initialise(), and G4ToolsSGQtZBViewer::Initialise().

◆ GetPickInfosWidget()

QWidget * G4UIQt::GetPickInfosWidget ( )

Get the Pick Widget

Definition at line 2233 of file G4UIQt.cc.

2234{
2235 if (fPickInfosDialog == nullptr) {
2236 CreatePickInfosDialog();
2237 }
2238 return fPickInfosWidget;
2239}

◆ GetSceneTreeWidget()

QWidget * G4UIQt::GetSceneTreeWidget ( )

Get the ViewerComponents ToolBox Widget

Definition at line 2219 of file G4UIQt.cc.

2219{ return fSceneTreeWidget; }

◆ getSearchIcon()

QPixmap * G4UIQt::getSearchIcon ( )
inline

Definition at line 206 of file G4UIQt.hh.

206{ return fSearchIcon; };

◆ GetUITabWidget()

QTabWidget * G4UIQt::GetUITabWidget ( )
inline

Definition at line 226 of file G4UIQt.hh.

226{ return fUITabWidget; }

◆ GetUserInterfaceWidget()

G4UIDockWidget * G4UIQt::GetUserInterfaceWidget ( )
inline

Definition at line 223 of file G4UIQt.hh.

223{ return fUIDockWidget; };

◆ GetViewerPropertiesWidget()

QWidget * G4UIQt::GetViewerPropertiesWidget ( )

Get the Viewer properties Widget

Definition at line 2223 of file G4UIQt.cc.

2224{
2225 if (fViewerPropertiesDialog == nullptr) {
2226 CreateViewerPropertiesDialog();
2227 }
2228 return fViewerPropertiesWidget;
2229}

◆ GetViewerTabWidget()

QTabWidget * G4UIQt::GetViewerTabWidget ( )
inline

◆ IsIconMoveSelected()

G4bool G4UIQt::IsIconMoveSelected ( )
inline

◆ IsIconPickSelected()

G4bool G4UIQt::IsIconPickSelected ( )
inline

Definition at line 186 of file G4UIQt.hh.

186{ return fPickSelected; };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsIconRotateSelected()

G4bool G4UIQt::IsIconRotateSelected ( )
inline

◆ IsIconZoomInSelected()

G4bool G4UIQt::IsIconZoomInSelected ( )
inline

Definition at line 187 of file G4UIQt.hh.

187{ return fZoomInSelected; };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsIconZoomOutSelected()

G4bool G4UIQt::IsIconZoomOutSelected ( )
inline

Definition at line 188 of file G4UIQt.hh.

188{ return fZoomOutSelected; };

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ IsSplitterReleased()

G4bool G4UIQt::IsSplitterReleased ( )

◆ NativeMenu()

void G4UIQt::NativeMenu ( G4bool aVal)
overridevirtual

Reimplemented from G4VInteractiveSession.

Definition at line 3102 of file G4UIQt.cc.

3103{
3104 if (fMainWindow->menuBar()->isNativeMenuBar() == aVal) return; // already in this state
3105
3106 // Menu become empty when goin from Qt to Native Bar
3107 fMainWindow->menuBar()->setNativeMenuBar(aVal);
3108}

◆ 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 2418 of file G4UIQt.cc.

2419{
2420 if (aState == nullptr) return;
2421
2422 if (aState == "G4_pause> ") { // TO KEEP
2423 SecondaryLoop("Pause, type continue to exit this state"); // TO KEEP
2424 } // TO KEEP
2425
2426 if (aState == "EndOfEvent") { // TO KEEP
2427 // Picking with feed back in event data Done here !!!
2428 SecondaryLoop("End of event, type continue to exit this state"); // TO KEEP
2429 } // TO KEEP
2430}

◆ Prompt()

void G4UIQt::Prompt ( G4String aPrompt)

Display the prompt in the prompt area

Parameters
aPrompt: string to display as the promt label

Definition at line 2396 of file G4UIQt.cc.

2397{
2398 if (aPrompt == nullptr) return;
2399
2400 fCommandLabel->setText((char*)aPrompt.data());
2401}

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 2654 of file G4UIQt.cc.

2655{
2656 if (aString.empty()) return 0;
2657
2658#ifdef G4MULTITHREADED
2659 G4AutoLock al(&ReceiveMutex);
2660#endif
2661
2662 // A workaround so that output is not lost after crash or G4Exception.
2663 // The "workaround" is to make sure all flushed output appears on
2664 // the terminal after a crash, because even flushed output can
2665 // get lost in the Qt UI system.
2666 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2667 // so limit this to the master thread
2668#ifdef G4MULTITHREADED
2670#endif
2671 std::cerr << aString << std::flush;
2672
2673 G4String aStringWithStyle;
2674 // aString has a \n on the end (maybe it comes from G4endl or from the
2675 // Enter key on the command line) - ignore it. That’s why
2676 // i < aString.length() - 1
2677 // But other \n need to be translated to an HTML newline.
2678 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2679 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2680 // on how many characters precede it. Probably needs an HTML table. For now
2681 // we replace \t with four spaces.
2682 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2683 if (aString[i] == '\n') {
2684 aStringWithStyle += "<br>";
2685 }
2686 else if (aString[i] == ' ') {
2687 aStringWithStyle += "&nbsp;";
2688 }
2689 else if (aString[i] == '\t') {
2690 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2691 }
2692 else if (aString[i] == '<') {
2693 aStringWithStyle += "&lt;";
2694 }
2695 else {
2696 aStringWithStyle += aString[i];
2697 }
2698 }
2699 if (fOutputStyles["cerr"].fixed) {
2700 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2701 }
2702 else {
2703 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2704 }
2705
2706 // Add to string
2707
2708 G4UIOutputString txt =
2709 G4UIOutputString(QString((char*)aStringWithStyle.data()).trimmed(), GetThreadPrefix(), "error");
2710 fG4OutputString.push_back(txt);
2711
2712#ifdef G4MULTITHREADED
2713 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2714#else
2715 QString result = FilterOutput(txt, "", fCoutFilter->text());
2716#endif
2717 if (result.isEmpty()) {
2718 return 0;
2719 }
2720
2721 // Suppress space, \n,\t,\r...
2722 if (QString(aString.data()).trimmed() != "") {
2723 if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
2724 (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit))
2725 {
2726 // In case of Abort or Quit, the useful error message should be in the last error message !
2727 fLastErrMessage += "\n" + aString;
2728 QString criticalMessage = fLastErrMessage.data();
2729 criticalMessage = criticalMessage.toHtmlEscaped();
2730 QMessageBox::critical(fMainWindow, "Error", QString(fLastErrMessage));
2731 }
2732 }
2733 fCoutTBTextArea->append(QString("<font color=\"Red\">") + result + QString("</font>"));
2734 fCoutTBTextArea->ensureCursorVisible();
2735
2736 if (QString(aString.data()).trimmed() != "") {
2737 fLastErrMessage += aString;
2738 }
2739#ifdef G4MULTITHREADED
2740 UpdateCoutThreadFilter();
2741#endif
2742 return 0;
2743}
@ G4State_Quit
@ G4State_Abort
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 2553 of file G4UIQt.cc.

2554{
2555 if (aString.empty()) return 0;
2556
2557 // Try to be smart :
2558 // "*** This is just a warning message. ***"
2559 if (G4StrUtil::contains(aString, "*** This is just a warning message. ***")) {
2560 return ReceiveG4cerr(aString);
2561 }
2562
2563#ifdef G4MULTITHREADED
2564 G4AutoLock al(&ReceiveMutex);
2565#endif
2566
2567 // A workaround so that output is not lost after crash or G4Exception.
2568 // The "workaround" is to make sure all flushed output appears on
2569 // the terminal after a crash, because even flushed output can
2570 // get lost in the Qt UI system.
2571 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2572 // so limit this to the master thread
2573#ifdef G4MULTITHREADED
2575#endif
2576 std::cout << aString << std::flush;
2577
2578 G4String aStringWithStyle;
2579 // aString has a \n on the end (maybe it comes from G4endl or from the
2580 // Enter key on the command line) - ignore it. That’s why
2581 // i < aString.length() - 1
2582 // But other \n need to be translated to an HTML newline.
2583 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2584 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2585 // on how many characters precede it. Probably needs an HTML table. For now
2586 // we replace \t with four spaces.
2587 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2588 if (aString[i] == '\n') {
2589 aStringWithStyle += "<br>";
2590 }
2591 else if (aString[i] == ' ') {
2592 aStringWithStyle += "&nbsp;";
2593 }
2594 else if (aString[i] == '\t') {
2595 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2596 }
2597 else if (aString[i] == '<') {
2598 aStringWithStyle += "&lt;";
2599 }
2600 else {
2601 aStringWithStyle += aString[i];
2602 }
2603 }
2604 if (fOutputStyles["cout"].fixed) {
2605 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2606 }
2607 else {
2608 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2609 }
2610
2611 // Add to string
2612 G4UIOutputString txt =
2613 G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
2614 fG4OutputString.push_back(txt);
2615
2616#ifdef G4MULTITHREADED
2617 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2618#else
2619 QString result = FilterOutput(txt, "", fCoutFilter->text());
2620#endif
2621
2622 if (result.isEmpty()) {
2623 return 0;
2624 }
2625
2627 if (fOutputStyles["cout"].highlight) {
2628 if (! UI->IsLastCommandOutputTreated()) {
2629 QPalette pal;
2630 result = QString("<span style='background:") + pal.link().color().name() +
2631 ";'>&nbsp;</span>" + "<span style='background:" + pal.highlight().color().name() +
2632 ";'> " + result + "</span>";
2633 }
2634 }
2636
2637 fCoutTBTextArea->append(result);
2638 fCoutTBTextArea->ensureCursorVisible();
2639
2640#ifdef G4MULTITHREADED
2641 UpdateCoutThreadFilter();
2642#endif
2643
2644 // reset error stack
2645 fLastErrMessage = aString;
2646 return 0;
2647}
G4int ReceiveG4cerr(const G4String &) override
Definition G4UIQt.cc:2654
bool IsLastCommandOutputTreated()
void SetLastCommandOutputTreated()

◆ 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 2464 of file G4UIQt.cc.

2465{
2466 if (aString.empty()) return 0;
2467
2468#ifdef G4MULTITHREADED
2469 G4AutoLock al(&ReceiveMutex);
2470#endif
2471
2472 // A workaround so that output is not lost after crash or G4Exception.
2473 // The "workaround" is to make sure all flushed output appears on
2474 // the terminal after a crash, because even flushed output can
2475 // get lost in the Qt UI system.
2476 // But...it seems workers write to std::cout/cerr anyway (is that a bug?),
2477 // so limit this to the master thread
2478#ifdef G4MULTITHREADED
2480#endif
2481 std::cout << aString << std::flush;
2482
2483 G4String aStringWithStyle;
2484 // aString has a \n on the end (maybe it comes from G4endl or from the
2485 // Enter key on the command line) - ignore it. That’s why
2486 // i < aString.length() - 1
2487 // But other \n need to be translated to an HTML newline.
2488 // Similarly, spaces need to be translated to an HTML "non-breaking space".
2489 // Tabs (\t) are more tricky since the number of equivalent spaces depends
2490 // on how many characters precede it. Probably needs an HTML table. For now
2491 // we replace \t with four spaces.
2492 for (G4int i = 0; i < (G4int)aString.length() - 1; ++i) {
2493 if (aString[i] == '\n') {
2494 aStringWithStyle += "<br>";
2495 }
2496 else if (aString[i] == ' ') {
2497 aStringWithStyle += "&nbsp;";
2498 }
2499 else if (aString[i] == '\t') {
2500 aStringWithStyle += "&nbsp;&nbsp;&nbsp;&nbsp;";
2501 }
2502 else if (aString[i] == '<') {
2503 aStringWithStyle += "&lt;";
2504 }
2505 else {
2506 aStringWithStyle += aString[i];
2507 }
2508 }
2509 if (fOutputStyles["debug"].fixed) {
2510 aStringWithStyle = "<span style='font-family:courier;'>" + aStringWithStyle + "</span>";
2511 }
2512 else {
2513 aStringWithStyle = "<span>" + aStringWithStyle + "</span>";
2514 }
2515
2516 // Add to string
2517 G4UIOutputString txt =
2518 G4UIOutputString(QString((char*)aStringWithStyle.data()), GetThreadPrefix());
2519 fG4OutputString.push_back(txt);
2520
2521#ifdef G4MULTITHREADED
2522 QString result = FilterOutput(txt, fThreadsFilterComboBox->currentText(), fCoutFilter->text());
2523#else
2524 QString result = FilterOutput(txt, "", fCoutFilter->text());
2525#endif
2526
2527 if (result.isEmpty()) {
2528 return 0;
2529 }
2530
2531 if (fOutputStyles["debug"].highlight) {
2532 QPalette pal;
2533 result = QString("<span style='background:") + pal.link().color().name() + ";'>&nbsp;</span>" +
2534 "<span style='background: Pink;'> " + result + "</span>";
2535 }
2536 result = QString("<font color=\"Green\">") + result + QString("</font>");
2537
2538 fCoutTBTextArea->append(result);
2539 fCoutTBTextArea->ensureCursorVisible();
2540
2541#ifdef G4MULTITHREADED
2542 UpdateCoutThreadFilter();
2543#endif
2544
2545 return 0;
2546}

◆ SessionStart()

G4UIsession * G4UIQt::SessionStart ( )
overridevirtual

Start the Qt main loop

Implements G4VBasicShell.

Definition at line 2355 of file G4UIQt.cc.

2356{
2357 G4Qt* interactorManager = G4Qt::getInstance();
2358 Prompt("Session :");
2359 exitSession = false;
2360
2361 QCoreApplication::sendPostedEvents();
2362
2363 fMainWindow->setVisible(true);
2364
2365 if (fDefaultIcons) {
2366 fToolbarApp->setVisible(true);
2367 }
2368 else {
2369 // Set not visible until session start
2370 fToolbarApp->setVisible(false);
2371 }
2372 // Rebuild help tree (new command could be registered)
2373 FillHelpTree();
2374
2375 // Rebuild command completion (new command could be registered)
2376 UpdateCommandCompleter();
2377
2378 // Set event filters
2379 fHistoryTBTableList->installEventFilter(this);
2380 fCommandArea->installEventFilter(this);
2381
2382 // Focus on command line
2383 fCommandArea->setFocus();
2384
2385 interactorManager->DisableSecondaryLoop(); // TO KEEP
2386 if ((QApplication*)interactorManager->GetMainInteractor() != nullptr)
2387 ((QApplication*)interactorManager->GetMainInteractor())->exec();
2388
2389 interactorManager->EnableSecondaryLoop();
2390 return this;
2391}
void Prompt(G4String)
Definition G4UIQt.cc:2396

◆ SessionTerminate()

void G4UIQt::SessionTerminate ( )

Definition at line 2403 of file G4UIQt.cc.

2404{
2405 G4Qt* interactorManager = G4Qt::getInstance();
2406 fMainWindow->close();
2407 ((QApplication*)interactorManager->GetMainInteractor())->exit();
2408}

◆ SetIconHLHSRSelected()

void G4UIQt::SetIconHLHSRSelected ( )

Definition at line 5335 of file G4UIQt.cc.

5336{
5337 // Theses actions should be in the app toolbar
5338
5339 QToolBar* bar = fToolbarApp;
5340 if (! fDefaultIcons) {
5341 bar = fToolbarUser;
5342 }
5343
5344 if (bar == nullptr) return;
5345
5346 QList<QAction*> list = bar->actions();
5347 for (auto i : list) {
5348 if (i->data().toString() == "hidden_line_and_surface_removal") {
5349 i->setChecked(true);
5350 }
5351 else if (i->data().toString() == "solid") {
5352 i->setChecked(false);
5353 }
5354 else if (i->data().toString() == "hidden_line_removal") {
5355 i->setChecked(false);
5356 }
5357 else if (i->data().toString() == "wireframe") {
5358 i->setChecked(false);
5359 }
5360 }
5361}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconHLRSelected()

void G4UIQt::SetIconHLRSelected ( )

Definition at line 5308 of file G4UIQt.cc.

5309{
5310 // Theses actions should be in the app toolbar
5311
5312 QToolBar* bar = fToolbarApp;
5313 if (! fDefaultIcons) {
5314 bar = fToolbarUser;
5315 }
5316 if (bar == nullptr) return;
5317
5318 QList<QAction*> list = bar->actions();
5319 for (auto i : list) {
5320 if (i->data().toString() == "hidden_line_removal") {
5321 i->setChecked(true);
5322 }
5323 else if (i->data().toString() == "solid") {
5324 i->setChecked(false);
5325 }
5326 else if (i->data().toString() == "hidden_line_and_surface_removal") {
5327 i->setChecked(false);
5328 }
5329 else if (i->data().toString() == "wireframe") {
5330 i->setChecked(false);
5331 }
5332 }
5333}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconMoveSelected()

void G4UIQt::SetIconMoveSelected ( )

Definition at line 5089 of file G4UIQt.cc.

5090{
5091 // Theses actions should be in the app toolbar
5092 fMoveSelected = true;
5093 fRotateSelected = false;
5094 fPickSelected = false;
5095 fZoomInSelected = false;
5096 fZoomOutSelected = false;
5097
5098 if (fToolbarApp == nullptr) return;
5099 QList<QAction*> list = fToolbarApp->actions();
5100 for (auto i : list) {
5101 if (i->data().toString() == "move") {
5102 i->setChecked(true);
5103 }
5104 else if (i->data().toString() == "rotate") {
5105 i->setChecked(false);
5106 }
5107 else if (i->data().toString() == "pick") {
5108 i->setChecked(false);
5109 }
5110 else if (i->data().toString() == "zoom_in") {
5111 i->setChecked(false);
5112 }
5113 else if (i->data().toString() == "zoom_out") {
5114 i->setChecked(false);
5115 }
5116 }
5117}

Referenced by AddIcon().

◆ SetIconOrthoSelected()

void G4UIQt::SetIconOrthoSelected ( )

Definition at line 5384 of file G4UIQt.cc.

5385{
5386 // Theses actions should be in the app toolbar
5387
5388 QToolBar* bar = fToolbarApp;
5389 if (! fDefaultIcons) {
5390 bar = fToolbarUser;
5391 }
5392
5393 if (bar == nullptr) return;
5394
5395 QList<QAction*> list = bar->actions();
5396 for (auto i : list) {
5397 if (i->data().toString() == "ortho") {
5398 i->setChecked(true);
5399 }
5400 else if (i->data().toString() == "perspective") {
5401 i->setChecked(false);
5402 }
5403 }
5404}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconPerspectiveSelected()

void G4UIQt::SetIconPerspectiveSelected ( )

Definition at line 5363 of file G4UIQt.cc.

5364{
5365 // Theses actions should be in the app toolbar
5366
5367 QToolBar* bar = fToolbarApp;
5368 if (! fDefaultIcons) {
5369 bar = fToolbarUser;
5370 }
5371 if (bar == nullptr) return;
5372
5373 QList<QAction*> list = bar->actions();
5374 for (auto i : list) {
5375 if (i->data().toString() == "perspective") {
5376 i->setChecked(true);
5377 }
5378 else if (i->data().toString() == "ortho") {
5379 i->setChecked(false);
5380 }
5381 }
5382}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconPickSelected()

void G4UIQt::SetIconPickSelected ( )

Definition at line 5149 of file G4UIQt.cc.

5150{
5151 // Theses actions should be in the app toolbar
5152 fPickSelected = true;
5153 fMoveSelected = false;
5154 fRotateSelected = false;
5155 fZoomInSelected = false;
5156 fZoomOutSelected = false;
5157
5158 QToolBar* bar = fToolbarApp;
5159 if (! fDefaultIcons) {
5160 bar = fToolbarUser;
5161 }
5162 if (bar == nullptr) return;
5163
5164 QList<QAction*> list = bar->actions();
5165 for (auto i : list) {
5166 if (i->data().toString() == "pick") {
5167 i->setChecked(true);
5168 }
5169 else if (i->data().toString() == "move") {
5170 i->setChecked(false);
5171 }
5172 else if (i->data().toString() == "rotate") {
5173 i->setChecked(false);
5174 }
5175 else if (i->data().toString() == "zoom_in") {
5176 i->setChecked(false);
5177 }
5178 else if (i->data().toString() == "zoom_out") {
5179 i->setChecked(false);
5180 }
5181 }
5182}

Referenced by AddIcon().

◆ SetIconRotateSelected()

void G4UIQt::SetIconRotateSelected ( )

Definition at line 5119 of file G4UIQt.cc.

5120{
5121 // Theses actions should be in the app toolbar
5122 fRotateSelected = true;
5123 fMoveSelected = false;
5124 fPickSelected = false;
5125 fZoomInSelected = false;
5126 fZoomOutSelected = false;
5127
5128 if (fToolbarApp == nullptr) return;
5129 QList<QAction*> list = fToolbarApp->actions();
5130 for (auto i : list) {
5131 if (i->data().toString() == "rotate") {
5132 i->setChecked(true);
5133 }
5134 else if (i->data().toString() == "move") {
5135 i->setChecked(false);
5136 }
5137 else if (i->data().toString() == "pick") {
5138 i->setChecked(false);
5139 }
5140 else if (i->data().toString() == "zoom_in") {
5141 i->setChecked(false);
5142 }
5143 else if (i->data().toString() == "zoom_out") {
5144 i->setChecked(false);
5145 }
5146 }
5147}

Referenced by AddIcon().

◆ SetIconSolidSelected()

void G4UIQt::SetIconSolidSelected ( )

Definition at line 5254 of file G4UIQt.cc.

5255{
5256 // Theses actions should be in the app toolbar
5257
5258 QToolBar* bar = fToolbarApp;
5259 if (! fDefaultIcons) {
5260 bar = fToolbarUser;
5261 }
5262 if (bar == nullptr) return;
5263
5264 QList<QAction*> list = bar->actions();
5265 for (auto i : list) {
5266 if (i->data().toString() == "solid") {
5267 i->setChecked(true);
5268 }
5269 else if (i->data().toString() == "hidden_line_removal") {
5270 i->setChecked(false);
5271 }
5272 else if (i->data().toString() == "hidden_line_and_surface_removal") {
5273 i->setChecked(false);
5274 }
5275 else if (i->data().toString() == "wireframe") {
5276 i->setChecked(false);
5277 }
5278 }
5279}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconWireframeSelected()

void G4UIQt::SetIconWireframeSelected ( )

Definition at line 5281 of file G4UIQt.cc.

5282{
5283 // Theses actions should be in the app toolbar
5284
5285 QToolBar* bar = fToolbarApp;
5286 if (! fDefaultIcons) {
5287 bar = fToolbarUser;
5288 }
5289 if (bar == nullptr) return;
5290
5291 QList<QAction*> list = bar->actions();
5292 for (auto i : list) {
5293 if (i->data().toString() == "wireframe") {
5294 i->setChecked(true);
5295 }
5296 else if (i->data().toString() == "hidden_line_removal") {
5297 i->setChecked(false);
5298 }
5299 else if (i->data().toString() == "hidden_line_and_surface_removal") {
5300 i->setChecked(false);
5301 }
5302 else if (i->data().toString() == "solid") {
5303 i->setChecked(false);
5304 }
5305 }
5306}

Referenced by AddIcon(), and G4OpenGLQtViewer::updateToolbarAndMouseContextMenu().

◆ SetIconZoomInSelected()

void G4UIQt::SetIconZoomInSelected ( )

Definition at line 5184 of file G4UIQt.cc.

5185{
5186 // Theses actions should be in the app toolbar
5187 fZoomInSelected = true;
5188 fMoveSelected = false;
5189 fRotateSelected = false;
5190 fPickSelected = false;
5191 fZoomOutSelected = false;
5192
5193 QToolBar* bar = fToolbarApp;
5194 if (! fDefaultIcons) {
5195 bar = fToolbarUser;
5196 }
5197 if (bar == nullptr) return;
5198
5199 QList<QAction*> list = bar->actions();
5200 for (auto i : list) {
5201 if (i->data().toString() == "zoom_in") {
5202 i->setChecked(true);
5203 }
5204 else if (i->data().toString() == "move") {
5205 i->setChecked(false);
5206 }
5207 else if (i->data().toString() == "rotate") {
5208 i->setChecked(false);
5209 }
5210 else if (i->data().toString() == "pick") {
5211 i->setChecked(false);
5212 }
5213 else if (i->data().toString() == "zoom_out") {
5214 i->setChecked(false);
5215 }
5216 }
5217}

Referenced by AddIcon().

◆ SetIconZoomOutSelected()

void G4UIQt::SetIconZoomOutSelected ( )

Definition at line 5219 of file G4UIQt.cc.

5220{
5221 // Theses actions should be in the app toolbar
5222 fZoomOutSelected = true;
5223 fMoveSelected = false;
5224 fRotateSelected = false;
5225 fPickSelected = false;
5226 fZoomInSelected = false;
5227
5228 QToolBar* bar = fToolbarApp;
5229 if (! fDefaultIcons) {
5230 bar = fToolbarUser;
5231 }
5232 if (bar == nullptr) return;
5233
5234 QList<QAction*> list = bar->actions();
5235 for (auto i : list) {
5236 if (i->data().toString() == "zoom_out") {
5237 i->setChecked(true);
5238 }
5239 else if (i->data().toString() == "move") {
5240 i->setChecked(false);
5241 }
5242 else if (i->data().toString() == "rotate") {
5243 i->setChecked(false);
5244 }
5245 else if (i->data().toString() == "pick") {
5246 i->setChecked(false);
5247 }
5248 else if (i->data().toString() == "zoom_in") {
5249 i->setChecked(false);
5250 }
5251 }
5252}

Referenced by AddIcon().

◆ SetOutputStyle()

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

Reimplemented from G4VInteractiveSession.

Definition at line 3093 of file G4UIQt.cc.

3094{
3095 // Specify an output style
3096 // First argument destination ("cout" etc or "all")
3097 // Second argument is the required style - see guidance
3098
3099 SetStyleUtility(destination, style);
3100}
void SetStyleUtility(const G4String &destination, const G4String &style)

◆ SetStartPage()

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

Definition at line 2311 of file G4UIQt.cc.

2312{
2313 if (! text.empty()) {
2314 fDefaultViewerFirstPageHTMLText = text;
2315 }
2316 if (fStartPage == nullptr) {
2317 fStartPage = new QTextBrowser();
2318 fStartPage->setContentsMargins(5, 5, 5, 5);
2319 fStartPage->setReadOnly(true);
2320 }
2321 fStartPage->setOpenExternalLinks(true);
2322 fStartPage->setHtml(fDefaultViewerFirstPageHTMLText.c_str());
2323}

◆ UpdateSceneTree()

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

Reimplemented from G4VInteractiveSession.

Definition at line 1510 of file G4UIQt.cc.

1511{
1512 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree summary\n";
1513 // root.DumpTree(G4debug); // Verbosity = 0 (one line per item)
1514 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree dump\n";
1515 // root.DumpTree(G4debug,1); // Verbosity = 1 (higher levels available)
1516
1517 // Clear the existing GUI-side tree
1518 fNewSceneTreeItemTreeWidget->clear();
1519 // (I think this deletes everything - the top level items and their children.)
1520
1521 // Build a new GUI-side tree
1522 fNewSceneTreeItemTreeWidget->setHeaderLabel (root.GetDescription().c_str());
1523 for (const auto& model : root.GetChildren()) {
1524
1525 auto item = new QTreeWidgetItem(fNewSceneTreeItemTreeWidget);
1526
1527 // Add this GUI-side representation of the model as a child of the top widget
1528 fNewSceneTreeItemTreeWidget->insertTopLevelItem(0,item);
1529
1530 // Add text that appears in the scene tree
1531 item->setText(0, model.GetModelType().c_str());
1532
1533 // Load with info from model
1534 // There may be a way to add data as a QVariant, or a list of QVariants,
1535 // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1536 // does not seem to be a way of adding a pointer directly.)
1537 std::ostringstream oss; oss << std::hex << &model;
1538 auto data = QVariant(oss.str().c_str());
1539 item->setData(0, Qt::UserRole, data);
1540
1541 // Load a tooltip
1542 item->setToolTip(0, model.GetModelDescription().c_str());
1543
1544 // Set the check state
1545 item->setCheckState
1546 (0, model.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1547
1548 // Set the expand state
1549 item->setExpanded(model.IsExpanded());
1550
1551 if (model.GetType() == G4SceneTreeItem::pvmodel) {
1552 BuildPVQTree(model,item);
1553 }
1554 }
1555}
const G4String & GetDescription() const
const std::list< G4SceneTreeItem > & GetChildren() const

Referenced by G4ToolsSGQtGLESViewer::UpdateGUISceneTree(), and G4ToolsSGQtZBViewer::UpdateGUISceneTree().


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