-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
65 lines (51 loc) · 1.97 KB
/
mainwindow.cpp
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
#include <vtkSmartPointer.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->dockWidget->setTitleBarWidget(new QWidget);
ConfigureTransferFunction();
ConfigureCanvas();
}
MainWindow::~MainWindow()
{
delete ui;
exit(0);
}
void MainWindow::ConfigureTransferFunction()
{
vtkSmartPointer<vtkPiecewiseFunction> opacityTransferFunc = vtkSmartPointer<vtkPiecewiseFunction>::New();
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunc = vtkSmartPointer<vtkColorTransferFunction>::New();
opacityTransferFunc->AddPoint(0, 0.0, 0.5, 0.5);
for(int i = 1; i <= 10; ++i)
{
opacityTransferFunc->AddPoint(0.1 * i, 0.5, 0.5, 0.5);
}
colorTransferFunc->AddRGBPoint(0. , 69./255., 199./255., 186./255.);
colorTransferFunc->AddRGBPoint(0.2, 172./255., 3./255., 57./255.);
colorTransferFunc->AddRGBPoint(0.4, 169./255., 83./255., 58./255.);
colorTransferFunc->AddRGBPoint(0.6, 43./255., 32./255., 161./255.);
colorTransferFunc->AddRGBPoint(0.8, 247./255., 158./255., 97./255.);
colorTransferFunc->AddRGBPoint(1., 183./255., 7./255., 140./255.);
tf = new TransferFunction(opacityTransferFunc, colorTransferFunc);
ui->opacityTransferFunc->view()->addCompositeFunction(colorTransferFunc, opacityTransferFunc, false, true);
ui->colorTransferFunc->view()->addColorTransferFunction(colorTransferFunc);
ui->opacityTransferFunc->view()->setAxesToChartBounds();
ui->colorTransferFunc->view()->setAxesToChartBounds();
}
void MainWindow::ConfigureCanvas()
{
QGLFormat format;
format.setDoubleBuffer(true);
format.setRgba(true);
format.setDepth(true);
canvas = new Canvas(format, this);
canvas->setMinimumSize(1280, 640);
canvas->setMaximumSize(1280, 640);
ui->centralLayout->addWidget(canvas);
}