# Synchronize two windows

**URL:** https://discourse.vtk.org/t/synchronize-two-windows/1703
**Category:** Development
**Created:** [September 5, 2019, 10:47am UTC](https://discourse.vtk.org/t/synchronize-two-windows/1703 "2019-09-05T10:47:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![1111](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/1/71e660/32.png) [@1111](https://discourse.vtk.org/u/1111)
#### Post date: [September 5, 2019, 10:47am UTC](https://discourse.vtk.org/t/synchronize-two-windows/1703/1 "2019-09-05T10:47:34Z")

</div>

Hi,  
Currently, we are creating a program that displays the display in vtkImplicitPlaneWidget2 and the plane in vtkImplicitPlaneWidget2 in two dimensions.

The display was successful in the two windows.  
However, when a plane in vtkImplicitPlaneWidget2 is selected, the 2D image cannot be updated automatically.

I want to automatically display 2D at the same time as selecting a plane.

Can you tell me where to improve?  
A portion of my code is shown below.

```
  class vtkIPWCallback : public vtkCommand
 {
 public:
static vtkIPWCallback *New()
{ return new vtkIPWCallback; }

virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkImplicitPlaneWidget2 *planeWidget =
  reinterpret_cast<vtkImplicitPlaneWidget2*>(caller);
vtkImplicitPlaneRepresentation *rep =
  reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation());
rep->GetPlane(this->Plane);

double normal[3];
Plane->GetNormal(normal);
double Origin[3];
Plane->GetOrigin(Origin);

// Set the slice orientation
vtkSmartPointer<vtkMatrix4x4> resliceMatrix =
vtkSmartPointer<vtkMatrix4x4>::New();
 (Compute of the 4x4 matrix)

vtkImageReslice *reslice = this->Reslice;
reslice->SetResliceAxes(resliceMatrix);
reslice->Update();
}
vtkIPWCallback():Plane(0) {}
vtkPlane *Plane;
vtkImageReslice *Reslice;
};

```

Reslice part code

```
  // Set the slice orientation
  vtkSmartPointer<vtkMatrix4x4> resliceMatrix =
  vtkSmartPointer<vtkMatrix4x4>::New();

  //Compute the center of the slice plane
int n = 512; // size in pixels
double s = 1.0; // size of each pixel

 // Extract a slice in the desired orientation
vtkSmartPointer<vtkImageReslice> reslice =
vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputConnection(reader->GetOutputPort());
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxes(resliceMatrix);
reslice->SetInterpolationModeToLinear();
reslice->SetOutputOrigin(0.0, 0.0, 0.0);
reslice->SetOutputExtent(0, n-1, 0, n-1, 0, 0);
reslice->SetOutputSpacing(s, s, s);
reslice->UpdateWholeExtent();
reslice->Update();

```

@dgobbi
