Skip to content

Commit

Permalink
COMP: Remove support for building against VTK <= 5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Sep 30, 2020
1 parent 4158cbc commit e419cee
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ int vtkLightBoxRendererManagerTest1(int argc, char* argv[])

// Read image
imageReader->SetFileName(imageFilename);
#if (VTK_MAJOR_VERSION <= 5)
imageReader->Update();
vtkImageData* image = imageReader->GetOutput();
#else
vtkAlgorithmOutput* imagePort = imageReader->GetOutputPort();
#endif

//----------------------------------------------------------------------------
// Renderer, RenderWindow and Interactor
Expand Down Expand Up @@ -172,18 +167,11 @@ int vtkLightBoxRendererManagerTest1(int argc, char* argv[])
return EXIT_FAILURE;
}

#if (VTK_MAJOR_VERSION <= 5)
lightBoxRendererManager->SetImageData(image);
#else
lightBoxRendererManager->SetImageDataConnection(imagePort);
#endif

if (mtime != lightBoxRendererManager->GetMTime())
{
#if (VTK_MAJOR_VERSION <= 5)
std::cerr << "line " << __LINE__ << " - Problem with SetImageData()" << std::endl;
#else
std::cerr << "line " << __LINE__ << " - Problem with SetImageDataConnection()" << std::endl;
#endif
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -215,12 +203,7 @@ int vtkLightBoxRendererManagerTest1(int argc, char* argv[])
return EXIT_FAILURE;
}


#if (VTK_MAJOR_VERSION <= 5)
lightBoxRendererManager->SetImageData(image);
#else
lightBoxRendererManager->SetImageDataConnection(imagePort);
#endif
lightBoxRendererManager->SetRenderWindowLayout(4, 5);
lightBoxRendererManager->SetHighlighted(2,2,true);
lightBoxRendererManager->SetColorWindowAndLevel(100, 100);
Expand Down
8 changes: 0 additions & 8 deletions Libs/Visualization/VTK/Core/ctkVTKPythonQtWrapperFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ PyObject* ctkVTKPythonQtWrapperFactory::wrap(const QByteArray& classname, void *
{
if (classname.startsWith("vtk"))
{
#if (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION <= 6) || VTK_MAJOR_VERSION < 5
return vtkPythonGetObjectFromPointer(reinterpret_cast<vtkObjectBase*>(ptr));
#else
return vtkPythonUtil::GetObjectFromPointer(reinterpret_cast<vtkObjectBase*>(ptr));
#endif
}
return NULL;
}
Expand All @@ -36,11 +32,7 @@ void* ctkVTKPythonQtWrapperFactory::unwrap(const QByteArray& classname, PyObject
{
if (classname.startsWith("vtk"))
{
#if (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION <= 6) || VTK_MAJOR_VERSION < 5
return vtkPythonGetPointerFromObject(object, classname.data());
#else
return vtkPythonUtil::GetPointerFromObject(object, classname.data());
#endif
}
return NULL;
}
54 changes: 1 addition & 53 deletions Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ RenderWindowItem::RenderWindowItem(const double rendererBackgroundColor[3],
//-----------------------------------------------------------------------------
RenderWindowItem::~RenderWindowItem()
{
#if (VTK_MAJOR_VERSION <= 5)
this->ImageMapper->SetInput(0);
#else
this->ImageMapper->SetInputConnection(0);
#endif
}

//-----------------------------------------------------------------------------
Expand All @@ -136,11 +132,6 @@ void RenderWindowItem::SetupImageMapperActor(double colorWindow, double colorLev
this->ImageActor = vtkSmartPointer<vtkActor2D>::New();
this->ImageActor->SetMapper(this->ImageMapper);
this->ImageActor->GetProperty()->SetDisplayLocationToBackground();

// .. and add it to the renderer
#if VTK_MAJOR_VERSION <= 5
this->Renderer->AddActor2D(this->ImageActor.GetPointer());
#endif
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -201,15 +192,9 @@ void RenderWindowItem::SetupHighlightedBoxActor(const double highlightedBoxColor
coordinate->SetViewport(this->Renderer);

vtkNew<vtkPolyDataMapper2D> polyDataMapper;
#if VTK_MAJOR_VERSION <= 5
polyDataMapper->SetInput(poly.GetPointer());
#else
polyDataMapper->SetInputData(poly.GetPointer());
#endif
polyDataMapper->SetTransformCoordinate(coordinate.GetPointer());
#if ! (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION == 8)
polyDataMapper->SetTransformCoordinateUseDouble(true);
#endif
polyDataMapper->SetTransformCoordinateUseDouble(true);

this->HighlightedBoxActor = vtkSmartPointer<vtkActor2D>::New();
this->HighlightedBoxActor->SetMapper(polyDataMapper.GetPointer());
Expand All @@ -219,10 +204,6 @@ void RenderWindowItem::SetupHighlightedBoxActor(const double highlightedBoxColor
this->HighlightedBoxActor->GetProperty()->SetDisplayLocationToForeground();
this->HighlightedBoxActor->GetProperty()->SetLineWidth(1.0f);
this->HighlightedBoxActor->SetVisibility(visible);

#if VTK_MAJOR_VERSION <= 5
this->Renderer->AddActor2D(this->HighlightedBoxActor);
#endif
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -257,12 +238,7 @@ class vtkLightBoxRendererManager::vtkInternal
vtkWeakPointer<vtkRenderWindowInteractor> CurrentInteractor;
vtkSmartPointer<vtkCornerAnnotation> CornerAnnotation;
std::string CornerAnnotationText;

#if (VTK_MAJOR_VERSION <= 5)
vtkWeakPointer<vtkImageData> ImageData;
#else
vtkWeakPointer<vtkAlgorithmOutput> ImageDataConnection;
#endif
double ColorWindow;
double ColorLevel;
double RendererBackgroundColor[3];
Expand Down Expand Up @@ -418,9 +394,6 @@ void vtkLightBoxRendererManager::vtkInternal::updateRenderWindowItemsZIndex(int
void vtkLightBoxRendererManager::vtkInternal
::SetItemInput(RenderWindowItem* item)
{
#if (VTK_MAJOR_VERSION <= 5)
item->ImageMapper->SetInput(this->ImageData);
#else
item->ImageMapper->SetInputConnection(this->ImageDataConnection);
bool hasViewProp = item->Renderer->HasViewProp(item->ImageActor);
if (!hasViewProp)
Expand All @@ -431,7 +404,6 @@ ::SetItemInput(RenderWindowItem* item)
item->Renderer->AddActor2D(item->HighlightedBoxActor);
}
item->ImageActor->SetVisibility(this->ImageDataConnection != NULL);
#endif
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -506,27 +478,15 @@ bool vtkLightBoxRendererManager::IsInitialized()
}

//----------------------------------------------------------------------------
#if (VTK_MAJOR_VERSION <= 5)
void vtkLightBoxRendererManager::SetImageData(vtkImageData* newImageData)
#else
void vtkLightBoxRendererManager::SetImageDataConnection(vtkAlgorithmOutput* newImageDataConnection)
#endif
{
if (!this->IsInitialized())
{
#if (VTK_MAJOR_VERSION <= 5)
vtkErrorMacro(<< "SetImageData failed - vtkLightBoxRendererManager is NOT initialized");
#else
vtkErrorMacro(<< "SetImageDataConnection failed - vtkLightBoxRendererManager is NOT initialized");
#endif
return;
}

#if (VTK_MAJOR_VERSION <= 5)
this->Internal->ImageData = newImageData;
#else
this->Internal->ImageDataConnection = newImageDataConnection;
#endif

vtkInternal::RenderWindowItemListIt it;
for(it = this->Internal->RenderWindowItemList.begin();
Expand All @@ -536,11 +496,7 @@ void vtkLightBoxRendererManager::SetImageDataConnection(vtkAlgorithmOutput* newI
this->Internal->SetItemInput(*it);
}

#if (VTK_MAJOR_VERSION <= 5)
if (newImageData)
#else
if (newImageDataConnection)
#endif
{
this->Internal->updateRenderWindowItemsZIndex(this->Internal->RenderWindowLayoutType);
}
Expand Down Expand Up @@ -643,11 +599,7 @@ void vtkLightBoxRendererManager::SetRenderWindowLayoutType(int layoutType)
return;
}

#if (VTK_MAJOR_VERSION <= 5)
if (this->Internal->ImageData)
#else
if (this->Internal->ImageDataConnection)
#endif
{
this->Internal->updateRenderWindowItemsZIndex(layoutType);
}
Expand Down Expand Up @@ -722,11 +674,7 @@ void vtkLightBoxRendererManager::SetRenderWindowLayout(int rowCount, int columnC
this->Internal->setupRendering();
this->Internal->SetupCornerAnnotation();

#if (VTK_MAJOR_VERSION <= 5)
if (this->Internal->ImageData)
#else
if (this->Internal->ImageDataConnection)
#endif
{
this->Internal->updateRenderWindowItemsZIndex(this->Internal->RenderWindowLayoutType);
}
Expand Down
4 changes: 0 additions & 4 deletions Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ class CTK_VISUALIZATION_VTK_CORE_EXPORT vtkLightBoxRendererManager : public vtkO
vtkRenderWindow* GetRenderWindow();

/// Set image data
#if (VTK_MAJOR_VERSION <= 5)
void SetImageData(vtkImageData* newImageData);
#else
void SetImageDataConnection(vtkAlgorithmOutput* newImageDataConnection);
#endif

/// Get active camera
/// Note that the same camera is used with all the renderWindowItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,19 @@ int ctkVTKChartViewTest1(int argc, char * argv [] )

// Add multiple line plots, setting the colors etc
vtkPlotBar* bar = vtkPlotBar::New();
#if (VTK_MAJOR_VERSION <= 5)
bar->SetInput(table.GetPointer(), 0, 1);
#else
bar->SetInputData(table.GetPointer(), 0, 1);
#endif
bar->SetColor(0, 255, 0, 255);
view.addPlot(bar);
bar->Delete();

bar = vtkPlotBar::New();
#if (VTK_MAJOR_VERSION <= 5)
bar->SetInput(table.GetPointer(), 0, 2);
#else
bar->SetInputData(table.GetPointer(), 0, 2);
#endif
bar->SetColor(255, 0, 0, 255);
view.addPlot(bar);
bar->Delete();

bar = vtkPlotBar::New();
#if (VTK_MAJOR_VERSION <= 5)
bar->SetInput(table.GetPointer(), 0, 3);
#else
bar->SetInputData(table.GetPointer(), 0, 3);
#endif
bar->SetColor(0, 0, 255, 255);
view.addPlot(bar);
bar->Delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,14 @@ int ctkVTKMagnifyViewTest2(int argc, char * argv [] )
// Read image
imageReader->SetFileName(imageFilename.toUtf8());
imageReader->Update();
#if (VTK_MAJOR_VERSION <= 5)
vtkImageData* image = imageReader->GetOutput();
#else
vtkAlgorithmOutput* imagePort = imageReader->GetOutputPort();
#endif

// Setup the slice views
for (int i = 0; i < numSliceViews; i++)
{
allSliceViews[i]->setRenderEnabled(true);
allSliceViews[i]->setMinimumSize(350,350);
#if (VTK_MAJOR_VERSION <= 5)
allSliceViews[i]->setImageData(image);
#else
allSliceViews[i]->setImageDataConnection(imagePort);
#endif
allSliceViews[i]->setHighlightedBoxColor(Qt::yellow);
allSliceViews[i]->scheduleRender();
}
Expand Down Expand Up @@ -383,18 +375,10 @@ int ctkVTKMagnifyViewTest2(int argc, char * argv [] )
}

vtkImageGaussianSmooth * gaussian = vtkImageGaussianSmooth::New();
#if (VTK_MAJOR_VERSION <= 5)
gaussian->SetInput(image);
#else
gaussian->SetInputConnection(imagePort);
#endif
gaussian->SetRadiusFactors(5,5);
gaussian->Update();
#if (VTK_MAJOR_VERSION <= 5)
allSliceViews[0]->setImageData(gaussian->GetOutput());
#else
allSliceViews[0]->setImageDataConnection(gaussian->GetOutputPort());
#endif
allSliceViews[0]->scheduleRender();
if (!runBaselineTest(time, app, magnify, allSliceViews[0], true,
baselineDirectory, testType, "h",
Expand All @@ -414,18 +398,10 @@ int ctkVTKMagnifyViewTest2(int argc, char * argv [] )
return EXIT_FAILURE;
}

#if (VTK_MAJOR_VERSION <= 5)
gaussian->SetInput(image);
#else
gaussian->SetInputConnection(imageReader->GetOutputPort());
#endif
gaussian->SetRadiusFactors(0,0);
gaussian->Update();
#if (VTK_MAJOR_VERSION <= 5)
allSliceViews[0]->setImageData(gaussian->GetOutput());
#else
allSliceViews[0]->setImageDataConnection(gaussian->GetOutputPort());
#endif
allSliceViews[0]->scheduleRender();
if (!runBaselineTest(time, app, magnify, allSliceViews[0], true,
baselineDirectory, testType, "h",
Expand All @@ -437,11 +413,7 @@ int ctkVTKMagnifyViewTest2(int argc, char * argv [] )
// Test changing the update interval
magnify->setUpdateInterval(time * 2);
magnify->setObserveRenderWindowEvents(true);
#if (VTK_MAJOR_VERSION <= 5)
allSliceViews[0]->setImageData(image);
#else
allSliceViews[0]->setImageDataConnection(imagePort);
#endif
allSliceViews[0]->scheduleRender();
QCursor::setPos(insideSlice0bottomRightCorner);
// It should be waiting to update here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ int ctkVTKScalarsToColorsViewTest2(int argc, char * argv [] )
image->SetDimensions(256, 256, 1);
image->SetSpacing(20000., 30., 900000000.);
image->SetOrigin(-251234568., 0.00001, 40.2);
#if (VTK_MAJOR_VERSION <= 5)
image->SetScalarTypeToUnsignedChar();
image->SetNumberOfScalarComponents(1); // image holds one value intensities
image->AllocateScalars(); // allocate storage for image data
#else
image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
#endif
unsigned char * ptr = static_cast<unsigned char *>(image->GetScalarPointer());
for (int i=0; i<256*256*1; ++i)
{
Expand All @@ -87,11 +81,7 @@ int ctkVTKScalarsToColorsViewTest2(int argc, char * argv [] )
// Histogram
vtkSmartPointer<vtkImageAccumulate> histogram =
vtkSmartPointer<vtkImageAccumulate>::New();
#if (VTK_MAJOR_VERSION <= 5)
histogram->SetInput(image);
#else
histogram->SetInputData(image);
#endif
histogram->SetComponentExtent(0, 255, 0 , 0 , 0, 0);
histogram->Update();
vtkAbstractArray* bins =
Expand All @@ -116,11 +106,7 @@ int ctkVTKScalarsToColorsViewTest2(int argc, char * argv [] )
//Histogram Plot
vtkSmartPointer<vtkPlotBar> histogramPlot =
vtkSmartPointer<vtkPlotBar>::New();
#if (VTK_MAJOR_VERSION <= 5)
histogramPlot->SetInput(table, 0, 1);
#else
histogramPlot->SetInputData(table, 0, 1);
#endif
histogramPlot->SetColor(0.078, 0.008, 0);//not exactly black...just because.
histogramPlot->GetPen()->SetLineType(vtkPen::NO_PEN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,15 @@ int ctkVTKScalarsToColorsViewTest4(int argc, char * argv [] )

// Add multiple line plots, setting the colors etc
vtkPlot *line = chart->AddPlot(vtkChart::LINE);
#if (VTK_MAJOR_VERSION <= 5)
line->SetInput(table, 0, 1);
#else
line->SetInputData(table, 0, 1);
#endif
line->SetColor(0, 255, 0, 255);
line->SetWidth(1.0);
line = chart->AddPlot(vtkChart::LINE);
#if (VTK_MAJOR_VERSION <= 5)
line->SetInput(table, 0, 2);
#else
line->SetInputData(table, 0, 2);
#endif
line->SetColor(255, 0, 0, 255);
line->SetWidth(5.0);
line = chart->AddPlot(vtkChart::LINE);
#if (VTK_MAJOR_VERSION <= 5)
line->SetInput(table, 0, 3);
#else
line->SetInputData(table, 0, 3);
#endif
line->SetColor(0, 0, 255, 255);
line->SetWidth(4.0);

Expand Down
Loading

0 comments on commit e419cee

Please sign in to comment.