00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id:$ 00028 // GEANT4 tag $Name: not supported by cvs2svn $ 00029 // 00030 // John Allison 27th October 2012 00031 // Base class for OpenGLImmediate/StoredQt graphics system factories. 00032 00033 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER 00034 00035 #include "G4OpenGLQt.hh" 00036 00037 #include "G4UIQt.hh" 00038 #include "G4UImanager.hh" 00039 #include "G4UIbatch.hh" 00040 00041 G4OpenGLQt::G4OpenGLQt (const G4String& name, 00042 const G4String& nickname, 00043 const G4String& description, 00044 Functionality f): 00045 G4VGraphicsSystem (name, 00046 nickname, 00047 description, 00048 f) 00049 {} 00050 00051 G4bool G4OpenGLQt::IsUISessionCompatible () const 00052 { 00053 G4bool isCompatible = false; 00054 G4UImanager* ui = G4UImanager::GetUIpointer(); 00055 G4UIsession* session = ui->GetSession(); 00056 // In case it's a G4UIbatch, find original session by recursive search until 00057 // the session is no longer a G4UIbatch, in which case it will be the 00058 // original session, if any. 00059 while (G4UIbatch* batch = dynamic_cast<G4UIbatch*>(session)) { 00060 session = batch->GetPreviousSession(); 00061 } 00062 if (!session) { 00063 // The user has not instantiated a session - must be batch. 00064 // It's OK to have a Qt window in batch - you can open a viewer, create a 00065 // scene, set view parameters and /vis/ogl/printEPS. 00066 isCompatible = true; 00067 } else { 00068 // The user has instantiated a session... 00069 if (dynamic_cast<G4UIQt*>(session)) { 00070 // ...and it's a G4UIQt session, which is OK. 00071 isCompatible = true; 00072 } else { 00073 // Not OK - go and find the fallback graphics system. 00074 isCompatible = false; 00075 } 00076 } 00077 return isCompatible; 00078 } 00079 00080 #endif