]> Creatis software - cpPlugins.git/commitdiff
sphere widget update
authorJose Luis Guzman <cycopepe@gmail.com>
Thu, 5 Nov 2015 14:10:30 +0000 (15:10 +0100)
committerJose Luis Guzman <cycopepe@gmail.com>
Thu, 5 Nov 2015 14:10:30 +0000 (15:10 +0100)
appli/examples/example_SphereWidget.cxx
lib/cpExtensions/Interaction/SphereWidget.cxx

index db3626f4f9298af27b3d5c6eac7a5a57ddfbcbf0..64ab70999b98403896008cb6efb3f4da0b224710 100644 (file)
@@ -11,9 +11,9 @@
 #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>
 
@@ -36,26 +36,29 @@ std::string _pathIOplugin = "C://dev//creatis//cpPlugins//build//Debug//cpPlugin
 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)
@@ -125,7 +128,7 @@ int main(int argc, char* argv[])
   placer->SetImageActor(image_actors->GetImageActor());
  
   // Create a sphere widget
-  vtkSmartPointer<TSphereWidget> sphereWidget =
+  sphereWidget =
     vtkSmartPointer<TSphereWidget>::New();
   sphereWidget->SetInteractor(interactor);
 
index 0b944654f0915fd173ce77d050a0c77001d9cb98..1778d3fbfa26996a1e27e9854e83a4e94508730f 100644 (file)
@@ -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;
 }
 
 // -------------------------------------------------------------------------