35 auto* q =
new Qt3DCore::QTransform;
42 q->setObjectName(
"transform");
53 return QVector3D(v.
x(),v.
y(),v.
z());
59 G4Qt3DUtils::LogFile <<
"node " << node->objectName().toStdString() << std::endl;
61 Qt3DCore::QEntity* entity =
dynamic_cast<Qt3DCore::QEntity*
>(node);
62 if(entity ==
nullptr){
64 G4String name = node->objectName().toStdString();
65 if (name ==
"") name =
"X";
66 G4Qt3DUtils::LogFile << (
void*)node <<
": "
67 <<
"Deleting non-entity node " << name << std::endl;
73 for (
auto component: entity->components()) {
75 G4String name = component->objectName().toStdString();
76 if (name ==
"") name =
"X";
77 G4Qt3DUtils::LogFile << (
void*)node <<
": " <<
"Deleting component " << name
78 <<
" of " << entity->objectName().toStdString() << std::endl;
80 entity->removeComponent(component);
84 for (
auto child_node: entity->childNodes()) {
85 G4String name = child_node->objectName().toStdString();
86 if (name ==
"") name =
"X";
88 G4Qt3DUtils::LogFile << (
void*)child_node <<
": " <<
"Child node " << name
89 <<
" of " << entity->objectName().toStdString() << std::endl;
93 G4String name = entity->objectName().toStdString();
94 if (name ==
"") name =
"X";
96 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Deleting entity " << name << std::endl;
103 Qt3DCore::QEntity* entity =
dynamic_cast<Qt3DCore::QEntity*
>(node);
104 if(entity ==
nullptr){
106 G4String name = node->objectName().toStdString();
107 if (name ==
"") name =
"X";
108 G4Qt3DUtils::LogFile << (
void*)node <<
": " <<
"Found non-entity node " << name << std::endl;
112 for (
auto component: entity->components()){
114 G4String name = component->objectName().toStdString();
115 if (name ==
"") name =
"X";
116 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Deleting component " << name
117 <<
" of " << entity->objectName().toStdString() << std::endl;
119 entity->removeComponent(component);
123 auto child_nodes = entity->childNodes();
124 for (
auto child_node: child_nodes) {
125 G4String name = child_node->objectName().toStdString();
126 if (name ==
"") name =
"X";
128 G4Qt3DUtils::LogFile << (
void*)child_node <<
": " <<
"Child node " << name
129 <<
" of " << entity->objectName().toStdString() << std::endl;
133 G4String name = entity->objectName().toStdString();
134 if (name ==
"") name =
"X";
136 G4Qt3DUtils::LogFile << (
void*)entity <<
": " <<
"Clearing child nodes of " << name << std::endl;
142std::ofstream G4Qt3DUtils::LogFile(
"LogFile.txt");
143void G4Qt3DUtils::PrintQObjectTree
144 (
const QObject* node,
147 auto& logFile = G4Qt3DUtils::LogFile;
148 if (where.length()) logFile <<
"\n===== QObjectTree at " << where << std::endl;
149 static G4int iDep = -1;
151 G4String nodeName = node->objectName().toStdString();
152 if (nodeName ==
"") nodeName =
"X";
153 for (
G4int i = 0; i < iDep; ++i) logFile <<
" ";
154 logFile << (
void*)node <<
": "
155 <<
"Node at depth " << iDep <<
": " << nodeName <<
": "
156 <<
"thread: " << node->thread() <<
": "
157 <<
"parent: " << node->parent() <<
": ";
158 const auto* g4node =
dynamic_cast<const G4Qt3DQEntity*
>(node);
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 G4PhysicalVolumeModel::G4PhysicalVolumeNodeID & GetPVNodeID() const
const char * name(G4int ptype)
Qt3DCore::QTransform * CreateQTransformFrom(const G4Transform3D &)
QColor ConvertToQColor(const G4Colour &c)
void delete_entity_recursively(Qt3DCore::QNode *node)
void delete_components_and_children_of_entity_recursively(Qt3DCore::QNode *node)
QVector3D ConvertToQVector3D(const G4ThreeVector &v)