28#if defined (G4VIS_BUILD_QT3D_DRIVER) || defined (G4VIS_USE_QT3D)
35Qt3DCore::QTransform* G4Qt3DUtils::CreateQTransformFrom(
const G4Transform3D& g)
37 auto* q =
new Qt3DCore::QTransform;
44 q->setObjectName(
"transform");
48QColor G4Qt3DUtils::ConvertToQColor(
const G4Colour& c) {
54QVector3D G4Qt3DUtils::ConvertToQVector3D(
const G4ThreeVector& v) {
55 return QVector3D(v.
x(),v.
y(),v.
z());
59void G4Qt3DUtils::delete_entity_recursively(Qt3DCore::QNode *node){
61 G4Qt3DUtils::LogFile <<
"node " << node->objectName().toStdString() << std::endl;
63 Qt3DCore::QEntity* entity =
dynamic_cast<Qt3DCore::QEntity*
>(node);
64 if(entity ==
nullptr){
66 if (name ==
"")
name =
"X";
68 G4Qt3DUtils::LogFile << (
void*)node <<
": "
69 <<
"Deleting non-entity node " << name << std::endl;
75 for (
auto component: entity->components()) {
77 if (name ==
"")
name =
"X";
79 G4Qt3DUtils::LogFile << (
void*)node <<
": " <<
"Deleting component " << name
80 <<
" of " << entity->objectName().toStdString() << std::endl;
82 entity->removeComponent(component);
86 for (
auto child_node: entity->childNodes()) {
88 if (name ==
"")
name =
"X";
90 G4Qt3DUtils::LogFile << (
void*)child_node <<
": " <<
"Child node " << name
91 <<
" of " << entity->objectName().toStdString() << std::endl;
93 delete_entity_recursively(child_node);
96 if (name ==
"")
name =
"X";
98 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Deleting entity " << name << std::endl;
104void G4Qt3DUtils::delete_components_and_children_of_entity_recursively(Qt3DCore::QNode *node){
105 Qt3DCore::QEntity* entity =
dynamic_cast<Qt3DCore::QEntity*
>(node);
106 if(entity ==
nullptr){
108 if (name ==
"")
name =
"X";
110 G4Qt3DUtils::LogFile << (
void*)node <<
": " <<
"Found non-entity node " << name << std::endl;
114 for (
auto component: entity->components()){
116 if (name ==
"")
name =
"X";
118 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Deleting component " << name
119 <<
" of " << entity->objectName().toStdString() << std::endl;
121 entity->removeComponent(component);
125 auto child_nodes = entity->childNodes();
126 for (
auto child_node: child_nodes) {
128 if (name ==
"")
name =
"X";
130 G4Qt3DUtils::LogFile << (
void*)child_node <<
": " <<
"Child node " << name
131 <<
" of " << entity->objectName().toStdString() << std::endl;
133 delete_entity_recursively(child_node);
136 if (name ==
"")
name =
"X";
138 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Clearing child nodes of " << name << std::endl;
144std::ofstream G4Qt3DUtils::LogFile(
"LogFile.txt");
145void G4Qt3DUtils::PrintQObjectTree
146 (
const QObject* node,
149 auto& logFile = G4Qt3DUtils::LogFile;
150 if (where.length()) logFile <<
"\n===== QObjectTree at " << where << std::endl;
151 static G4int iDep = -1;
153 const auto* g4node =
dynamic_cast<const G4Qt3DQEntity*
>(node);
154 G4String nodeName = node->objectName().toStdString();
155 if (nodeName ==
"") nodeName =
"X";
156 for (
G4int i = 0; i < iDep; ++i) logFile <<
" ";
157 logFile << (
void*)node <<
": "
158 <<
"Node at depth " << iDep <<
": " << nodeName <<
": ";
160 logFile << g4node->GetPVNodeID() << std::endl;
162 logFile <<
typeid(node).
name() << std::endl;
165 for (
const auto& component: g4node->components()) {
167 if (name ==
"")
name =
"X";
168 for (
G4int i = 0; i < iDep; ++i) logFile <<
" ";
169 logFile << (
void*)component <<
": "<<
"Component at depth " << iDep <<
" "
170 << name <<
" of " << nodeName << std::endl;
173 for (
const auto& child: node->children()) {
174 PrintQObjectTree(child);
177 if (where.length()) logFile <<
"===== End: QObjectTree at " << where << std::endl;
G4double GetAlpha() const
G4double GetGreen() const
const char * name(G4int ptype)