From: Jose Luis Guzman Date: Thu, 5 Nov 2015 14:10:30 +0000 (+0100) Subject: sphere widget update X-Git-Tag: v0.1~306 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1d209899b01c1b3620f98c4fb716d02f58b42c60;p=cpPlugins.git sphere widget update --- diff --git a/appli/examples/example_SphereWidget.cxx b/appli/examples/example_SphereWidget.cxx index db3626f..64ab709 100644 --- a/appli/examples/example_SphereWidget.cxx +++ b/appli/examples/example_SphereWidget.cxx @@ -11,9 +11,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include @@ -36,26 +36,29 @@ std::string _pathIOplugin = "C://dev//creatis//cpPlugins//build//Debug//cpPlugin std::string _img = "C://img//SphereVolume.mhd"; vtkSmartPointer image_actors; +vtkSmartPointer 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 sphere = - reinterpret_cast(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 <SetCenter(center); + vtkMapper * mapper = image_actors->GetPlaneActor()->GetMapper(); + //vtkImageSliceMapper* imageSliceMapper = dynamic_cast(mapper); + //vtkImageSliceMapper* imageSliceMapper = vtkImageSliceMapper::SafeDownCast(mapper); + vtkAbstractMapper3D* abs = dynamic_cast(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) @@ -125,7 +128,7 @@ int main(int argc, char* argv[]) placer->SetImageActor(image_actors->GetImageActor()); // Create a sphere widget - vtkSmartPointer sphereWidget = + sphereWidget = vtkSmartPointer::New(); sphereWidget->SetInteractor(interactor); diff --git a/lib/cpExtensions/Interaction/SphereWidget.cxx b/lib/cpExtensions/Interaction/SphereWidget.cxx index 0b94465..1778d3f 100644 --- a/lib/cpExtensions/Interaction/SphereWidget.cxx +++ b/lib/cpExtensions/Interaction/SphereWidget.cxx @@ -93,6 +93,7 @@ void cpExtensions::Interaction::SphereWidget::SetCenter(double * center) this->Superclass::SetCenter(center); this->SphereActor->SetPosition(center); this->SphereActor->Modified(); + this->Modified(); this->GetInteractor()->Render(); } @@ -103,8 +104,10 @@ void cpExtensions::Interaction::SphereWidget::SetCenter(void* data, double * cen 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; } // -------------------------------------------------------------------------