Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 // 29 // Laurent Garnier 27th October 2011 30 31 #include "G4OpenGLStoredQtSceneHandler.hh" 32 33 #include "G4PhysicalVolumeModel.hh" 34 #include "G4LogicalVolumeModel.hh" 35 #include "G4Text.hh" 36 #include "G4VPhysicalVolume.hh" 37 #include "G4OpenGLQtViewer.hh" 38 #include <typeinfo> 39 #include <sstream> 40 41 G4OpenGLStoredQtSceneHandler::G4OpenGLStoredQt 42 (G4VGraphicsSystem& system, 43 const G4String& name): 44 G4OpenGLStoredSceneHandler (system, name) 45 {} 46 47 G4OpenGLStoredQtSceneHandler::~G4OpenGLStoredQ 48 {} 49 50 G4bool G4OpenGLStoredQtSceneHandler::ExtraPOPr 51 (const G4Visible& visible, size_t currentPOLis 52 { 53 G4bool usesGLCommands = true; 54 55 try { 56 const G4Text& g4Text = dynamic_cast<const 57 G4TextPlus* pG4TextPlus = new G4TextPlus(g 58 pG4TextPlus->fProcessing2D = fProcessing2D 59 fPOList[currentPOListIndex].fpG4TextPlus = 60 usesGLCommands = false; 61 } 62 catch (const std::bad_cast&) {} // No speci 63 64 G4PhysicalVolumeModel* pPVModel = 65 dynamic_cast<G4PhysicalVolumeModel*>(fpMod 66 G4LogicalVolumeModel* pLVModel = 67 dynamic_cast<G4LogicalVolumeModel*>(pPVMod 68 if (pPVModel && !pLVModel) { 69 70 // This call comes from a G4PhysicalVolume 71 // the path of the current drawn (non-cull 72 // drawn (non-culled) ancestors. Each nod 73 // PVNodeID object, which is a physical vo 74 // is a vector of PVNodeIDs corresponding 75 // actually selected, i.e., not culled. 76 // typedef G4PhysicalVolumeModel::G4Phy 77 // typedef std::vector<PVNodeID> PVPath 78 79 // The simplest algorithm, used by the Ope 80 // developers, is to rely on the fact the 81 // traverses the geometry hierarchy in an 82 // mother, if any, will be the node to whi 83 // added. So it is enough to keep a map o 84 // on the volume path ID. Actually, it is 85 // volume as the key. (An alternative wou 86 // in the tree and match the PVPath from t 87 88 // BUT IN OPENGL, IF THERE ARE TRANSPARENT 89 // ARRIVE IN THE ABOVE ORDER. (TRANSPAREN 90 // LAST.) SO WE MUST BE MORE SOPHISTICATE 91 // TREE. 92 93 // build a path for tree viewer 94 G4OpenGLQtViewer* pGLViewer = dynamic_cast 95 if ( pGLViewer ) { 96 pGLViewer->addPVSceneTreeElement(fpModel 97 } 98 99 } else { // Not from a G4PhysicalVolumeMode 100 101 if (fpModel) { 102 103 104 // build a path for tree viewer 105 G4OpenGLQtViewer* pGLViewer = dynamic_ca 106 if ( pGLViewer ) { 107 pGLViewer->addNonPVSceneTreeElement(fp 108 } 109 } 110 } 111 112 return usesGLCommands; 113 } 114 115 G4bool G4OpenGLStoredQtSceneHandler::ExtraTOPr 116 (const G4Visible& visible, size_t currentTOLis 117 { 118 119 G4bool usesGLCommands = true; 120 121 try { 122 const G4Text& g4Text = dynamic_cast<const 123 G4TextPlus* pG4TextPlus = new G4TextPlus(g 124 pG4TextPlus->fProcessing2D = fProcessing2D 125 fTOList[currentTOListIndex].fpG4TextPlus = 126 usesGLCommands = false; 127 } 128 catch (const std::bad_cast&) {} // Do nothi 129 130 return usesGLCommands; 131 } 132 133 void G4OpenGLStoredQtSceneHandler::ClearStore 134 135 //G4cout << "G4OpenGLStoredQtSceneHandler::C 136 137 G4OpenGLStoredSceneHandler::ClearStore (); 138 139 // Not needed - the old scene tree is curren 140 // this code somehow affects the view in rar 141 // the volume does not return to its origina 142 // this, pending a review of the old scene t 143 // // Should recreate the tree 144 // G4OpenGLQtViewer* pGLQtViewer = dynamic_ca 145 // if ( pGLQtViewer ) { 146 // pGLQtViewer->clearTreeWidget(); 147 // } 148 } 149 150 void G4OpenGLStoredQtSceneHandler::ClearTransi 151 152 //G4cout << "G4OpenGLStoredQtSceneHandler::C 153 154 G4OpenGLStoredSceneHandler::ClearTransientSt 155 156 // Should recreate the tree 157 // Make sure screen corresponds to graphical 158 // FIXME : L.Garnier April 2012 : Could caus 159 if (fpViewer) { 160 fpViewer -> SetView (); 161 fpViewer -> ClearView (); 162 fpViewer -> DrawView (); 163 } 164 } 165 166 void G4OpenGLStoredQtSceneHandler::SetScene(G4 167 168 if (pScene != fpScene) { 169 G4OpenGLQtViewer* pGLQtViewer = dynamic_ca 170 if ( pGLQtViewer ) { 171 pGLQtViewer->clearTreeWidget(); 172 } 173 } 174 G4VSceneHandler::SetScene(pScene); 175 } 176