Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/Qt3D/src/G4Qt3DSceneHandler.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/Qt3D/src/G4Qt3DSceneHandler.cc (Version 11.3.0) and /visualization/Qt3D/src/G4Qt3DSceneHandler.cc (Version 9.3.p1)


  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 // John Allison  17th June 2019                   
 27                                                   
 28 #include "G4Qt3DSceneHandler.hh"                  
 29                                                   
 30 #include "G4PhysicalVolumeModel.hh"               
 31 #include "G4LogicalVolumeModel.hh"                
 32 #include "G4VPhysicalVolume.hh"                   
 33 #include "G4LogicalVolume.hh"                     
 34 #include "G4TransportationManager.hh"             
 35 #include "G4Box.hh"                               
 36 #include "G4Polyline.hh"                          
 37 #include "G4Polymarker.hh"                        
 38 #include "G4Text.hh"                              
 39 #include "G4Circle.hh"                            
 40 #include "G4Square.hh"                            
 41 #include "G4Polyhedron.hh"                        
 42 #include "G4Scene.hh"                             
 43 #include "G4Threading.hh"                         
 44 #include "G4Mesh.hh"                              
 45 #include "G4PseudoScene.hh"                       
 46 #include "G4VisManager.hh"                        
 47                                                   
 48 #include "G4Qt3DViewer.hh"                        
 49 #include "G4Qt3DUtils.hh"                         
 50 #include "G4Qt3DQEntity.hh"                       
 51                                                   
 52 #include <Qt3DCore>                               
 53 #include <Qt3DExtras>                             
 54 #include <Qt3DRender>                             
 55                                                   
 56 #include <utility>                                
 57                                                   
 58 #define G4warn G4cout                             
 59                                                   
 60 // Qt3D seems to offer a choice of type - floa    
 61 // to use double since it offers the prospect     
 62 // avoiding some issues that we see at high zo    
 63 // following warning:                             
 64 // Qt5: "findBoundingVolumeComputeData: Positi    
 65 // suited for bounding volume computation",       
 66 // Qt6: "Failed to build graphics pipeline: Ge    
 67 // An attribute type is not supported "vertexP    
 68 // so for now we use float.                       
 69 #define PRECISION float                           
 70 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))      
 71 #define BASETYPE Qt3DRender::QAttribute::Float    
 72 #else                                             
 73 #define BASETYPE Qt3DCore::QAttribute::Float      
 74 #endif                                            
 75                                                   
 76 // Qt3D types move between namespaces between     
 77 namespace G4Qt3DCompat                            
 78 {                                                 
 79 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))      
 80   using Qt3DRender::QAttribute;                   
 81   using Qt3DRender::QBuffer;                      
 82   using Qt3DRender::QGeometry;                    
 83 #else                                             
 84   using Qt3DCore::QAttribute;                     
 85   using Qt3DCore::QBuffer;                        
 86   using Qt3DCore::QGeometry;                      
 87 #endif                                            
 88 }                                                 
 89                                                   
 90 G4int G4Qt3DSceneHandler::fSceneIdCount = 0;      
 91                                                   
 92 G4Qt3DSceneHandler::G4Qt3DSceneHandler            
 93  (G4VGraphicsSystem& system, const G4String& n    
 94 : G4VSceneHandler(system, fSceneIdCount++, nam    
 95 ,fpQt3DScene(nullptr)                             
 96 ,fpTransientObjects(nullptr)                      
 97 ,fpPersistentObjects(nullptr)                     
 98 {                                                 
 99 #ifdef G4QT3DDEBUG                                
100   G4cout << "G4Qt3DSceneHandler::G4Qt3DSceneHa    
101 #endif                                            
102   fpQt3DScene = new Qt3DCore::QEntity;            
103   fpQt3DScene->setObjectName("G4Qt3DSceneRoot"    
104   EstablishG4Qt3DQEntities();                     
105 }                                                 
106                                                   
107 G4Qt3DSceneHandler::~G4Qt3DSceneHandler()         
108 {                                                 
109   if (fpQt3DScene) {                              
110     G4Qt3DUtils::delete_components_and_childre    
111     delete fpQt3DScene;                           
112   }                                               
113 }                                                 
114                                                   
115 void G4Qt3DSceneHandler::EstablishG4Qt3DQEntit    
116 {                                                 
117   fpTransientObjects  = new G4Qt3DQEntity(fpQt    
118   fpTransientObjects  ->setObjectName("G4Qt3DT    
119   fpPersistentObjects = new G4Qt3DQEntity(fpQt    
120   fpPersistentObjects ->setObjectName("G4Qt3DP    
121                                                   
122   // Physical volume objects hang from POs        
123   fpPhysicalVolumeObjects.clear();                
124   if (fpScene) {                                  
125     const auto& sceneModels = fpScene->GetRunD    
126     for (const auto& sceneModel : sceneModels)    
127       const auto& pvModel = dynamic_cast<G4Phy    
128       if (pvModel) {                              
129         auto entity = new G4Qt3DQEntity(fpPers    
130         const auto& pv = pvModel->GetTopPhysic    
131         entity->setObjectName("G4Qt3DPORoot_"+    
132         entity->SetPVNodeID(G4PhysicalVolumeMo    
133         fpPhysicalVolumeObjects.push_back(enti    
134       }                                           
135     }                                             
136   }                                               
137 }                                                 
138                                                   
139 G4Qt3DQEntity* G4Qt3DSceneHandler::CreateNewNo    
140 {                                                 
141   // Create a G4Qt3DQEntity node suitable for     
142                                                   
143   G4Qt3DQEntity* newNode = nullptr;               
144                                                   
145   if (fReadyForTransients) {  // All transient    
146     newNode = new G4Qt3DQEntity(fpTransientObj    
147     G4String name = fpModel? fpModel->GetGloba    
148     newNode->setObjectName(name.c_str());         
149     return newNode;                               
150   }                                               
151                                                   
152   G4PhysicalVolumeModel* pPVModel =               
153     dynamic_cast<G4PhysicalVolumeModel*>(fpMod    
154                                                   
155   if (!pPVModel) {  // Persistent objects (e.g    
156     newNode = new G4Qt3DQEntity(fpPersistentOb    
157     newNode->setObjectName(fpModel->GetGlobalT    
158     return newNode;                               
159   }                                               
160                                                   
161   // So this is a G4PhysicalVolumeModel           
162                                                   
163   typedef G4PhysicalVolumeModel::G4PhysicalVol    
164   typedef std::vector<PVNodeID> PVPath;           
165 //  const PVPath& drawnPVPath = pPVModel->GetD    
166   const PVPath& fullPVPath  = pPVModel->GetFul    
167   //G4int currentDepth = pPVModel->GetCurrentD    
168   //G4VPhysicalVolume* pCurrentPV = pPVModel->    
169   //G4LogicalVolume* pCurrentLV = pPVModel->Ge    
170   //G4Material* pCurrentMaterial = pPVModel->G    
171   // Note: pCurrentMaterial may be zero (paral    
172                                                   
173 #ifdef G4QTDEBUG                                  
174   G4cout << "A: " << fullPVPath << G4endl;  //    
175 #endif                                            
176                                                   
177   // Find appropriate root                        
178   const std::size_t nWorlds = fpPhysicalVolume    
179   std::size_t iWorld = 0;                         
180   for (; iWorld < nWorlds; ++iWorld) {            
181     if (fullPVPath[0].GetPhysicalVolume() ==      
182         fpPhysicalVolumeObjects[iWorld]->GetPV    
183   }                                               
184   if (iWorld == nWorlds) {                        
185     G4Exception("G4Qt3DSceneHandler::CreateNew    
186                 "World mis-match - not possibl    
187   }                                               
188                                                   
189   // (Re-)establish pv path of root entity        
190   G4Qt3DQEntity* wrld = fpPhysicalVolumeObject    
191   wrld->SetPVNodeID(fullPVPath[0]);               
192                                                   
193   // Create nodes as required                     
194   G4Qt3DQEntity* node = wrld;                     
195   newNode = node;                                 
196   const std::size_t depth = fullPVPath.size();    
197   std::size_t iDepth = 1;                         
198   while (iDepth < depth) {                        
199     const auto& children = node->children();      
200     const G4int nChildren = (G4int)children.si    
201     G4int iChild = 0;                             
202     G4Qt3DQEntity* child = nullptr;               
203     for (; iChild < nChildren; ++iChild) {        
204       child = static_cast<G4Qt3DQEntity*>(chil    
205       if (child->GetPVNodeID() == fullPVPath[i    
206     }                                             
207     if (iChild != nChildren) {  // Existing no    
208       node = child;  // Must be the ancestor o    
209     } else {                                      
210       // Add a new node as child of node          
211       newNode = new G4Qt3DQEntity(node);          
212       newNode->SetPVNodeID(fullPVPath[iDepth])    
213       std::ostringstream oss;                     
214       oss << newNode->GetPVNodeID().GetPhysica    
215       << ':' << newNode->GetPVNodeID().GetCopy    
216       newNode->setObjectName(oss.str().c_str()    
217       node = newNode;                             
218     }                                             
219     ++iDepth;                                     
220   }                                               
221                                                   
222   return node;                                    
223 }                                                 
224                                                   
225 void G4Qt3DSceneHandler::PreAddSolid              
226  (const G4Transform3D& objectTransformation,      
227   const G4VisAttributes& visAttribs)              
228 {                                                 
229   G4VSceneHandler::PreAddSolid(objectTransform    
230 }                                                 
231                                                   
232 void G4Qt3DSceneHandler::PostAddSolid()           
233 {                                                 
234   G4VSceneHandler::PostAddSolid();                
235 }                                                 
236                                                   
237 void G4Qt3DSceneHandler::BeginPrimitives2D(con    
238 {                                                 
239 // The x,y coordinates of the primitives passe    
240 // intrepreted as screen coordinates, -1 < x,y    
241 // z-coordinate is ignored.                       
242 // IMPORTANT: invoke this from your polymorphi    
243 // void MyXXXSceneHandler::BeginPrimitives2D      
244 // (const G4Transform3D& objectTransformation)    
245   static G4bool first = true;                     
246   if (first) {                                    
247     first = false;                                
248     G4Exception("G4Qt3DSceneHandler::BeginPrim    
249                 JustWarning,                      
250                 "2D drawing not yet implemente    
251   }                                               
252    G4VSceneHandler::BeginPrimitives2D (objectT    
253 //   ...                                          
254 }                                                 
255                                                   
256 void G4Qt3DSceneHandler::EndPrimitives2D ()       
257 {                                                 
258 // IMPORTANT: invoke this from your polymorphi    
259 // void MyXXXSceneHandler::EndPrimitives2D ()     
260 //   ...                                          
261   G4VSceneHandler::EndPrimitives2D ();            
262 }                                                 
263                                                   
264 void G4Qt3DSceneHandler::BeginPrimitives          
265  (const G4Transform3D& objectTransformation)      
266 {                                                 
267   G4VSceneHandler::BeginPrimitives(objectTrans    
268 }                                                 
269                                                   
270 void G4Qt3DSceneHandler::EndPrimitives ()         
271 {                                                 
272   G4VSceneHandler::EndPrimitives ();              
273 }                                                 
274                                                   
275 void G4Qt3DSceneHandler::AddPrimitive(const G4    
276 {                                                 
277 #ifdef G4QT3DDEBUG                                
278   G4cout <<                                       
279   "G4Qt3DSceneHandler::AddPrimitive(const G4Po    
280   << polyline                                     
281   << G4endl;                                      
282 #endif                                            
283                                                   
284   if (polyline.size() == 0) return;               
285                                                   
286   auto currentNode = CreateNewNode();             
287   if (!currentNode) {                             
288     static G4bool first = true;                   
289     if (first) {                                  
290       first = false;                              
291       G4Exception("G4Qt3DSceneHandler::AddPrim    
292       "qt3d-0003", JustWarning,                   
293       "No available node!");                      
294     }                                             
295     return;                                       
296   }                                               
297                                                   
298   fpVisAttribs = fpViewer->GetApplicableVisAtt    
299                                                   
300   auto transform = G4Qt3DUtils::CreateQTransfo    
301   transform->setObjectName("transform");          
302                                                   
303   auto polylineEntity = new Qt3DCore::QEntity(    
304   polylineEntity->addComponent(transform);        
305                                                   
306   const auto vertexByteSize  = 3*sizeof(PRECIS    
307                                                   
308   const std::size_t nLines = polyline.size() -    
309   QByteArray polylineByteArray;                   
310   const auto polylineBufferByteSize = 2*nLines    
311   polylineByteArray.resize((G4int)polylineBuff    
312   auto polylineBufferArray = reinterpret_cast<    
313   G4int iLine = 0;                                
314   for (std::size_t i = 0; i < nLines; ++i) {      
315     polylineBufferArray[iLine++] = polyline[i]    
316     polylineBufferArray[iLine++] = polyline[i]    
317     polylineBufferArray[iLine++] = polyline[i]    
318     polylineBufferArray[iLine++] = polyline[i+    
319     polylineBufferArray[iLine++] = polyline[i+    
320     polylineBufferArray[iLine++] = polyline[i+    
321   }                                               
322   auto polylineGeometry = new G4Qt3DCompat::QG    
323   polylineGeometry->setObjectName("polylineGeo    
324                                                   
325   auto polylineBuffer = new G4Qt3DCompat::QBuf    
326   polylineBuffer->setObjectName("Polyline buff    
327   polylineBuffer->setData(polylineByteArray);     
328                                                   
329   auto polylineAtt = new G4Qt3DCompat::QAttrib    
330   polylineAtt->setObjectName("Position attribu    
331   polylineAtt->setName(G4Qt3DCompat::QAttribut    
332   polylineAtt->setBuffer(polylineBuffer);         
333   polylineAtt->setAttributeType(G4Qt3DCompat::    
334   polylineAtt->setVertexBaseType(BASETYPE);       
335   polylineAtt->setVertexSize(3);                  
336   polylineAtt->setCount((G4int)nLines);           
337   polylineAtt->setByteOffset(0);                  
338   polylineAtt->setByteStride(vertexByteSize);     
339   // Normal attribute (a dummy with count==0)     
340   auto dummyNormalLineAtt = new G4Qt3DCompat::    
341   dummyNormalLineAtt->setObjectName("Normal at    
342   dummyNormalLineAtt->setName(G4Qt3DCompat::QA    
343   dummyNormalLineAtt->setBuffer(polylineBuffer    
344   dummyNormalLineAtt->setAttributeType(G4Qt3DC    
345   dummyNormalLineAtt->setVertexBaseType(BASETY    
346   dummyNormalLineAtt->setVertexSize(3);           
347   dummyNormalLineAtt->setCount(0);                
348   dummyNormalLineAtt->setByteOffset(0);           
349   dummyNormalLineAtt->setByteStride(vertexByte    
350                                                   
351   const auto& colour = fpVisAttribs->GetColour    
352                                                   
353   polylineGeometry->addAttribute(polylineAtt);    
354   polylineGeometry->addAttribute(dummyNormalLi    
355                                                   
356   auto material = new Qt3DExtras::QDiffuseSpec    
357   material->setObjectName("materialForPolyline    
358   material->setAmbient(G4Qt3DUtils::ConvertToQ    
359   material->setShininess(0.);                     
360   material->setSpecular(0.);                      
361   polylineEntity->addComponent(material);         
362                                                   
363   auto renderer = new Qt3DRender::QGeometryRen    
364   renderer->setObjectName("polylineRenderer");    
365   renderer->setGeometry(polylineGeometry);        
366   renderer->setVertexCount(2*(G4int)nLines);      
367   renderer->setPrimitiveType(Qt3DRender::QGeom    
368   polylineEntity->addComponent(renderer);         
369 }                                                 
370                                                   
371 void G4Qt3DSceneHandler::AddPrimitive (const G    
372 {                                                 
373   if (polymarker.size() == 0) return;             
374                                                   
375   auto currentNode = CreateNewNode();             
376   if (!currentNode) {                             
377     static G4bool first = true;                   
378     if (first) {                                  
379       first = false;                              
380       G4Exception("G4Qt3DSceneHandler::AddPrim    
381       "qt3d-0003", JustWarning,                   
382       "No available node!");                      
383     }                                             
384     return;                                       
385   }                                               
386                                                   
387   fpVisAttribs = fpViewer->GetApplicableVisAtt    
388                                                   
389   MarkerSizeType markerSizeType;                  
390   G4double markerSize = GetMarkerSize(polymark    
391                                                   
392   switch (polymarker.GetMarkerType()) {           
393     default:                                      
394     case G4Polymarker::dots:                      
395     {                                             
396       const std::size_t nDots = polymarker.siz    
397                                                   
398       auto transform = G4Qt3DUtils::CreateQTra    
399       transform->setObjectName("transform");      
400                                                   
401       auto polymarkerEntity = new Qt3DCore::QE    
402       polymarkerEntity->addComponent(transform    
403                                                   
404       const auto vertexByteSize  = 3*sizeof(PR    
405                                                   
406       QByteArray polymarkerByteArray;             
407       const auto polymarkerBufferByteSize = nD    
408       polymarkerByteArray.resize((G4int)polyma    
409       auto polymarkerBufferArray = reinterpret    
410       G4int iMarker = 0;                          
411       for (std::size_t i = 0; i < polymarker.s    
412         polymarkerBufferArray[iMarker++] = pol    
413         polymarkerBufferArray[iMarker++] = pol    
414         polymarkerBufferArray[iMarker++] = pol    
415       }                                           
416       auto polymarkerGeometry = new G4Qt3DComp    
417       polymarkerGeometry->setObjectName("polym    
418       auto polymarkerBuffer = new G4Qt3DCompat    
419       polymarkerBuffer->setObjectName("Polymar    
420       polymarkerBuffer->setData(polymarkerByte    
421                                                   
422       auto polymarkerAtt = new G4Qt3DCompat::Q    
423       polymarkerAtt->setObjectName("Position a    
424       polymarkerAtt->setName(G4Qt3DCompat::QAt    
425       polymarkerAtt->setBuffer(polymarkerBuffe    
426       polymarkerAtt->setAttributeType(G4Qt3DCo    
427       polymarkerAtt->setVertexBaseType(BASETYP    
428       polymarkerAtt->setVertexSize(3);            
429       polymarkerAtt->setCount((G4int)nDots);      
430       polymarkerAtt->setByteOffset(0);            
431       polymarkerAtt->setByteStride(vertexByteS    
432                                                   
433       const auto& colour = fpVisAttribs->GetCo    
434                                                   
435       polymarkerGeometry->addAttribute(polymar    
436                                                   
437       auto material = new Qt3DExtras::QDiffuse    
438       material->setObjectName("materialForPoly    
439       material->setAmbient(G4Qt3DUtils::Conver    
440       material->setShininess(0.);                 
441       material->setSpecular(0.);                  
442       polymarkerEntity->addComponent(material)    
443                                                   
444       auto renderer = new Qt3DRender::QGeometr    
445       renderer->setObjectName("polymarkerWiref    
446       renderer->setGeometry(polymarkerGeometry    
447       renderer->setVertexCount((G4int)nDots);     
448       renderer->setPrimitiveType(Qt3DRender::Q    
449       polymarkerEntity->addComponent(renderer)    
450     }                                             
451       break;                                      
452     case G4Polymarker::circles:                   
453     {                                             
454       G4Circle circle (polymarker);  // Defaul    
455                                                   
456       const auto& colour = fpVisAttribs->GetCo    
457       auto material = new Qt3DExtras::QDiffuse    
458       material->setObjectName("materialForCirc    
459       material->setAmbient(G4Qt3DUtils::Conver    
460       if (colour.GetAlpha() < 1.) material->se    
461                                                   
462       auto sphereMesh = new Qt3DExtras::QSpher    
463       sphereMesh->setObjectName("sphereMesh");    
464       G4double radius = markerSize/2.;            
465       if (markerSizeType == G4VSceneHandler::s    
466         // Not figured out how to do screen-si    
467         const G4double scale = 200.;  // Rough    
468         radius *= fpScene->GetExtent().GetExte    
469       }                                           
470       sphereMesh->setRadius(radius);              
471 //      sphereMesh->setInstanceCount(polymarke    
472                                                   
473 //      auto currentEntity = new Qt3DCore::QEn    
474       for (std::size_t iPoint = 0; iPoint < po    
475         auto position = fObjectTransformation*    
476         auto transform = G4Qt3DUtils::CreateQT    
477   auto currentEntity = new Qt3DCore::QEntity(c    
478         currentEntity->addComponent(material);    
479         currentEntity->addComponent(transform)    
480         currentEntity->addComponent(sphereMesh    
481       }                                           
482     }                                             
483       break;                                      
484     case G4Polymarker::squares:                   
485     {                                             
486       G4Square square (polymarker);  // Defaul    
487                                                   
488       const auto& colour = fpVisAttribs->GetCo    
489       auto material = new Qt3DExtras::QDiffuse    
490       material->setObjectName("materialForSqua    
491       material->setAmbient(G4Qt3DUtils::Conver    
492       if (colour.GetAlpha() < 1.) material->se    
493                                                   
494       auto boxMesh = new Qt3DExtras::QCuboidMe    
495       boxMesh->setObjectName("boxMesh");          
496       G4double side = markerSize;                 
497       if (markerSizeType == G4VSceneHandler::s    
498         // Not figured out how to do screen-si    
499         const G4double scale = 200.;  // Rough    
500         side *= fpScene->GetExtent().GetExtent    
501       }                                           
502       boxMesh->setXExtent(side);                  
503       boxMesh->setYExtent(side);                  
504       boxMesh->setZExtent(side);                  
505                                                   
506       for (std::size_t iPoint = 0; iPoint < po    
507         auto position = fObjectTransformation*    
508         auto transform = G4Qt3DUtils::CreateQT    
509         auto currentEntity = new Qt3DCore::QEn    
510         currentEntity->addComponent(material);    
511         currentEntity->addComponent(transform)    
512         currentEntity->addComponent(boxMesh);     
513       }                                           
514     }                                             
515       break;                                      
516   }                                               
517 }                                                 
518                                                   
519 #ifdef G4QT3DDEBUG                                
520 void G4Qt3DSceneHandler::AddPrimitive(const G4    
521   G4cout <<                                       
522   "G4Qt3DSceneHandler::AddPrimitive(const G4Te    
523   << text                                         
524   << G4endl;                                      
525 #else                                             
526 void G4Qt3DSceneHandler::AddPrimitive(const G4    
527 #endif                                            
528                                                   
529   static G4bool first = true;                     
530   if (first) {                                    
531     first = false;                                
532     G4Exception("G4Qt3DSceneHandler::AddPrimit    
533                 "qt3D-0002", JustWarning,         
534                 "Text drawing doesn't work yet    
535   }  // OK. Not working, but let it execute, w    
536                                                   
537   /* But it crashes after /vis/viewer/rebuild!    
538   auto currentNode = CreateNewNode();             
539    if (!currentNode) {                            
540    static G4bool first = true;                    
541    if (first) {                                   
542    first = false;                                 
543    G4Exception("G4Qt3DSceneHandler::AddPrimiti    
544    "qt3d-0003", JustWarning,                      
545    "No available node!");                         
546    }                                              
547    return;                                        
548    }                                              
549                                                   
550   fpVisAttribs = fpViewer->GetApplicableVisAtt    
551                                                   
552   auto position = fObjectTransformation*G4Tran    
553   auto transform = G4Qt3DUtils::CreateQTransfo    
554 //  transform->setScale(10);                      
555   transform->setScale(0.1);                       
556                                                   
557 //  auto currentEntity = new Qt3DCore::QEntity    
558                                                   
559   // This simply does not work                    
560   auto qtext = new Qt3DExtras::QText2DEntity()    
561   qtext->setParent(currentNode);                  
562 //  qtext->setParent(currentEntity);  // ??  D    
563   qtext->setText(text.GetText().c_str());         
564 //  qtext->setHeight(100);                        
565 //  qtext->setWidth(1000);                        
566   qtext->setHeight(20);                           
567   qtext->setWidth(100);                           
568   qtext->setColor(Qt::green);                     
569   qtext->setFont(QFont("Courier New", 10));       
570   qtext->addComponent(transform);                 
571                                                   
572   // This produces text in 3D facing +z - not     
573 //  const auto& colour = GetTextColour(text);     
574 //  auto material = new Qt3DExtras::QDiffuseSp    
575 //  material->setObjectName("materialForText")    
576 //  material->setAmbient(G4Qt3DUtils::ConvertT    
577 //  if (colour.GetAlpha() < 1.) material->setA    
578 //                                                
579 //  auto textMesh = new Qt3DExtras::QExtrudedT    
580 //  textMesh->setText(text.GetText().c_str());    
581 //  textMesh->setFont(QFont("Courier New", 10)    
582 //  textMesh->setDepth(.01f);                     
583 //                                                
584 //  currentNode->addComponent(material);          
585 //  currentNode->addComponent(transform);         
586 //  currentNode->addComponent(textMesh);          
587    */                                             
588 }                                                 
589                                                   
590 void G4Qt3DSceneHandler::AddPrimitive(const G4    
591 {                                                 
592 #ifdef G4QT3DDEBUG                                
593   G4cout <<                                       
594   "G4Qt3DSceneHandler::AddPrimitive(const G4Ci    
595   << circle                                       
596   << G4endl;                                      
597 #endif                                            
598                                                   
599 #ifdef G4QT3DDEBUG                                
600   MarkerSizeType sizeType;                        
601   G4double size = GetMarkerSize (circle, sizeT    
602   switch (sizeType) {                             
603     default:                                      
604     case screen:                                  
605       // Draw in screen coordinates.              
606       G4cout << "screen";                         
607       break;                                      
608     case world:                                   
609       // Draw in world coordinates.               
610       G4cout << "world";                          
611       break;                                      
612   }                                               
613   G4cout << " size: " << size << G4endl;          
614 #endif                                            
615                                                   
616   auto currentNode = CreateNewNode();             
617   if (!currentNode) {                             
618     static G4bool first = true;                   
619     if (first) {                                  
620       first = false;                              
621       G4Exception("G4Qt3DSceneHandler::AddPrim    
622       "qt3d-0003", JustWarning,                   
623       "No available node!");                      
624     }                                             
625     return;                                       
626   }                                               
627                                                   
628   fpVisAttribs = fpViewer->GetApplicableVisAtt    
629                                                   
630   auto position = fObjectTransformation*G4Tran    
631   auto transform = G4Qt3DUtils::CreateQTransfo    
632                                                   
633   const auto& colour = fpVisAttribs->GetColour    
634   auto material = new Qt3DExtras::QDiffuseSpec    
635   material->setObjectName("materialForCircle")    
636   material->setAmbient(G4Qt3DUtils::ConvertToQ    
637   if (colour.GetAlpha() < 1.) material->setAlp    
638                                                   
639   auto sphereMesh = new Qt3DExtras::QSphereMes    
640   sphereMesh->setObjectName("sphereMesh");        
641   G4double radius;                                
642   if (circle.GetSizeType() == G4VMarker::world    
643     radius =circle.GetWorldRadius();              
644   } else {  // Screen-size or none                
645     // Not figured out how to do screen-size,     
646     const G4double scale = 200.;  // Roughly p    
647     radius = circle.GetScreenRadius()*fpScene-    
648   }                                               
649   sphereMesh->setRadius(radius);                  
650                                                   
651   auto currentEntity = new Qt3DCore::QEntity(c    
652   currentEntity->addComponent(material);          
653   currentEntity->addComponent(transform);         
654   currentEntity->addComponent(sphereMesh);        
655 }                                                 
656                                                   
657 void G4Qt3DSceneHandler::AddPrimitive(const G4    
658 {                                                 
659 #ifdef G4QT3DDEBUG                                
660   G4cout <<                                       
661   "G4Qt3DSceneHandler::AddPrimitive(const G4Sq    
662   << square                                       
663   << G4endl;                                      
664 #endif                                            
665                                                   
666 #ifdef G4QT3DDEBUG                                
667   MarkerSizeType sizeType;                        
668   G4double size = GetMarkerSize (square, sizeT    
669   switch (sizeType) {                             
670     default:                                      
671     case screen:                                  
672       // Draw in screen coordinates.              
673       G4cout << "screen";                         
674       break;                                      
675     case world:                                   
676       // Draw in world coordinates.               
677       G4cout << "world";                          
678       break;                                      
679   }                                               
680   G4cout << " size: " << size << G4endl;          
681 #endif                                            
682                                                   
683   auto currentNode = CreateNewNode();             
684   if (!currentNode) {                             
685     static G4bool first = true;                   
686     if (first) {                                  
687       first = false;                              
688       G4Exception("G4Qt3DSceneHandler::AddPrim    
689       "qt3d-0003", JustWarning,                   
690       "No available node!");                      
691     }                                             
692     return;                                       
693   }                                               
694                                                   
695   fpVisAttribs = fpViewer->GetApplicableVisAtt    
696                                                   
697   auto position = fObjectTransformation*G4Tran    
698   auto transform = G4Qt3DUtils::CreateQTransfo    
699                                                   
700   const auto& colour = fpVisAttribs->GetColour    
701   auto material = new Qt3DExtras::QDiffuseSpec    
702   material->setObjectName("materialForSquare")    
703   material->setAmbient(G4Qt3DUtils::ConvertToQ    
704   if (colour.GetAlpha() < 1.) material->setAlp    
705                                                   
706   auto boxMesh = new Qt3DExtras::QCuboidMesh()    
707   boxMesh->setObjectName("boxMesh");              
708   G4double side;                                  
709   if (square.GetSizeType() == G4VMarker::world    
710     side = square.GetWorldDiameter();             
711   } else {  // Screen-size or none                
712     // Not figured out how to do screen-size,     
713     const G4double scale = 200.;  // Roughly p    
714     side = square.GetScreenDiameter()*fpScene-    
715   }                                               
716   boxMesh->setXExtent(side);                      
717   boxMesh->setYExtent(side);                      
718   boxMesh->setZExtent(side);                      
719                                                   
720   auto currentEntity = new Qt3DCore::QEntity(c    
721   currentEntity->addComponent(material);          
722   currentEntity->addComponent(transform);         
723   currentEntity->addComponent(boxMesh);           
724 }                                                 
725                                                   
726 void G4Qt3DSceneHandler::AddPrimitive(const G4    
727 {                                                 
728   auto currentNode = CreateNewNode();             
729   if (!currentNode) {                             
730     static G4bool first = true;                   
731     if (first) {                                  
732       first = false;                              
733       G4Exception("G4Qt3DSceneHandler::AddPrim    
734       "qt3d-0003", JustWarning,                   
735       "No available node!");                      
736     }                                             
737     return;                                       
738   }                                               
739                                                   
740   if (polyhedron.GetNoFacets() == 0) return;      
741                                                   
742   fpVisAttribs = fpViewer->GetApplicableVisAtt    
743                                                   
744   // Roll out vertices and normals for the fac    
745   // are duplicated. For example a box has 8 v    
746   // you need 12 triangles and 36 vertices. If    
747   // we could restrict the number to 8 and use    
748   // triangles, but we also have to consider t    
749   // more than one normal, depending on which     
750   // So we roll out all the vertices and norma    
751   std::vector<G4Point3D> vertices;                
752   std::vector<G4Normal3D> normals;                
753                                                   
754   // Also roll out edges (as lines) for wirefr    
755   // including those that differ only in the o    
756   typedef std::pair<G4Point3D,G4Point3D> Line;    
757   std::vector<Line> lines;                        
758   auto insertIfNew = [&lines](const Line& newL    
759     // For a large polyhedron, eliminating lin    
760     // expensive. Comment out for now, and may    
761     // Allow the graphics-reps utilities to op    
762 //    for (const auto& line: lines) {             
763 //      if ((newLine.first==line.first && newL    
764 //          (newLine.first==line.second && new    
765 //      return;                                   
766 //    }                                           
767     lines.push_back(newLine);                     
768   };                                              
769                                                   
770   G4bool isAuxilaryEdgeVisible = fpViewer->Get    
771   G4bool notLastFace;                             
772   do {                                            
773     G4int      nEdges;                            
774     G4Point3D  vertex  [4];                       
775     G4int      edgeFlag[4];                       
776     G4Normal3D normal  [4];                       
777     notLastFace = polyhedron.GetNextFacet(nEdg    
778     vertices.push_back(vertex[0]);                
779     vertices.push_back(vertex[1]);                
780     vertices.push_back(vertex[2]);                
781     normals.push_back(normal[0]);                 
782     normals.push_back(normal[1]);                 
783     normals.push_back(normal[2]);                 
784     if(isAuxilaryEdgeVisible||edgeFlag[0]>0)in    
785     if(isAuxilaryEdgeVisible||edgeFlag[1]>0)in    
786     if (nEdges == 3) {                            
787       // Face is a triangle                       
788       // One more line for wireframe, triangle    
789       if(isAuxilaryEdgeVisible||edgeFlag[2]>0)    
790     } else if (nEdges == 4) {                     
791       // Face is a quadrilateral                  
792       // Create another triangle for surfaces,    
793       vertices.push_back(vertex[2]);              
794       vertices.push_back(vertex[3]);              
795       vertices.push_back(vertex[0]);              
796       normals.push_back(normal[2]);               
797       normals.push_back(normal[3]);               
798       normals.push_back(normal[0]);               
799       if(isAuxilaryEdgeVisible||edgeFlag[2]>0)    
800       if(isAuxilaryEdgeVisible||edgeFlag[3]>0)    
801     } else {                                      
802       G4warn                                      
803       << "ERROR: polyhedron face with unexpect    
804       << "\n  Tag: " << fpModel->GetCurrentTag    
805       << G4endl;                                  
806       return;                                     
807     }                                             
808   } while (notLastFace);                          
809   const auto nVerts = vertices.size();            
810   const auto nLines = lines.size();               
811                                                   
812   // Now put stuff into Qt objects                
813                                                   
814   auto transform = G4Qt3DUtils::CreateQTransfo    
815   transform->setObjectName("transform");          
816                                                   
817   Qt3DCore::QEntity* wireframeEntity = nullptr    
818   Qt3DCore::QEntity* surfaceEntity   = nullptr    
819   static G4int errorCount = 0;                    
820   G4ViewParameters::DrawingStyle drawing_style    
821   switch (drawing_style) {                        
822     case G4ViewParameters::wireframe:             
823       wireframeEntity = new Qt3DCore::QEntity(    
824       wireframeEntity->addComponent(transform)    
825       break;                                      
826     case G4ViewParameters::hlr:                   
827       wireframeEntity = new Qt3DCore::QEntity(    
828       wireframeEntity->addComponent(transform)    
829       surfaceEntity = new Qt3DCore::QEntity(cu    
830       surfaceEntity->addComponent(transform);     
831       break;                                      
832     case G4ViewParameters::hsr:                   
833       surfaceEntity = new Qt3DCore::QEntity(cu    
834       surfaceEntity->addComponent(transform);     
835       break;                                      
836     case G4ViewParameters::hlhsr:                 
837       wireframeEntity = new Qt3DCore::QEntity(    
838       wireframeEntity->addComponent(transform)    
839       surfaceEntity = new Qt3DCore::QEntity(cu    
840       surfaceEntity->addComponent(transform);     
841       break;                                      
842     case G4ViewParameters::cloud:                 
843       // Shouldn't happen in this function (it    
844       if (errorCount == 0) {                      
845         ++errorCount;                             
846         G4warn << "WARNING: Qt3D: cloud drawin    
847       }                                           
848       return;                                     
849       break;                                      
850   }                                               
851                                                   
852   const auto vertexByteSize  = 3*sizeof(PRECIS    
853                                                   
854   G4Qt3DCompat::QGeometry* vertexGeometry = nu    
855   G4Qt3DCompat::QGeometry* lineGeometry   = nu    
856                                                   
857   G4Qt3DCompat::QAttribute* positionAtt = null    
858   G4Qt3DCompat::QAttribute* normalAtt   = null    
859   G4Qt3DCompat::QAttribute* lineAtt     = null    
860   G4Qt3DCompat::QAttribute* dummyNormalLineAtt    
861                                                   
862   G4Qt3DCompat::QBuffer* vertexBuffer = nullpt    
863   if (drawing_style == G4ViewParameters::hlr |    
864       drawing_style == G4ViewParameters::hsr |    
865       drawing_style == G4ViewParameters::hlhsr    
866                                                   
867     // Put vertices, normals into  QByteArray     
868     // Accomodates both vertices and normals -    
869     QByteArray vertexByteArray;                   
870     const auto vertexBufferByteSize = 2*nVerts    
871     vertexByteArray.resize((G4int)vertexBuffer    
872     auto vertexBufferArray = reinterpret_cast<    
873     G4int i1 = 0;                                 
874     for (std::size_t i = 0; i < nVerts; ++i) {    
875       vertexBufferArray[i1++] = vertices[i].x(    
876       vertexBufferArray[i1++] = vertices[i].y(    
877       vertexBufferArray[i1++] = vertices[i].z(    
878       vertexBufferArray[i1++] = normals[i].x()    
879       vertexBufferArray[i1++] = normals[i].y()    
880       vertexBufferArray[i1++] = normals[i].z()    
881     }                                             
882     // Vertex buffer (vertices and normals)       
883     vertexGeometry = new G4Qt3DCompat::QGeomet    
884     vertexGeometry->setObjectName("vertexGeome    
885     vertexBuffer = new G4Qt3DCompat::QBuffer(v    
886     vertexBuffer->setObjectName("Vertex buffer    
887     vertexBuffer->setData(vertexByteArray);       
888                                                   
889     // Position attribute                         
890     positionAtt = new G4Qt3DCompat::QAttribute    
891     positionAtt->setObjectName("Position attri    
892     positionAtt->setName(G4Qt3DCompat::QAttrib    
893     positionAtt->setBuffer(vertexBuffer);         
894     positionAtt->setAttributeType(G4Qt3DCompat    
895     positionAtt->setVertexBaseType(BASETYPE);     
896     positionAtt->setVertexSize(3);                
897     positionAtt->setCount((G4int)nVerts);         
898     positionAtt->setByteOffset(0);                
899     positionAtt->setByteStride(2*vertexByteSiz    
900                                                   
901     // Normal attribute                           
902     normalAtt = new G4Qt3DCompat::QAttribute;     
903     normalAtt->setObjectName("Normal attribute    
904     normalAtt->setName(G4Qt3DCompat::QAttribut    
905     normalAtt->setBuffer(vertexBuffer);           
906     normalAtt->setAttributeType(G4Qt3DCompat::    
907     normalAtt->setVertexBaseType(BASETYPE);       
908     normalAtt->setVertexSize(3);                  
909     normalAtt->setCount((G4int)nVerts);           
910     normalAtt->setByteOffset(vertexByteSize);     
911     normalAtt->setByteStride(2*vertexByteSize)    
912   }                                               
913                                                   
914   G4Qt3DCompat::QBuffer* lineBuffer = nullptr;    
915   if (drawing_style == G4ViewParameters::wiref    
916       drawing_style == G4ViewParameters::hlr |    
917       drawing_style == G4ViewParameters::hlhsr    
918                                                   
919     // Put lines into a QByteArray                
920     QByteArray lineByteArray;                     
921     const auto lineBufferByteSize = 2*nLines*v    
922     lineByteArray.resize((G4int)lineBufferByte    
923     auto lineBufferArray = reinterpret_cast<PR    
924     G4int i2 = 0;                                 
925     for (const auto& line: lines) {               
926       lineBufferArray[i2++] = line.first.x();     
927       lineBufferArray[i2++] = line.first.y();     
928       lineBufferArray[i2++] = line.first.z();     
929       lineBufferArray[i2++] = line.second.x();    
930       lineBufferArray[i2++] = line.second.y();    
931       lineBufferArray[i2++] = line.second.z();    
932     }                                             
933     // Line loop buffer                           
934     lineGeometry = new G4Qt3DCompat::QGeometry    
935     lineGeometry->setObjectName("lineGeometry"    
936     lineBuffer = new G4Qt3DCompat::QBuffer(lin    
937     lineBuffer->setObjectName("Line buffer");     
938     lineBuffer->setData(lineByteArray);           
939                                                   
940     // Line attribute                             
941     lineAtt = new G4Qt3DCompat::QAttribute;       
942     lineAtt->setObjectName("Position attribute    
943     lineAtt->setName(G4Qt3DCompat::QAttribute:    
944     lineAtt->setBuffer(lineBuffer);               
945     lineAtt->setAttributeType(G4Qt3DCompat::QA    
946     lineAtt->setVertexBaseType(BASETYPE);         
947     lineAtt->setVertexSize(3);                    
948     lineAtt->setCount((G4int)nLines);             
949     lineAtt->setByteOffset(0);                    
950     lineAtt->setByteStride(vertexByteSize);       
951     // Normal attribute (a dummy with count==0    
952     dummyNormalLineAtt = new G4Qt3DCompat::QAt    
953     dummyNormalLineAtt->setObjectName("Normal     
954     dummyNormalLineAtt->setName(G4Qt3DCompat::    
955     dummyNormalLineAtt->setBuffer(lineBuffer);    
956     dummyNormalLineAtt->setAttributeType(G4Qt3    
957     dummyNormalLineAtt->setVertexBaseType(BASE    
958     dummyNormalLineAtt->setVertexSize(3);         
959     dummyNormalLineAtt->setCount(0);              
960     dummyNormalLineAtt->setByteOffset(0);         
961     dummyNormalLineAtt->setByteStride(vertexBy    
962   }                                               
963                                                   
964   // Create material and renderer(s)...           
965                                                   
966   const auto& colour = fpVisAttribs->GetColour    
967   Qt3DExtras::QDiffuseSpecularMaterial* materi    
968   Qt3DRender::QGeometryRenderer* renderer;        
969   switch (drawing_style) {                        
970                                                   
971     case G4ViewParameters::wireframe:             
972                                                   
973       lineGeometry->addAttribute(lineAtt);        
974       lineGeometry->addAttribute(dummyNormalLi    
975                                                   
976       material = new Qt3DExtras::QDiffuseSpecu    
977       material->setObjectName("materialForWire    
978       material->setAmbient(G4Qt3DUtils::Conver    
979       material->setShininess(0.);                 
980       material->setSpecular(0.);                  
981       wireframeEntity->addComponent(material);    
982                                                   
983       renderer = new Qt3DRender::QGeometryRend    
984       renderer->setObjectName("polyhedronWiref    
985       renderer->setGeometry(lineGeometry);        
986       renderer->setVertexCount(2*(G4int)nLines    
987       renderer->setPrimitiveType(Qt3DRender::Q    
988       wireframeEntity->addComponent(renderer);    
989                                                   
990       break;                                      
991                                                   
992     case G4ViewParameters::hlr:                   
993                                                   
994       // Surfaces with background colour to hi    
995                                                   
996       vertexGeometry->addAttribute(positionAtt    
997       vertexGeometry->addAttribute(normalAtt);    
998                                                   
999       material = new Qt3DExtras::QDiffuseSpecu    
1000       material->setObjectName("materialForHid    
1001       material->setAmbient(Qt::white);  // Wh    
1002       material->setShininess(0.);                
1003       material->setSpecular(0.);                 
1004       surfaceEntity->addComponent(material);     
1005                                                  
1006       renderer = new Qt3DRender::QGeometryRen    
1007       renderer->setObjectName("polyhedronSurf    
1008       renderer->setGeometry(vertexGeometry);     
1009       renderer->setVertexCount((G4int)nVerts)    
1010       renderer->setPrimitiveType(Qt3DRender::    
1011       surfaceEntity->addComponent(renderer);     
1012                                                  
1013       // Edges                                   
1014                                                  
1015       lineGeometry->addAttribute(lineAtt);       
1016       lineGeometry->addAttribute(dummyNormalL    
1017                                                  
1018       material = new Qt3DExtras::QDiffuseSpec    
1019       material->setObjectName("materialForWir    
1020       material->setAmbient(G4Qt3DUtils::Conve    
1021       material->setShininess(0.);                
1022       material->setSpecular(0.);                 
1023       wireframeEntity->addComponent(material)    
1024                                                  
1025       renderer = new Qt3DRender::QGeometryRen    
1026       renderer->setObjectName("polyhedronWire    
1027       renderer->setGeometry(lineGeometry);       
1028       renderer->setVertexCount(2*(G4int)nLine    
1029       renderer->setPrimitiveType(Qt3DRender::    
1030       wireframeEntity->addComponent(renderer)    
1031                                                  
1032       break;                                     
1033                                                  
1034     case G4ViewParameters::hsr:                  
1035                                                  
1036       vertexGeometry->addAttribute(positionAt    
1037       vertexGeometry->addAttribute(normalAtt)    
1038                                                  
1039       material = new Qt3DExtras::QDiffuseSpec    
1040       material->setObjectName("materialForSur    
1041       material->setAmbient(G4Qt3DUtils::Conve    
1042       if (colour.GetAlpha() < 1.) material->s    
1043       surfaceEntity->addComponent(material);     
1044                                                  
1045       renderer = new Qt3DRender::QGeometryRen    
1046       renderer->setObjectName("polyhedronSurf    
1047       renderer->setGeometry(vertexGeometry);     
1048       renderer->setVertexCount((G4int)nVerts)    
1049       renderer->setPrimitiveType(Qt3DRender::    
1050       surfaceEntity->addComponent(renderer);     
1051                                                  
1052       break;                                     
1053                                                  
1054     case G4ViewParameters::hlhsr:                
1055                                                  
1056       // Surfaces                                
1057                                                  
1058       vertexGeometry->addAttribute(positionAt    
1059       vertexGeometry->addAttribute(normalAtt)    
1060                                                  
1061       material = new Qt3DExtras::QDiffuseSpec    
1062       material->setObjectName("materialForSur    
1063       material->setAmbient(G4Qt3DUtils::Conve    
1064       if (colour.GetAlpha() < 1.) material->s    
1065       surfaceEntity->addComponent(material);     
1066                                                  
1067       renderer = new Qt3DRender::QGeometryRen    
1068       renderer->setObjectName("polyhedronSurf    
1069       renderer->setGeometry(vertexGeometry);     
1070       renderer->setVertexCount((G4int)nVerts)    
1071       renderer->setPrimitiveType(Qt3DRender::    
1072       surfaceEntity->addComponent(renderer);     
1073                                                  
1074       // Edges                                   
1075                                                  
1076       lineGeometry->addAttribute(lineAtt);       
1077       lineGeometry->addAttribute(dummyNormalL    
1078                                                  
1079       material = new Qt3DExtras::QDiffuseSpec    
1080       material->setObjectName("materialForWir    
1081       material->setAmbient(G4Qt3DUtils::Conve    
1082       material->setShininess(0.);                
1083       material->setSpecular(0.);                 
1084       wireframeEntity->addComponent(material)    
1085                                                  
1086       renderer = new Qt3DRender::QGeometryRen    
1087       renderer->setObjectName("polyhedronSurf    
1088       renderer->setGeometry(lineGeometry);       
1089       renderer->setVertexCount(2*(G4int)nLine    
1090       renderer->setPrimitiveType(Qt3DRender::    
1091       wireframeEntity->addComponent(renderer)    
1092                                                  
1093       break;                                     
1094                                                  
1095     case G4ViewParameters::cloud:                
1096       // Case trapped at start of function, s    
1097       break;                                     
1098   }                                              
1099 }                                                
1100                                                  
1101 void G4Qt3DSceneHandler::AddCompound(const G4    
1102 {                                                
1103   StandardSpecialMeshRendering(mesh);            
1104 }                                                
1105                                                  
1106 void G4Qt3DSceneHandler::ClearStore ()           
1107 {                                                
1108   G4Qt3DUtils::delete_components_and_children    
1109   EstablishG4Qt3DQEntities();                    
1110 }                                                
1111                                                  
1112 void G4Qt3DSceneHandler::ClearTransientStore     
1113 {                                                
1114   G4Qt3DUtils::delete_components_and_children    
1115 }                                                
1116