#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
-#include <vtkSphere.h>
+#include <vtkMapper.h>
#include <vtkSphereRepresentation.h>
-#include <vtkSphereWidget2.h>
+#include <vtkImageSliceMapper.h>
#include <vtkCommand.h>
#include <vtkCallbackCommand.h>
std::string _img = "C://img//SphereVolume.mhd";
vtkSmartPointer<cpExtensions::Visualization::ImageSliceActors> image_actors;
+vtkSmartPointer<cpExtensions::Interaction::SphereWidget> sphereWidget;
-void WheelCallbackFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* vtkNotUsed(callData))
+
+void WheelCallbackFunction(vtkObject* caller, long unsigned int eventId, void* vtkNotUsed(clientData), void* vtkNotUsed(callData))
{
std::cout << "WheelCallbackFunction callback" << std::endl;
- vtkSmartPointer<TSphereWidget> sphere =
- reinterpret_cast<TSphereWidget*>(clientData);
-
- // double * center = image_actors->GetImageActor()->GetCenter();
- double * center = image_actors->GetPlaneActor()->GetCenter();
- auto slice = image_actors->GetSliceNumber();
- std::cout << "plane: [" << center[0] << " , " << center[1] + slice << " , " << (center[2] + 19)*(-1) << "] " << std::endl;
- std::cout << "slice #. " << slice <<std::endl;
-
- sphere->SetCenter(center);
+ vtkMapper * mapper = image_actors->GetPlaneActor()->GetMapper();
+ //vtkImageSliceMapper* imageSliceMapper = dynamic_cast<vtkImageSliceMapper*>(mapper);
+ //vtkImageSliceMapper* imageSliceMapper = vtkImageSliceMapper::SafeDownCast(mapper);
+ vtkAbstractMapper3D* abs = dynamic_cast<vtkAbstractMapper3D*>(mapper);
+ auto imgSliceMap = vtkImageSliceMapper::SafeDownCast(abs);
+ auto center = imgSliceMap->GetCenter();
+
+
+ sphereWidget->SetCenter(center);
+ //actor mapper -> cast image slice mapper -> cast dynamic plane
}
+
int main(int argc, char* argv[])
{
if (argc >= 3)
placer->SetImageActor(image_actors->GetImageActor());
// Create a sphere widget
- vtkSmartPointer<TSphereWidget> sphereWidget =
+ sphereWidget =
vtkSmartPointer<TSphereWidget>::New();
sphereWidget->SetInteractor(interactor);
this->Superclass::SetCenter(center);
this->SphereActor->SetPosition(center);
this->SphereActor->Modified();
+ this->Modified();
this->GetInteractor()->Render();
}
self->Superclass::SetCenter(center);
self->SphereActor->SetPosition(center);
self->SphereActor->Modified();
+ self->Modified();
+ self->GetInteractor()->Render();
- std::cout << "sphere: {" << center[0] << " , " << center[1] << " , " << center[2] + 19 << "} " << std::endl;
+ std::cout << "sphere: {" << center[0] << " , " << center[1] << " , " << center[2] << "} " << std::endl;
}
// -------------------------------------------------------------------------