Commit 5e139b30 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Dan Lipsa

Renable charts example and update them to use Qt5.

parent 7e234553
......@@ -51,9 +51,11 @@ else()
if(VTK_RENDERING_BACKEND STREQUAL "OpenGL" AND vtkTestingCore_LOADED)
add_subdirectory(LIC/Cxx)
endif()
if(vtkParallelMPI_LOADED AND vtkRenderingParallel_LOADED)
add_subdirectory(ParallelProcessing/Generic)
endif()
if(vtkParallelMPI_LOADED AND vtkRenderingParallel_LOADED)
add_subdirectory(ParallelProcessing/Generic)
endif()
# This may have been already built as part of the VTK build.
# If so we cannot create the target "vtkLocalExample" because
# an imported target of the same name already exists in the
......@@ -72,11 +74,12 @@ else()
if (NOT VTK_RENDERING_BACKEND STREQUAL "None")
add_subdirectory(Infovis/Cxx)
endif ()
if (vtkChartsCore_LOADED)
add_subdirectory(Charts/Cxx)
endif()
#
# IF(VTK_USE_INFOVIS)
# IF(VTK_USE_CHARTS)
# add_subdirectory(Charts/Cxx)
# ENDIF()
# IF(VTK_USE_N_WAY_ARRAYS)
# add_subdirectory(Array/Cxx)
# ENDIF()
......
......@@ -2,36 +2,23 @@ PROJECT (Charts)
IF(NOT VTK_BINARY_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_CHARTS)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_CHARTS.")
IF(NOT vtkChartsCore_LOADED)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires vtkChartsCore module.")
ENDIF()
INCLUDE(${VTK_USE_FILE})
ENDIF()
IF(VTK_USE_VIEWS)
IF(vtkViewsInfovis_LOADED)
ADD_EXECUTABLE(GraphItem GraphItem.cxx vtkGraphItem.cxx)
TARGET_LINK_LIBRARIES(GraphItem vtkCharts)
TARGET_LINK_LIBRARIES(GraphItem ${VTK_LIBRARIES})
ENDIF()
ADD_EXECUTABLE(PiecewiseItem PiecewiseItem.cxx)
TARGET_LINK_LIBRARIES(PiecewiseItem vtkCharts)
TARGET_LINK_LIBRARIES(PiecewiseItem ${VTK_LIBRARIES})
IF(VTK_USE_QVTK)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
IF(vtkGUISupportQt_LOADED)
ADD_EXECUTABLE(QChartTable QChartTable.cxx)
TARGET_LINK_LIBRARIES(QChartTable
QVTK
${QT_LIBRARIES}
vtkRendering
vtkCharts
)
TARGET_LINK_LIBRARIES(QChartTable ${VTK_LIBRARIES})
ADD_EXECUTABLE(QScalarsToColors QScalarsToColors.cxx)
TARGET_LINK_LIBRARIES(QScalarsToColors
QVTK
${QT_LIBRARIES}
vtkRendering
vtkCharts
)
TARGET_LINK_LIBRARIES(QScalarsToColors ${VTK_LIBRARIES})
ENDIF()
......@@ -12,64 +12,64 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "QVTKOpenGLWidget.h"
#include "vtkChartXY.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
#include "vtkFloatArray.h"
#include "vtkGenericOpenGLRenderWindow.h"
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPlot.h"
#include "vtkQtTableView.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkContextView.h"
#include "vtkContextScene.h"
#include "vtkChartXY.h"
#include "vtkPlot.h"
#include "vtkTable.h"
#include "vtkTimerLog.h"
#include <QApplication>
#include <QWidget>
#include <QMainWindow>
#include <QHBoxLayout>
#include "QVTKWidget.h"
#include "vtkQtTableView.h"
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
#include <QSurfaceFormat>
//----------------------------------------------------------------------------
int main( int argc, char * argv [] )
{
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
// Qt initialization
QApplication app(argc, argv);
QMainWindow mainWindow;
mainWindow.setGeometry(0, 0, 1150, 600);
// QVTK set up and initialization
QVTKWidget *qvtkWidget = new QVTKWidget(&mainWindow);
QVTKOpenGLWidget *qvtkWidget = new QVTKOpenGLWidget(&mainWindow);
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
qvtkWidget->SetRenderWindow(renderWindow);
// Set up my 2D world...
VTK_CREATE(vtkContextView, view); // This contains a chart object
vtkNew<vtkContextView> view; // This contains a chart object
view->SetRenderWindow(renderWindow);
view->SetInteractor(qvtkWidget->GetInteractor());
qvtkWidget->SetRenderWindow(view->GetRenderWindow());
// Create a table with some points in it...
VTK_CREATE(vtkTable, table);
VTK_CREATE(vtkFloatArray, arrX);
vtkNew<vtkTable> table;
vtkNew<vtkFloatArray> arrX;
arrX->SetName("X Axis");
table->AddColumn(arrX);
VTK_CREATE(vtkFloatArray, arrC);
vtkNew<vtkFloatArray> arrC;
arrC->SetName("Cosine");
table->AddColumn(arrC);
VTK_CREATE(vtkFloatArray, arrS);
vtkNew<vtkFloatArray> arrS;
arrS->SetName("Sine");
table->AddColumn(arrS);
// Make a timer object - need to get some frame rates/render times
VTK_CREATE(vtkTimerLog, timer);
vtkNew<vtkTimerLog> timer;
// Test charting with a few more points...
int numPoints = 29;
......@@ -85,7 +85,7 @@ int main( int argc, char * argv [] )
// table->Update();
// Add multiple line plots, setting the colors etc
vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
vtkNew<vtkChartXY> chart;
view->GetScene()->AddItem(chart);
vtkPlot *line = chart->AddPlot(vtkChart::LINE);
line->SetInputData(table, 0, 1);
......@@ -109,7 +109,7 @@ int main( int argc, char * argv [] )
// Now lets try to add a table view
QWidget *widget = new QWidget(&mainWindow);
QHBoxLayout *layout = new QHBoxLayout(widget);
VTK_CREATE(vtkQtTableView, tableView);
vtkNew<vtkQtTableView> tableView;
tableView->SetSplitMultiComponentColumns(true);
tableView->AddRepresentationFromInput(table);
tableView->Update();
......
......@@ -13,22 +13,21 @@
=========================================================================*/
#include "vtkFloatArray.h"
#include "vtkMath.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "QVTKOpenGLWidget.h"
#include "vtkChartXY.h"
#include "vtkColorTransferFunction.h"
#include "vtkPiecewiseFunction.h"
#include "vtkCompositeTransferFunctionItem.h"
#include "vtkContextView.h"
#include "vtkContextScene.h"
#include "vtkChartXY.h"
#include "vtkContextView.h"
#include "vtkFloatArray.h"
#include "vtkGenericOpenGLRenderWindow.h"
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPiecewiseFunction.h"
#include "vtkPlot.h"
#include "vtkQtTableView.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTimerLog.h"
#include <QApplication>
......@@ -36,61 +35,50 @@
#include <QMainWindow>
#include <QHBoxLayout>
#include "QVTKWidget.h"
#include "vtkQtTableView.h"
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
//----------------------------------------------------------------------------
int main( int argc, char * argv [] )
{
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
// Qt initialization
QApplication app(argc, argv);
// QVTK set up and initialization
QVTKWidget qvtkWidget(0);
QVTKOpenGLWidget qvtkWidget(nullptr);
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
qvtkWidget.SetRenderWindow(renderWindow);
// Set up my 2D world...
VTK_CREATE(vtkContextView, view); // This contains a chart object
vtkNew<vtkContextView> view;; // This contains a chart object
view->SetRenderWindow(qvtkWidget.GetRenderWindow());
view->SetInteractor(qvtkWidget.GetInteractor());
qvtkWidget.SetRenderWindow(view->GetRenderWindow());
vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
vtkNew<vtkChartXY> chart;
chart->SetTitle("Chart");
view->GetScene()->AddItem(chart);
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
vtkSmartPointer<vtkColorTransferFunction>::New();
vtkNew<vtkColorTransferFunction> colorTransferFunction;
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<vtkPiecewiseFunction> opacityFunction =
vtkSmartPointer<vtkPiecewiseFunction>::New();
vtkNew<vtkPiecewiseFunction> opacityFunction;
opacityFunction->AddPoint(0.,0.);
opacityFunction->AddPoint(0.5,0.5);
opacityFunction->AddPoint(1.,1.);
vtkSmartPointer<vtkCompositeTransferFunctionItem> item3 =
vtkSmartPointer<vtkCompositeTransferFunctionItem>::New();
vtkNew<vtkCompositeTransferFunctionItem> item3;
item3->SetColorTransferFunction(colorTransferFunction);
item3->SetOpacityFunction(opacityFunction);
item3->SetOpacity(0.2);
item3->SetMaskAboveCurve(true);
chart->AddPlot(item3);
// Now lets try to add a table view
//QWidget *widget = new QWidget(mainWindow);
//QHBoxLayout *layout = new QHBoxLayout(widget);
//layout->addWidget(qvtkWidget);
//mainWindow->setCentralWidget(widget);
// Now show the application and start the event loop
qvtkWidget.show();
//view->GetRenderWindow()->SetMultiSamples(0);
return app.exec();
}
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