fixed vtk containerbox handler
This commit is contained in:
@@ -110,21 +110,13 @@ BOOST_AUTO_TEST_CASE(vtkVoxRaytracerRepresentationTest) {
|
||||
// renderer //
|
||||
Vtk::Viewer viewer;
|
||||
|
||||
// widget //
|
||||
vtkBoxWidget *widget = v_grid.GetWidget();
|
||||
|
||||
vtkWidgetCallback *cbk = vtkWidgetCallback::New();
|
||||
cbk->SetTracer(&v_rt);
|
||||
cbk->SetMuon(&muon);
|
||||
cbk->SetAnnotation(viewer.GetAnnotation());
|
||||
widget->AddObserver(vtkCommand::InteractionEvent, cbk);
|
||||
widget->SetInteractor(viewer.GetInteractor());
|
||||
widget->PlaceWidget();
|
||||
widget->On();
|
||||
|
||||
viewer.AddPuppet(v_grid);
|
||||
viewer.AddPuppet(v_rt);
|
||||
viewer.AddPuppet(v_muon);
|
||||
|
||||
// Select grid to show handler widget
|
||||
viewer.SelectPuppet(&v_grid);
|
||||
|
||||
viewer.Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,35 +42,52 @@ namespace Vtk {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content)
|
||||
: m_Content(&content), m_Assembly(vtkAssembly::New()),
|
||||
: m_Content(&content),
|
||||
m_Sphere1(vtkSphereSource::New()), m_Sphere2(vtkSphereSource::New()),
|
||||
m_Line1(vtkLineSource::New()), m_Line2(vtkLineSource::New()),
|
||||
m_Line3(vtkLineSource::New()), m_RayLine(vtkAppendPolyData::New()),
|
||||
m_RayLineActor(vtkActor::New()),
|
||||
m_RayRepresentation(vtkAppendPolyData::New()),
|
||||
m_RayRepresentationActor(vtkActor::New()),
|
||||
m_Transform(vtkTransform::New()) {
|
||||
m_Transform(vtkTransform::New()),
|
||||
m_HasMuon(false), m_HasPoca(false) {
|
||||
default_radius = content.GetImage()->GetSpacing()(0) / 4;
|
||||
m_Sphere1->SetRadius(default_radius);
|
||||
m_Sphere2->SetRadius(default_radius);
|
||||
m_SelectedElement = m_RayLine;
|
||||
|
||||
this->SetSelectable(false);
|
||||
InstallPipe();
|
||||
|
||||
if (m_Content && m_Content->GetImage()) {
|
||||
Object::connect(m_Content->GetImage(), &StructuredGrid::Updated, this, &vtkVoxRaytracerRepresentation::imageUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
vtkVoxRaytracerRepresentation::~vtkVoxRaytracerRepresentation() {
|
||||
m_Assembly->Delete();
|
||||
m_RayLine->Delete();
|
||||
m_RayLineActor->Delete();
|
||||
m_RayRepresentationActor->Delete();
|
||||
m_Transform->Delete();
|
||||
}
|
||||
|
||||
VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm() {
|
||||
uLib::VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm() {
|
||||
return m_Content;
|
||||
}
|
||||
|
||||
vtkProp *vtkVoxRaytracerRepresentation::GetProp() { return m_Assembly; }
|
||||
void vtkVoxRaytracerRepresentation::Update() {
|
||||
this->imageUpdate();
|
||||
}
|
||||
|
||||
void vtkVoxRaytracerRepresentation::imageUpdate() {
|
||||
if (m_HasMuon) {
|
||||
if (m_HasPoca) {
|
||||
this->SetMuon(m_Muon, m_Poca);
|
||||
} else {
|
||||
this->SetMuon(m_Muon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const {
|
||||
std::cout << "get Raytracer polydata\n";
|
||||
@@ -94,6 +111,10 @@ void vtkVoxRaytracerRepresentation::SetRepresentationElements(
|
||||
}
|
||||
|
||||
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
|
||||
m_Muon = muon;
|
||||
m_HasMuon = true;
|
||||
m_HasPoca = false;
|
||||
|
||||
HPoint3f pt1, pt2, src;
|
||||
src = muon.LineIn().origin;
|
||||
m_Content->GetEntryPoint(muon.LineIn(), pt1);
|
||||
@@ -152,6 +173,11 @@ void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
|
||||
}
|
||||
|
||||
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca) {
|
||||
m_Muon = muon;
|
||||
m_Poca = poca;
|
||||
m_HasMuon = true;
|
||||
m_HasPoca = true;
|
||||
|
||||
HPoint3f pt1, pt2, src;
|
||||
src = muon.LineIn().origin;
|
||||
m_Content->GetEntryPoint(muon.LineIn(), pt1);
|
||||
|
||||
@@ -58,7 +58,7 @@ class vtkActor;
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
class vtkVoxRaytracerRepresentation : public Puppet {
|
||||
class vtkVoxRaytracerRepresentation : public Puppet, public Object {
|
||||
typedef VoxRaytracer Content;
|
||||
|
||||
public:
|
||||
@@ -67,7 +67,9 @@ public:
|
||||
|
||||
uLib::VoxRaytracer *GetRaytracerAlgorithm();
|
||||
|
||||
vtkProp *GetProp();
|
||||
virtual void Update() override;
|
||||
|
||||
void imageUpdate();
|
||||
|
||||
vtkPolyData *GetPolyData() const;
|
||||
|
||||
@@ -99,9 +101,12 @@ private:
|
||||
void SetColor(vtkActor *actor, Vector4f rgba);
|
||||
|
||||
VoxRaytracer *m_Content;
|
||||
MuonScatter m_Muon;
|
||||
HPoint3f m_Poca;
|
||||
bool m_HasMuon;
|
||||
bool m_HasPoca;
|
||||
|
||||
Scalarf default_radius;
|
||||
vtkAssembly *m_Assembly;
|
||||
vtkAppendPolyData *m_RayLine;
|
||||
vtkActor *m_RayLineActor;
|
||||
vtkActor *m_RayRepresentationActor;
|
||||
|
||||
Reference in New Issue
Block a user