Commit 4ce9cf11 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell Committed by Kitware Robot
Browse files

Merge topic 'charts/tests'

3da3d33d ENH: Ported code to use vtkTestingInteractor.
87f92d15 ENH: Use the vtkTestingObjectFactory.
71c9ca45 ENH: New test for line plot mouse interaction.
parents b44485dd 3da3d33d
# if we have rendering and views add the following tests
IF (VTK_USE_RENDERING AND VTK_USE_VIEWS)
SET(KIT Charts)
# add tests that do not require data
SET(MyTests
......@@ -16,6 +18,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_VIEWS)
TestContextImage.cxx
TestDiagram.cxx
TestLinePlot.cxx
TestLinePlotInteraction.cxx
TestMarks.cxx
TestMarksCallback.cxx
TestMarksWedge.cxx
......@@ -48,8 +51,8 @@ IF (VTK_USE_RENDERING AND VTK_USE_VIEWS)
)
ENDIF (VTK_DATA_ROOT)
ENDIF(VTK_USE_QT)
CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx ${MyTests}
EXTRA_INCLUDE vtkTestDriver.h)
# Use the testing object factory, to reduce boilerplate code in tests.
INCLUDE("${VTK_SOURCE_DIR}/Rendering/vtkTestingObjectFactory.cmake")
ADD_EXECUTABLE(${KIT}CxxTests ${Tests})
TARGET_LINK_LIBRARIES(${KIT}CxxTests vtkCharts)
......
......@@ -90,12 +90,7 @@ int TestBarGraph( int argc, char * argv [] )
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
//int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -59,11 +59,7 @@ int TestContext( int argc, char * argv [] )
view->GetRenderWindow()->Render();
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......
......@@ -49,10 +49,6 @@ int TestContextImage(int argc, char * argv [])
view->GetRenderWindow()->Render();
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -67,11 +67,7 @@ int TestDiagram( int argc, char * argv [] )
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow);
if( retVal == vtkRegressionTester::DO_INTERACTOR)
{
interactor->Start();
}
interactor->Start();
return !retVal;
}
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestContext.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 "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkObjectFactory.h"
#include "vtkContext2D.h"
#include "vtkTransform2D.h"
#include "vtkImageItem.h"
#include "vtkImageData.h"
#include "vtkContextView.h"
#include "vtkContextScene.h"
#include "vtkTextProperty.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkUnicodeString.h"
#include "vtkQtRenderUtility.h"
#include "vtkRegressionTestImage.h"
#include <QApplication>
//----------------------------------------------------------------------------
int TestFreeTypeRender(int argc, char * argv [])
{
QApplication app(argc, argv);
// Set up a 2D context view, context test object and add it to the scene
vtkSmartPointer<vtkContextView> view = vtkSmartPointer<vtkContextView>::New();
view->GetRenderWindow()->SetSize(200, 200);
vtkSmartPointer<vtkImageItem> item = vtkSmartPointer<vtkImageItem>::New();
view->GetScene()->AddItem(item);
// Now try to render some text using freetype...
vtkSmartPointer<vtkQtRenderUtility> qt =
vtkSmartPointer<vtkQtRenderUtility>::New();
vtkSmartPointer<vtkFreeTypeUtilities> freetype =
vtkFreeTypeUtilities::GetInstance();
vtkSmartPointer<vtkTextProperty> prop =
vtkSmartPointer<vtkTextProperty>::New();
prop->SetColor(0.0, 0.0, 0.0);
prop->SetFontSize(24);
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
//int result = freetype->RenderString(prop, "My String", image);
int result = qt->RenderString(prop,
vtkUnicodeString::from_utf8("\xe2\x84\xab"),
image);
item->SetImage(image);
item->SetPosition(20, 20);
view->GetRenderWindow()->SetMultiSamples(0);
view->GetRenderWindow()->Render();
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
return !retVal;
}
......@@ -103,11 +103,7 @@ int TestGLSL( int argc, char * argv [] )
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
if (test->IsCompiled)
{
......
......@@ -79,12 +79,6 @@ int TestLinePlot( int argc, char * argv [] )
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
//int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
/*=========================================================================
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 "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkSmartPointer.h"
#include "vtkChartXY.h"
#include "vtkPlot.h"
#include "vtkTable.h"
#include "vtkFloatArray.h"
#include "vtkContextView.h"
#include "vtkContextScene.h"
#include "vtkInteractorEventRecorder.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRegressionTestImage.h"
char TestLinePlotInteractionLog[] =
"# StreamVersion 1\n"
"RenderEvent 0 0 0 0 0 0 0\n"
"EnterEvent 198 5 0 0 0 0 0\n"
"MouseMoveEvent 198 5 0 0 0 0 0\n"
"MouseMoveEvent 190 49 0 0 0 0 0\n"
"MouseMoveEvent 190 54 0 0 0 0 0\n"
"MouseMoveEvent 190 59 0 0 0 0 0\n"
"MouseMoveEvent 190 64 0 0 0 0 0\n"
"MouseMoveEvent 190 69 0 0 0 0 0\n"
"MouseMoveEvent 192 73 0 0 0 0 0\n"
"MouseMoveEvent 192 77 0 0 0 0 0\n"
"MouseMoveEvent 193 83 0 0 0 0 0\n"
"LeftButtonPressEvent 131 124 0 0 0 0 0\n"
"MouseMoveEvent 132 124 0 0 0 0 0\n"
"MouseMoveEvent 134 124 0 0 0 0 0\n"
"MouseMoveEvent 135 124 0 0 0 0 0\n"
"MouseMoveEvent 136 124 0 0 0 0 0\n"
"MouseMoveEvent 137 124 0 0 0 0 0\n"
"MouseMoveEvent 138 124 0 0 0 0 0\n"
"MouseMoveEvent 139 124 0 0 0 0 0\n"
"MouseMoveEvent 140 124 0 0 0 0 0\n"
"MouseMoveEvent 141 124 0 0 0 0 0\n"
"MouseMoveEvent 142 124 0 0 0 0 0\n"
"LeftButtonReleaseEvent 166 143 0 0 0 0 0\n"
"MouseMoveEvent 165 143 0 0 0 0 0\n"
"MouseMoveEvent 164 144 0 0 0 0 0\n"
"MouseMoveEvent 163 144 0 0 0 0 0\n"
"LeftButtonPressEvent 131 246 0 0 0 0 0\n"
"MouseMoveEvent 132 245 0 0 0 0 0\n"
"MouseMoveEvent 133 244 0 0 0 0 0\n"
"MouseMoveEvent 136 241 0 0 0 0 0\n"
"MouseMoveEvent 137 240 0 0 0 0 0\n"
"MouseMoveEvent 138 239 0 0 0 0 0\n"
"MouseMoveEvent 139 238 0 0 0 0 0\n"
"MouseMoveEvent 140 237 0 0 0 0 0\n"
"MouseMoveEvent 140 236 0 0 0 0 0\n"
"MouseMoveEvent 141 235 0 0 0 0 0\n"
"MouseMoveEvent 142 234 0 0 0 0 0\n"
"MouseMoveEvent 143 233 0 0 0 0 0\n"
"LeftButtonReleaseEvent 104 251 0 0 0 0 0\n"
"MouseMoveEvent 104 252 0 0 0 0 0\n"
"MouseMoveEvent 104 253 0 0 0 0 0\n"
"MouseMoveEvent 104 254 0 0 0 0 0\n"
"MouseMoveEvent 104 255 0 0 0 0 0\n"
"RightButtonPressEvent 104 258 0 0 0 0 0\n"
"MouseMoveEvent 105 258 0 0 0 0 0\n"
"MouseMoveEvent 105 257 0 0 0 0 0\n"
"MouseMoveEvent 106 256 0 0 0 0 0\n"
"MouseMoveEvent 106 255 0 0 0 0 0\n"
"MouseMoveEvent 106 254 0 0 0 0 0\n"
"MouseMoveEvent 107 253 0 0 0 0 0\n"
"MouseMoveEvent 108 252 0 0 0 0 0\n"
"MouseMoveEvent 216 136 0 0 0 0 0\n"
"MouseMoveEvent 278 64 0 0 0 0 0\n"
"RightButtonReleaseEvent 278 64 0 0 0 0 0\n"
"MouseWheelBackwardEvent 271 185 0 0 0 0 0\n"
"MouseWheelBackwardEvent 271 185 0 0 0 0 0\n"
"MouseWheelBackwardEvent 271 185 0 0 0 1 0\n"
"RightButtonPressEvent 177 248 0 0 0 0 0\n"
"MouseMoveEvent 178 247 0 0 0 0 0\n"
"MouseMoveEvent 178 246 0 0 0 0 0\n"
"MouseMoveEvent 179 245 0 0 0 0 0\n"
"MouseMoveEvent 181 243 0 0 0 0 0\n"
"MouseMoveEvent 182 241 0 0 0 0 0\n"
"MouseMoveEvent 184 239 0 0 0 0 0\n"
"MouseMoveEvent 186 237 0 0 0 0 0\n"
"MouseMoveEvent 295 79 0 0 0 0 0\n"
"RightButtonReleaseEvent 295 79 0 0 0 0 0\n"
"MouseMoveEvent 295 80 0 0 0 0 0\n"
"MiddleButtonPressEvent 304 74 0 0 0 0 0\n"
"MouseMoveEvent 303 74 0 0 0 0 0\n"
"MouseMoveEvent 300 76 0 0 0 0 0\n"
"MouseMoveEvent 296 77 0 0 0 0 0\n"
"MouseMoveEvent 294 78 0 0 0 0 0\n"
"MouseMoveEvent 214 177 0 0 0 0 0\n"
"MiddleButtonReleaseEvent 214 177 0 0 0 0 0\n"
"MouseWheelBackwardEvent 214 177 0 0 0 0 0\n"
"MouseWheelBackwardEvent 214 177 0 0 0 1 0\n"
"MouseWheelBackwardEvent 214 177 0 0 0 0 0\n"
"MouseWheelBackwardEvent 214 177 0 0 0 1 0\n"
"MouseMoveEvent 213 177 0 0 0 0 0\n"
"LeftButtonPressEvent 133 138 0 0 0 0 0\n"
"MouseMoveEvent 133 137 0 0 0 0 0\n"
"MouseMoveEvent 178 116 0 0 0 0 0\n"
"LeftButtonReleaseEvent 178 116 0 0 0 0 0\n"
"MouseMoveEvent 177 117 0 0 0 0 0\n"
"MouseMoveEvent 377 293 0 0 0 0 0\n"
"LeaveEvent 379 300 0 0 0 0 0\n"
"ExitEvent 379 300 0 0 0 0 0\n"
"ExitEvent 379 300 0 0 0 0 0\n"
"EnterEvent 399 285 0 0 0 0 0\n"
"MouseMoveEvent 399 285 0 0 0 0 0\n"
"MouseMoveEvent 398 286 0 0 0 0 0\n"
"MouseMoveEvent 395 299 0 0 0 0 0\n"
"LeaveEvent 395 300 0 0 0 0 0\n"
"ExitEvent 395 300 0 0 0 0 0";
//----------------------------------------------------------------------------
int TestLinePlotInteraction(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);
// Create a table with some points in it...
vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
arrX->SetName("X Axis");
table->AddColumn(arrX);
vtkSmartPointer<vtkFloatArray> arrC = vtkSmartPointer<vtkFloatArray>::New();
arrC->SetName("Cosine");
table->AddColumn(arrC);
vtkSmartPointer<vtkFloatArray> arrS = vtkSmartPointer<vtkFloatArray>::New();
arrS->SetName("Sine");
table->AddColumn(arrS);
vtkSmartPointer<vtkFloatArray> arrS2 = vtkSmartPointer<vtkFloatArray>::New();
arrS2->SetName("Sine2");
table->AddColumn(arrS2);
// Test charting with a few more points...
int numPoints = 69;
float inc = 7.5 / (numPoints-1);
table->SetNumberOfRows(numPoints);
for (int i = 0; i < numPoints; ++i)
{
table->SetValue(i, 0, i * inc);
table->SetValue(i, 1, cos(i * inc) + 0.0);
table->SetValue(i, 2, sin(i * inc) + 0.0);
table->SetValue(i, 3, sin(i * inc) + 0.5);
}
// Add multiple line plots, setting the colors etc
vtkPlot *line = chart->AddPlot(vtkChart::LINE);
line->SetInput(table, 0, 1);
line->SetColor(0, 255, 0, 255);
line->SetWidth(1.0);
line = chart->AddPlot(vtkChart::LINE);
line->SetInput(table, 0, 2);
line->SetColor(255, 0, 0, 255);
line->SetWidth(5.0);
line = chart->AddPlot(vtkChart::LINE);
line->SetInput(table, 0, 3);
line->SetColor(0, 0, 255, 255);
line->SetWidth(4.0);
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
// recorder to play back previously events
vtkSmartPointer<vtkInteractorEventRecorder> recorder =
vtkSmartPointer<vtkInteractorEventRecorder>::New();
recorder->SetInteractor(view->GetInteractor());
// recorder->SetFileName("record.log");
// recorder->SetKeyPressActivationValue('b');
recorder->ReadFromInputStringOn();
recorder->SetInputString(TestLinePlotInteractionLog);
view->GetInteractor()->Initialize();
view->Render();
recorder->Play();
// Remove the observers so we can go interactive. Without this the "-I"
// testing option fails.
recorder->Off();
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
view->GetInteractor()->Start();
return !retVal;
}
......@@ -67,7 +67,6 @@ int TestMultipleChartRenderers( int argc, char * argv [] )
ren->AddActor(chartActor);
chartScene->SetRenderer(ren);
// Create a table with some points in it...
VTK_CREATE(vtkTable, table);
VTK_CREATE(vtkFloatArray, arrX);
......@@ -110,10 +109,7 @@ int TestMultipleChartRenderers( int argc, char * argv [] )
}
int retVal = vtkRegressionTestImage(iren->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
iren->Start();
return !retVal;
}
......@@ -76,7 +76,6 @@ int TestMultipleRenderers( int argc, char * argv [] )
ren2d->AddActor(chartActor);
chartScene->SetRenderer( ren2d );
// Create a table with some points in it...
VTK_CREATE(vtkTable, table);
VTK_CREATE(vtkFloatArray, arrX);
......@@ -121,10 +120,7 @@ int TestMultipleRenderers( int argc, char * argv [] )
ren2d->SetViewport(0,0.5,1,1);
int retVal = vtkRegressionTestImage(iren->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
iren->Start();
return !retVal;
}
......@@ -68,13 +68,7 @@ int TestParallelCoordinates(int argc, char* argv[])
view->GetRenderWindow()->SetMultiSamples(0);
//Finally render the scene and compare the image to a reference image
//int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -81,12 +81,7 @@ int TestPieChart( int argc, char * argv [] )
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
//int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -54,12 +54,8 @@ int TestQtContextUnicode(int argc, char * argv [])
view->GetRenderWindow()->SetMultiSamples(0);
view->GetRenderWindow()->Render();
int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 30);
view->GetInteractor()->Start();
return !retVal;
}
......
......@@ -80,11 +80,7 @@ int TestQtDiagram( int argc, char * argv [] )
renderWindow->Render();
int retVal = vtkRegressionTestImageThreshold(renderWindow, 15);
if( retVal == vtkRegressionTester::DO_INTERACTOR)
{
interactor->Start();
}
interactor->Start();
return !retVal;
}
......
......@@ -85,11 +85,7 @@ int TestScalarsToColors( int argc, char * argv [] )
//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();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -82,12 +82,7 @@ int TestScatterPlot( int argc, char * argv [] )
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
//int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -142,12 +142,7 @@ int TestStackedBarGraph( int argc, char * argv [] )
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
//int retVal = vtkRegressionTestImage(view->GetRenderWindow());
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
view->GetInteractor()->Start();
return !retVal;
}
......@@ -38,7 +38,7 @@
// Monthly checkout data
static const char *month_labels[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
static const char *month_labels[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static int book[] = {5675, 5902, 6388, 5990, 5575, 7393, 9878, 8082, 6417, 5946, 5526, 5166};
static int new_popular[] = {701, 687, 736, 696, 750, 814, 923, 860, 786, 735, 680, 741};
......@@ -123,16 +123,12 @@ int TestStackedPlot( int argc, char * argv [] )
VTK_CREATE(vtkColorSeries,colorSeries);
colorSeries->SetColorScheme(vtkColorSeries::COOL);
stack->SetColorSeries(colorSeries);
//Finally render the scene and compare the image to a reference image
view->GetRenderWindow()->SetMultiSamples(0);
int retVal = vtkRegressionTestImageThreshold(view->GetRenderWindow(), 25);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
}
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