Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Qt3DUtils Namespace Reference

Functions

Qt3DCore::QTransform * CreateQTransformFrom (const G4Transform3D &)
 
QColor ConvertToQColor (const G4Colour &c)
 
QVector3D ConvertToQVector3D (const G4ThreeVector &v)
 
void delete_entity_recursively (Qt3DCore::QNode *node)
 
void delete_components_and_children_of_entity_recursively (Qt3DCore::QNode *node)
 

Function Documentation

◆ ConvertToQColor()

QColor G4Qt3DUtils::ConvertToQColor ( const G4Colour c)

Definition at line 46 of file G4Qt3DUtils.cc.

46 {
47 QColor qColor;
48 qColor.setRgbF(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
49 return qColor;
50}
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetAlpha() const
Definition: G4Colour.hh:155
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153

Referenced by G4Qt3DSceneHandler::AddPrimitive(), and G4Qt3DViewer::SetView().

◆ ConvertToQVector3D()

QVector3D G4Qt3DUtils::ConvertToQVector3D ( const G4ThreeVector v)

Definition at line 52 of file G4Qt3DUtils.cc.

52 {
53 return QVector3D(v.x(),v.y(),v.z());
54}
double z() const
double x() const
double y() const

Referenced by G4Qt3DViewer::SetView().

◆ CreateQTransformFrom()

Qt3DCore::QTransform * G4Qt3DUtils::CreateQTransformFrom ( const G4Transform3D g)

Definition at line 33 of file G4Qt3DUtils.cc.

34{
35 auto* q = new Qt3DCore::QTransform;
36 q->setMatrix
37 (QMatrix4x4
38 (g.xx(),g.xy(),g.xz(),g.dx(),
39 g.yx(),g.yy(),g.yz(),g.dy(),
40 g.zx(),g.zy(),g.zz(),g.dz(),
41 0,0,0,1));
42 q->setObjectName("transform");
43 return q;
44}
double dy() const
Definition: Transform3D.h:287
double zz() const
Definition: Transform3D.h:281
double yz() const
Definition: Transform3D.h:272
double dz() const
Definition: Transform3D.h:290
double dx() const
Definition: Transform3D.h:284
double xy() const
Definition: Transform3D.h:260
double zx() const
Definition: Transform3D.h:275
double yx() const
Definition: Transform3D.h:266
double zy() const
Definition: Transform3D.h:278
double xx() const
Definition: Transform3D.h:257
double yy() const
Definition: Transform3D.h:269
double xz() const
Definition: Transform3D.h:263

Referenced by G4Qt3DSceneHandler::AddPrimitive().

◆ delete_components_and_children_of_entity_recursively()

void G4Qt3DUtils::delete_components_and_children_of_entity_recursively ( Qt3DCore::QNode *  node)

Definition at line 102 of file G4Qt3DUtils.cc.

102 {
103 Qt3DCore::QEntity* entity = dynamic_cast<Qt3DCore::QEntity*>(node);
104 if(entity == nullptr){
105#ifdef G4QT3DDEBUG
106 G4String name = node->objectName().toStdString();
107 if (name == "") name = "X";
108 G4Qt3DUtils::LogFile << (void*)node << ": " << "Found non-entity node " << name << std::endl;
109#endif
110 return;
111 }
112 for (auto component: entity->components()){
113#ifdef G4QT3DDEBUG
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;
118#endif
119 entity->removeComponent(component);
120 delete(component);
121 component = nullptr;
122 }
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";
127#ifdef G4QT3DDEBUG
128 G4Qt3DUtils::LogFile << (void*)child_node << ": " << "Child node " << name
129 << " of " << entity->objectName().toStdString() << std::endl;
130#endif
131 delete_entity_recursively(child_node);
132 }
133 G4String name = entity->objectName().toStdString();
134 if (name == "") name = "X";
135#ifdef G4QT3DDEBUG
136 G4Qt3DUtils::LogFile << (void*)entity << ": " << "Clearing child nodes of " << name << std::endl;
137#endif
138 child_nodes.clear();
139}
const char * name(G4int ptype)
void delete_entity_recursively(Qt3DCore::QNode *node)
Definition: G4Qt3DUtils.cc:57

Referenced by G4Qt3DSceneHandler::ClearStore(), and G4Qt3DSceneHandler::ClearTransientStore().

◆ delete_entity_recursively()

void G4Qt3DUtils::delete_entity_recursively ( Qt3DCore::QNode *  node)

Definition at line 57 of file G4Qt3DUtils.cc.

57 {
58#ifdef G4QT3DDEBUG
59 G4Qt3DUtils::LogFile << "node " << node->objectName().toStdString() << std::endl;
60#endif
61 Qt3DCore::QEntity* entity = dynamic_cast<Qt3DCore::QEntity*>(node);
62 if(entity == nullptr){
63#ifdef G4QT3DDEBUG
64 G4String name = node->objectName().toStdString();
65 if (name == "") name = "X";
66 G4Qt3DUtils::LogFile << (void*)node << ": "
67 << "Deleting non-entity node " << name << std::endl;
68#endif
69 delete node;
70 node = nullptr;
71 return;
72 }
73 for (auto component: entity->components()) {
74#ifdef G4QT3DDEBUG
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;
79#endif
80 entity->removeComponent(component);
81 delete component;
82 component = nullptr;
83 }
84 for (auto child_node: entity->childNodes()) {
85 G4String name = child_node->objectName().toStdString();
86 if (name == "") name = "X";
87#ifdef G4QT3DDEBUG
88 G4Qt3DUtils::LogFile << (void*)child_node << ": " << "Child node " << name
89 << " of " << entity->objectName().toStdString() << std::endl;
90#endif
91 delete_entity_recursively(child_node);
92 }
93 G4String name = entity->objectName().toStdString();
94 if (name == "") name = "X";
95#ifdef G4QT3DDEBUG
96 G4Qt3DUtils::LogFile << (void*)entity << ": " << "Deleting entity " << name << std::endl;
97#endif
98 delete entity;
99 entity = nullptr;
100}

Referenced by delete_components_and_children_of_entity_recursively(), and delete_entity_recursively().