Commit bf664afe authored by Julien Finet's avatar Julien Finet

ENH: Add testing framework for transfer function 2D items

parent 1050b901
......@@ -28,6 +28,8 @@ SET(Kit_SRCS
vtkChartPie.cxx
vtkPlotPie.cxx
vtkColorSeries.cxx
vtkColorTransferFunctionItem.cxx
vtkCompositeTransferFunctionItem.cxx
vtkContext2D.cxx
vtkContextActor.cxx
vtkContextBufferId.cxx
......@@ -42,12 +44,14 @@ SET(Kit_SRCS
vtkDataValue.cxx
vtkImageItem.cxx
vtkLineMark.cxx
vtkLookupTableItem.cxx
vtkMark.cxx
vtkMarkUtil.cxx
vtkOpenGLContextBufferId.cxx
vtkOpenGLContextDevice2D.cxx
vtkPanelMark.cxx
vtkPen.cxx
vtkPiecewiseFunctionItem.cxx
vtkPlot.cxx
vtkPlotBar.cxx
vtkPlotGrid.cxx
......@@ -55,6 +59,7 @@ SET(Kit_SRCS
vtkPlotStacked.cxx
vtkPlotParallelCoordinates.cxx
vtkPlotPoints.cxx
vtkScalarsToColorsItem.cxx
vtkTooltipItem.cxx
vtkWedgeMark.cxx
)
......@@ -68,6 +73,7 @@ SET_SOURCE_FILES_PROPERTIES(
vtkContextMapper2D
vtkDataValue
vtkPlot
vtkScalarsToColorsItem.cxx
ABSTRACT
)
......
......@@ -8,6 +8,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_VIEWS)
TestPCPlot.cxx
TestDiagram.cxx
TestLinePlot.cxx
TestScalarsToColors.cxx
TestStackedPlot.cxx
TestBarGraph.cxx
TestStackedBarGraph.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestLinePlot.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkColorTransferFunction.h"
#include "vtkColorTransferFunctionItem.h"
#include "vtkCompositeTransferFunctionItem.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
#include "vtkFloatArray.h"
#include "vtkLookupTable.h"
#include "vtkLookupTableItem.h"
#include "vtkPiecewiseFunction.h"
#include "vtkPiecewiseFunctionItem.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
//----------------------------------------------------------------------------
int TestScalarsToColors( int argc, char * argv [] )
{
// Set up a 2D scene, add an XY chart to it
vtkSmartPointer<vtkContextView> view =
vtkSmartPointer<vtkContextView>::New();
view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
view->GetRenderWindow()->SetSize(400, 300);
//vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
//view->GetScene()->AddItem(chart);
vtkSmartPointer<vtkLookupTable> lookupTable =
vtkSmartPointer<vtkLookupTable>::New();
lookupTable->Build();
//vtkSmartPointer<vtkLookupTableChart> lChart =
// vtkSmartPointer<vtkLookupTableChart>::New();
//lChart->SetLookupTable(lookupTable);
//lChart->SetChart(chart);
vtkSmartPointer<vtkLookupTableItem> item =
vtkSmartPointer<vtkLookupTableItem>::New();
item->SetLookupTable(lookupTable);
//view->GetScene()->AddItem(item);
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
vtkSmartPointer<vtkColorTransferFunction>::New();
colorTransferFunction->AddHSVSegment(0.,0.,1.,1.,0.3333,0.3333,1.,1.);
colorTransferFunction->AddHSVSegment(0.3333,0.3333,1.,1.,0.6666,0.6666,1.,1.);
colorTransferFunction->AddHSVSegment(0.6666,0.6666,1.,1.,1.,0.,1.,1.);
colorTransferFunction->Build();
vtkSmartPointer<vtkColorTransferFunctionItem> item2 =
vtkSmartPointer<vtkColorTransferFunctionItem>::New();
item2->SetColorTransferFunction(colorTransferFunction);
//view->GetScene()->AddItem(item2);
vtkSmartPointer<vtkPiecewiseFunction> opacityFunction =
vtkSmartPointer<vtkPiecewiseFunction>::New();
opacityFunction->AddPoint(0.,0.);
opacityFunction->AddPoint(1.,1.);
vtkSmartPointer<vtkCompositeTransferFunctionItem> item3 =
vtkSmartPointer<vtkCompositeTransferFunctionItem>::New();
item3->SetColorTransferFunction(colorTransferFunction);
item3->SetOpacityFunction(opacityFunction);
item3->SetOpacity(0.2);
//view->GetScene()->AddItem(item3);
vtkSmartPointer<vtkPiecewiseFunctionItem> item4 =
vtkSmartPointer<vtkPiecewiseFunctionItem>::New();
item4->SetPiecewiseFunction(opacityFunction);
item4->SetColor(255,0,0);
view->GetScene()->AddItem(item4);
//Finally render the scene and compare the image to a reference image
//view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
return !retVal;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment