-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwidget.cpp
650 lines (546 loc) · 18.9 KB
/
mainwidget.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#include "mainwidget.h"
#include "QDebug"
#include <QMessageBox>
#include <QStackedWidget>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "mitkobject.h"
#include <mitkVolume.h>
#include <mitkOoCVolume.h>
#include <mitkRawReader.h>
#include <mitkRawWriter.h> //raw数据输出类
#include "mitkRegionGrowImageFilter.h" //区域生长算法类头文件
#include"mitkScene.h"
#include"mitkSurfaceModel.h"
#include"mitkMarchingCubes.h"
#include"mitkRawReader.h"
#include<QFileDialog>
#include<QString>
#include<QInputDialog>
#include<mitkICVolume.h>
#include<mitkOoCVolume.h>
#include <mitkOoCTriangleMesh.h>
#include <mitkBinMarchingCubes.h>
#include <mitkMeshViewManipulatorStandard.h>
#include <mitkLineWidgetModel3D.h>
using namespace cv;
using namespace std;
MainWidget::MainWidget(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QHBoxLayout * mainLayout = new QHBoxLayout(this); //水平布局
mainLayout->addWidget(ui.tabWidget);
//mainLayout->addWidget(ui.stackedWidget);
topOneBottomThree = new TopOneBottomThree();
oneWidget = new OneWidget();
oneWidgetThreeDimensional = new OneWidgetThreeDimensional();
topTwoBottomTwo = new TopTwoBottomTwo();
leftThreeRightOne = new LeftThreeRightOne();
ui.stackedWidget->addWidget(topOneBottomThree);
ui.stackedWidget->addWidget(oneWidget);
ui.stackedWidget->addWidget(oneWidgetThreeDimensional);
ui.stackedWidget->addWidget(topTwoBottomTwo);
ui.stackedWidget->addWidget(leftThreeRightOne);
ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui.tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui.centralWidget->setLayout(mainLayout);
connect(ui.action_open, SIGNAL(triggered()), this, SLOT(on_open_triggered()));
connect(ui.action_machine, SIGNAL(triggered()), this, SLOT(on_newMachine_triggered()));
connect(ui.action_experiment, SIGNAL(triggered()), this, SLOT(on_newExperiment_triggered()));
connect(ui.action_save, SIGNAL(triggered()), this, SLOT(on_output_triggered()));
connect(ui.action_8, SIGNAL(triggered()), this, SLOT(on_segmentation1_triggered())); //自动阈值分割
connect(ui.action_9, SIGNAL(triggered()), this, SLOT(on_segmentation2_triggered())); //GrabCut分割
connect(ui.action_10, SIGNAL(triggered()), this, SLOT(on_segmentation3_triggered())); //区域生长分割
connect(ui.action_15, SIGNAL(triggered()), this, SLOT(on_top2bottom2_triggered()));
connect(ui.action_16, SIGNAL(triggered()), this, SLOT(on_top1bottom3_triggered()));
connect(ui.action_17, SIGNAL(triggered()), this, SLOT(on_left3right1_triggered()));
connect(ui.actionX_Y, SIGNAL(triggered()), this, SLOT(on_twoDimentional_triggered()));
connect(ui.actionX_Z, SIGNAL(triggered()), this, SLOT(on_twoDimentional_triggered()));
connect(ui.actionY_Z, SIGNAL(triggered()), this, SLOT(on_twoDimentional_triggered()));
connect(ui.action_19, SIGNAL(triggered()), this, SLOT(on_threeDimentional_triggered()));
connect(ui.action_20, SIGNAL(triggered()), this, SLOT(on_threeDimentional_triggered()));
connect(ui.action_0, SIGNAL(triggered()), this, SLOT(on_marchingCubes_triggered())); //表面重建
connect(ui.action_3, SIGNAL(triggered()), this, SLOT(on_volumeRender1_triggered()));
connect(ui.action_5, SIGNAL(triggered()), this, SLOT(on_volumeRender2_triggered()));
m_scene = ui.showwidget->CreateMitkScene();
m_model = new mitkSurfaceModel;
m_scene->AddModel(m_model);
}
MainWidget::~MainWidget()
{
}
void MainWidget::on_open_triggered()
{
InputWidget * inputWidget = new InputWidget;
inputWidget->show();
}
void MainWidget::on_newMachine_triggered()
{
NewMachineWidget * newMachineWiget = new NewMachineWidget;
newMachineWiget->show();
}
void MainWidget::on_newExperiment_triggered()
{
NewExperimentWidget * newExperimentWiget = new NewExperimentWidget;
newExperimentWiget->show();
}
void MainWidget::on_output_triggered()
{
OutputWidget * outputWidget = new OutputWidget;
outputWidget->show();
}
void MainWidget::on_left3right1_triggered()
{
ui.stackedWidget->setCurrentWidget(leftThreeRightOne);
}
void MainWidget::on_top1bottom3_triggered()
{
ui.stackedWidget->setCurrentWidget(topOneBottomThree);
}
void MainWidget::on_top2bottom2_triggered()
{
ui.stackedWidget->setCurrentWidget(topTwoBottomTwo);
}
void MainWidget::on_twoDimentional_triggered()
{
ui.stackedWidget->setCurrentWidget(oneWidget);
}
void MainWidget::on_threeDimentional_triggered(){
ui.stackedWidget->setCurrentWidget(oneWidgetThreeDimensional);
}
//Canny分割算法,针对二维图片
void MainWidget::on_segmentation1_triggered()
{
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
query.seek(1); //定位记录
QString path = query.value(2).toString();
//将QString转换为char *
QByteArray newPath = path.toLatin1();
const char *filename = newPath.data();
Mat img = imread(filename, 1);
Mat grey;
cvtColor(img, grey, CV_BGR2GRAY);
Mat edges(img.size(), CV_8U);
double threshold = 50;
Canny(img, edges, threshold, threshold * 3, 3);
on_twoDimentional_triggered();
oneWidget->showImage(edges);
}
static void on_mouse(int event, int x, int y, int flags, void* param)
{
GrubCuts gc;
gc.mouseClick(event, x, y, flags, param);
}
//GrabCut分割
void MainWidget::on_segmentation2_triggered()
{
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
string filename = "2.jpg";
Mat image = imread(filename, 1);
if (image.empty())
{
cout << "\n Durn, couldn't read image filename " << filename << endl;
}
const string winName = "image";
cvNamedWindow(winName.c_str(), CV_WINDOW_AUTOSIZE);
cvSetMouseCallback(winName.c_str(), on_mouse, 0);
gc.setImageAndWinName(image, winName);
gc.showImage();
for (;;)
{
int c = cvWaitKey(0);
switch ((char)c)
{
case '\x1b':
cout << "Exiting ..." << endl;
goto exit_main;
case 'r':
cout << endl;
gc.reset();
gc.showImage();
break;
case 'n':
int iterCount = gc.getIterCount();
cout << "<" << iterCount << "... ";
int newIterCount = gc.nextIter();
if (newIterCount > iterCount)
{
gc.showImage();
cout << iterCount << ">" << endl;
}
else
cout << "rect must be determined>" << endl;
break;
}
}
exit_main:
cvDestroyWindow(winName.c_str());
}
//区域生长分割
void MainWidget::on_segmentation3_triggered()
{
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
char OutputFile[] = "G:\\imagedb\\resultRG.raw"; //存储分割结果的路径文件名
int dataType = MITK_UNSIGNED_SHORT; //投影数据的类型,默认为浮点型,这里为unsigned short
int sliceWidth = 384, sliceHeight = 384, sliceNum = 384, sliceChannelNum = 1;
float sliceSpacingX = 1, sliceSpacingY = 1, sliceSpacingZ = 1;
int outWidth = 384, outHeight = 384, outSliceNum = 384;
mitkRawReader * aReader = new mitkRawReader;
aReader->SetWidth(sliceWidth);
aReader->SetHeight(sliceHeight);
aReader->SetImageNum(sliceNum);
aReader->SetSpacingX(sliceSpacingX); //设置X、Y、Z方向上像素间距,因重建为用到该信息,暂时设置为1mm
aReader->SetSpacingY(sliceSpacingY);
aReader->SetSpacingZ(sliceSpacingZ);
aReader->SetChannelNum(sliceChannelNum); //设置数据通道数
aReader->SetDataType(dataType); //设置投影数据类型
query.first(); //定位记录
QString path = query.value(2).toString();
//将QString转换为char *
QByteArray newPath = path.toLatin1();
const char *filename = newPath.data();
aReader->AddFileName(filename);
if (aReader->Run())
{
mitkVolume * aVolume = aReader->GetOutput();
//区域分割算法
mitkRegionGrowImageFilter * filterRG = new mitkRegionGrowImageFilter;
filterRG->SetInput(aVolume);
filterRG->SetSeedPoint(2, 3, 4);
//设置相似度条件
filterRG->SetMaxChangeValue(3.9);
filterRG->SetMaxDifferentValue(2.0);
//设置输出分割结果的参数
mitkVolume * m_RGVolume = filterRG->GetOutput(); //输出数据类指针m_RGVolume
m_RGVolume->SetWidth(outWidth); //设置分割体的宽度
m_RGVolume->SetHeight(outHeight); //设置分割体的高度
m_RGVolume->SetSliceNum(outSliceNum); //设置分割体切片数
filterRG->Run();
filterRG->Delete();
on_threeDimentional_triggered();
oneWidgetThreeDimensional->showImage3D(m_RGVolume);
//保存分割结果
mitkRawWriter * aWriter = new mitkRawWriter;
aWriter->SetInput(m_RGVolume);
aWriter->AddFileName(OutputFile);
aWriter->Run();
}
//在数据库中插入记录
//query.exec("insert into test0(name,filepath,x,y,z,stage,belong) values ('mice','G:\\\imagedb\\\resultRG.raw',384,384,384,'segmentation3','mice')");
qDebug() << "Segmentation Done!";
}
void MainWidget::on_marchingCubes_triggered(){
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
int dataType = MITK_UNSIGNED_INT;
int sliceWidth = 384, sliceHeight = 384, sliceNum = 384, sliceChannelNum = 1;
float sliceSpacingX = 1, sliceSpacingY = 1, sliceSpacingZ = 1;
int outWidth = 384, outHeight = 384, outSliceNum = 384;
mitkRawReader * aReader = new mitkRawReader;
aReader->SetWidth(sliceWidth);
aReader->SetHeight(sliceHeight);
aReader->SetImageNum(sliceNum);
aReader->SetSpacingX(sliceSpacingX); //设置X、Y、Z方向上像素间距,因重建为用到该信息,暂时设置为1mm
aReader->SetSpacingY(sliceSpacingY);
aReader->SetSpacingZ(sliceSpacingZ);
aReader->SetChannelNum(sliceChannelNum); //设置数据通道数
aReader->SetDataType(dataType); //设置投影数据类型
query.first(); //定位记录
QString path = query.value(2).toString();
//将QString转换为char *
QByteArray newPath = path.toLatin1();
const char * filename = newPath.data();
aReader->AddFileName(filename);
aReader->Run();
mitkVolume * aVolume = aReader->GetOutput();
aReader->Delete();
on_threeDimentional_triggered();
oneWidgetThreeDimensional->showImage3D_marchingCubes(aVolume);
}
void MainWidget::on_volumeRender1_triggered(){
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
int dataType = MITK_UNSIGNED_SHORT; //投影数据的类型,默认为浮点型,这里为unsigned short
int sliceWidth = 384, sliceHeight = 384, sliceNum = 384, sliceChannelNum = 1;
float sliceSpacingX = 1, sliceSpacingY = 1, sliceSpacingZ = 1;
int outWidth = 384, outHeight = 384, outSliceNum = 384;
mitkRawReader * aReader = new mitkRawReader;
aReader->SetWidth(sliceWidth);
aReader->SetHeight(sliceHeight);
aReader->SetImageNum(sliceNum);
aReader->SetSpacingX(sliceSpacingX); //设置X、Y、Z方向上像素间距,因重建为用到该信息,暂时设置为1mm
aReader->SetSpacingY(sliceSpacingY);
aReader->SetSpacingZ(sliceSpacingZ);
aReader->SetChannelNum(sliceChannelNum); //设置数据通道数
aReader->SetDataType(dataType); //设置投影数据类型
query.first(); //定位记录
QString path = query.value(2).toString();
//将QString转换为char *
QByteArray newPath = path.toLatin1();
const char *filename = newPath.data();
aReader->AddFileName(filename);
aReader->Run();
mitkVolume * aVolume = aReader->GetOutput();
on_threeDimentional_triggered();
oneWidgetThreeDimensional->showImage3D_volumeRender1(aVolume);
aReader->Delete();
}
void MainWidget::on_volumeRender2_triggered(){
//创建数据库连接
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //加载数据库驱动
db.setHostName("localhost"); //设置主机名
db.setPort(3306);
db.setDatabaseName("imagedb");
db.setUserName("root");
db.setPassword("lan19950725");
if (!db.open()){
QMessageBox::critical(0, "Cannot open database.", "Unable to establish a database connection.", QMessageBox::Cancel);
return;
}
QSqlQuery query;
query.exec("select * from test0");
while (query.next()){
qDebug() << query.value(0).toInt()
<< query.value(1).toString()
<< query.value(2).toString()
<< query.value(3).toInt()
<< query.value(4).toInt()
<< query.value(5).toInt()
<< query.value(6).toString()
<< query.value(7).toString();
}
int dataType = MITK_UNSIGNED_SHORT; //投影数据的类型,默认为浮点型,这里为unsigned short
int sliceWidth = 384, sliceHeight = 384, sliceNum = 384, sliceChannelNum = 1;
float sliceSpacingX = 1, sliceSpacingY = 1, sliceSpacingZ = 1;
int outWidth = 384, outHeight = 384, outSliceNum = 384;
mitkRawReader * aReader = new mitkRawReader;
aReader->SetWidth(sliceWidth);
aReader->SetHeight(sliceHeight);
aReader->SetImageNum(sliceNum);
aReader->SetSpacingX(sliceSpacingX); //设置X、Y、Z方向上像素间距,因重建为用到该信息,暂时设置为1mm
aReader->SetSpacingY(sliceSpacingY);
aReader->SetSpacingZ(sliceSpacingZ);
aReader->SetChannelNum(sliceChannelNum); //设置数据通道数
aReader->SetDataType(dataType); //设置投影数据类型
query.first(); //定位记录
QString path = query.value(2).toString();
//将QString转换为char *
QByteArray newPath = path.toLatin1();
const char *filename = newPath.data();
aReader->AddFileName(filename);
if (aReader->Run())
{
mitkVolume * aVolume = aReader->GetOutput();
mitkICVolume * icVolume = mitkICVolume::SafeDownCast(aVolume);
on_threeDimentional_triggered();
oneWidgetThreeDimensional->showImage3D_volumeRender2(icVolume);
aReader->Delete();
}
}
void MainWidget::on_open_clicked()
{
char DISK_CACHE_PATH[] = "D:\\Cone Beam CT\\CT Construction\\mice_proj_data_arrangement\\miceproj_temp\\temp1\\";
char DISK_CACHE_PATH_OUT[] = "D:\\Cone Beam CT\\CT Construction\\mice_proj_data_arrangement\\miceproj_temp\\temp2\\";
int dataType = MITK_UNSIGNED_CHAR;//文件:mice_recon_result_uint8.raw老鼠重建结果数据类型是uint8:unsigned char型的
int inchannelNum = 1;
int inWidth = 384;
int inHeigth = 384;
int inSliceNum = 384;
float sliceSpacingX = 1, sliceSpacingY = 1, sliceSpacingZ = 1;
//mitkOoCVolume *aVolume = new mitkOoCVolume;
mitkICVolume *aVolume = new mitkICVolume;
//aVolume->SetPathOfDiskBuffer(DISK_CACHE_PATH);
//aVolume->SetBufferedSliceNum(64);
aVolume->SetWidth(inWidth);
aVolume->SetHeight(inHeigth);
aVolume->SetSliceNum(inSliceNum);
aVolume->SetSpacingX(sliceSpacingX);
aVolume->SetSpacingY(sliceSpacingY);
aVolume->SetSpacingZ(sliceSpacingZ);
aVolume->SetChannelNum(inchannelNum);
aVolume->SetDataType(dataType);
if (aVolume->Allocate())
{
unsigned char *p = new unsigned char[384 * 384];
FILE *fid;
const char *filename = "D:\\Cone Beam CT\\CT Construction\\mice_recon_result_data\\mice_recon_result_uint8_RegionGrow_cut_20_20.raw";
if ((fid = fopen(filename, "rb")) == NULL)
{
printf("can't open file!\n");
}
for (int i = 0; i < inSliceNum; i++)
{
fread(p, sizeof(unsigned char), inWidth * inHeigth, fid);
aVolume->WriteSliceData(i, p);
}
fclose(fid);
delete p;
}
double minV, maxV;
aVolume->GetMinMaxValue(minV, maxV);
double thresh = 100.0;//这个阈值暂时没起作用??
mitkMarchingCubes *mc = new mitkMarchingCubes;
//mitkBinMarchingCubes *mc = new mitkBinMarchingCubes;
mc->SetInput(aVolume);
mc->SetThreshold(thresh, maxV);
//m_Mesh = mc->GetOutput();//mc->GetOutput()是mitkMesh*类型
//mc->SetBinData(aVolume);
mc->Run();
m_model->SetData(mc->GetOutput());
float point0[3] = { 0, 0, 0 };
float point1[3] = { 300, 200, 200 };
mitkLineWidgetModel3D *lineModel = new mitkLineWidgetModel3D(point0, point1);
m_scene->AddModel(lineModel);
m_scene->Update();
}
static int leftRotate=0;
void MainWidget::on_leftRotate_clicked()
{
if (leftRotate < 0)
leftRotate = 360;
leftRotate = leftRotate - 10;
float rot[3];
//float ax, ay, az, angle;
//m_model->GetRotation(ax,ay,az,angle);
//m_model->SetRotation(ax, ay, az, angle);
m_model->GetRotation(rot);
m_model->SetRotation(rot[0], leftRotate, rot[2]);
m_scene->Update();
}
static int vertical=0;
void MainWidget::on_vertical_clicked()
{
if (vertical > 360)
vertical = 0;
vertical = vertical + 10;
float rot[3];
m_model->GetRotation(rot);
m_model->SetRotation(vertical, rot[1], rot[2]);
m_scene->Update();
}
static int rightRotate = 0;
void MainWidget::on_rightRotate_clicked()
{
if (rightRotate >0)
rightRotate = 0;
rightRotate = rightRotate - 10;
float rot[3];
//float ax, ay, az, angle;
//m_model->GetRotation(ax,ay,az,angle);
//m_model->SetRotation(ax, ay, az, angle);
m_model->GetRotation(rot);
m_model->SetRotation(rot[0], rightRotate, rot[2]);
m_scene->Update();
}