Opened 14 years ago
Last modified 13 years ago
#45 new defect
OGLSQt and OGLIQt with non Qt UI
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | major | Milestone: | Geant4.9.5 |
Component: | Config | Version: | |
Keywords: | Cc: |
Description
What should we do about that ? allow ? not ?
See mail thread Rép : Loss of default arguments in G4UIExecutive constructor
Cc: Joseph, Guy for comment. OK. Sounds good. I think we have to handle both cases because there will always be someone who will try it. However, what do we do about the second case? It provides no more functionality than OGL[IS]X because one cannot interact with the window. Do we: a) allow it? b) (simply?) issue a message that says, "With this user interface you cannot exploit the full functionality of the Qt viewer. Please use the G4UIQt session. (In the standard configuration, set appropriate environment variables - G4UI_USE_QT - and unset G4UI_USE_TCSH.)" or some such? c) both? Either way, this is, of course, for a future release or patch. Cheers, John. On 30 Nov 2009, at 10:46, Laurent Garnier wrote: The problem is to switch between two cases (I wrote it, perhaps it will be more clear for me) * First case : G4UIQt with or without vis -> had to create QApp -> Set mainInteractor to QApp * Second case : G4UI but NOT Qt, and QtVIS -> had to create QApp -> do NOT set mainInteractor to QApp For the moment, I choose beween the two by looking arguments, but that is clearlyNOT the good solution. I do not understand why when I check this last week it was working. I've check it again this morning and it exit! Fine, I'm now in the good way. To solve this, we could provide a new method in G4Qt :G4Qt :: getInstanceWithInteractor Then we have to change one line in G4OpenGLQtViewer.cc What do you think about ? Cheers, Laurent Le 29 nov. 2009 à 12:20, John Allison a écrit : The problem is in l.107: G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt"); if (!(QApplication*)interactorManager->GetMainInteractor()) { G4cout << "G4UIQt : Unable to init Qt. Aborted" << G4endl; and then in G4Qt.cc, l.66: instance = new G4Qt(a_argn,a_args,a_class); and then in G4Qt::G4Qt. With G4DEBUG_INTERFACES_COMMON and G4DEBUG_INTERFACES_BASIC set I get G4Qt::G4Qt try to inited Qt G4Qt::G4Qt inited Qt END G4Qt::qApp exist G4UIQt : Unable to init Qt. Aborted G4UIQt::Initialise after main window creation I think it is to do with the logic you have here: // Then two cases : // - It is the first time we create G4UI (argc!=0) // -> Inited and register // - It is the first time we create G4VIS (argc == 0) // -> Inited and NOT register Is there another way to distinguish between G4UI and G4VIS? Cheers, John. On 27 Nov 2009, at 13:57, Laurent Garnier wrote: Still no problem for me.... Could you recompil raising the flag "G4DEBUG_INTERFACES_COMMON" in GNUmakefile ?Thanks. Everything is done in G4Qt line 130-140 :#if QT_VERSION < 0x040000 qApp = new QApplication (*p_argn, args);#else new QApplication (*p_argn, args);#endif if(!qApp) { G4cout << "G4Qt : Unable to init Qt." << G4endl; } else { QtInited = TRUE; if (a_argn != 0) { SetMainInteractor (qApp); } SetArguments (a_argn,a_args);#ifdef G4DEBUG_INTERFACES_COMMON printf("G4Qt::G4Qt inited Qt END\n");#endif } Laurent Le 27 nov. 2009 à 13:45, John Allison a écrit : G4UIExecutive* ui = new G4UIExecutive(0,0); gives message and a normal exit. G4UIQt : Unable to init Qt. AbortedGraphics systems deleted.Visualization Manager deleting... On 27 Nov 2009, at 12:38, John Allison wrote: On 27 Nov 2009, at 11:26, Laurent Garnier wrote: Le 27 nov. 2009 à 10:23, John Allison a écrit : Dear Laurent, I think we have lost this one. Koichi is adamant that we keep argc and argv. But it is strange that G4UIQt exits if argc=0 and argv=0. Perhaps you could fix this to avoid future troubles. My Qt version (4.6) has no problem with that. What is your Qt version, and what is your use case ? /Library/Frameworks/QtOpenGL.framework/Versions/:total 16drwxr-xr-x 5 johnaold wheel 170 Oct 21 15:55 4lrwxr-xr-x 1 root wheel 1 Oct 21 15:55 4.0 -> 4lrwxr-xr-x 1 root wheel 1 Oct 21 15:55 Current -> 4 Mac OS 10.5.8 I will check. John. Cheers, Laurent Like you, I do not know what G4UIXm does, but you could ask Guy - he wrote it! Cheers, John. On 26 Nov 2009, at 11:16, Laurent Garnier wrote: Le 26 nov. 2009 à 10:32, Koichi Murakami a écrit : Dear John, It is not a matter of C++, but our software design as toolkit. I would avoid ambiguity of different usages, different behaviors. If the default arguments is presented, then something unexpected might happen. For example, a user set Qt environments, and in the main code, int main() { ... G4UIExecutive(); .. In that case, options for Qt applications, such as --geometry=600x400, will not be parsed. To avoid such a misuse, our API should be unambiguous for users. Then what do we do ? "No argc and argv" OR "argc and argv" ? For the moment, it is not so easy to follow : > #if defined(G4UI_USE_TCSH) > shell = new G4UItcsh; > session = new G4UIterminal(shell); > #elif defined(G4UI_USE_XM) > session = new G4UIXm(argc, argv); > isGUI = true; > #elif defined(G4UI_USE_WIN32) > session = new G4UIWin32(); > #elif defined(G4UI_USE_QT) > session = new G4UIQt(argc, argv); > isGUI = true; > #else > shell = new G4UIcsh; > session = new G4UIterminal(shell); For information, argc and argv are not used for G4QtUI, and I don't understand what Xm does with argc and argv. Do we have to suppress argv and argc for each UI ? Cheers, Laurent Cheers, Koichi --- Koichi Murakami, KEK/CRC email: Koichi.Murakami@kek.jp Dear Koichi, (Laurent, can G4UIQt be changed? See below.) I am thinking of the user who wishes to write his own main routine: main() {...} without argc and argv, which is allowed by C++. If it is allowed in C++, we should allow it in G4UIExecutive. Why not???? I suggest default arguments: G4UIExecutive(G4int argc = 0, char** argv = 0); I have confirmed that G4UIXm works fine. G4UIQt should be changed. That is my suggestion. Of course, all geant4/examples will have G4UIExecutive* ui = new G4UIExecutive(argc, argv); To avoid possible compiler complaints about casting to void, perhaps we should adopt the code in interfaces-V09-02-06. Cheers, John. On 25 Nov 2009, at 08:20, Koichi Murakami wrote: Dear John, There no needs to define default arguments in G4UIExective. I am also afraid that compiler may complain about the void casting for them. (This is ok so far.) That is the reason. Actually, argc and argv will be provided with main() in any cases. In fact I get a crash with arcg=1, argv=0: Qt will try to parse the arguments. There should be one argument, but you set no arguments. So it will crash! With argc=0, argv=0, I get an immediate return from G4UIQt: Qt says no! Cheers, Koichi --- Koichi Murakami, KEK/CRC email: Koichi.Murakami@kek.jp Dear Koichi, In fact I get a crash with arcg=1, argv=0: (gdb) where #0 0x04f8fd3c in G4VInteractorManager::SetArguments (this=0x198352a0, a_argc=1, a_argv=0x0) at src/G4VInteractorManager.cc:103 #1 0x04f8b69e in G4Qt::G4Qt (this=0x198352a0, a_argn=1, a_args=0x0) at src/G4Qt.cc:136 #2 0x04f8b6ec in G4Qt::G4Qt (this=0x198352a0, a_argn=1, a_args=0x0) at src/G4Qt.cc:151 #3 0x04f8b737 in G4Qt::getInstance (a_argn=1, a_args=0x0, a_class=0xb34ef0 "Qt") at src/G4Qt.cc:66 #4 0x00b24ddf in G4UIQt::G4UIQt (this=0x19831830, argc=1, argv=0x0) at src/G4UIQt.cc:107 #5 0x00b25e29 in G4UIQt::G4UIQt (this=0x19831830, argc=1, argv=0x0) at src/G4UIQt.cc:279 #6 0x00004503 in G4UIExecutive::G4UIExecutive (this=0x198244c0, argc=1, argv=0x0) at G4UIExecutive.icc:82 #7 0x00004577 in G4UIExecutive::G4UIExecutive (this=0x198244c0, argc=1, argv=0x0) at G4UIExecutive.icc:93 #8 0x00004b57 in main (argc=1, argv=0xbfffe708) at K01.cc:62 With argc=0, argv=0, I get an immediate return from G4UIQt: G4UIQt : Unable to init Qt. Aborted It seems that I must really provide argc, argv. So maybe you are right to insist in it. Cheers, John. On 24 Nov 2009, at 15:50, John Allison wrote: Dear Kiochi, I see as a result of your recent change you have removed the default arguments: 63c67 < G4UIExecutive(G4int argc=1, char** argv=0); --- G4UIExecutive(G4int argc, char** argv); Is there a reason for this? Could we not continue to offer default arguments? And if we do, should they not be: G4UIExecutive(G4int argc=0, char** argv=0); ? Cheers, John. John Allison Tel: +44-1422-845624 Dept. of Physics & Astronomy Mobile/Cell: +44-7810-242262 The Univ. of Manchester Email: John.Allison@manchester.ac.uk MANCHESTER M13 9PL Email(2): John.Allison@3-C.Coop UK WWW: http://www.hep.man.ac.uk/u/johna John Allison 9 Royd Terrace Tel: 01422-845624 Hebden Bridge Mobile: 07810-242262 W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison 9 Royd Terrace Tel: 01422-845624 Hebden Bridge Mobile: 07810-242262 W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison9 Royd Terrace Tel: 01422-845624Hebden Bridge Mobile: 07810-242262W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison9 Royd Terrace Tel: 01422-845624Hebden Bridge Mobile: 07810-242262W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison9 Royd Terrace Tel: 01422-845624Hebden Bridge Mobile: 07810-242262W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison9 Royd Terrace Tel: 01422-845624Hebden Bridge Mobile: 07810-242262W. Yorks HX7 7BT Email: John.Allison@3-C.Coop John Allison Tel: +44-1422-845624Dept. of Physics & Astronomy Mobile/Cell: +44-7810-242262The Univ. of Manchester Email: John.Allison@manchester.ac.ukMANCHESTER M13 9PL Email(2): John.Allison@3-C.CoopUK WWW: http://www.hep.man.ac.uk/u/johna
Note: See
TracTickets for help on using
tickets.