{
std::cout << "WheelCallbackFunction callback" << std::endl;
- vtkMapper * mapper = image_actors->GetPlaneActor()->GetMapper();
- //vtkImageSliceMapper* imageSliceMapper = dynamic_cast<vtkImageSliceMapper*>(mapper);
- //vtkImageSliceMapper* imageSliceMapper = vtkImageSliceMapper::SafeDownCast(mapper);
-
+ int axis = image_actors->GetAxis();
+ vtkImageMapper3D * mapper = image_actors->GetImageActor()->GetMapper();
vtkAbstractMapper3D* abs = dynamic_cast<vtkAbstractMapper3D*>(mapper);
auto imgSliceMap = vtkImageSliceMapper::SafeDownCast(abs);
- auto center = imgSliceMap->GetCenter();
+ // auto centerImg = imgSliceMap->GetCenter();
-
+ auto center = image_actors->GetPlaneActor()->GetCenter();
+
+ std::cout << "plane: {" << center[0] << " , " << center[1] << " , " << center[2] << "} " << std::endl;
+ //std::cout << "slice: {" << centerImg[0] << " , " << centerImg[1] << " , " << centerImg[2] << "} " << std::endl;
+
+ switch (axis)
+ {
+ case 0: // X
+ center[1] = sphereWidget->GetPosition()[1];
+ center[2] = sphereWidget->GetPosition()[2];
+ break;
+ case 1: // Y
+ center[0] = sphereWidget->GetPosition()[0];
+ center[2] = sphereWidget->GetPosition()[2];
+ break;
+ case 2: // Z
+ center[1] = sphereWidget->GetPosition()[1];
+ center[0] = sphereWidget->GetPosition()[0];
+ break;
+ default:
+ break;
+ }
+
sphereWidget->SetCenter(center);
- //actor mapper -> cast image slice mapper -> cast dynamic plane
+
}
// Create slice actors
image_actors = vtkSmartPointer< TSliceActors >::New();
image_actors->SetInputImage(image->GetVTK< vtkImageData >());
- image_actors->SetAxis(2);
+ image_actors->SetAxis(0);
image_actors->PushActorsInto(window);
vtkSmartPointer< vtkImageActorPointPlacer > placer =
sphereWidget =
vtkSmartPointer<TSphereWidget>::New();
sphereWidget->SetInteractor(interactor);
+ sphereWidget->SetAxis(image_actors->GetAxis()); //sinchronize image pane with sphere plane
vtkSmartPointer<vtkCallbackCommand> myCallBack =
vtkSmartPointer<vtkCallbackCommand>::New();
SphereWidget()
: Superclass()
{
+ //this->SetAxis(0);
+
this->SetTranslation(0);
this->SetRadius(7);
{
SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
self->Superclass::EndInteraction();
-
-
}
// -------------------------------------------------------------------------
self->Superclass::StartInteraction();*/
}
+void cpExtensions::Interaction::SphereWidget::SetAxis(int axis)
+{
+ this->m_axis = axis;
+}
+
+
+void cpExtensions::Interaction::SphereWidget::SetAxis(void* data, int axis)
+{
+ SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
+ self->SetAxis(axis);
+}
+
+int cpExtensions::Interaction::SphereWidget::GetAxis()
+{
+ return this->m_axis;
+}
+
+int cpExtensions::Interaction::SphereWidget::GetAxis(void* data)
+{
+ SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
+ return self->GetAxis();
+}
+
+double* cpExtensions::Interaction::SphereWidget::GetPosition()
+{
+ return this->SphereActor->GetPosition();
+}
+
+double* cpExtensions::Interaction::SphereWidget::GetPosition(void* data)
+{
+ SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
+ return self->GetPosition();
+}
+
void cpExtensions::Interaction::SphereWidget::SetCenter(double * center)
{
- this->Superclass::SetCenter(center);
+ //this->Superclass::SetCenter(center);
this->SphereActor->SetPosition(center);
this->SphereActor->Modified();
this->Modified();
{
SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
- self->Superclass::SetCenter(center);
+ //self->Superclass::SetCenter(center);
self->SphereActor->SetPosition(center);
self->SphereActor->Modified();
self->Modified();
SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
self->Superclass::StartInteraction();
- double * center = self->GetCenter();
+ double * center = self->SphereActor->GetPosition();
auto radius = self->GetRadius();
+ auto axis = self->GetAxis();
+
switch (key)
{
case 122: // Z & z
break;
case 119: // W & w
case 87:
- center[0] += 1;
+ if (axis == 0)
+ {
+ center[2] += 1;
+ } else if (axis == 1)
+ {
+ center[2] += 1;
+ } else
+ {
+ center[1] -= 1;
+ }
+
break;
case 83: // S & s
case 115:
- center[0] -= 1;
+ if (axis == 0)
+ {
+ center[2] -= 1;
+ }
+ else if (axis == 1)
+ {
+ center[2] -= 1;
+ }
+ else
+ {
+ center[1] += 1;
+ }
break;
case 65: // A & a
case 97:
- center[1] += 1;
+ if (axis == 0)
+ {
+ center[1] -= 1;
+ }
+ else if (axis == 1)
+ {
+ center[0] -= 1;
+ }
+ else
+ {
+ center[0] += 1;
+ }
break;
case 100: // D & d
case 68:
- center[1] -= 1;
+ if (axis == 0)
+ {
+ center[1] += 1;
+ }
+ else if (axis == 1)
+ {
+ center[0] += 1;
+ }
+ else
+ {
+ center[0] -= 1;
+ }
break;
- case 81: // Q & q
- case 113:
- center[2] += 1;
-
- break;
- case 69: // E & e
- case 101:
- center[2] -= 1;
-
- break;
+ //case 81: // Q & q
+ //case 113:
+ // center[2] += 1;
+ //
+ // break;
+ //case 69: // E & e
+ //case 101:
+ // center[2] -= 1;
+ //
+ // break;
default:
break;
virtual void SetInteractor( vtkRenderWindowInteractor* rwi );
void SetCenter(double* center);
-
-
+ void SetAxis(int axis);
+ int GetAxis();
+ double * GetPosition();
protected:
SphereWidget( );
virtual ~SphereWidget( );
static void SetCenter(void* data, double* center);
+ static void SetAxis(void* data, int axis);
+ static int GetAxis(void* data);
+ static double * GetPosition(void* data);
private:
+ int m_axis;
+
// Purposely not implemented
SphereWidget( const Self& );
Self& operator=( const Self& );