28#if defined (G4VIS_BUILD_QT3D_DRIVER) || defined (G4VIS_USE_QT3D)
62#define PRECISION float
63#define BASETYPE Qt3DRender::QAttribute::Float
65G4int G4Qt3DSceneHandler::fSceneIdCount = 0;
67G4Qt3DSceneHandler::G4Qt3DSceneHandler
72 G4cout <<
"G4Qt3DSceneHandler::G4Qt3DSceneHandler called" <<
G4endl;
74 fpQt3DScene =
new Qt3DCore::QEntity;
75 fpQt3DScene->setObjectName(
"G4Qt3DSceneRoot");
76 EstablishG4Qt3DQEntities();
79G4Qt3DSceneHandler::~G4Qt3DSceneHandler()
96void G4Qt3DSceneHandler::EstablishG4Qt3DQEntities()
98 fpTransientObjects =
new G4Qt3DQEntity(fpQt3DScene);
99 fpTransientObjects ->setObjectName(
"G4Qt3DTORoot");
100 fpPersistentObjects =
new G4Qt3DQEntity(fpQt3DScene);
101 fpPersistentObjects ->setObjectName(
"G4Qt3DPORoot");
106 size_t nWorlds = transportationManager->
GetNoWorlds();
107 std::vector<G4VPhysicalVolume*>::iterator iterWorld
109 fpPhysicalVolumeObjects.resize(nWorlds);
110 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
112 auto entity =
new G4Qt3DQEntity(fpPersistentObjects);
113 entity->setObjectName(
"G4Qt3DPORoot_"+QString(world->
GetName()));
115 fpPhysicalVolumeObjects[i] = entity;
119G4Qt3DQEntity* G4Qt3DSceneHandler::CreateNewNode()
123#ifdef G4MULTITHREADED
127 G4Qt3DQEntity* newNode =
nullptr;
129 if (fReadyForTransients) {
130 newNode =
new G4Qt3DQEntity(fpTransientObjects);
131 newNode->setObjectName(fpModel->GetGlobalTag().c_str());
139 newNode =
new G4Qt3DQEntity(fpPersistentObjects);
140 newNode->setObjectName(fpModel->GetGlobalTag().c_str());
147 typedef std::vector<PVNodeID>
PVPath;
161 const size_t nWorlds = fpPhysicalVolumeObjects.size();
163 for (; iWorld < nWorlds; ++iWorld) {
164 if (fullPVPath[0].GetPhysicalVolume() ==
165 fpPhysicalVolumeObjects[iWorld]->GetPVNodeID().GetPhysicalVolume())
break;
167 if (iWorld == nWorlds) {
169 "World mis-match - not possible(!?)");
173 G4Qt3DQEntity* world = fpPhysicalVolumeObjects[iWorld];
174 world->SetPVNodeID(fullPVPath[0]);
177 G4Qt3DQEntity* node = world;
179 const size_t depth = fullPVPath.size();
181 while (iDepth < depth) {
182 const auto& children = node->children();
183 const G4int nChildren = children.size();
185 G4Qt3DQEntity* child =
nullptr;
186 for (; iChild < nChildren; ++iChild) {
187 child =
static_cast<G4Qt3DQEntity*
>(children[iChild]);
188 if (child->GetPVNodeID() == fullPVPath[iDepth])
break;
190 if (iChild != nChildren) {
194 newNode =
new G4Qt3DQEntity(node);
195 newNode->SetPVNodeID(fullPVPath[iDepth]);
196 std::ostringstream oss;
197 oss << newNode->GetPVNodeID().GetPhysicalVolume()->GetName()
198 <<
':' << newNode->GetPVNodeID().GetCopyNo();
199 newNode->setObjectName(oss.str().c_str());
208void G4Qt3DSceneHandler::PreAddSolid
215void G4Qt3DSceneHandler::PostAddSolid()
220void G4Qt3DSceneHandler::BeginPrimitives2D(
const G4Transform3D& objectTransformation)
228 static G4bool first =
true;
231 G4Exception(
"G4Qt3DSceneHandler::BeginPrimitives2D",
"qt3D-0001",
233 "2D drawing not yet implemented");
239void G4Qt3DSceneHandler::EndPrimitives2D ()
247void G4Qt3DSceneHandler::BeginPrimitives
253void G4Qt3DSceneHandler::EndPrimitives ()
258void G4Qt3DSceneHandler::AddPrimitive(
const G4Polyline& polyline)
262 "G4Qt3DSceneHandler::AddPrimitive(const G4Polyline& polyline) called.\n"
267 auto currentNode = CreateNewNode();
268 if (!currentNode)
return;
270 if (polyline.size() == 0)
return;
272 fpVisAttribs = fpViewer->GetApplicableVisAttributes(polyline.
GetVisAttributes());
274 auto transform = G4Qt3DUtils::CreateQTransformFrom(fObjectTransformation);
275 transform->setObjectName(
"transform");
277 auto polylineEntity =
new Qt3DCore::QEntity(currentNode);
278 polylineEntity->addComponent(transform);
280 const auto vertexByteSize = 3*
sizeof(PRECISION);
282 const size_t nLines = polyline.size() - 1;
283 QByteArray polylineByteArray;
284 const auto polylineBufferByteSize = 2*nLines*vertexByteSize;
285 polylineByteArray.resize(polylineBufferByteSize);
286 auto polylineBufferArray =
reinterpret_cast<PRECISION*
>(polylineByteArray.data());
288 for (
size_t i = 0; i < nLines; ++i) {
289 polylineBufferArray[iLine++] = polyline[i].x();
290 polylineBufferArray[iLine++] = polyline[i].y();
291 polylineBufferArray[iLine++] = polyline[i].z();
292 polylineBufferArray[iLine++] = polyline[i+1].x();
293 polylineBufferArray[iLine++] = polyline[i+1].y();
294 polylineBufferArray[iLine++] = polyline[i+1].z();
296 auto polylineGeometry =
new Qt3DRender::QGeometry();
297 polylineGeometry->setObjectName(
"polylineGeometry");
298 auto polylineBuffer =
new Qt3DRender::QBuffer(polylineGeometry);
299 polylineBuffer->setObjectName(
"Polyline buffer");
300 polylineBuffer->setData(polylineByteArray);
302 auto polylineAtt =
new Qt3DRender::QAttribute;
303 polylineAtt->setObjectName(
"Position attribute");
304 polylineAtt->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
305 polylineAtt->setBuffer(polylineBuffer);
306 polylineAtt->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
307 polylineAtt->setVertexBaseType(BASETYPE);
308 polylineAtt->setVertexSize(3);
309 polylineAtt->setCount(nLines);
310 polylineAtt->setByteOffset(0);
311 polylineAtt->setByteStride(vertexByteSize);
313 const auto& colour = fpVisAttribs->GetColour();
315 polylineGeometry->addAttribute(polylineAtt);
317 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
318 material->setObjectName(
"materialForPolyline");
319 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
320 material->setShininess(0.);
321 material->setSpecular(0.);
322 polylineEntity->addComponent(material);
324 auto renderer =
new Qt3DRender::QGeometryRenderer;
325 renderer->setObjectName(
"polyhedronWireframeRenderer");
326 renderer->setGeometry(polylineGeometry);
327 renderer->setVertexCount(2*nLines);
328 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines);
329 polylineEntity->addComponent(renderer);
332void G4Qt3DSceneHandler::AddPrimitive (
const G4Polymarker& polymarker)
334 auto currentNode = CreateNewNode();
335 if (!currentNode)
return;
337 if (polymarker.size() == 0)
return;
339 fpVisAttribs = fpViewer->GetApplicableVisAttributes(polymarker.
GetVisAttributes());
345 const size_t nDots = polymarker.size();
347 auto transform = G4Qt3DUtils::CreateQTransformFrom(fObjectTransformation);
348 transform->setObjectName(
"transform");
350 auto polymarkerEntity =
new Qt3DCore::QEntity(currentNode);
351 polymarkerEntity->addComponent(transform);
353 const auto vertexByteSize = 3*
sizeof(PRECISION);
355 QByteArray polymarkerByteArray;
356 const auto polymarkerBufferByteSize = nDots*vertexByteSize;
357 polymarkerByteArray.resize(polymarkerBufferByteSize);
358 auto polymarkerBufferArray =
reinterpret_cast<PRECISION*
>(polymarkerByteArray.data());
360 for (
size_t i = 0; i < polymarker.size(); ++i) {
361 polymarkerBufferArray[iMarker++] = polymarker[i].x();
362 polymarkerBufferArray[iMarker++] = polymarker[i].y();
363 polymarkerBufferArray[iMarker++] = polymarker[i].z();
365 auto polymarkerGeometry =
new Qt3DRender::QGeometry();
366 polymarkerGeometry->setObjectName(
"polymarkerGeometry");
367 auto polymarkerBuffer =
new Qt3DRender::QBuffer(polymarkerGeometry);
368 polymarkerBuffer->setObjectName(
"Polymarker buffer");
369 polymarkerBuffer->setData(polymarkerByteArray);
371 auto polymarkerAtt =
new Qt3DRender::QAttribute;
372 polymarkerAtt->setObjectName(
"Position attribute");
373 polymarkerAtt->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
374 polymarkerAtt->setBuffer(polymarkerBuffer);
375 polymarkerAtt->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
376 polymarkerAtt->setVertexBaseType(BASETYPE);
377 polymarkerAtt->setVertexSize(3);
378 polymarkerAtt->setCount(nDots);
379 polymarkerAtt->setByteOffset(0);
380 polymarkerAtt->setByteStride(vertexByteSize);
382 const auto& colour = fpVisAttribs->GetColour();
384 polymarkerGeometry->addAttribute(polymarkerAtt);
386 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
387 material->setObjectName(
"materialForPolymarker");
388 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
389 material->setShininess(0.);
390 material->setSpecular(0.);
391 polymarkerEntity->addComponent(material);
393 auto renderer =
new Qt3DRender::QGeometryRenderer;
394 renderer->setObjectName(
"polymarkerWireframeRenderer");
395 renderer->setGeometry(polymarkerGeometry);
396 renderer->setVertexCount(nDots);
397 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Points);
398 polymarkerEntity->addComponent(renderer);
405 const auto& colour = fpVisAttribs->GetColour();
406 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
407 material->setObjectName(
"materialForCircle");
408 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
409 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
411 auto sphereMesh =
new Qt3DExtras::QSphereMesh;
412 sphereMesh->setObjectName(
"sphereMesh");
415 radius =circle.GetWorldRadius();
419 radius = circle.GetScreenRadius()*fpScene->GetExtent().GetExtentRadius()/scale;
421 sphereMesh->setRadius(radius);
423 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
425 auto transform = G4Qt3DUtils::CreateQTransformFrom(
position);
426 auto currentEntity =
new Qt3DCore::QEntity(currentNode);
427 currentEntity->addComponent(material);
428 currentEntity->addComponent(transform);
429 currentEntity->addComponent(sphereMesh);
437 const auto& colour = fpVisAttribs->GetColour();
438 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
439 material->setObjectName(
"materialForSquare");
440 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
441 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
443 auto boxMesh =
new Qt3DExtras::QCuboidMesh();
444 boxMesh->setObjectName(
"boxMesh");
447 side = square.GetWorldDiameter();
451 side = square.GetScreenDiameter()*fpScene->GetExtent().GetExtentRadius()/scale;
453 boxMesh->setXExtent(side);
454 boxMesh->setYExtent(side);
455 boxMesh->setZExtent(side);
457 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
459 auto transform = G4Qt3DUtils::CreateQTransformFrom(
position);
460 auto currentEntity =
new Qt3DCore::QEntity(currentNode);
461 currentEntity->addComponent(material);
462 currentEntity->addComponent(transform);
463 currentEntity->addComponent(boxMesh);
470void G4Qt3DSceneHandler::AddPrimitive(
const G4Text& text) {
473 "G4Qt3DSceneHandler::AddPrimitive(const G4Text& text) called.\n"
478 static G4bool first =
true;
481 G4Exception(
"G4Qt3DSceneHandler::AddPrimitive(const G4Text& text)",
483 "Text drawing not yet implemented");
487 auto currentNode = CreateNewNode();
488 if (!currentNode)
return;
490 fpVisAttribs = fpViewer->GetApplicableVisAttributes(text.
GetVisAttributes());
493 auto transform = G4Qt3DUtils::CreateQTransformFrom(
position);
494 transform->setScale(10);
508 const auto& colour = GetTextColour(text);
509 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
510 material->setObjectName(
"materialForText");
511 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
512 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
514 auto textMesh =
new Qt3DExtras::QExtrudedTextMesh();
515 textMesh->setText(text.
GetText().c_str());
516 textMesh->setFont(QFont(
"Courier New", 10));
517 textMesh->setDepth(.01f);
519 currentNode->addComponent(material);
520 currentNode->addComponent(transform);
521 currentNode->addComponent(textMesh);
524void G4Qt3DSceneHandler::AddPrimitive(
const G4Circle& circle)
528 "G4Qt3DSceneHandler::AddPrimitive(const G4Circle& circle) called.\n"
534 MarkerSizeType sizeType;
535 G4double size = GetMarkerSize (circle, sizeType);
550 auto currentNode = CreateNewNode();
551 if (!currentNode)
return;
553 fpVisAttribs = fpViewer->GetApplicableVisAttributes(circle.
GetVisAttributes());
556 auto transform = G4Qt3DUtils::CreateQTransformFrom(
position);
558 const auto& colour = fpVisAttribs->GetColour();
559 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
560 material->setObjectName(
"materialForCircle");
561 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
562 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
564 auto sphereMesh =
new Qt3DExtras::QSphereMesh;
565 sphereMesh->setObjectName(
"sphereMesh");
572 radius = circle.
GetScreenRadius()*fpScene->GetExtent().GetExtentRadius()/scale;
574 sphereMesh->setRadius(radius);
576 auto currentEntity =
new Qt3DCore::QEntity(currentNode);
577 currentEntity->addComponent(material);
578 currentEntity->addComponent(transform);
579 currentEntity->addComponent(sphereMesh);
582void G4Qt3DSceneHandler::AddPrimitive(
const G4Square& square)
586 "G4Qt3DSceneHandler::AddPrimitive(const G4Square& square) called.\n"
592 MarkerSizeType sizeType;
593 G4double size = GetMarkerSize (square, sizeType);
608 auto currentNode = CreateNewNode();
609 if (!currentNode)
return;
611 fpVisAttribs = fpViewer->GetApplicableVisAttributes(square.
GetVisAttributes());
614 auto transform = G4Qt3DUtils::CreateQTransformFrom(
position);
616 const auto& colour = fpVisAttribs->GetColour();
617 auto material =
new Qt3DExtras::QDiffuseSpecularMaterial();
618 material->setObjectName(
"materialForSquare");
619 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
620 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
622 auto boxMesh =
new Qt3DExtras::QCuboidMesh();
623 boxMesh->setObjectName(
"boxMesh");
632 boxMesh->setXExtent(side);
633 boxMesh->setYExtent(side);
634 boxMesh->setZExtent(side);
636 auto currentEntity =
new Qt3DCore::QEntity(currentNode);
637 currentEntity->addComponent(material);
638 currentEntity->addComponent(transform);
639 currentEntity->addComponent(boxMesh);
642void G4Qt3DSceneHandler::AddPrimitive(
const G4Polyhedron& polyhedron)
644 auto currentNode = CreateNewNode();
645 if (!currentNode)
return;
649 fpVisAttribs = fpViewer->GetApplicableVisAttributes(polyhedron.
GetVisAttributes());
658 std::vector<G4Point3D> vertices;
659 std::vector<G4Normal3D> normals;
663 typedef std::pair<G4Point3D,G4Point3D> Line;
664 std::vector<Line> lines;
665 auto insertIfNew = [&lines](
const Line& newLine) {
666 for (
const auto& line: lines) {
667 if ((newLine.first==line.first && newLine.second==line.second) ||
668 (newLine.first==line.second && newLine.second==line.first))
671 lines.push_back(newLine);
680 notLastFace = polyhedron.
GetNextFacet(nEdges, vertex, edgeFlag, normal);
681 vertices.push_back(vertex[0]);
682 vertices.push_back(vertex[1]);
683 vertices.push_back(vertex[2]);
684 normals.push_back(normal[0]);
685 normals.push_back(normal[1]);
686 normals.push_back(normal[2]);
687 insertIfNew(Line(vertex[0],vertex[1]));
688 insertIfNew(Line(vertex[1],vertex[2]));
692 insertIfNew(Line(vertex[2],vertex[0]));
693 }
else if (nEdges == 4) {
696 vertices.push_back(vertex[2]);
697 vertices.push_back(vertex[3]);
698 vertices.push_back(vertex[0]);
699 normals.push_back(normal[2]);
700 normals.push_back(normal[3]);
701 normals.push_back(normal[0]);
702 insertIfNew(Line(vertex[2],vertex[3]));
703 insertIfNew(Line(vertex[3],vertex[0]));
705 G4cerr <<
"ERROR: polyhedron face with more than 4 edges" <<
G4endl;
708 }
while (notLastFace);
709 const auto nVerts = vertices.size();
710 const auto nLines = lines.size();
714 auto transform = G4Qt3DUtils::CreateQTransformFrom(fObjectTransformation);
715 transform->setObjectName(
"transform");
717 Qt3DCore::QEntity* wireframeEntity =
nullptr;
718 Qt3DCore::QEntity* surfaceEntity =
nullptr;
719 static G4int errorCount = 0;
721 switch (drawing_style) {
723 wireframeEntity =
new Qt3DCore::QEntity(currentNode);
724 wireframeEntity->addComponent(transform);
727 wireframeEntity =
new Qt3DCore::QEntity(currentNode);
728 wireframeEntity->addComponent(transform);
729 surfaceEntity =
new Qt3DCore::QEntity(currentNode);
730 surfaceEntity->addComponent(transform);
733 surfaceEntity =
new Qt3DCore::QEntity(currentNode);
734 surfaceEntity->addComponent(transform);
737 wireframeEntity =
new Qt3DCore::QEntity(currentNode);
738 wireframeEntity->addComponent(transform);
739 surfaceEntity =
new Qt3DCore::QEntity(currentNode);
740 surfaceEntity->addComponent(transform);
744 if (errorCount == 0) {
746 G4cerr <<
"WARNING: Qt3D: cloud drawing not implemented" <<
G4endl;
752 const auto vertexByteSize = 3*
sizeof(PRECISION);
754 Qt3DRender::QGeometry* vertexGeometry =
nullptr;
755 Qt3DRender::QGeometry* lineGeometry =
nullptr;
757 Qt3DRender::QAttribute* positionAtt =
nullptr;
758 Qt3DRender::QAttribute* normalAtt =
nullptr;
759 Qt3DRender::QAttribute* lineAtt =
nullptr;
761 Qt3DRender::QBuffer* vertexBuffer =
nullptr;
768 QByteArray vertexByteArray;
769 const auto vertexBufferByteSize = 2*nVerts*vertexByteSize;
770 vertexByteArray.resize(vertexBufferByteSize);
771 auto vertexBufferArray =
reinterpret_cast<PRECISION*
>(vertexByteArray.data());
773 for (
size_t i = 0; i < nVerts; i++) {
774 vertexBufferArray[i1++] = vertices[i].x();
775 vertexBufferArray[i1++] = vertices[i].y();
776 vertexBufferArray[i1++] = vertices[i].z();
777 vertexBufferArray[i1++] = normals[i].x();
778 vertexBufferArray[i1++] = normals[i].y();
779 vertexBufferArray[i1++] = normals[i].z();
782 vertexGeometry =
new Qt3DRender::QGeometry();
783 vertexGeometry->setObjectName(
"vertexGeometry");
784 vertexBuffer =
new Qt3DRender::QBuffer(vertexGeometry);
785 vertexBuffer->setObjectName(
"Vertex buffer");
786 vertexBuffer->setData(vertexByteArray);
789 positionAtt =
new Qt3DRender::QAttribute;
790 positionAtt->setObjectName(
"Position attribute");
791 positionAtt->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
792 positionAtt->setBuffer(vertexBuffer);
793 positionAtt->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
794 positionAtt->setVertexBaseType(BASETYPE);
795 positionAtt->setVertexSize(3);
796 positionAtt->setCount(nVerts);
797 positionAtt->setByteOffset(0);
798 positionAtt->setByteStride(2*vertexByteSize);
801 normalAtt =
new Qt3DRender::QAttribute;
802 normalAtt->setObjectName(
"Normal attribute");
803 normalAtt->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
804 normalAtt->setBuffer(vertexBuffer);
805 normalAtt->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
806 normalAtt->setVertexBaseType(BASETYPE);
807 normalAtt->setVertexSize(3);
808 normalAtt->setCount(nVerts);
809 normalAtt->setByteOffset(vertexByteSize);
810 normalAtt->setByteStride(2*vertexByteSize);
813 Qt3DRender::QBuffer* lineBuffer =
nullptr;
819 QByteArray lineByteArray;
820 const auto lineBufferByteSize = 2*nLines*vertexByteSize;
821 lineByteArray.resize(lineBufferByteSize);
822 auto lineBufferArray =
reinterpret_cast<PRECISION*
>(lineByteArray.data());
824 for (
const auto& line: lines) {
825 lineBufferArray[i2++] = line.first.x();
826 lineBufferArray[i2++] = line.first.y();
827 lineBufferArray[i2++] = line.first.z();
828 lineBufferArray[i2++] = line.second.x();
829 lineBufferArray[i2++] = line.second.y();
830 lineBufferArray[i2++] = line.second.z();
833 lineGeometry =
new Qt3DRender::QGeometry();
834 lineGeometry->setObjectName(
"lineGeometry");
835 lineBuffer =
new Qt3DRender::QBuffer(lineGeometry);
836 lineBuffer->setObjectName(
"Line buffer");
837 lineBuffer->setData(lineByteArray);
840 lineAtt =
new Qt3DRender::QAttribute;
841 lineAtt->setObjectName(
"Position attribute");
842 lineAtt->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
843 lineAtt->setBuffer(lineBuffer);
844 lineAtt->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
845 lineAtt->setVertexBaseType(BASETYPE);
846 lineAtt->setVertexSize(3);
847 lineAtt->setCount(nLines);
848 lineAtt->setByteOffset(0);
849 lineAtt->setByteStride(vertexByteSize);
854 const auto& colour = fpVisAttribs->GetColour();
855 Qt3DExtras::QDiffuseSpecularMaterial* material;
856 Qt3DRender::QGeometryRenderer* renderer;
857 switch (drawing_style) {
861 lineGeometry->addAttribute(lineAtt);
863 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
864 material->setObjectName(
"materialForWireframe");
865 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
866 material->setShininess(0.);
867 material->setSpecular(0.);
868 wireframeEntity->addComponent(material);
870 renderer =
new Qt3DRender::QGeometryRenderer;
871 renderer->setObjectName(
"polyhedronWireframeRenderer");
872 renderer->setGeometry(lineGeometry);
873 renderer->setVertexCount(2*nLines);
874 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines);
875 wireframeEntity->addComponent(renderer);
883 vertexGeometry->addAttribute(positionAtt);
884 vertexGeometry->addAttribute(normalAtt);
886 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
887 material->setObjectName(
"materialForHiddenLines");
888 material->setAmbient(Qt::white);
889 material->setShininess(0.);
890 material->setSpecular(0.);
891 surfaceEntity->addComponent(material);
893 renderer =
new Qt3DRender::QGeometryRenderer;
894 renderer->setObjectName(
"polyhedronSurfaceRenderer");
895 renderer->setGeometry(vertexGeometry);
896 renderer->setVertexCount(nVerts);
897 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles);
898 surfaceEntity->addComponent(renderer);
902 lineGeometry->addAttribute(lineAtt);
904 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
905 material->setObjectName(
"materialForWireFrame");
906 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
907 material->setShininess(0.);
908 material->setSpecular(0.);
909 wireframeEntity->addComponent(material);
911 renderer =
new Qt3DRender::QGeometryRenderer;
912 renderer->setObjectName(
"polyhedronWireframeRenderer");
913 renderer->setGeometry(lineGeometry);
914 renderer->setVertexCount(2*nLines);
915 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines);
916 wireframeEntity->addComponent(renderer);
922 vertexGeometry->addAttribute(positionAtt);
923 vertexGeometry->addAttribute(normalAtt);
925 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
926 material->setObjectName(
"materialForSurface");
927 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
928 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
929 surfaceEntity->addComponent(material);
931 renderer =
new Qt3DRender::QGeometryRenderer;
932 renderer->setObjectName(
"polyhedronSurfaceRenderer");
933 renderer->setGeometry(vertexGeometry);
934 renderer->setVertexCount(nVerts);
935 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles);
936 surfaceEntity->addComponent(renderer);
944 vertexGeometry->addAttribute(positionAtt);
945 vertexGeometry->addAttribute(normalAtt);
947 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
948 material->setObjectName(
"materialForSurface");
949 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
950 if (colour.GetAlpha() < 1.) material->setAlphaBlendingEnabled(
true);
951 surfaceEntity->addComponent(material);
953 renderer =
new Qt3DRender::QGeometryRenderer;
954 renderer->setObjectName(
"polyhedronSurfaceRenderer");
955 renderer->setGeometry(vertexGeometry);
956 renderer->setVertexCount(nVerts);
957 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Triangles);
958 surfaceEntity->addComponent(renderer);
962 lineGeometry->addAttribute(lineAtt);
964 material =
new Qt3DExtras::QDiffuseSpecularMaterial();
965 material->setObjectName(
"materialForWireframe");
966 material->setAmbient(G4Qt3DUtils::ConvertToQColor(colour));
967 material->setShininess(0.);
968 material->setSpecular(0.);
969 wireframeEntity->addComponent(material);
971 renderer =
new Qt3DRender::QGeometryRenderer;
972 renderer->setObjectName(
"polyhedronSurfaceRenderer");
973 renderer->setGeometry(lineGeometry);
974 renderer->setVertexCount(2*nLines);
975 renderer->setPrimitiveType(Qt3DRender::QGeometryRenderer::Lines);
976 wireframeEntity->addComponent(renderer);
986void G4Qt3DSceneHandler::ClearStore ()
988 G4Qt3DUtils::delete_components_and_children_of_entity_recursively(fpQt3DScene);
989 EstablishG4Qt3DQEntities();
992void G4Qt3DSceneHandler::ClearTransientStore ()
994 G4Qt3DUtils::delete_components_and_children_of_entity_recursively(fpTransientObjects);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath() const
MarkerType GetMarkerType() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
SizeType GetSizeType() const
G4double GetScreenRadius() const
G4double GetWorldDiameter() const
G4Point3D GetPosition() const
G4double GetScreenDiameter() const
G4double GetWorldRadius() const
const G4String & GetName() const
virtual void EndPrimitives()
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void PostAddSolid()
virtual void EndPrimitives2D()
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())
const G4VisAttributes * GetVisAttributes() const
G4int GetNoFacets() const
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=0, G4Normal3D *normals=0) const
const char * name(G4int ptype)
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath