|
vtk 视觉化工具函式库(VTK,Visualization Toolkit)是一个开放源码,跨平台、支援平行处理(VTK曾用于处理大小近乎1个Petabyte的资料,其平台为美国Los Alamos国家实验室所有的具1024个处理器之大型系统)的图形应用函式库。2005年实曾被美国陆军研究实验室用于即时模拟俄罗斯制反导弹战车ZSU23-4受到平面波攻击的情形,其计算节点高达2.5兆个之多。
介绍及使用: http://www.cnblogs.com/buffer/archive/2009/03/13/1410235.html结合Qt使用,部分代码示例(线图):(\vtk-5.6.1\GUISupport\Qt\Testing\CxxTestLineSeries.cxx)
/**//* 曲线 */ vtkQtChartWidget *chart = new vtkQtChartWidget; vtkQtChartArea *area = chart->getChartArea(); vtkQtLineChart *line = new vtkQtLineChart;
area->addLayer(line);
vtkQtChartLegend *legend = new vtkQtChartLegend(); vtkQtChartLegendManager *manager = new vtkQtChartLegendManager(legend); manager->setChartLegend(legend); manager->setChartArea(area); chart->setLegend(legend);
vtkQtChartMouseSelection *selector = vtkQtChartInteractorSetup::createDefault(area); vtkQtChartSeriesSelectionHandler *handler = new vtkQtChartSeriesSelectionHandler(selector); handler->setModeNames("Line Chart - Series", "Line Chart - Points"); handler->setMousePressModifiers(Qt::ControlModifier, Qt::ControlModifier); handler->setLayer(line); selector->addHandler(handler); selector->setSelectionMode("Line Chart - Points"); vtkQtChartInteractorSetup::setupDefaultKeys(area->getInteractor());
QStandardItemModel *model = new QStandardItemModel(3, 2); model->setItemPrototype(new QStandardItem()); model->setVerticalHeaderItem(0, new QStandardItem()); model->setVerticalHeaderItem(1, new QStandardItem()); model->setVerticalHeaderItem(2, new QStandardItem()); model->verticalHeaderItem(0)->setData(0.0, Qt::DisplayRole); model->verticalHeaderItem(1)->setData(1.0, Qt::DisplayRole); model->verticalHeaderItem(2)->setData(2.0, Qt::DisplayRole);
model->setHorizontalHeaderItem(0, new QStandardItem("series 1")); model->setHorizontalHeaderItem(1, new QStandardItem("series 2"));
model->setItem(0, 0, new QStandardItem()); model->setItem(1, 0, new QStandardItem()); model->setItem(2, 0, new QStandardItem()); model->item(0, 0)->setData(0.5, Qt::DisplayRole); model->item(1, 0)->setData(0.4, Qt::DisplayRole); model->item(2, 0)->setData(0.6, Qt::DisplayRole);
model->setItem(0, 1, new QStandardItem()); model->setItem(1, 1, new QStandardItem()); model->setItem(2, 1, new QStandardItem()); model->item(0, 1)->setData(0.4, Qt::DisplayRole); model->item(1, 1)->setData(0.5, Qt::DisplayRole); model->item(2, 1)->setData(0.4, Qt::DisplayRole);
vtkQtChartTableSeriesModel *tableModel = new vtkQtChartTableSeriesModel(model, line); line->setModel(tableModel);
chart->show();
|