refactor: rename Vtk classes by removing the vtk prefix to follow project naming conventions

This commit is contained in:
AndreaRigoni
2026-04-08 15:14:55 +00:00
parent 8a01ee7f40
commit 77f00a2b8a
66 changed files with 494 additions and 477 deletions

View File

@@ -124,7 +124,7 @@ void MainPanel::setContext(uLib::ObjectsContext* context) {
if (context) {
if (auto* viewport = qobject_cast<uLib::Vtk::QViewport*>(m_firstPane->currentViewport())) {
m_mainVtkContext = new uLib::Vtk::vtkObjectsContext(context);
m_mainVtkContext = new uLib::Vtk::ObjectsContext(context);
// viewport->AddPuppet(*m_mainVtkContext); // redundant
auto syncSelection = [this](uLib::Vtk::Puppet* p) {
@@ -138,7 +138,7 @@ void MainPanel::setContext(uLib::ObjectsContext* context) {
};
connect(viewport, &uLib::Vtk::QViewport::puppetSelected, syncSelection);
uLib::Object::connect(m_mainVtkContext, &uLib::Vtk::vtkObjectsContext::PuppetAdded, [this](uLib::Vtk::Puppet* p) {
uLib::Object::connect(m_mainVtkContext, &uLib::Vtk::ObjectsContext::PuppetAdded, [this](uLib::Vtk::Puppet* p) {
if (p) {
auto panes = this->findChildren<ViewportPane*>();
for (auto* pane : panes) {
@@ -151,7 +151,7 @@ void MainPanel::setContext(uLib::ObjectsContext* context) {
}
});
uLib::Object::connect(m_mainVtkContext, &uLib::Vtk::vtkObjectsContext::PuppetRemoved, [this](uLib::Vtk::Puppet* p) {
uLib::Object::connect(m_mainVtkContext, &uLib::Vtk::ObjectsContext::PuppetRemoved, [this](uLib::Vtk::Puppet* p) {
if (p) {
auto panes = this->findChildren<ViewportPane*>();
for (auto* pane : panes) {

View File

@@ -11,7 +11,7 @@ class PropertiesPanel;
namespace uLib {
class ObjectsContext;
namespace Vtk {
class vtkObjectsContext;
class ObjectsContext;
}
}
@@ -40,7 +40,7 @@ private:
ViewportPane* m_firstPane;
ContextPanel* m_contextPanel;
uLib::ObjectsContext* m_context;
uLib::Vtk::vtkObjectsContext* m_mainVtkContext;
uLib::Vtk::ObjectsContext* m_mainVtkContext;
};
#endif // MAINPANEL_H

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "HEP/Detectors/DetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
@@ -43,13 +43,13 @@ BOOST_AUTO_TEST_CASE(vtkDetectorChamberTest) {
d2.Scale(Vector3f(1_m, 2_m, 20_cm));
d2.Translate(Vector3f(1_m, 0, 10_m));
Vtk::vtkDetectorChamber v_d1(&d1);
Vtk::vtkDetectorChamber v_d2(&d2);
Vtk::DetectorChamber v_d1(&d1);
Vtk::DetectorChamber v_d2(&d2);
v_d1.SetRepresentation(Vtk::Puppet::Surface);
v_d2.SetRepresentation(Vtk::Puppet::Surface);
if (!v_d1.GetProp()) {
BOOST_FAIL("vtkDetectorChamber::GetProp() returned NULL");
BOOST_FAIL("DetectorChamber::GetProp() returned NULL");
}
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {

View File

@@ -23,8 +23,8 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "HEP/Detectors/DetectorChamber.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
#include "Math/Units.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
@@ -125,9 +125,9 @@ BOOST_AUTO_TEST_CASE(vtkDetectorMuonProjectionTest) {
MuonEvent mu_proj1 = d1.ProjectMuonEvent(mu_event);
MuonEvent mu_proj2 = d2.ProjectMuonEvent(mu_event);
Vtk::vtkDetectorChamber v_d1(&d1);
Vtk::vtkDetectorChamber v_d2(&d2);
Vtk::vtkMuonScatter v_event(event);
Vtk::DetectorChamber v_d1(&d1);
Vtk::DetectorChamber v_d2(&d2);
Vtk::MuonScatter v_event(event);
v_event.AddPocaPoint(HPoint3f(0, 0, 0));
v_event.SetColor(1, 0, 0); // Red muon event

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
#include "Vtk/uLibVtkViewer.h"
@@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(vtkMuonScatterTest) {
event.LineOut().direction << 0, -1, 0, 0;
event.LineOut().origin << 0, -1, 0, 1;
Vtk::vtkMuonScatter v_event(event);
Vtk::MuonScatter v_event(event);
v_event.AddPocaPoint(HPoint3f(0, 0, 0));
v_event.SaveToXMLFile("vtk_testing_muonevent.vtp");
@@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(vtkMuonScatterTest) {
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
Vtk::Viewer viewer;
// Vtk::Tie<Vtk::vtkMuonScatter> tms;
// Vtk::Tie<Vtk::MuonScatter> tms;
// tms.DoAction();
// Vtk::Tie<Vtk::Viewer> vms;
// vms.DoAction();

View File

@@ -48,8 +48,8 @@
namespace uLib {
namespace Vtk {
vtkDetectorChamber::vtkDetectorChamber(DetectorChamber *content)
: vtkContainerBox(content) {
DetectorChamber::DetectorChamber(uLib::DetectorChamber *content)
: ContainerBox(content) {
m_PlaneSource = vtkPlaneSource::New();
vtkNew<vtkPolyDataMapper> mapper;
@@ -67,20 +67,20 @@ vtkDetectorChamber::vtkDetectorChamber(DetectorChamber *content)
this->Update();
}
vtkDetectorChamber::~vtkDetectorChamber() {
DetectorChamber::~DetectorChamber() {
m_PlaneSource->Delete();
m_PlaneActor->Delete();
}
DetectorChamber *vtkDetectorChamber::GetContent() {
return static_cast<DetectorChamber *>(m_Content);
DetectorChamber::Content *DetectorChamber::GetContent() const {
return static_cast<Content *>(m_Content);
}
void vtkDetectorChamber::Update() {
void DetectorChamber::Update() {
this->BaseClass::Update();
if (!m_Content) return;
DetectorChamber *c = this->GetContent();
Content *c = this->GetContent();
Vector3f size = c->GetSize();
HLine3f plane = c->GetProjectionPlane();

View File

@@ -32,7 +32,7 @@
#include <vtkTransform.h>
#include "HEP/Detectors/DetectorChamber.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/uLibVtkInterface.h"
#include "Vtk/Math/vtkContainerBox.h"
#include <vtkActor.h>
@@ -44,17 +44,17 @@ class vtkPlaneSource;
namespace uLib {
namespace Vtk {
// class vtkHandlerWidget; // Removed as we use vtkBoxWidget now
// class HandlerWidget; // Removed as we use vtkBoxWidget now
class vtkDetectorChamber : public vtkContainerBox {
typedef DetectorChamber Content;
typedef vtkContainerBox BaseClass;
class DetectorChamber : public ContainerBox {
typedef uLib::DetectorChamber Content;
typedef ContainerBox BaseClass;
public:
vtkDetectorChamber(DetectorChamber *content);
virtual ~vtkDetectorChamber();
DetectorChamber(uLib::DetectorChamber *content);
virtual ~DetectorChamber();
Content *GetContent();
Content *GetContent() const override;
virtual void Update() override;

View File

@@ -27,7 +27,7 @@
#include "config.h"
#endif
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/HEP/Detectors/vtkMuonEvent.h"
namespace uLib {
@@ -38,7 +38,7 @@ namespace Vtk {
class vtkWidgetCallback : public vtkCommand {
public:
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
void SetParent(uLib::Vtk::vtkMuonEvent *parent) { this->parent = parent; }
void SetParent(uLib::Vtk::MuonEvent *parent) { this->parent = parent; }
virtual void Execute(vtkObject *caller, unsigned long, void *) {
vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget *>(caller);
@@ -48,30 +48,30 @@ public:
}
private:
uLib::Vtk::vtkMuonEvent *parent;
uLib::Vtk::MuonEvent *parent;
};
////////////////////////////////////////////////////////////////////////////////
///// VTK MUON EVENT /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonEvent::vtkMuonEvent(MuonEventData &content)
MuonEvent::MuonEvent(MuonEventData &content)
: m_PolyData(NULL), m_Appender(vtkAppendPolyData::New()),
content(&content) {
InstallPipe();
}
vtkMuonEvent::vtkMuonEvent(const MuonEventData &content)
MuonEvent::MuonEvent(const MuonEventData &content)
: m_PolyData(NULL), m_Appender(vtkAppendPolyData::New()),
content(const_cast<MuonEventData *>(&content)) {
InstallPipe();
}
vtkMuonEvent::~vtkMuonEvent() {}
MuonEvent::~MuonEvent() {}
vtkMuonEvent::Content &vtkMuonEvent::GetContent() { return *content; }
MuonEventData &MuonEvent::GetModel() { return *content; }
void vtkMuonEvent::PrintSelf(std::ostream &o) const {
void MuonEvent::PrintSelf(std::ostream &o) const {
o << "..:: MuonEvent ::..\n"
"\t[in] Origin > "
<< content->LineIn().origin.transpose() << "\n"
@@ -83,7 +83,7 @@ void vtkMuonEvent::PrintSelf(std::ostream &o) const {
<< "...................\n";
}
void vtkMuonEvent::InstallPipe() {
void MuonEvent::InstallPipe() {
vtkAppendPolyData *appender = m_Appender;
vtkSmartPointer<vtkPolyDataMapper> mapper =
@@ -121,11 +121,11 @@ void vtkMuonEvent::InstallPipe() {
this->SetProp(actor);
}
vtkPolyData *vtkMuonEvent::GetPolyData() const {
vtkPolyData *MuonEvent::GetPolyData() const {
return m_Appender->GetOutput();
}
void vtkMuonEvent::AddPocaPoint(HPoint3f poca) {
void MuonEvent::AddPocaPoint(HPoint3f poca) {
m_Poca = poca;
vtkSmartPointer<vtkSphereSource> sphere =
vtkSmartPointer<vtkSphereSource>::New();
@@ -139,7 +139,8 @@ void vtkMuonEvent::AddPocaPoint(HPoint3f poca) {
m_Appender->Update();
}
HPoint3f vtkMuonEvent::GetPocaPoint() { return m_Poca; }
HPoint3f MuonEvent::GetPocaPoint() { return m_Poca; }
uLib::Object* MuonEvent::GetContent() const { return (uLib::Object*)content; }
} // namespace Vtk
} // namespace uLib

View File

@@ -41,7 +41,7 @@
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "HEP/Detectors/MuonEvent.h"
#include "Vtk/uLibVtkInterface.h"
@@ -50,15 +50,16 @@
namespace uLib {
namespace Vtk {
class vtkMuonEvent : public Puppet, public Polydata {
class MuonEvent : public Puppet, public Polydata {
typedef MuonEventData Content;
public:
vtkMuonEvent(const MuonEventData &content);
vtkMuonEvent(MuonEventData &content);
~vtkMuonEvent();
MuonEvent(const MuonEventData &content);
MuonEvent(MuonEventData &content);
~MuonEvent();
Content &GetContent();
Content &GetModel();
uLib::Object* GetContent() const override;
void PrintSelf(std::ostream &o) const;
@@ -73,7 +74,7 @@ public:
private:
void InstallPipe();
vtkMuonEvent::Content *content;
MuonEvent::Content *content;
vtkPolyData *m_PolyData;
vtkAppendPolyData *m_Appender;

View File

@@ -27,7 +27,7 @@
#include "config.h"
#endif
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
namespace uLib {
@@ -37,21 +37,21 @@ namespace Vtk {
///// VTK MUON Scatter ///////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonScatter::vtkMuonScatter(MuonScatter &content)
MuonScatter::MuonScatter(uLib::MuonScatter &content)
: m_Content(&content), m_LineIn(vtkLineSource::New()),
m_LineOut(vtkLineSource::New()), m_PolyData(vtkPolyData::New()),
m_SpherePoca(NULL), m_Asm(vtkAssembly::New()) {
InstallPipe();
}
vtkMuonScatter::vtkMuonScatter(const MuonScatter &content)
: m_Content(const_cast<MuonScatter *>(&content)),
MuonScatter::MuonScatter(const MuonScatter &content)
: m_Content(content.m_Content),
m_LineIn(vtkLineSource::New()), m_LineOut(vtkLineSource::New()),
m_PolyData(vtkPolyData::New()), m_SpherePoca(NULL), m_Asm(vtkAssembly::New()) {
InstallPipe();
}
vtkMuonScatter::~vtkMuonScatter() {
MuonScatter::~MuonScatter() {
m_LineIn->Delete();
m_LineOut->Delete();
m_Asm->Delete();
@@ -59,11 +59,11 @@ vtkMuonScatter::~vtkMuonScatter() {
m_SpherePoca->Delete();
}
vtkMuonScatter::Content &vtkMuonScatter::GetContent() { return *m_Content; }
MuonScatter::Content &MuonScatter::GetModel() { return *m_Content; }
void vtkMuonScatter::PrintSelf(std::ostream &o) const {}
void MuonScatter::PrintSelf(std::ostream &o) const {}
void vtkMuonScatter::InstallPipe() {
void MuonScatter::InstallPipe() {
if (m_Content) {
vtkLineSource *line_in = m_LineIn;
vtkLineSource *line_out = m_LineOut;
@@ -99,7 +99,7 @@ void vtkMuonScatter::InstallPipe() {
this->SetProp(m_Asm);
}
vtkPolyData *vtkMuonScatter::GetPolyData() const {
vtkPolyData *MuonScatter::GetPolyData() const {
vtkSmartPointer<vtkAppendPolyData> append =
vtkSmartPointer<vtkAppendPolyData>::New();
append->AddInputConnection(m_LineIn->GetOutputPort());
@@ -111,7 +111,7 @@ vtkPolyData *vtkMuonScatter::GetPolyData() const {
return m_PolyData;
}
void vtkMuonScatter::AddPocaPoint(HPoint3f poca) {
void MuonScatter::AddPocaPoint(HPoint3f poca) {
vtkSphereSource *sphere = vtkSphereSource::New();
float size =
(m_Content->LineIn().origin - m_Content->LineOut().origin).head(3).norm();
@@ -129,7 +129,7 @@ void vtkMuonScatter::AddPocaPoint(HPoint3f poca) {
m_Asm->AddPart(actor);
}
HPoint3f vtkMuonScatter::GetPocaPoint() {
HPoint3f MuonScatter::GetPocaPoint() {
double center[3];
if (m_SpherePoca) {
m_SpherePoca->GetCenter(center);
@@ -139,7 +139,7 @@ HPoint3f vtkMuonScatter::GetPocaPoint() {
}
}
void vtkMuonScatter::ConnectInteractor(vtkRenderWindowInteractor *interactor) {
void MuonScatter::ConnectInteractor(vtkRenderWindowInteractor *interactor) {
// TODO
}

View File

@@ -43,7 +43,7 @@
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/uLibVtkInterface.h"
@@ -54,16 +54,17 @@ class vtkRenderWindowInteractor;
namespace uLib {
namespace Vtk {
class vtkMuonScatter : public Puppet, public Polydata {
typedef MuonScatter Content;
class MuonScatter : public Puppet, public Polydata {
typedef uLib::MuonScatter Content;
public:
vtkMuonScatter(const MuonScatter &content);
vtkMuonScatter(MuonScatter &content);
MuonScatter(const MuonScatter &content);
MuonScatter(uLib::MuonScatter &content);
~vtkMuonScatter();
~MuonScatter();
Content &GetContent();
Content &GetModel();
uLib::Object* GetContent() const override { return (uLib::Object*)m_Content; }
void PrintSelf(std::ostream &o) const;
@@ -81,7 +82,7 @@ protected:
private:
void InstallPipe();
vtkMuonScatter::Content *m_Content;
MuonScatter::Content *m_Content;
vtkLineSource *m_LineIn;
vtkLineSource *m_LineOut;
vtkSphereSource *m_SpherePoca;

View File

@@ -10,11 +10,11 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Geant/Solid.h"
#include "HEP/Geant/GeantEvent.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "HEP/Geant/Scene.h"
#include "HEP/Geant/EmitterPrimary.hh"
#include "Math/Cylinder.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkCylinder.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
@@ -58,7 +58,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
std::cout << " Collected event " << lastEvent->GetEventID()
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
Vtk::vtkGeantEvent* vtkEvent = new Vtk::vtkGeantEvent(lastEvent);
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->GetRenderer()->Render();
@@ -97,13 +97,13 @@ int main(int argc, char** argv) {
Vtk::Viewer viewer;
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
Vtk::vtkContainerBox* vtkWorld = new Vtk::vtkContainerBox(scene.GetWorldBox());
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
Vtk::vtkContainerBox* vtkIron = new Vtk::vtkContainerBox(&iron_box);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);

View File

@@ -1,15 +1,15 @@
#include "Geant/Solid.h"
#include "HEP/Geant/GeantEvent.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "HEP/Geant/Scene.h"
#include "HEP/Geant/EmitterPrimary.hh"
#include "Math/ContainerBox.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "Vtk/HEP/Geant/vtkEmitterPrimary.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "HEP/Detectors/DetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include <vtkSmartPointer.h>
@@ -51,7 +51,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
// Wrap it for VTK
Vtk::vtkGeantEvent* vtkEvent = new Vtk::vtkGeantEvent(lastEvent);
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
// Re-render
@@ -105,34 +105,34 @@ int main(int argc, char** argv) {
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
// Visualize world box
Vtk::vtkContainerBox* vtkWorld = new Vtk::vtkContainerBox(scene.GetWorldBox());
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
// Visualize iron cube
Vtk::vtkContainerBox* vtkIron = new Vtk::vtkContainerBox(&iron_box);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
// Visualize Top Chamber
Vtk::vtkDetectorChamber* vtkTop = new Vtk::vtkDetectorChamber(top_chamber_box);
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box);
vtkTop->SetOpacity(0.5);
vtkTop->SetColor(0.2, 0.8, 0.2);
vtkTop->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkTop);
// Visualize Bottom Chamber
Vtk::vtkDetectorChamber* vtkBottom = new Vtk::vtkDetectorChamber(bottom_chamber_box);
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box);
vtkBottom->SetOpacity(0.5);
vtkBottom->SetColor(0.2, 0.8, 0.2);
vtkBottom->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkBottom);
// Visualize Emitter
Vtk::vtkEmitterPrimary* vtkEmitter = new Vtk::vtkEmitterPrimary(*emitter);
Vtk::EmitterPrimary* vtkEmitter = new Vtk::EmitterPrimary(*emitter);
viewer.AddPuppet(*vtkEmitter);
// 3. Event Handling

View File

@@ -10,11 +10,11 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Geant/Solid.h"
#include "HEP/Geant/GeantEvent.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "HEP/Geant/Scene.h"
#include "HEP/Geant/EmitterPrimary.hh"
#include "Math/ContainerBox.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
@@ -82,7 +82,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
// Wrap it for VTK
Vtk::vtkGeantEvent* vtkEvent = new Vtk::vtkGeantEvent(lastEvent);
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
// Re-render
@@ -117,13 +117,13 @@ int main(int argc, char** argv) {
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
// Visualize world box
Vtk::vtkContainerBox* vtkWorld = new Vtk::vtkContainerBox(scene.GetWorldBox());
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
// vtkWorld->ShowBoundingBox(true);
vtkWorld->ShowScaleMeasures(true);
viewer.AddPuppet(*vtkWorld);
// Visualize iron cube
Vtk::vtkContainerBox* vtkIron = new Vtk::vtkContainerBox(&iron_box);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);

View File

@@ -11,8 +11,8 @@
#include "Geant/Solid.h"
#include "HEP/Geant/Scene.h"
#include "Math/ContainerBox.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/HEP/Geant/vtkGeantScene.h"
@@ -46,11 +46,11 @@ int main(int argc, char** argv) {
Vtk::Viewer viewer;
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
Vtk::vtkGeantScene vtkScene(&scene);
Vtk::GeantScene vtkScene(&scene);
vtkScene.AddToViewer(viewer);
std::cout << "==================================================" << std::endl;
std::cout << " vtkGeantScene Test" << std::endl;
std::cout << " GeantScene Test" << std::endl;
std::cout << " World box + 1 iron cube displayed" << std::endl;
std::cout << "==================================================" << std::endl;

View File

@@ -1,15 +1,15 @@
#include "Geant/Solid.h"
#include "HEP/Geant/GeantEvent.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "HEP/Geant/Scene.h"
#include "HEP/Geant/EmitterPrimary.hh"
#include "Math/ContainerBox.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/Units.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/HEP/Geant/vtkGeantEvent.h"
#include "Vtk/HEP/Geant/vtkEmitterPrimary.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "HEP/Detectors/DetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include <vtkSmartPointer.h>
@@ -49,7 +49,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
std::cout << " Collected event " << lastEvent->GetEventID()
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
Vtk::vtkGeantEvent* vtkEvent = new Vtk::vtkGeantEvent(lastEvent);
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->GetRenderer()->Render();
@@ -107,32 +107,32 @@ int main(int argc, char** argv) {
Vtk::Viewer viewer;
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
Vtk::vtkContainerBox* vtkWorld = new Vtk::vtkContainerBox(scene.GetWorldBox());
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
Vtk::vtkContainerBox* vtkIron = new Vtk::vtkContainerBox(&iron_box);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
// Visualize Top Chamber
Vtk::vtkDetectorChamber* vtkTop = new Vtk::vtkDetectorChamber(top_chamber_box);
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box);
vtkTop->SetOpacity(0.5);
vtkTop->SetColor(0.2, 0.8, 0.2);
vtkTop->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkTop);
// Visualize Bottom Chamber
Vtk::vtkDetectorChamber* vtkBottom = new Vtk::vtkDetectorChamber(bottom_chamber_box);
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box);
vtkBottom->SetOpacity(0.5);
vtkBottom->SetColor(0.2, 0.8, 0.2);
vtkBottom->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkBottom);
// Use vtkSkyPlaneEmitterPrimary instead of vtkEmitterPrimary
// Use vtkSkyPlaneEmitterPrimary instead of EmitterPrimary
Vtk::vtkSkyPlaneEmitterPrimary* vtkEmitter = new Vtk::vtkSkyPlaneEmitterPrimary(*emitter);
vtkEmitter->SetSelectable(false);
viewer.AddPuppet(*vtkEmitter);

View File

@@ -13,8 +13,8 @@
#include "Vtk/HEP/Geant/vtkTessellatedSolid.h"
#include "Vtk/uLibVtkViewer.h"
#include "HEP/Geant/Solid.h"
#include "Math/ContainerBox.h"
#include "Math/TriangleMesh.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkTriangleMesh.h"
#include "Math/Units.h"
#include <vtkProperty.h>
@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
Geant::BoxSolid gBox("MyBox", &box);
gBox.Update();
Vtk::vtkBoxSolid vtkBox(&gBox);
Vtk::BoxSolid vtkBox(&gBox);
// 2. Create a TessellatedSolid
Geant::TessellatedSolid gTess("MyTess");
@@ -53,7 +53,7 @@ int main(int argc, char** argv) {
gTess.SetMesh(mesh);
gTess.Update();
Vtk::vtkTessellatedSolid vtkTess(&gTess);
Vtk::TessellatedSolid vtkTess(&gTess);
// 3. Visualization setup
Vtk::Viewer viewer;

View File

@@ -24,28 +24,28 @@
namespace uLib {
namespace Vtk {
vtkBoxSolid::vtkBoxSolid(Geant::BoxSolid *content)
: vtkGeantSolid(content), m_BoxContent(content) {
BoxSolid::BoxSolid(Geant::BoxSolid *content)
: GeantSolid(content), m_BoxContent(content) {
this->InstallPipe();
// Connect the model's Updated event to updateTransform to ensure VTK sync
m_UpdateConnection = Object::connect(m_BoxContent, &uLib::Object::Updated, this, &vtkBoxSolid::Update);
m_UpdateConnection = Object::connect(m_BoxContent, &uLib::Object::Updated, this, &BoxSolid::Update);
// Initial sync
this->Update();
}
vtkBoxSolid::~vtkBoxSolid() {
BoxSolid::~BoxSolid() {
}
void vtkBoxSolid::Update() {
void BoxSolid::Update() {
ConnectionBlock blocker(m_UpdateConnection);
this->UpdateGeometry();
// Ensure base Puppet properties (color, opacity, etc) and transform are applied
this->Puppet::Update();
}
void vtkBoxSolid::SyncFromVtk() {
void BoxSolid::SyncFromVtk() {
this->Puppet::SyncFromVtk();
if (auto* proxy = vtkProp3D::SafeDownCast(this->GetProxyProp())) {
if (vtkMatrix4x4* mat = proxy->GetUserMatrix()) {
@@ -54,17 +54,17 @@ void vtkBoxSolid::SyncFromVtk() {
}
}
void vtkBoxSolid::UpdateGeometry() {
// Sync geometry from G4VSolid provided by vtkGeantSolid (tessellation)
vtkGeantSolid::UpdateGeometry();
void BoxSolid::UpdateGeometry() {
// Sync geometry from G4VSolid provided by GeantSolid (tessellation)
GeantSolid::UpdateGeometry();
}
void vtkBoxSolid::UpdateTransform() {
void BoxSolid::UpdateTransform() {
// Take transform from Puppet base (which uses GetContent() -> ContainerBox TRS)
this->Puppet::Update();
}
void vtkBoxSolid::serialize_display(uLib::Archive::display_properties_archive &ar,
void BoxSolid::serialize_display(uLib::Archive::display_properties_archive &ar,
const unsigned int version) {
// Expose Geant solid properties and underlying Box/TRS properties
this->Puppet::serialize_display(ar, version);
@@ -76,8 +76,8 @@ void vtkBoxSolid::serialize_display(uLib::Archive::display_properties_archive &a
}
}
void vtkBoxSolid::InstallPipe() {
vtkGeantSolid::InstallPipe();
void BoxSolid::InstallPipe() {
GeantSolid::InstallPipe();
}
} // namespace Vtk

View File

@@ -41,12 +41,12 @@ namespace Vtk {
/**
* @brief VTK Puppet for visualizing a Geant::BoxSolid.
*/
class vtkBoxSolid : public vtkGeantSolid {
uLibTypeMacro(vtkBoxSolid, uLib::Vtk::vtkGeantSolid)
class BoxSolid : public GeantSolid {
uLibTypeMacro(BoxSolid, uLib::Vtk::GeantSolid)
public:
vtkBoxSolid(Geant::BoxSolid *content);
virtual ~vtkBoxSolid();
BoxSolid(Geant::BoxSolid *content);
virtual ~BoxSolid();
virtual void Update() override;
virtual void UpdateGeometry() override;
@@ -71,7 +71,7 @@ protected:
Geant::BoxSolid *m_BoxContent;
uLib::Connection m_UpdateConnection;
ULIB_DECLARE_PROPERTIES(vtkBoxSolid)
ULIB_DECLARE_PROPERTIES(BoxSolid)
};
} // namespace Vtk

View File

@@ -11,12 +11,12 @@
#include <vtkPolyData.h>
#include <vtkProperty.h>
#include <vtkCylinderSource.h>
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
namespace uLib {
namespace Vtk {
vtkEmitterPrimary::vtkEmitterPrimary(Geant::EmitterPrimary &emitter)
EmitterPrimary::EmitterPrimary(Geant::EmitterPrimary &emitter)
: m_emitter(emitter), m_Actor(vtkActor::New()) {
vtkNew<vtkArrowSource> arrow;
@@ -43,16 +43,16 @@ vtkEmitterPrimary::vtkEmitterPrimary(Geant::EmitterPrimary &emitter)
this->SetProp(m_Actor);
Object::connect(&m_emitter, &Object::Updated, this, &vtkEmitterPrimary::contentUpdate);
Object::connect(&m_emitter, &Object::Updated, this, &EmitterPrimary::contentUpdate);
this->contentUpdate();
}
vtkEmitterPrimary::~vtkEmitterPrimary() {
Object::disconnect(&m_emitter, &Object::Updated, this, &vtkEmitterPrimary::contentUpdate);
EmitterPrimary::~EmitterPrimary() {
Object::disconnect(&m_emitter, &Object::Updated, this, &EmitterPrimary::contentUpdate);
m_Actor->Delete();
}
void vtkEmitterPrimary::contentUpdate() {
void EmitterPrimary::contentUpdate() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) {
vtkNew<vtkMatrix4x4> mat;
@@ -66,7 +66,7 @@ void vtkEmitterPrimary::contentUpdate() {
Puppet::Update();
}
void vtkEmitterPrimary::Update() {
void EmitterPrimary::Update() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) return;
@@ -79,7 +79,7 @@ void vtkEmitterPrimary::Update() {
// vtkSkyPlaneEmitterPrimary
vtkSkyPlaneEmitterPrimary::vtkSkyPlaneEmitterPrimary(Geant::SkyPlaneEmitterPrimary &emitter)
: vtkEmitterPrimary(emitter), m_skyEmitter(emitter), m_PlaneSource(vtkPlaneSource::New()) {
: EmitterPrimary(emitter), m_skyEmitter(emitter), m_PlaneSource(vtkPlaneSource::New()) {
vtkNew<vtkAppendPolyData> append;
// Base class constructor already set an arrow. We keep it as a directional indicator.
@@ -107,27 +107,27 @@ void vtkSkyPlaneEmitterPrimary::contentUpdate() {
m_PlaneSource->SetPoint2(-size(0)/2.0, size(1)/2.0, 0.0);
m_PlaneSource->Update();
vtkEmitterPrimary::contentUpdate();
EmitterPrimary::contentUpdate();
}
// -------------------------------------------------------------------------- //
// vtkQuadMeshEmitterPrimary
vtkQuadMeshEmitterPrimary::vtkQuadMeshEmitterPrimary(Geant::QuadMeshEmitterPrimary &emitter)
: vtkEmitterPrimary(emitter), m_meshEmitter(emitter) {
: EmitterPrimary(emitter), m_meshEmitter(emitter) {
this->contentUpdate();
}
void vtkQuadMeshEmitterPrimary::contentUpdate() {
// For now stick with the arrow. In the future visualize the mesh if useful.
vtkEmitterPrimary::contentUpdate();
EmitterPrimary::contentUpdate();
}
// -------------------------------------------------------------------------- //
// vtkCylinderEmitterPrimary
vtkCylinderEmitterPrimary::vtkCylinderEmitterPrimary(Geant::CylinderEmitterPrimary &emitter)
: vtkEmitterPrimary(emitter), m_cylinderEmitter(emitter), m_CylinderSource(vtkCylinderSource::New()) {
: EmitterPrimary(emitter), m_cylinderEmitter(emitter), m_CylinderSource(vtkCylinderSource::New()) {
// vtkCylinderSource is along Y by default.
// We will update its actual dimensions in contentUpdate().
@@ -170,7 +170,7 @@ void vtkCylinderEmitterPrimary::contentUpdate() {
m_CylinderSource->SetCenter(0, h/2.0, 0);
m_CylinderSource->Update();
vtkEmitterPrimary::contentUpdate();
EmitterPrimary::contentUpdate();
}
} // namespace Vtk

View File

@@ -14,10 +14,10 @@ class vtkCylinderSource;
namespace uLib {
namespace Vtk {
class vtkEmitterPrimary : public Puppet {
class EmitterPrimary : public Puppet {
public:
vtkEmitterPrimary(Geant::EmitterPrimary &emitter);
virtual ~vtkEmitterPrimary();
EmitterPrimary(Geant::EmitterPrimary &emitter);
virtual ~EmitterPrimary();
virtual void contentUpdate();
virtual void Update();
@@ -27,7 +27,7 @@ protected:
vtkActor *m_Actor;
};
class vtkSkyPlaneEmitterPrimary : public vtkEmitterPrimary {
class vtkSkyPlaneEmitterPrimary : public EmitterPrimary {
public:
vtkSkyPlaneEmitterPrimary(Geant::SkyPlaneEmitterPrimary &emitter);
virtual ~vtkSkyPlaneEmitterPrimary();
@@ -41,7 +41,7 @@ private:
class vtkQuadMeshEmitterPrimary : public vtkEmitterPrimary {
class vtkQuadMeshEmitterPrimary : public EmitterPrimary {
public:
vtkQuadMeshEmitterPrimary(Geant::QuadMeshEmitterPrimary &emitter);
virtual void contentUpdate();
@@ -50,7 +50,7 @@ private:
Geant::QuadMeshEmitterPrimary &m_meshEmitter;
};
class vtkCylinderEmitterPrimary : public vtkEmitterPrimary {
class vtkCylinderEmitterPrimary : public EmitterPrimary {
public:
vtkCylinderEmitterPrimary(Geant::CylinderEmitterPrimary &emitter);
virtual ~vtkCylinderEmitterPrimary();

View File

@@ -35,23 +35,23 @@
namespace uLib {
namespace Vtk {
vtkGeantEvent::vtkGeantEvent(Content *content)
GeantEvent::GeantEvent(Content *content)
: m_MuonPath(vtkActor::New()), m_Content(content) {
this->InstallPipe();
this->Update();
}
vtkGeantEvent::~vtkGeantEvent() {
GeantEvent::~GeantEvent() {
m_MuonPath->Delete();
}
vtkPolyData *vtkGeantEvent::GetPolyData() const {
vtkPolyData *GeantEvent::GetPolyData() const {
if (!m_MuonPath || !m_MuonPath->GetMapper())
return NULL;
return vtkPolyData::SafeDownCast(m_MuonPath->GetMapper()->GetInput());
}
void vtkGeantEvent::Update() {
void GeantEvent::Update() {
if (!m_Content)
return;
@@ -88,7 +88,7 @@ void vtkGeantEvent::Update() {
}
}
void vtkGeantEvent::InstallPipe() {
void GeantEvent::InstallPipe() {
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();

View File

@@ -34,12 +34,12 @@
namespace uLib {
namespace Vtk {
class vtkGeantEvent : public Puppet, public Polydata {
class GeantEvent : public Puppet, public Polydata {
typedef Geant::GeantEvent Content;
public:
vtkGeantEvent(Content *content);
~vtkGeantEvent();
GeantEvent(Content *content);
~GeantEvent();
virtual class vtkPolyData *GetPolyData() const override;

View File

@@ -32,15 +32,15 @@
namespace uLib {
namespace Vtk {
vtkGeantScene::vtkGeantScene(Geant::Scene *scene)
GeantScene::GeantScene(Geant::Scene *scene)
: m_Scene(scene), m_WorldPuppet(nullptr) {
if (!m_Scene)
return;
// 1. Create the world box wireframe puppet
ContainerBox *worldBox = m_Scene->GetWorldBox();
uLib::ContainerBox *worldBox = m_Scene->GetWorldBox();
if (worldBox) {
m_WorldPuppet = new vtkContainerBox(worldBox);
m_WorldPuppet = new ContainerBox(worldBox);
m_WorldPuppet->SetRepresentation(Puppet::Wireframe);
m_WorldPuppet->ShowScaleMeasures(true);
}
@@ -56,13 +56,13 @@ vtkGeantScene::vtkGeantScene(Geant::Scene *scene)
// Only create a puppet if the solid has a valid G4VSolid
if (solid->GetG4Solid()) {
vtkGeantSolid *vtkSolid = nullptr;
GeantSolid *vtkSolid = nullptr;
if (auto *box = dynamic_cast<Geant::BoxSolid *>(solid)) {
vtkSolid = new vtkBoxSolid(box);
vtkSolid = new BoxSolid(box);
} else if (auto *tess = dynamic_cast<Geant::TessellatedSolid *>(solid)) {
vtkSolid = new vtkTessellatedSolid(tess);
vtkSolid = new TessellatedSolid(tess);
} else {
vtkSolid = new vtkGeantSolid(solid);
vtkSolid = new GeantSolid(solid);
vtkSolid->Update();
}
@@ -73,14 +73,14 @@ vtkGeantScene::vtkGeantScene(Geant::Scene *scene)
}
}
vtkGeantScene::~vtkGeantScene() {
GeantScene::~GeantScene() {
delete m_WorldPuppet;
for (auto *p : m_SolidPuppets) {
delete p;
}
}
void vtkGeantScene::AddToViewer(Viewport &viewer) {
void GeantScene::AddToViewer(Viewport &viewer) {
if (m_WorldPuppet) {
viewer.AddPuppet(*m_WorldPuppet);
}
@@ -89,7 +89,7 @@ void vtkGeantScene::AddToViewer(Viewport &viewer) {
}
}
void vtkGeantScene::RemoveFromViewer(Viewport &viewer) {
void GeantScene::RemoveFromViewer(Viewport &viewer) {
if (m_WorldPuppet) {
viewer.RemovePuppet(*m_WorldPuppet);
}

View File

@@ -36,14 +36,14 @@
namespace uLib {
namespace Vtk {
class vtkGeantSolid;
class GeantSolid;
/**
* @brief VTK Puppet representing the entire Geant::Scene.
*
* When constructed, it creates child puppets for the world box (as a
* vtkContainerBox wireframe) and for each non-world Solid in the scene
* (as vtkGeantSolid surfaces).
* ContainerBox wireframe) and for each non-world Solid in the scene
* (as GeantSolid surfaces).
*
* Usage:
* @code
@@ -53,15 +53,15 @@ class vtkGeantSolid;
* scene.Initialize();
*
* Vtk::Viewer viewer;
* Vtk::vtkGeantScene vtkScene(&scene);
* Vtk::GeantScene vtkScene(&scene);
* vtkScene.AddToViewer(viewer);
* viewer.Start();
* @endcode
*/
class vtkGeantScene : public Object {
class GeantScene : public Object {
public:
vtkGeantScene(Geant::Scene *scene);
~vtkGeantScene();
GeantScene(Geant::Scene *scene);
~GeantScene();
/// Add all puppets (world box + solids) to a viewer.
void AddToViewer(class Viewport &viewer);
@@ -70,15 +70,15 @@ public:
void RemoveFromViewer(class Viewport &viewer);
/// Get the world box puppet
vtkContainerBox* GetWorldPuppet() const { return m_WorldPuppet; }
ContainerBox* GetWorldPuppet() const { return m_WorldPuppet; }
/// Get the solid puppets
const std::vector<vtkGeantSolid*>& GetSolidPuppets() const { return m_SolidPuppets; }
const std::vector<GeantSolid*>& GetSolidPuppets() const { return m_SolidPuppets; }
private:
Geant::Scene *m_Scene;
vtkContainerBox *m_WorldPuppet;
std::vector<vtkGeantSolid*> m_SolidPuppets;
ContainerBox *m_WorldPuppet;
std::vector<GeantSolid*> m_SolidPuppets;
};
} // namespace Vtk

View File

@@ -42,27 +42,27 @@
namespace uLib {
namespace Vtk {
vtkGeantSolid::vtkGeantSolid(Content *content)
GeantSolid::GeantSolid(Content *content)
: m_SolidActor(vtkActor::New()), m_Content(content) {
this->InstallPipe();
}
vtkGeantSolid::~vtkGeantSolid() {
GeantSolid::~GeantSolid() {
m_SolidActor->Delete();
}
vtkPolyData *vtkGeantSolid::GetPolyData() const {
vtkPolyData *GeantSolid::GetPolyData() const {
if (!m_SolidActor || !m_SolidActor->GetMapper())
return NULL;
return vtkPolyData::SafeDownCast(m_SolidActor->GetMapper()->GetInput());
}
void vtkGeantSolid::Update() {
void GeantSolid::Update() {
this->UpdateGeometry();
this->UpdateTransform();
}
void vtkGeantSolid::UpdateGeometry() {
void GeantSolid::UpdateGeometry() {
if (!m_Content)
return;
@@ -110,7 +110,7 @@ void vtkGeantSolid::UpdateGeometry() {
}
}
void vtkGeantSolid::UpdateTransform() {
void GeantSolid::UpdateTransform() {
if (!m_Content || !m_SolidActor)
return;
@@ -142,7 +142,7 @@ void vtkGeantSolid::UpdateTransform() {
}
}
void vtkGeantSolid::InstallPipe() {
void GeantSolid::InstallPipe() {
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();

View File

@@ -42,12 +42,12 @@ namespace Vtk {
* Works with BoxSolid, TessellatedSolid, or any Solid that provides
* a valid G4VSolid via GetG4Solid().
*/
class vtkGeantSolid : public Puppet, public Polydata {
class GeantSolid : public Puppet, public Polydata {
typedef Geant::Solid Content;
public:
vtkGeantSolid(Content *content);
~vtkGeantSolid();
GeantSolid(Content *content);
~GeantSolid();
virtual class vtkPolyData *GetPolyData() const override;

View File

@@ -18,22 +18,22 @@
namespace uLib {
namespace Vtk {
vtkTessellatedSolid::vtkTessellatedSolid(Geant::TessellatedSolid *content)
: vtkGeantSolid(content), m_TessContent(content) {
TessellatedSolid::TessellatedSolid(Geant::TessellatedSolid *content)
: GeantSolid(content), m_TessContent(content) {
this->Update();
}
vtkTessellatedSolid::~vtkTessellatedSolid() {}
TessellatedSolid::~TessellatedSolid() {}
void vtkTessellatedSolid::Update() {
void TessellatedSolid::Update() {
this->UpdateGeometry();
this->UpdateTransform();
}
void vtkTessellatedSolid::UpdateGeometry() {
void TessellatedSolid::UpdateGeometry() {
if (!m_TessContent || m_TessContent->GetMesh().Points().empty()) {
// Fallback to base tessellation if no model mesh
vtkGeantSolid::UpdateGeometry();
GeantSolid::UpdateGeometry();
return;
}

View File

@@ -20,10 +20,10 @@ namespace Vtk {
/**
* @brief VTK Puppet for visualizing a Geant::TessellatedSolid.
*/
class vtkTessellatedSolid : public vtkGeantSolid {
class TessellatedSolid : public GeantSolid {
public:
vtkTessellatedSolid(Geant::TessellatedSolid *content);
virtual ~vtkTessellatedSolid();
TessellatedSolid(Geant::TessellatedSolid *content);
virtual ~TessellatedSolid();
virtual void Update() override;
virtual void UpdateGeometry() override;

View File

@@ -46,7 +46,7 @@ class vtkWidgetCallback : public vtkCommand {
public:
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
void SetTracer(Vtk::vtkVoxRaytracerRepresentation *parent) {
void SetTracer(Vtk::VoxRaytracerRepresentation *parent) {
this->vtk_raytr = parent;
}
@@ -74,7 +74,7 @@ private:
vtkWidgetCallback() : vtk_raytr(NULL), muon(NULL), annotation(NULL) {}
uLib::VoxRaytracer *raytracer;
Vtk::vtkVoxRaytracerRepresentation *vtk_raytr;
Vtk::VoxRaytracerRepresentation *vtk_raytr;
uLib::MuonScatter *muon;
vtkCornerAnnotation *annotation;
};
@@ -87,14 +87,14 @@ BOOST_AUTO_TEST_CASE(vtkVoxRaytracerRepresentationTest) {
muon.LineOut().origin << 6, -4, 6, 1;
muon.LineOut().direction << 1, -1, 1, 0;
Vtk::vtkMuonScatter v_muon(muon);
Vtk::MuonScatter v_muon(muon);
// structured grid //
StructuredGrid grid(Vector3i(12, 10, 12));
grid.SetSpacing(Vector3f(1, 1, 1));
grid.SetPosition(Vector3f(0, 0, 0));
Vtk::vtkStructuredGrid v_grid(grid);
Vtk::StructuredGrid v_grid(grid);
// voxraytracer //
VoxRaytracer rt(grid);
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(vtkVoxRaytracerRepresentationTest) {
rt.GetEntryPoint(muon.LineIn(), pt);
std::cout << pt.transpose() << "\n";
Vtk::vtkVoxRaytracerRepresentation v_rt(rt);
Vtk::VoxRaytracerRepresentation v_rt(rt);
v_rt.SetMuon(muon);
v_rt.SetRayColor(Vector4f(1, 0, 0, 1));

View File

@@ -30,7 +30,7 @@
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonScatter.h"
@@ -39,11 +39,11 @@ class vtkRenderWindowInteractor;
namespace uLib {
class vtkMuonContainerScattering : public Abstract::uLibVtkPolydata {
typedef MuonScatter Content;
class MuonContainerScattering : public Abstract::uLibVtkPolydata {
typedef uLib::MuonScatter Content;
public:
vtkMuonContainerScattering(const MuonScatter &content);
~vtkMuonScatter();
MuonContainerScattering(const MuonScatter &content);
~MuonScatter();
Content& GetContent();

View File

@@ -41,7 +41,7 @@ namespace Vtk {
////// VOX RAYTRACER REPRESENTATION ///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content)
VoxRaytracerRepresentation::VoxRaytracerRepresentation(Content &content)
: m_Content(&content),
m_Sphere1(vtkSphereSource::New()), m_Sphere2(vtkSphereSource::New()),
m_Line1(vtkLineSource::New()), m_Line2(vtkLineSource::New()),
@@ -51,6 +51,7 @@ vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content)
m_RayRepresentationActor(vtkActor::New()),
m_Transform(vtkTransform::New()),
m_Asm(vtkAssembly::New()),
m_Muon(nullptr),
m_HasMuon(false), m_HasPoca(false) {
default_radius = content.GetImage()->GetSpacing()(0) / 4;
m_Sphere1->SetRadius(default_radius);
@@ -61,48 +62,49 @@ vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content)
InstallPipe();
if (m_Content && m_Content->GetImage()) {
Object::connect(m_Content->GetImage(), &StructuredGrid::Updated, this, &vtkVoxRaytracerRepresentation::imageUpdate);
Object::connect(m_Content->GetImage(), &StructuredGrid::Updated, this, &VoxRaytracerRepresentation::imageUpdate);
}
}
vtkVoxRaytracerRepresentation::~vtkVoxRaytracerRepresentation() {
VoxRaytracerRepresentation::~VoxRaytracerRepresentation() {
m_RayLine->Delete();
m_RayLineActor->Delete();
m_RayRepresentationActor->Delete();
m_Transform->Delete();
if (m_Muon) delete m_Muon;
}
uLib::VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm() {
uLib::VoxRaytracer *VoxRaytracerRepresentation::GetRaytracerAlgorithm() {
return m_Content;
}
void vtkVoxRaytracerRepresentation::Update() {
void VoxRaytracerRepresentation::Update() {
this->imageUpdate();
}
void vtkVoxRaytracerRepresentation::imageUpdate() {
if (m_HasMuon) {
void VoxRaytracerRepresentation::imageUpdate() {
if (m_HasMuon && m_Muon) {
if (m_HasPoca) {
this->SetMuon(m_Muon, m_Poca);
this->SetMuon(m_Muon->GetModel(), m_Poca);
} else {
this->SetMuon(m_Muon);
this->SetMuon(*m_Muon);
}
}
}
vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const {
vtkPolyData *VoxRaytracerRepresentation::GetPolyData() const {
std::cout << "get Raytracer polydata\n";
m_SelectedElement->Update();
return m_SelectedElement->GetOutput();
}
void vtkVoxRaytracerRepresentation::SetRepresentationElements(
vtkVoxRaytracerRepresentation::RepresentationElements el) {
void VoxRaytracerRepresentation::SetRepresentationElements(
VoxRaytracerRepresentation::RepresentationElements el) {
switch (el) {
case Vtk::vtkVoxRaytracerRepresentation::RayElements:
case Vtk::VoxRaytracerRepresentation::RayElements:
m_SelectedElement = m_RayLine;
break;
case Vtk::vtkVoxRaytracerRepresentation::VoxelsElements:
case Vtk::VoxRaytracerRepresentation::VoxelsElements:
m_SelectedElement = m_RayRepresentation;
break;
default:
@@ -111,8 +113,9 @@ void vtkVoxRaytracerRepresentation::SetRepresentationElements(
}
}
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
m_Muon = muon;
void VoxRaytracerRepresentation::SetMuon(uLib::MuonScatter &muon) {
if (m_Muon) delete m_Muon;
m_Muon = new MuonScatter(muon);
m_HasMuon = true;
m_HasPoca = false;
@@ -173,8 +176,9 @@ void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
this->SetRay(pt1, pt2);
}
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca) {
m_Muon = muon;
void VoxRaytracerRepresentation::SetMuon(uLib::MuonScatter &muon, HPoint3f poca) {
if (m_Muon) delete m_Muon;
m_Muon = new MuonScatter(muon);
m_Poca = poca;
m_HasMuon = true;
m_HasPoca = true;
@@ -247,27 +251,27 @@ void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca) {
this->SetRay(pt1, pt2);
}
void vtkVoxRaytracerRepresentation::SetMuon(vtkMuonScatter &muon) {
void VoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
HPoint3f poca = muon.GetPocaPoint();
MuonScatter &mu = muon.GetContent();
uLib::MuonScatter &mu = muon.GetModel();
this->SetMuon(mu, poca);
}
VoxRaytracer::RayData vtkVoxRaytracerRepresentation::GetRay() { return m_Ray; }
VoxRaytracer::RayData VoxRaytracerRepresentation::GetRay() { return m_Ray; }
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f out) {
void VoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f out) {
m_Ray = m_Content->TraceBetweenPoints(in, out);
this->SetRay(&m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f mid,
void VoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f mid,
HPoint3f out) {
m_Ray = m_Content->TraceBetweenPoints(in, mid);
m_Ray.AppendRay(m_Content->TraceBetweenPoints(mid, out));
this->SetRay(&m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray) {
void VoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray) {
vtkAppendPolyData *appender = m_RayRepresentation;
appender->RemoveAllInputs();
@@ -286,15 +290,15 @@ void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray) {
appender->Modified();
}
void vtkVoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba) {
void VoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba) {
this->SetColor(m_RayRepresentationActor, rgba);
}
void vtkVoxRaytracerRepresentation::SetRayColor(Vector4f rgba) {
void VoxRaytracerRepresentation::SetRayColor(Vector4f rgba) {
this->SetColor(m_RayLineActor, rgba);
}
void vtkVoxRaytracerRepresentation::SetColor(vtkActor *actor, Vector4f rgba) {
void VoxRaytracerRepresentation::SetColor(vtkActor *actor, Vector4f rgba) {
if (!actor)
return;
vtkProperty *pr = actor->GetProperty();
@@ -303,7 +307,7 @@ void vtkVoxRaytracerRepresentation::SetColor(vtkActor *actor, Vector4f rgba) {
pr->SetDiffuse(1);
}
void vtkVoxRaytracerRepresentation::InstallPipe() {
void VoxRaytracerRepresentation::InstallPipe() {
vtkSmartPointer<vtkAppendPolyData> append =
vtkSmartPointer<vtkAppendPolyData>::New();

View File

@@ -44,13 +44,13 @@
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/uLibVtkInterface.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
#include "Math/StructuredGrid.h"
#include "Vtk/Math/vtkStructuredGrid.h"
#include "Math/VoxRaytracer.h"
class vtkActor;
@@ -58,12 +58,12 @@ class vtkActor;
namespace uLib {
namespace Vtk {
class vtkVoxRaytracerRepresentation : public Puppet {
class VoxRaytracerRepresentation : public Puppet {
typedef VoxRaytracer Content;
public:
vtkVoxRaytracerRepresentation(Content &content);
~vtkVoxRaytracerRepresentation();
VoxRaytracerRepresentation(Content &content);
~VoxRaytracerRepresentation();
uLib::VoxRaytracer *GetRaytracerAlgorithm();
@@ -76,13 +76,13 @@ public:
enum RepresentationElements { RayElements, VoxelsElements };
void SetRepresentationElements(enum RepresentationElements el);
void SetMuon(MuonScatter &muon);
void SetMuon(uLib::MuonScatter &muon);
void SetMuon(MuonScatter &muon, HPoint3f poca);
void SetMuon(uLib::MuonScatter &muon, HPoint3f poca);
void SetMuon(class vtkMuonEvent &muon);
void SetMuon(class MuonEvent &muon);
void SetMuon(class vtkMuonScatter &muon);
void SetMuon(class MuonScatter &muon);
VoxRaytracer::RayData GetRay();
@@ -101,7 +101,7 @@ private:
void SetColor(vtkActor *actor, Vector4f rgba);
VoxRaytracer *m_Content;
MuonScatter m_Muon;
MuonScatter *m_Muon;
HPoint3f m_Poca;
bool m_HasMuon;
bool m_HasPoca;

View File

@@ -9,9 +9,9 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Math/Assembly.h"
#include "Math/ContainerBox.h"
#include "Math/Cylinder.h"
#include "Vtk/Math/vtkAssembly.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkCylinder.h"
#include "Vtk/Math/vtkAssembly.h"
#include "Vtk/vtkObjectsContext.h"
#include "Vtk/uLibVtkViewer.h"

View File

@@ -25,7 +25,7 @@
#include "Vtk/uLibVtkViewer.h"
#include "Math/ContainerBox.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Math/Units.h"
#include "Vtk/Math/vtkContainerBox.h"
@@ -40,7 +40,7 @@ int main() {
box.Scale(Vector3f(1_m,2_m,1_m));
box.SetPosition(Vector3f(0,0,0));
Vtk::vtkContainerBox v_box(&box);
Vtk::ContainerBox v_box(&box);
v_box.Update();
// v_box.SetRepresentation(Vtk::Puppet::Surface);

View File

@@ -6,7 +6,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/uLibVtkViewer.h"
#include "Math/ContainerBox.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Math/Units.h"
#include "Vtk/Math/vtkContainerBox.h"
#include <iostream>
@@ -19,7 +19,7 @@ int main() {
box.SetInstanceName("MyTestBox");
std::cout << "Creating VTK representation..." << std::endl;
Vtk::vtkContainerBox v_box(&box);
Vtk::ContainerBox v_box(&box);
v_box.SetRepresentation(Vtk::Puppet::Wireframe);
v_box.SetColor(1.0, 0.0, 0.0); // Red

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/Math/vtkQuadMesh.h"
#include "Math/QuadMesh.h"
#include "Vtk/Math/vtkQuadMesh.h"
#include "Vtk/uLibVtkViewer.h"
#define BOOST_TEST_MODULE VtkQuadMeshTest
@@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(vtkQuadMeshConstruction) {
mesh.AddQuad(Vector4i(0, 1, 2, 3));
Vtk::vtkQuadMesh v_mesh(mesh);
Vtk::QuadMesh v_mesh(mesh);
Object::connect(&mesh, &QuadMesh::Updated, [&mesh]() {
Vector3f points[4];

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/Math/vtkStructuredGrid.h"
#include "Math/StructuredGrid.h"
#include "Vtk/Math/vtkStructuredGrid.h"
#include "Vtk/uLibVtkViewer.h"
#define BOOST_TEST_MODULE VtkStructuredGridTest
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(vtkStructuredGridTest) {
StructuredGrid grid(Vector3i(10, 10, 100));
grid.SetSpacing(Vector3f(3, 1, 1));
Vtk::vtkStructuredGrid grid_viewer(grid);
Vtk::StructuredGrid grid_viewer(grid);
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
Vtk::Viewer viewer;

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/Math/vtkTriangleMesh.h"
#include "Math/TriangleMesh.h"
#include "Vtk/Math/vtkTriangleMesh.h"
#include "Vtk/uLibVtkViewer.h"
#define BOOST_TEST_MODULE VtkTriangleMeshTest
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(vtkTriangleMeshConstruction) {
mesh.AddPoint(Vector3f(1, 0, 0));
mesh.AddTriangle(Vector3i(0, 1, 2));
Vtk::vtkTriangleMesh v_mesh(mesh);
Vtk::TriangleMesh v_mesh(mesh);
Object::connect(&mesh, &TriangleMesh::Updated, [&mesh]() {
Vector3f points[3];
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(vtkTriangleMeshConstruction) {
BOOST_AUTO_TEST_CASE(vtkTriangleMeshConstruction2) {
TriangleMesh mesh;
Vtk::vtkTriangleMesh v_mesh(mesh);
Vtk::TriangleMesh v_mesh(mesh);
v_mesh.ReadFromStlFile("capelluzzo.stl");
v_mesh.Update();

View File

@@ -10,7 +10,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/Math/vtkVoxImage.h"
#include "Math/VoxImage.h"
#include "Vtk/Math/vtkVoxImage.h"
#include "Vtk/uLibVtkViewer.h"
#include <vtkSmartPointer.h>
#include <vtkCallbackCommand.h>
@@ -24,7 +24,7 @@
using namespace uLib;
struct AppState {
std::vector<Vtk::vtkVoxImage*> images;
std::vector<Vtk::VoxImage*> images;
Vtk::Viewer* viewer;
};
@@ -96,10 +96,10 @@ int main(int argc, char** argv) {
}
}
Vtk::vtkVoxImage vtk_img1(img1);
Vtk::VoxImage vtk_img1(img1);
vtk_img1.setShadingPreset(0);
Vtk::vtkVoxImage vtk_img2(img2);
Vtk::VoxImage vtk_img2(img2);
vtk_img2.setShadingPreset(1); // Use Composite without MIP for variety
Vtk::Viewer viewer;
@@ -119,7 +119,7 @@ int main(int argc, char** argv) {
viewer.GetInteractor()->AddObserver(vtkCommand::KeyPressEvent, keyCallback);
std::cout << "=========================================" << std::endl;
std::cout << " vtkVoxImage Interactive Viewer Test" << std::endl;
std::cout << " VoxImage Interactive Viewer Test" << std::endl;
std::cout << " [LEFT] Spherical Shell (MIP)" << std::endl;
std::cout << " [RIGHT] Axes Gradient (Composite)" << std::endl;
std::cout << "-----------------------------------------" << std::endl;

View File

@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/Math/vtkVoxImage.h"
#include "Math/VoxImage.h"
#include "Vtk/Math/vtkVoxImage.h"
#include "Vtk/uLibVtkViewer.h"
#define BOOST_TEST_MODULE VtkVoxImageTest
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(vtkVoxImageConstruction) {
img.InitVoxels(zero);
img[Vector3i(3, 3, 3)] = nonzero;
Vtk::vtkVoxImage vtk_img(img);
Vtk::VoxImage vtk_img(img);
vtk_img.SaveToXMLFile("test_vtkvoximage.vti");
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {

View File

@@ -11,7 +11,7 @@
#include "vtkAssembly.h" // uLib::Vtk::Assembly
#include "Vtk/vtkObjectsContext.h"
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
#include <vtkAssembly.h> // VTK library ::vtkAssembly
#include <vtkActor.h>
@@ -77,7 +77,7 @@ void Assembly::InstallPipe() {
// 3. Build a child-objects context (auto-creates puppets for each child)
if (m_Content) {
m_ChildContext = new vtkObjectsContext(m_Content);
m_ChildContext = new ObjectsContext(m_Content);
// Link the children context's assembly into our group assembly
if (auto* childProp = vtkProp3D::SafeDownCast(m_ChildContext->GetProp())) {
m_VtkAsm->AddPart(childProp);
@@ -189,7 +189,7 @@ void Assembly::UpdateBoundingBox() {
}
// ------------------------------------------------------------------ //
vtkObjectsContext *Assembly::GetChildrenContext() const {
ObjectsContext *Assembly::GetChildrenContext() const {
return m_ChildContext;
}

View File

@@ -21,7 +21,7 @@ class vtkAssembly; // VTK library forward declaration (must be before namespace
namespace uLib {
namespace Vtk {
class vtkObjectsContext; // forward
class ObjectsContext; // forward
/**
* @brief VTK Puppet for visualizing uLib::Assembly.
@@ -55,14 +55,14 @@ public:
*/
/** @brief Returns the puppet managing child objects. */
vtkObjectsContext *GetChildrenContext() const;
ObjectsContext *GetChildrenContext() const;
private:
void UpdateBoundingBox();
void InstallPipe();
uLib::Assembly *m_Content;
vtkObjectsContext *m_ChildContext;
ObjectsContext *m_ChildContext;
vtkActor *m_BBoxActor;
::vtkAssembly *m_VtkAsm; // VTK library assembly — NOT this class
bool m_InUpdate; // re-entrancy guard

View File

@@ -41,7 +41,7 @@
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
namespace uLib {
@@ -65,23 +65,23 @@ struct ContainerBoxData {
vtkContainerBox::vtkContainerBox(vtkContainerBox::Content *content)
ContainerBox::ContainerBox(ContainerBox::Content *content)
: d(new ContainerBoxData()), m_Content(content) {
this->InstallPipe();
d->m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &vtkContainerBox::Update);
d->m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &ContainerBox::Update);
}
vtkContainerBox::~vtkContainerBox() {
ContainerBox::~ContainerBox() {
delete d;
}
vtkPolyData *vtkContainerBox::GetPolyData() const {
vtkPolyData *ContainerBox::GetPolyData() const {
// TODO
return NULL;
}
void vtkContainerBox::Update() {
void ContainerBox::Update() {
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
if (!m_Content) return;
@@ -102,7 +102,7 @@ void vtkContainerBox::Update() {
void vtkContainerBox::SyncFromVtk() {
void ContainerBox::SyncFromVtk() {
RecursiveMutex::ScopedLock lock(this->m_UpdateMutex);
if (!m_Content) return;
@@ -125,7 +125,7 @@ void vtkContainerBox::SyncFromVtk() {
void vtkContainerBox::InstallPipe() {
void ContainerBox::InstallPipe() {
if (!m_Content)
return;
Content *c = m_Content;

View File

@@ -37,14 +37,14 @@ namespace Vtk {
struct ContainerBoxData;
class vtkContainerBox : public Puppet, public Polydata {
class ContainerBox : public Puppet, public Polydata {
uLibTypeMacro(vtkContainerBox, Puppet, Polydata)
typedef ContainerBox Content;
uLibTypeMacro(ContainerBox, Puppet, Polydata)
typedef uLib::ContainerBox Content;
public:
vtkContainerBox(Content *content);
~vtkContainerBox();
ContainerBox(Content *content);
~ContainerBox();
virtual class vtkPolyData *GetPolyData() const override;
@@ -64,9 +64,9 @@ protected:
virtual void InstallPipe();
struct ContainerBoxData *d;
ContainerBox *m_Content;
uLib::ContainerBox *m_Content;
ULIB_DECLARE_PROPERTIES(vtkContainerBox)
ULIB_DECLARE_PROPERTIES(ContainerBox)
};
} // namespace Vtk

View File

@@ -32,23 +32,23 @@
#include <vtkProperty.h>
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
namespace uLib {
namespace Vtk {
vtkCylinder::vtkCylinder(vtkCylinder::Content *content)
Cylinder::Cylinder(Cylinder::Content *content)
: m_Content(content), m_Actor(nullptr), m_VtkAsm(nullptr) {
this->InstallPipe();
m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &vtkCylinder::Update);
m_UpdateSignal = Object::connect(m_Content, &uLib::Object::Updated, this, &Cylinder::Update);
}
vtkCylinder::~vtkCylinder() {
Cylinder::~Cylinder() {
if (m_Actor) m_Actor->Delete();
if (m_VtkAsm) m_VtkAsm->Delete();
}
void vtkCylinder::Update() {
void Cylinder::Update() {
if (!m_Content)
return;
@@ -85,7 +85,7 @@ void vtkCylinder::Update() {
this->Puppet::Update();
}
void vtkCylinder::SyncFromVtk() {
void Cylinder::SyncFromVtk() {
if (!m_Content) return;
vtkProp3D* root = this->GetProxyProp();
@@ -100,7 +100,7 @@ void vtkCylinder::SyncFromVtk() {
m_Content->Updated();
}
void vtkCylinder::InstallPipe() {
void Cylinder::InstallPipe() {
if (!m_Content)
return;

View File

@@ -41,12 +41,12 @@ namespace Vtk {
* mathematical state of a Cylinder object. It manages the alignment
* between VTK's Y-centered cylinder and uLib's Z-based coordinate system.
*/
class vtkCylinder : public Puppet {
typedef Cylinder Content;
class Cylinder : public Puppet {
typedef uLib::Cylinder Content;
public:
vtkCylinder(Content *content);
virtual ~vtkCylinder();
Cylinder(Content *content);
virtual ~Cylinder();
/** Synchronizes the VTK actor with the uLib model matrix and vice-versa */
virtual void Update() override;

View File

@@ -31,10 +31,10 @@ class vtkPolyData;
namespace uLib {
class vtkHLineRepresentationDefault {
class HLineRepresentationDefault {
public:
vtkHLineRepresentationDefault();
HLineRepresentationDefault();
};
} // namespace uLib

View File

@@ -42,14 +42,14 @@
#include <vtkMatrix4x4.h>
#include <vtkNew.h>
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/Math/vtkQuadMesh.h"
#include <iostream>
namespace uLib {
namespace Vtk {
void vtkQuadMesh::vtk2uLib_update() {
void QuadMesh::vtk2uLib_update() {
vtkIdType number_of_points = m_Poly->GetNumberOfPoints();
vtkIdType number_of_quads = m_Poly->GetNumberOfPolys();
@@ -80,7 +80,7 @@ void vtkQuadMesh::vtk2uLib_update() {
m_Actor->GetMapper()->Update();
}
void vtkQuadMesh::uLib2vtk_update() {
void QuadMesh::uLib2vtk_update() {
vtkIdType number_of_points = m_content.Points().size();
vtkIdType number_of_quads = m_content.Quads().size();
@@ -110,7 +110,7 @@ void vtkQuadMesh::uLib2vtk_update() {
m_Poly->Modified();
}
void vtkQuadMesh::contentUpdate() {
void QuadMesh::contentUpdate() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) {
vtkNew<vtkMatrix4x4> mat;
@@ -128,7 +128,7 @@ void vtkQuadMesh::contentUpdate() {
Puppet::Update();
}
void vtkQuadMesh::Update() {
void QuadMesh::Update() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) return;
@@ -139,7 +139,7 @@ void vtkQuadMesh::Update() {
// -------------------------------------------------------------------------- //
vtkQuadMesh::vtkQuadMesh(vtkQuadMesh::Content &content)
QuadMesh::QuadMesh(QuadMesh::Content &content)
: m_content(content), m_Poly(vtkPolyData::New()), m_Actor(vtkActor::New()) {
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
@@ -151,17 +151,17 @@ vtkQuadMesh::vtkQuadMesh(vtkQuadMesh::Content &content)
m_Actor->SetUserMatrix(vmat);
this->SetProp(m_Actor);
Object::connect(&m_content, &Content::Updated, this, &vtkQuadMesh::contentUpdate);
Object::connect(&m_content, &Content::Updated, this, &QuadMesh::contentUpdate);
this->contentUpdate();
}
vtkQuadMesh::~vtkQuadMesh() {
Object::disconnect(&m_content, &Content::Updated, this, &vtkQuadMesh::contentUpdate);
QuadMesh::~QuadMesh() {
Object::disconnect(&m_content, &Content::Updated, this, &QuadMesh::contentUpdate);
m_Poly->Delete();
m_Actor->Delete();
}
void vtkQuadMesh::ReadFromFile(const char *filename) {
void QuadMesh::ReadFromFile(const char *filename) {
vtkSmartPointer<vtkPolyDataReader> reader =
vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(filename);
@@ -170,7 +170,7 @@ void vtkQuadMesh::ReadFromFile(const char *filename) {
vtk2uLib_update();
}
void vtkQuadMesh::ReadFromXMLFile(const char *filename) {
void QuadMesh::ReadFromXMLFile(const char *filename) {
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(filename);
@@ -179,7 +179,7 @@ void vtkQuadMesh::ReadFromXMLFile(const char *filename) {
vtk2uLib_update();
}
void vtkQuadMesh::ReadFromObjFile(const char *filename) {
void QuadMesh::ReadFromObjFile(const char *filename) {
vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(filename);
reader->Update();
@@ -187,7 +187,7 @@ void vtkQuadMesh::ReadFromObjFile(const char *filename) {
vtk2uLib_update();
}
void vtkQuadMesh::ReadFromStlFile(const char *filename) {
void QuadMesh::ReadFromStlFile(const char *filename) {
vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(filename);
reader->Update();
@@ -195,7 +195,7 @@ void vtkQuadMesh::ReadFromStlFile(const char *filename) {
vtk2uLib_update();
}
vtkPolyData *vtkQuadMesh::GetPolyData() const { return m_Poly; }
vtkPolyData *QuadMesh::GetPolyData() const { return m_Poly; }
} // namespace Vtk
} // namespace uLib

View File

@@ -36,12 +36,12 @@ class vtkActor;
namespace uLib {
namespace Vtk {
class vtkQuadMesh : public Puppet, public Polydata {
typedef QuadMesh Content;
class QuadMesh : public Puppet, public Polydata {
typedef uLib::QuadMesh Content;
public:
vtkQuadMesh(Content &content);
~vtkQuadMesh();
QuadMesh(Content &content);
~QuadMesh();
void ReadFromFile(const char *filename);
@@ -61,7 +61,7 @@ private:
void vtk2uLib_update();
void uLib2vtk_update();
QuadMesh &m_content;
uLib::QuadMesh &m_content;
vtkPolyData *m_Poly;
vtkActor *m_Actor;
};

View File

@@ -27,7 +27,7 @@
#include "config.h"
#endif
#include "Math/StructuredGrid.h"
#include "Vtk/Math/vtkStructuredGrid.h"
#include "Vtk/Math/vtkStructuredGrid.h"
#include "Vtk/Math/vtkDense.h"
@@ -39,19 +39,19 @@ namespace Vtk {
////// VTK STRUCTURED GRID /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkStructuredGrid::vtkStructuredGrid(Content &content)
StructuredGrid::StructuredGrid(Content &content)
: m_Content(&content), m_Actor(vtkActor::New()),
m_Transform(vtkTransform::New()) {
this->InstallPipe();
}
vtkStructuredGrid::~vtkStructuredGrid() {
StructuredGrid::~StructuredGrid() {
m_Actor->Delete();
m_Transform->Delete();
}
void vtkStructuredGrid::SetTransform(vtkTransform *t) {
void StructuredGrid::SetTransform(vtkTransform *t) {
vtkMatrix4x4 *vmat = t->GetMatrix();
Matrix4f mat = VtkToMatrix4f(vmat);
m_Content->SetMatrix(mat);
@@ -64,7 +64,7 @@ void vtkStructuredGrid::SetTransform(vtkTransform *t) {
this->Update();
}
void vtkStructuredGrid::Update() {
void StructuredGrid::Update() {
if (!m_Content) return;
vtkProp3D* actor = vtkProp3D::SafeDownCast(this->GetProp());
@@ -86,7 +86,7 @@ void vtkStructuredGrid::Update() {
m_Content->Updated(); // Notify others (like raytracer)
}
void vtkStructuredGrid::InstallPipe() {
void StructuredGrid::InstallPipe() {
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
Vector3i dims = m_Content->GetDims();

View File

@@ -39,7 +39,7 @@
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Math/StructuredGrid.h"
#include "Vtk/uLibVtkInterface.h"
@@ -47,12 +47,12 @@
namespace uLib {
namespace Vtk {
class vtkStructuredGrid : public Puppet {
typedef StructuredGrid Content;
class StructuredGrid : public Puppet {
typedef uLib::StructuredGrid Content;
public:
vtkStructuredGrid(Content &content);
~vtkStructuredGrid();
StructuredGrid(Content &content);
~StructuredGrid();
void SetTransform(class vtkTransform *t);
@@ -62,7 +62,7 @@ private:
void InstallPipe();
vtkActor *m_Actor;
StructuredGrid *m_Content;
uLib::StructuredGrid *m_Content;
vtkTransform *m_Transform;
};

View File

@@ -42,14 +42,14 @@
#include <vtkMatrix4x4.h>
#include <vtkNew.h>
#include "Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/Math/vtkTriangleMesh.h"
#include <iostream>
namespace uLib {
namespace Vtk {
void vtkTriangleMesh::vtk2uLib_update() {
void TriangleMesh::vtk2uLib_update() {
vtkIdType number_of_points = m_Poly->GetNumberOfPoints();
vtkIdType number_of_triangles = m_Poly->GetNumberOfPolys();
@@ -77,7 +77,7 @@ void vtkTriangleMesh::vtk2uLib_update() {
m_Actor->GetMapper()->Update();
}
void vtkTriangleMesh::uLib2vtk_update() {
void TriangleMesh::uLib2vtk_update() {
vtkIdType number_of_points = m_content.Points().size();
vtkIdType number_of_triangles = m_content.Triangles().size();
@@ -105,7 +105,7 @@ void vtkTriangleMesh::uLib2vtk_update() {
m_Poly->Modified();
}
void vtkTriangleMesh::contentUpdate() {
void TriangleMesh::contentUpdate() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) {
vtkNew<vtkMatrix4x4> mat;
@@ -123,7 +123,7 @@ void vtkTriangleMesh::contentUpdate() {
Puppet::Update();
}
void vtkTriangleMesh::Update() {
void TriangleMesh::Update() {
vtkMatrix4x4 *vmat = m_Actor->GetUserMatrix();
if (!vmat) return;
@@ -134,7 +134,7 @@ void vtkTriangleMesh::Update() {
// -------------------------------------------------------------------------- //
vtkTriangleMesh::vtkTriangleMesh(vtkTriangleMesh::Content &content)
TriangleMesh::TriangleMesh(TriangleMesh::Content &content)
: m_content(content), m_Poly(vtkPolyData::New()), m_Actor(vtkActor::New()) {
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
@@ -146,17 +146,17 @@ vtkTriangleMesh::vtkTriangleMesh(vtkTriangleMesh::Content &content)
m_Actor->SetUserMatrix(vmat);
this->SetProp(m_Actor);
Object::connect(&m_content, &Content::Updated, this, &vtkTriangleMesh::contentUpdate);
Object::connect(&m_content, &Content::Updated, this, &TriangleMesh::contentUpdate);
this->contentUpdate();
}
vtkTriangleMesh::~vtkTriangleMesh() {
Object::disconnect(&m_content, &Content::Updated, this, &vtkTriangleMesh::contentUpdate);
TriangleMesh::~TriangleMesh() {
Object::disconnect(&m_content, &Content::Updated, this, &TriangleMesh::contentUpdate);
m_Poly->Delete();
m_Actor->Delete();
}
void vtkTriangleMesh::ReadFromFile(const char *filename) {
void TriangleMesh::ReadFromFile(const char *filename) {
vtkSmartPointer<vtkPolyDataReader> reader =
vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(filename);
@@ -165,7 +165,7 @@ void vtkTriangleMesh::ReadFromFile(const char *filename) {
vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromXMLFile(const char *filename) {
void TriangleMesh::ReadFromXMLFile(const char *filename) {
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(filename);
@@ -174,7 +174,7 @@ void vtkTriangleMesh::ReadFromXMLFile(const char *filename) {
vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromObjFile(const char *filename) {
void TriangleMesh::ReadFromObjFile(const char *filename) {
vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(filename);
reader->Update();
@@ -182,7 +182,7 @@ void vtkTriangleMesh::ReadFromObjFile(const char *filename) {
vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromStlFile(const char *filename) {
void TriangleMesh::ReadFromStlFile(const char *filename) {
vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(filename);
reader->Update();
@@ -190,7 +190,7 @@ void vtkTriangleMesh::ReadFromStlFile(const char *filename) {
vtk2uLib_update();
}
vtkPolyData *vtkTriangleMesh::GetPolyData() const { return m_Poly; }
vtkPolyData *TriangleMesh::GetPolyData() const { return m_Poly; }
} // namespace Vtk
} // namespace uLib

View File

@@ -36,12 +36,12 @@ class vtkActor;
namespace uLib {
namespace Vtk {
class vtkTriangleMesh : public Puppet, public Polydata {
typedef TriangleMesh Content;
class TriangleMesh : public Puppet, public Polydata {
typedef uLib::TriangleMesh Content;
public:
vtkTriangleMesh(Content &content);
~vtkTriangleMesh();
TriangleMesh(Content &content);
~TriangleMesh();
void ReadFromFile(const char *filename);
@@ -61,7 +61,7 @@ private:
void vtk2uLib_update();
void uLib2vtk_update();
TriangleMesh &m_content;
uLib::TriangleMesh &m_content;
vtkPolyData *m_Poly;
vtkActor *m_Actor;
};

View File

@@ -60,7 +60,7 @@ VTK_MODULE_INIT(vtkInteractionStyle);
namespace uLib {
namespace Vtk {
void vtkVoxImage::GetContent() {
void VoxImage::UpdateFromContent() {
Vector3i ev_dims = m_Content.GetDims();
m_Image->SetDimensions(ev_dims.data());
@@ -91,7 +91,7 @@ void vtkVoxImage::GetContent() {
}
}
void vtkVoxImage::SetContent() {
void VoxImage::UpdateToContent() {
int *ext = m_Image->GetExtent();
int dims[3] = {ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, ext[5] - ext[4] + 1};
m_Content.SetDims(Vector3i(dims[0], dims[1], dims[2]));
@@ -124,7 +124,7 @@ void vtkVoxImage::SetContent() {
////////////////////////////////////////////////////////////////////////////////
// VTK VOXIMAGE
vtkVoxImage::vtkVoxImage(Content &content)
VoxImage::VoxImage(Content &content)
: m_Content(content), m_Actor(vtkVolume::New()),
m_Asm(vtkAssembly::New()),
m_Image(vtkImageData::New()), m_Outline(vtkCubeSource::New()),
@@ -134,15 +134,15 @@ vtkVoxImage::vtkVoxImage(Content &content)
// Transfer functions
m_ColorFun = vtkColorTransferFunction::New();
m_OpacityFun = vtkPiecewiseFunction::New();
m_UpdateConnection = Object::connect(&m_Content, &uLib::Object::Updated, this, &vtkVoxImage::Update);
m_UpdateConnection = Object::connect(&m_Content, &uLib::Object::Updated, this, &VoxImage::Update);
GetContent();
UpdateFromContent();
InstallPipe();
RescaleShaderRange();
ULIB_ACTIVATE_DISPLAY_PROPERTIES;
}
vtkVoxImage::~vtkVoxImage() {
VoxImage::~VoxImage() {
m_Image->Delete();
m_Actor->Delete();
m_Asm->Delete();
@@ -152,16 +152,16 @@ vtkVoxImage::~vtkVoxImage() {
m_OpacityFun->Delete();
}
vtkImageData *vtkVoxImage::GetImageData() {
GetContent();
vtkImageData *VoxImage::GetImageData() {
UpdateFromContent();
return m_Image;
}
void vtkVoxImage::SaveToXMLFile(const char *fname) {
void VoxImage::SaveToXMLFile(const char *fname) {
vtkSmartPointer<vtkXMLImageDataWriter> writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
writer->SetFileName(fname);
GetContent();
UpdateFromContent();
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
@@ -177,7 +177,7 @@ void vtkVoxImage::SaveToXMLFile(const char *fname) {
writer->Write();
}
void vtkVoxImage::ReadFromVKTFile(const char *fname) {
void VoxImage::ReadFromVKTFile(const char *fname) {
vtkSmartPointer<vtkGenericDataObjectReader> reader =
vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader->SetFileName(fname);
@@ -190,7 +190,7 @@ void vtkVoxImage::ReadFromVKTFile(const char *fname) {
vtkscale->Update();
m_Image->DeepCopy(vtkscale->GetOutput());
SetContent();
UpdateToContent();
RescaleShaderRange();
} else {
std::cerr << "Error: file does not contain structured points\n";
@@ -198,7 +198,7 @@ void vtkVoxImage::ReadFromVKTFile(const char *fname) {
m_Actor->Update();
}
void vtkVoxImage::ReadFromXMLFile(const char *fname) {
void VoxImage::ReadFromXMLFile(const char *fname) {
vtkSmartPointer<vtkXMLImageDataReader> reader =
vtkSmartPointer<vtkXMLImageDataReader>::New();
reader->SetFileName(fname);
@@ -210,11 +210,11 @@ void vtkVoxImage::ReadFromXMLFile(const char *fname) {
vtkscale->Update();
m_Image->DeepCopy(vtkscale->GetOutput());
SetContent();
UpdateToContent();
RescaleShaderRange();
}
void vtkVoxImage::setShadingPreset(int blendType) {
void VoxImage::setShadingPreset(int blendType) {
m_ShadingPreset = blendType;
vtkSmartVolumeMapper *mapper = (vtkSmartVolumeMapper *)m_Actor->GetMapper();
if (!mapper) return;
@@ -270,7 +270,7 @@ void vtkVoxImage::setShadingPreset(int blendType) {
}
}
void vtkVoxImage::RescaleShaderRange() {
void VoxImage::RescaleShaderRange() {
double range[2];
m_Image->GetScalarRange(range);
m_Level = (range[0] + range[1]) / 2.0;
@@ -280,7 +280,7 @@ void vtkVoxImage::RescaleShaderRange() {
setShadingPreset(m_ShadingPreset);
}
void vtkVoxImage::SetRepresentation(Representation mode) {
void VoxImage::SetRepresentation(Representation mode) {
Puppet::SetRepresentation(mode); // Ensure base class data state is updated
if (mode == Wireframe) {
@@ -297,7 +297,7 @@ void vtkVoxImage::SetRepresentation(Representation mode) {
}
}
void vtkVoxImage::serialize_display(uLib::Archive::display_properties_archive & ar, const unsigned int version) {
void VoxImage::serialize_display(uLib::Archive::display_properties_archive & ar, const unsigned int version) {
// Call base class to show Transform and Appearance properties
// Puppet::serialize_display(ar, version);
@@ -308,7 +308,7 @@ void vtkVoxImage::serialize_display(uLib::Archive::display_properties_archive &
{"MIP", "Composite", "Composite Shaded", "MIP Bone", "MIP Hot", "Additive"});
}
void vtkVoxImage::SyncFromVtk() {
void VoxImage::SyncFromVtk() {
if (auto *root = this->GetProxyProp()) {
vtkMatrix4x4 *rootMat = root->GetUserMatrix();
if (rootMat) {
@@ -320,13 +320,13 @@ void vtkVoxImage::SyncFromVtk() {
}
}
void vtkVoxImage::Update() {
void VoxImage::Update() {
if (auto *root = vtkProp3D::SafeDownCast(this->GetProp())) {
vtkNew<vtkMatrix4x4> m;
Matrix4fToVtk(m_Content.GetMatrix(), m); // * m_Content.GetLocalMatrix(), m);
root->SetUserMatrix(m);
root->Modified();
// std::cout << "[vtkVoxImage::Update] Set Proxy UserMatrix:" << std::endl;
// std::cout << "[VoxImage::Update] Set Proxy UserMatrix:" << std::endl;
// std::cout << m_Content.GetMatrix() << std::endl;
}
setShadingPreset(m_ShadingPreset);
@@ -339,7 +339,7 @@ void vtkVoxImage::Update() {
}
void vtkVoxImage::InstallPipe() {
void VoxImage::InstallPipe() {
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();
#if VTK_MAJOR_VERSION <= 5

View File

@@ -45,17 +45,18 @@ class vtkPiecewiseFunction;
namespace uLib {
namespace Vtk {
class vtkVoxImage : public Puppet {
class VoxImage : public Puppet {
public:
typedef Abstract::VoxImage Content;
vtkVoxImage(Content &content);
VoxImage(Content &content);
~vtkVoxImage();
~VoxImage();
void GetContent();
void UpdateFromContent();
void SetContent();
void UpdateToContent();
uLib::Object* GetContent() const override { return (uLib::Object*)&m_Content; }
vtkProp3D *GetProp() override { return m_Asm; }
@@ -89,7 +90,7 @@ private:
vtkXMLImageDataReader *m_Reader;
vtkXMLImageDataWriter *m_Writer;
vtkVoxImage::Content &m_Content;
VoxImage::Content &m_Content;
float m_Window;
float m_Level;

View File

@@ -33,7 +33,7 @@ int main() {
// Create the display context, linked to the model context.
// It will automatically create visual puppets for each model object.
Vtk::vtkObjectsContext viewerContext(&globalContext);
Vtk::ObjectsContext viewerContext(&globalContext);
viewerContext.ConnectRenderer(viewer.GetRenderer());
// 1. Create a model Assembly
@@ -56,7 +56,7 @@ int main() {
assembly->AddObject(box1);
// Verify child puppet was created in the assembly's child context
Vtk::vtkObjectsContext* childVtkCtx = vtkAss->GetChildrenContext();
Vtk::ObjectsContext* childVtkCtx = vtkAss->GetChildrenContext();
ASSERT_NOT_NULL(childVtkCtx);
Vtk::Puppet* box1Puppet = childVtkCtx->GetPuppet(box1);

View File

@@ -23,7 +23,7 @@
//////////////////////////////////////////////////////////////////////////////*/
#include "Math/ContainerBox.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/uLibVtkViewer.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/vtkHandlerWidget.h"
@@ -39,7 +39,7 @@
using namespace uLib;
int main() {
BEGIN_TESTING(vtkHandlerWidget with ContainerBox);
BEGIN_TESTING(HandlerWidget with ContainerBox);
// 1. Create a ContainerBox (Math object)
ContainerBox box;
@@ -49,16 +49,16 @@ int main() {
// 3. Setup the Viewer
Vtk::Viewer viewer;
// 2. Wrap it in a Vtk::vtkContainerBox (Vtk Puppet)
Vtk::vtkContainerBox v_box(&box);
// 2. Wrap it in a Vtk::ContainerBox (Vtk Puppet)
Vtk::ContainerBox v_box(&box);
v_box.SetRepresentation(Vtk::Puppet::Surface);
v_box.SetOpacity(0.5);
viewer.AddPuppet(v_box);
// 4. Create and setup the vtkHandlerWidget
vtkSmartPointer<Vtk::vtkHandlerWidget> handler =
vtkSmartPointer<Vtk::vtkHandlerWidget>::New();
// 4. Create and setup the HandlerWidget
vtkSmartPointer<Vtk::HandlerWidget> handler =
vtkSmartPointer<Vtk::HandlerWidget>::New();
handler->SetInteractor(viewer.GetInteractor());
@@ -83,20 +83,20 @@ int main() {
auto key_callback = vtkSmartPointer<vtkCallbackCommand>::New();
key_callback->SetCallback([](vtkObject *caller, unsigned long, void *clientData, void *) {
auto interactor = static_cast<vtkRenderWindowInteractor *>(caller);
auto h = static_cast<Vtk::vtkHandlerWidget *>(clientData);
auto h = static_cast<Vtk::HandlerWidget *>(clientData);
std::string key = interactor->GetKeySym();
if (key == "g") {
std::cout << "Switching to GLOBAL frame" << std::endl;
h->SetReferenceFrame(Vtk::vtkHandlerWidget::GLOBAL);
h->SetReferenceFrame(Vtk::HandlerWidget::GLOBAL);
} else if (key == "l") {
std::cout << "Switching to LOCAL frame" << std::endl;
h->SetReferenceFrame(Vtk::vtkHandlerWidget::LOCAL);
h->SetReferenceFrame(Vtk::HandlerWidget::LOCAL);
} else if (key == "c") {
std::cout << "Switching to CENTER frame" << std::endl;
h->SetReferenceFrame(Vtk::vtkHandlerWidget::CENTER);
h->SetReferenceFrame(Vtk::HandlerWidget::CENTER);
} else if (key == "k") {
std::cout << "Switching to CENTER_LOCAL frame" << std::endl;
h->SetReferenceFrame(Vtk::vtkHandlerWidget::CENTER_LOCAL);
h->SetReferenceFrame(Vtk::HandlerWidget::CENTER_LOCAL);
}
});
key_callback->SetClientData(handler.GetPointer());

View File

@@ -63,7 +63,7 @@
#include "uLibVtkInterface.h"
#include "vtkHandlerWidget.h"
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "Vtk/Math/vtkDense.h"
#include "Core/Property.h"
#include "Math/Transform.h"
@@ -594,7 +594,7 @@ void Puppet::Update()
// so all derived classes benefit without duplicating the matrix code.
this->ApplyPuppetTransform(vtkProp3D::SafeDownCast(this->GetProp()));
// Use virtual GetProp() for appearance so overriders (e.g. vtkVoxImage)
// Use virtual GetProp() for appearance so overriders (e.g. VoxImage)
// that never call SetProp() are handled correctly.
pd->ApplyAppearance(this->GetProp());

View File

@@ -85,12 +85,12 @@ struct HandlerWidgetData {
}
};
vtkStandardNewMacro(vtkHandlerWidget);
vtkStandardNewMacro(HandlerWidget);
vtkHandlerWidget::vtkHandlerWidget() : d(new HandlerWidgetData()) {
HandlerWidget::HandlerWidget() : d(new HandlerWidgetData()) {
this->Interaction = IDLE;
d->m_Picker->SetTolerance(0.01); // Increased tolerance for thin gizmos
this->EventCallbackCommand->SetCallback(vtkHandlerWidget::ProcessEvents);
this->EventCallbackCommand->SetCallback(HandlerWidget::ProcessEvents);
this->EventCallbackCommand->SetClientData(this);
this->m_Frame = LOCAL;
d->m_OverlayRenderer->SetLayer(1);
@@ -103,17 +103,17 @@ vtkHandlerWidget::vtkHandlerWidget() : d(new HandlerWidgetData()) {
this->CreateGizmos();
}
vtkHandlerWidget::~vtkHandlerWidget() {
HandlerWidget::~HandlerWidget() {
this->SetEnabled(0);
delete d;
}
::vtkRenderer *vtkHandlerWidget::GetOverlayRenderer() {
::vtkRenderer *HandlerWidget::GetOverlayRenderer() {
return d->m_OverlayRenderer;
}
void vtkHandlerWidget::SetProp3D(::vtkProp3D *prop) {
void HandlerWidget::SetProp3D(::vtkProp3D *prop) {
if (this->Prop3D == prop) {
return;
}
@@ -125,7 +125,7 @@ void vtkHandlerWidget::SetProp3D(::vtkProp3D *prop) {
this->Modified();
}
void vtkHandlerWidget::SetEnabled(int enabling) {
void HandlerWidget::SetEnabled(int enabling) {
if (enabling) {
if (this->Enabled)
return;
@@ -210,15 +210,15 @@ void vtkHandlerWidget::SetEnabled(int enabling) {
}
}
void vtkHandlerWidget::ProcessEvents(::vtkObject *caller, unsigned long event,
void HandlerWidget::ProcessEvents(::vtkObject *caller, unsigned long event,
void *clientdata, void *calldata) {
(void)caller;
(void)calldata;
vtkHandlerWidget *self = reinterpret_cast<vtkHandlerWidget *>(clientdata);
HandlerWidget *self = reinterpret_cast<HandlerWidget *>(clientdata);
switch (event) {
case ::vtkCommand::LeftButtonPressEvent:
self->OnLeftButtonDown();
if (self->Interaction != ::uLib::Vtk::vtkHandlerWidget::IDLE)
if (self->Interaction != ::uLib::Vtk::HandlerWidget::IDLE)
self->EventCallbackCommand->SetAbortFlag(1);
break;
case ::vtkCommand::LeftButtonReleaseEvent:
@@ -229,7 +229,7 @@ void vtkHandlerWidget::ProcessEvents(::vtkObject *caller, unsigned long event,
break;
case ::vtkCommand::MouseMoveEvent:
self->OnMouseMove();
if (self->Interaction != ::uLib::Vtk::vtkHandlerWidget::IDLE)
if (self->Interaction != ::uLib::Vtk::HandlerWidget::IDLE)
self->EventCallbackCommand->SetAbortFlag(1);
break;
case ::vtkCommand::RenderEvent:
@@ -241,7 +241,7 @@ void vtkHandlerWidget::ProcessEvents(::vtkObject *caller, unsigned long event,
}
}
void vtkHandlerWidget::OnKeyPress() {
void HandlerWidget::OnKeyPress() {
std::string key = this->Interactor->GetKeySym();
bool ctrl = (this->Interactor->GetControlKey() != 0);
@@ -268,7 +268,7 @@ void vtkHandlerWidget::OnKeyPress() {
}
}
void vtkHandlerWidget::OnLeftButtonDown() {
void HandlerWidget::OnLeftButtonDown() {
int X = this->Interactor->GetEventPosition()[0];
int Y = this->Interactor->GetEventPosition()[1];
@@ -322,7 +322,7 @@ void vtkHandlerWidget::OnLeftButtonDown() {
}
}
void vtkHandlerWidget::OnLeftButtonUp() {
void HandlerWidget::OnLeftButtonUp() {
if (this->Interaction == IDLE)
return;
@@ -332,7 +332,7 @@ void vtkHandlerWidget::OnLeftButtonUp() {
this->Interactor->Render();
}
void vtkHandlerWidget::OnMouseMove() {
void HandlerWidget::OnMouseMove() {
if (!this->Prop3D || !this->CurrentRenderer)
return;
@@ -564,37 +564,37 @@ void vtkHandlerWidget::OnMouseMove() {
this->Interactor->Render();
}
void vtkHandlerWidget::SetReferenceFrame(ReferenceFrame frame) {
void HandlerWidget::SetReferenceFrame(ReferenceFrame frame) {
this->m_Frame = frame;
this->UpdateGizmoPosition();
if (this->Interactor)
this->Interactor->Render();
}
void vtkHandlerWidget::PlaceWidget(double bounds[6]) {
void HandlerWidget::PlaceWidget(double bounds[6]) {
(void)bounds;
this->UpdateGizmoPosition();
}
void vtkHandlerWidget::SetTranslationEnabled(bool enabled) {
void HandlerWidget::SetTranslationEnabled(bool enabled) {
this->m_TranslationEnabled = enabled;
this->UpdateVisibility();
if (this->Interactor) this->Interactor->Render();
}
void vtkHandlerWidget::SetRotationEnabled(bool enabled) {
void HandlerWidget::SetRotationEnabled(bool enabled) {
this->m_RotationEnabled = enabled;
this->UpdateVisibility();
if (this->Interactor) this->Interactor->Render();
}
void vtkHandlerWidget::SetScalingEnabled(bool enabled) {
void HandlerWidget::SetScalingEnabled(bool enabled) {
this->m_ScalingEnabled = enabled;
this->UpdateVisibility();
if (this->Interactor) this->Interactor->Render();
}
void vtkHandlerWidget::UpdateVisibility() {
void HandlerWidget::UpdateVisibility() {
if (!d->m_AxesX) return;
d->m_AxesX->SetVisibility(m_TranslationEnabled);
@@ -633,22 +633,22 @@ void vtkHandlerWidget::UpdateVisibility() {
}
}
void vtkHandlerWidget::PlaceWidget() { this->UpdateGizmoPosition(); }
void HandlerWidget::PlaceWidget() { this->UpdateGizmoPosition(); }
void vtkHandlerWidget::SetTransform(::vtkTransform *t) {
void HandlerWidget::SetTransform(::vtkTransform *t) {
if (!t || !this->Prop3D)
return;
this->Prop3D->SetUserMatrix(t->GetMatrix());
this->UpdateGizmoPosition();
}
void vtkHandlerWidget::GetTransform(::vtkTransform *t) {
void HandlerWidget::GetTransform(::vtkTransform *t) {
if (!t || !this->Prop3D)
return;
t->SetMatrix(this->Prop3D->GetMatrix());
}
void vtkHandlerWidget::CreateGizmos() {
void HandlerWidget::CreateGizmos() {
auto create_arrow = [](double dir[3], double color[3]) {
auto arrow = vtkSmartPointer<::vtkArrowSource>::New();
arrow->SetTipLength(0.2);
@@ -756,7 +756,7 @@ void vtkHandlerWidget::CreateGizmos() {
d->m_Picker->PickFromListOn();
}
void vtkHandlerWidget::UpdateGizmoPosition() {
void HandlerWidget::UpdateGizmoPosition() {
if (!this->Prop3D)
return;
@@ -909,7 +909,7 @@ void vtkHandlerWidget::UpdateGizmoPosition() {
}
}
void vtkHandlerWidget::Highlight(::vtkProp *prop) {
void HandlerWidget::Highlight(::vtkProp *prop) {
if (this->d->m_HighlightedProp == prop)
return;

View File

@@ -26,7 +26,7 @@
#ifndef U_VTKHANDLERWIDGET_H
#define U_VTKHANDLERWIDGET_H
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "uLibVtkInterface.h"
#include <vtk3DWidget.h>
@@ -48,16 +48,16 @@ namespace uLib {
namespace Vtk {
/**
* @class vtkHandlerWidget
* @class HandlerWidget
* @brief A Blender-like transform gizmo for move, rotate, and scale.
*/
class vtkHandlerWidget : public ::vtk3DWidget {
class HandlerWidget : public ::vtk3DWidget {
public:
static vtkHandlerWidget *New();
vtkTypeMacro(vtkHandlerWidget, ::vtk3DWidget);
static HandlerWidget *New();
vtkTypeMacro(HandlerWidget, ::vtk3DWidget);
vtkHandlerWidget();
virtual ~vtkHandlerWidget();
HandlerWidget();
virtual ~HandlerWidget();
virtual void SetEnabled(int enabling) override;
static void ProcessEvents(::vtkObject *caller, unsigned long event,
@@ -134,8 +134,8 @@ public:
void OnKeyPress();
private:
vtkHandlerWidget(const vtkHandlerWidget &) = delete;
void operator=(const vtkHandlerWidget &) = delete;
HandlerWidget(const HandlerWidget &) = delete;
void operator=(const HandlerWidget &) = delete;
};
} // namespace Vtk

View File

@@ -30,7 +30,7 @@
#include "Math/Dense.h"
#include "Vtk/Math/vtkDense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonScatter.h"
@@ -39,11 +39,11 @@ class vtkRenderWindowInteractor;
namespace uLib {
class vtkMuonContainerScattering : public Abstract::uLibVtkPolydata {
typedef MuonScatter Content;
class MuonContainerScattering : public Abstract::uLibVtkPolydata {
typedef uLib::MuonScatter Content;
public:
vtkMuonContainerScattering(const MuonScatter &content);
~vtkMuonScatter();
MuonContainerScattering(const MuonScatter &content);
~MuonScatter();
Content& GetContent();

View File

@@ -4,35 +4,43 @@
#include "Vtk/Math/vtkAssembly.h"
#include "Vtk/Math/vtkVoxImage.h"
#include "HEP/Detectors/vtkDetectorChamber.h"
#include "HEP/Geant/vtkBoxSolid.h"
#include "Vtk/HEP/Detectors/vtkDetectorChamber.h"
#include "Vtk/HEP/Geant/vtkBoxSolid.h"
#include <vtkAssembly.h>
#include <vtkPropCollection.h>
#include <iostream>
#include <cstring>
#include "Math/ContainerBox.h"
#include "Math/Cylinder.h"
#include "Math/Assembly.h"
#include "Math/VoxImage.h"
#include "HEP/Detectors/DetectorChamber.h"
#include "HEP/Geant/Solid.h"
namespace uLib {
namespace Vtk {
vtkObjectsContext::vtkObjectsContext(uLib::ObjectsContext *context)
ObjectsContext::ObjectsContext(uLib::ObjectsContext *context)
: m_Context(context), m_Assembly(::vtkAssembly::New()) {
this->SetProp(m_Assembly);
if (m_Context) {
Object::connect(m_Context, &uLib::ObjectsContext::ObjectAdded, this, &vtkObjectsContext::OnObjectAdded);
Object::connect(m_Context, &uLib::ObjectsContext::ObjectRemoved, this, &vtkObjectsContext::OnObjectRemoved);
Object::connect(m_Context, &uLib::ObjectsContext::ObjectAdded, this, &ObjectsContext::OnObjectAdded);
Object::connect(m_Context, &uLib::ObjectsContext::ObjectRemoved, this, &ObjectsContext::OnObjectRemoved);
this->Synchronize();
}
}
vtkObjectsContext::~vtkObjectsContext() {
ObjectsContext::~ObjectsContext() {
for (auto const& [obj, puppet] : m_Puppets) {
delete puppet;
}
m_Assembly->Delete();
}
void vtkObjectsContext::Synchronize() {
void ObjectsContext::Synchronize() {
if (!m_Context) return;
// 1. Identify objects to add and remove
@@ -70,7 +78,7 @@ void vtkObjectsContext::Synchronize() {
}
}
void vtkObjectsContext::OnObjectAdded(uLib::Object* obj) {
void ObjectsContext::OnObjectAdded(uLib::Object* obj) {
if (!obj) return;
if (m_Puppets.find(obj) == m_Puppets.end()) {
Puppet* puppet = this->CreatePuppet(obj);
@@ -83,7 +91,7 @@ void vtkObjectsContext::OnObjectAdded(uLib::Object* obj) {
}
}
void vtkObjectsContext::OnObjectRemoved(uLib::Object* obj) {
void ObjectsContext::OnObjectRemoved(uLib::Object* obj) {
if (!obj) return;
auto it = m_Puppets.find(obj);
if (it != m_Puppets.end()) {
@@ -97,55 +105,55 @@ void vtkObjectsContext::OnObjectRemoved(uLib::Object* obj) {
}
}
Puppet* vtkObjectsContext::GetPuppet(uLib::Object* obj) {
Puppet* ObjectsContext::GetPuppet(uLib::Object* obj) {
auto it = m_Puppets.find(obj);
if (it != m_Puppets.end()) return it->second;
return nullptr;
}
void vtkObjectsContext::Update() {
void ObjectsContext::Update() {
for (auto const& [obj, puppet] : m_Puppets) {
puppet->Update();
}
}
void vtkObjectsContext::SyncFromVtk() {
void ObjectsContext::SyncFromVtk() {
for (auto const& [obj, puppet] : m_Puppets) {
puppet->SyncFromVtk();
}
}
Puppet* vtkObjectsContext::CreatePuppet(uLib::Object* obj) {
Puppet* ObjectsContext::CreatePuppet(uLib::Object* obj) {
if (!obj) return nullptr;
if (auto* vox = dynamic_cast<uLib::Abstract::VoxImage*>(obj)) {
return new vtkVoxImage(*vox);
return new VoxImage(*vox);
} else if (auto* box = dynamic_cast<uLib::ContainerBox*>(obj)) {
return new vtkContainerBox(box);
return new ContainerBox(box);
} else if (auto* chamber = dynamic_cast<uLib::DetectorChamber*>(obj)) {
return new vtkDetectorChamber(chamber);
return new DetectorChamber(chamber);
} else if (auto* cylinder = dynamic_cast<uLib::Cylinder*>(obj)) {
return new vtkCylinder(cylinder);
return new Cylinder(cylinder);
} else if (auto* assembly = dynamic_cast<uLib::Assembly*>(obj)) {
return new Assembly(assembly);
} else if (auto* box = dynamic_cast<uLib::Geant::BoxSolid*>(obj)) {
return new vtkBoxSolid(box);
return new BoxSolid(box);
}
// Fallback if we don't know the exact class but it might be a context itself
if (auto subCtx = dynamic_cast<uLib::ObjectsContext*>(obj)) {
return new vtkObjectsContext(subCtx);
return new ObjectsContext(subCtx);
}
return nullptr;
}
void vtkObjectsContext::PuppetAdded(Puppet* puppet) {
ULIB_SIGNAL_EMIT(vtkObjectsContext::PuppetAdded, puppet);
void ObjectsContext::PuppetAdded(Puppet* puppet) {
ULIB_SIGNAL_EMIT(ObjectsContext::PuppetAdded, puppet);
}
void vtkObjectsContext::PuppetRemoved(Puppet* puppet) {
ULIB_SIGNAL_EMIT(vtkObjectsContext::PuppetRemoved, puppet);
void ObjectsContext::PuppetRemoved(Puppet* puppet) {
ULIB_SIGNAL_EMIT(ObjectsContext::PuppetRemoved, puppet);
}
} // namespace Vtk

View File

@@ -11,13 +11,13 @@ namespace uLib {
namespace Vtk {
/**
* @brief vtkObjectsContext manages VTK representations (Puppets) for a collection of uLib::Objects.
* @brief ObjectsContext manages VTK representations (Puppets) for a collection of uLib::Objects.
*/
class vtkObjectsContext : public Puppet {
class ObjectsContext : public Puppet {
public:
uLibTypeMacro(vtkObjectsContext, Puppet)
vtkObjectsContext(uLib::ObjectsContext *context);
virtual ~vtkObjectsContext();
uLibTypeMacro(ObjectsContext, Puppet)
ObjectsContext(uLib::ObjectsContext *context);
virtual ~ObjectsContext();
/** @brief Synchronizes the VTK puppets with the core ObjectsContext. */
void Synchronize();

View File

@@ -31,9 +31,9 @@
#include <cstdlib>
#include "vtkHandlerWidget.h"
#include "vtkObjectsContext.h"
#include "Math/Assembly.h"
#include "Math/ContainerBox.h"
#include "Math/Cylinder.h"
#include "Vtk/Math/vtkAssembly.h"
#include "Vtk/Math/vtkContainerBox.h"
#include "Vtk/Math/vtkCylinder.h"
#include "Math/Transform.h"
#include "Vtk/Math/vtkAssembly.h"
@@ -53,7 +53,7 @@ struct ViewportData {
vtkSmartPointer<vtkNamedColors> m_Colors;
vtkSmartPointer<vtkHandlerWidget> m_HandlerWidget;
vtkSmartPointer<HandlerWidget> m_HandlerWidget;
vtkSmartPointer<vtkCellPicker> m_Picker;
vtkSmartPointer<vtkCallbackCommand> m_KeyCallback;
@@ -194,7 +194,7 @@ void Viewport::SetupPipeline(vtkRenderWindowInteractor* iren)
// Setup Handler Widget
if (!std::getenv("CTEST_PROJECT_NAME")) {
pv->m_HandlerWidget = vtkSmartPointer<vtkHandlerWidget>::New();
pv->m_HandlerWidget = vtkSmartPointer<HandlerWidget>::New();
pv->m_HandlerWidget->SetInteractor(iren);
pv->m_HandlerWidget->SetCurrentRenderer(pv->m_Renderer);
if (pv->m_HandlerWidget->GetOverlayRenderer()) {
@@ -308,28 +308,28 @@ void Viewport::SetupPipeline(vtkRenderWindowInteractor* iren)
if (self->pv->m_HandlerWidget && self->pv->m_HandlerWidget->GetEnabled()) {
if (key == "l") {
if (event == vtkCommand::KeyPressEvent) {
self->pv->m_HandlerWidget->SetReferenceFrame(vtkHandlerWidget::LOCAL);
self->pv->m_HandlerWidget->SetReferenceFrame(HandlerWidget::LOCAL);
std::cout << "Widget Frame: LOCAL" << std::endl;
}
handled = true;
}
else if (key == "g") {
if (event == vtkCommand::KeyPressEvent) {
self->pv->m_HandlerWidget->SetReferenceFrame(vtkHandlerWidget::GLOBAL);
self->pv->m_HandlerWidget->SetReferenceFrame(HandlerWidget::GLOBAL);
std::cout << "Widget Frame: GLOBAL" << std::endl;
}
handled = true;
}
else if (key == "c") {
if (event == vtkCommand::KeyPressEvent) {
self->pv->m_HandlerWidget->SetReferenceFrame(vtkHandlerWidget::CENTER);
self->pv->m_HandlerWidget->SetReferenceFrame(HandlerWidget::CENTER);
std::cout << "Widget Frame: CENTER" << std::endl;
}
handled = true;
}
else if (key == "k") {
if (event == vtkCommand::KeyPressEvent) {
self->pv->m_HandlerWidget->SetReferenceFrame(vtkHandlerWidget::CENTER_LOCAL);
self->pv->m_HandlerWidget->SetReferenceFrame(HandlerWidget::CENTER_LOCAL);
std::cout << "Widget Frame: CENTER_LOCAL" << std::endl;
}
handled = true;
@@ -480,7 +480,7 @@ void Viewport::UnregisterPuppet(Puppet* p) {
p->DisconnectRenderer(pv->m_Renderer);
}
void Viewport::ObserveContext(vtkObjectsContext* ctx) {
void Viewport::ObserveContext(ObjectsContext* ctx) {
if (!ctx) return;
// Process existing puppets
@@ -489,10 +489,10 @@ void Viewport::ObserveContext(vtkObjectsContext* ctx) {
}
// Listen for future puppets
uLib::Object::connect(ctx, &vtkObjectsContext::PuppetAdded, [this](Puppet* p){
uLib::Object::connect(ctx, &ObjectsContext::PuppetAdded, [this](Puppet* p){
this->RegisterPuppet(p, true);
});
uLib::Object::connect(ctx, &vtkObjectsContext::PuppetRemoved, [this](Puppet* p){
uLib::Object::connect(ctx, &ObjectsContext::PuppetRemoved, [this](Puppet* p){
this->UnregisterPuppet(p);
});
}

View File

@@ -28,7 +28,8 @@ namespace uLib {
namespace Vtk {
struct ViewportData;
class vtkHandlerWidget;
class HandlerWidget;
class ObjectsContext;
/**
* @class Viewport
@@ -85,7 +86,7 @@ protected:
// Internal puppet registration
void RegisterPuppet(Puppet* p, bool isPart = false);
void UnregisterPuppet(Puppet* p);
void ObserveContext(class vtkObjectsContext* ctx);
void ObserveContext(ObjectsContext* ctx);
struct ViewportData *pv;
Axis m_GridAxis;