/usr/share/vtk/Charts/Cxx/QChartTable.cxx is in vtk-examples 5.8.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile$
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 "vtkFloatArray.h"
#include "vtkMath.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()
//----------------------------------------------------------------------------
int main( int argc, char * argv [] )
{
// Qt initialization
QApplication app(argc, argv);
QMainWindow mainWindow;
mainWindow.setGeometry(0, 0, 1150, 600);
// QVTK set up and initialization
QVTKWidget *qvtkWidget = new QVTKWidget(&mainWindow);
// Set up my 2D world...
VTK_CREATE(vtkContextView, view); // This contains a chart object
view->SetInteractor(qvtkWidget->GetInteractor());
qvtkWidget->SetRenderWindow(view->GetRenderWindow());
// Create a table with some points in it...
VTK_CREATE(vtkTable, table);
VTK_CREATE(vtkFloatArray, arrX);
arrX->SetName("X Axis");
table->AddColumn(arrX);
VTK_CREATE(vtkFloatArray, arrC);
arrC->SetName("Cosine");
table->AddColumn(arrC);
VTK_CREATE(vtkFloatArray, arrS);
arrS->SetName("Sine");
table->AddColumn(arrS);
// Make a timer object - need to get some frame rates/render times
VTK_CREATE(vtkTimerLog, timer);
// Test charting with a few more points...
int numPoints = 29;
float inc = 7.0 / (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->Update();
// Add multiple line plots, setting the colors etc
vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
view->GetScene()->AddItem(chart);
vtkPlot *line = chart->AddPlot(vtkChart::LINE);
line->SetInput(table, 0, 1);
line->SetColor(255, 0, 0, 255);
line = chart->AddPlot(vtkChart::LINE);
line->SetInput(table, 0, 2);
line->SetColor(0, 255, 0, 255);
line->SetWidth(2.0);
// Instantiate a vtkQtChart and use that too
/* vtkQtChart *qtChart = new vtkQtChart;
chart = qtChart->chart();
line = chart->AddPlot(vtkChart::LINE);
line->SetTable(table, 0, 1);
line->SetColor(255, 0, 0, 255);
line = chart->AddPlot(vtkChart::LINE);
line->SetTable(table, 0, 2);
line->SetColor(0, 255, 0, 255);
line->SetWidth(2.0);
*/
// Now lets try to add a table view
QWidget *widget = new QWidget(&mainWindow);
QHBoxLayout *layout = new QHBoxLayout(widget);
VTK_CREATE(vtkQtTableView, tableView);
tableView->SetSplitMultiComponentColumns(true);
tableView->AddRepresentationFromInput(table);
tableView->Update();
layout->addWidget(qvtkWidget, 2);
//layout->addWidget(qtChart, 2);
layout->addWidget(tableView->GetWidget());
mainWindow.setCentralWidget(widget);
// Now show the application and start the event loop
mainWindow.show();
return app.exec();
}
|