feat: implement Geant Material class, add object registration, and update PropertyWidget signal handling and read-only state

This commit is contained in:
AndreaRigoni
2026-04-01 11:13:47 +00:00
parent e1bd7eb44f
commit 8e6e332217
10 changed files with 148 additions and 21 deletions

View File

@@ -146,6 +146,9 @@ void Solid::SetParent(Solid *parent) {
TessellatedSolid::TessellatedSolid()
: BaseClass("unnamed_tessellated"), m_Solid(new G4TessellatedSolid("unnamed_tessellated")) {}
TessellatedSolid::TessellatedSolid(const char *name)
: BaseClass(name), m_Solid(new G4TessellatedSolid(name)) {
}
@@ -173,9 +176,15 @@ void TessellatedSolid::Update() {
BoxSolid::BoxSolid(const char *name) :
BaseClass(name),
m_ContainerBox(new ContainerBox()),
m_Solid(new G4Box(name, 1, 1, 1))
{}
BoxSolid::BoxSolid(const char *name, ContainerBox *box) : BaseClass(name) {
m_Solid = new G4Box(name, 1,1,1);
m_Object = box;
m_Solid = new G4Box(name, 1, 1, 1);
m_ContainerBox = box;
Object::connect(box, &ContainerBox::Updated, this, &BoxSolid::Update);
if (m_Logical) {
m_Logical->SetSolid(m_Solid);
@@ -184,27 +193,30 @@ BoxSolid::BoxSolid(const char *name, ContainerBox *box) : BaseClass(name) {
}
void BoxSolid::Update() {
if (m_Object) {
Vector3f size = m_Object->GetSize();
if (m_ContainerBox) {
Vector3f size = m_ContainerBox->GetSize();
m_Solid->SetXHalfLength(size(0) * 0.5);
m_Solid->SetYHalfLength(size(1) * 0.5);
m_Solid->SetZHalfLength(size(2) * 0.5);
// Geant4 placement is relative to center. uLib Box is anchored at corner.
// 1. Get position and rotation (clean, without scale)
Vector3f pos = m_Object->GetPosition();
Matrix3f rot = m_Object->GetRotation();
Vector3f pos = m_ContainerBox->GetPosition();
Matrix3f rot = m_ContainerBox->GetRotation();
// 2. Center = Corner + Rotation * (Half-Size)
// We must rotate the offset vector because uLib box can be rotated.
Vector3f center = pos + rot * (size * 0.5);
uLib::AffineTransform t;
uLib::AffineTransform t;
t.SetPosition(center);
t.SetRotation(rot);
this->SetTransform(t.GetMatrix());
}
}