-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_axialcoronallores.cpp
1073 lines (881 loc) · 46.2 KB
/
view_axialcoronallores.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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "view_axialcoronallores.h"
#include "ui_view_axialcoronallores.h"
#include "ui_mainwindow.h"
#include "mainwindow.h"
viewAxialCoronalLoRes::viewAxialCoronalLoRes(QWidget *parent, NIFTImage *fatImage, NIFTImage *waterImage, SubjectConfig *subConfig, TracingData *tracingData) :
QWidget(parent),
ui(new Ui::viewAxialCoronalLoRes),
fatImage(fatImage), waterImage(waterImage), subConfig(subConfig), tracingData(tracingData),
undoView(NULL), undoStack(new QUndoStack(this)),
lblStatusLocation(new QLabel(this)),
// Home Tab Shortcuts
upShortcut(new QShortcut(QKeySequence("up"), this)), downShortcut(new QShortcut(QKeySequence("down"), this)),
leftShortcut(new QShortcut(QKeySequence("left"), this)), rightShortcut(new QShortcut(QKeySequence("right"), this)),
// Axial Display Tab Shortcuts
fatRadioBtnShortcut(new QShortcut(QKeySequence("q"), this)),
waterRadioBtnShortcut(new QShortcut(QKeySequence("w"), this)),
fatFracRadioBtnShortcut(new QShortcut(QKeySequence("e"), this)),
waterFracRadioBtnShortcut(new QShortcut(QKeySequence("r"), this)),
fatWaterRadioBtnShortcut(new QShortcut(QKeySequence("t"), this)),
waterFatRadioBtnShortcut(new QShortcut(QKeySequence("y"), this)),
resetViewShortcut(new QShortcut(QKeySequence("Space"), this)),
// Tracing Tab Shortcuts
EATRadioBtnShortcut(new QShortcut(QKeySequence("1"), this)), IMATRadioBtnShortcut(new QShortcut(QKeySequence("2"), this)),
PAATRadioBtnShortcut(new QShortcut(QKeySequence("3"), this)), PATRadioBtnShortcut(new QShortcut(QKeySequence("4"), this)),
SCATRadioBtnShortcut(new QShortcut(QKeySequence("5"), this)), VATRadioBtnShortcut(new QShortcut(QKeySequence("6"), this)),
EATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+1"), this)), IMATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+2"), this)),
PAATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+3"), this)), PATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+4"), this)),
SCATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+5"), this)), VATCheckBoxShortcut(new QShortcut(QKeySequence("Ctrl+6"), this)),
drawPointsModeShortcut(new QShortcut(QKeySequence("z"), this)),
erasePointsModeShortcut(new QShortcut(QKeySequence("x"), this))
{
this->ui->setupUi(this);
connect(undoStack, SIGNAL(canUndoChanged(bool)), this, SLOT(undoStack_canUndoChanged(bool)));
connect(undoStack, SIGNAL(canRedoChanged(bool)), this, SLOT(undoStack_canRedoChanged(bool)));
this->ui->glWidgetAxial->setUndoStack(undoStack);
this->ui->glWidgetCoronal->setUndoStack(undoStack);
this->ui->glWidgetAxial->setup(fatImage, waterImage, tracingData);
this->ui->glWidgetCoronal->setup(fatImage, waterImage);
this->parentMain()->ui->statusBar->addPermanentWidget(this->lblStatusLocation);
this->ui->glWidgetAxial->setLocationLabel(this->lblStatusLocation);
// Set current tab to zero in case I am on a different tab in designer.
this->ui->settingsWidget->setCurrentIndex(0);
if (fatImage->isLoaded() && waterImage->isLoaded())
{
setEnableSettings(true);
setupDefaults();
}
else
setEnableSettings(false);
// Home Tab Shortcuts
connect(upShortcut, SIGNAL(activated()), this, SLOT(upShortcut_triggered()));
connect(downShortcut, SIGNAL(activated()), this, SLOT(downShortcut_triggered()));
connect(leftShortcut, SIGNAL(activated()), this, SLOT(leftShortcut_triggered()));
connect(rightShortcut, SIGNAL(activated()), this, SLOT(rightShortcut_triggered()));
// Axial Display Tab Shortcuts
connect(fatRadioBtnShortcut, SIGNAL(activated()), ui->fatRadioBtn, SLOT(toggle()));
connect(waterRadioBtnShortcut, SIGNAL(activated()), ui->waterRadioBtn, SLOT(toggle()));
connect(fatFracRadioBtnShortcut, SIGNAL(activated()), ui->fatFracRadioBtn, SLOT(toggle()));
connect(waterFracRadioBtnShortcut, SIGNAL(activated()), ui->waterFracRadioBtn, SLOT(toggle()));
connect(fatWaterRadioBtnShortcut, SIGNAL(activated()), ui->fatWaterRadioBtn, SLOT(toggle()));
connect(waterFatRadioBtnShortcut, SIGNAL(activated()), ui->waterFatRadioBtn, SLOT(toggle()));
connect(resetViewShortcut, SIGNAL(activated()), ui->resetViewBtn, SLOT(click()));
// Tracing Tab Shortcuts
connect(EATRadioBtnShortcut, SIGNAL(activated()), ui->EATRadioBtn, SLOT(toggle()));
connect(IMATRadioBtnShortcut, SIGNAL(activated()), ui->IMATRadioBtn, SLOT(toggle()));
connect(PAATRadioBtnShortcut, SIGNAL(activated()), ui->PAATRadioBtn, SLOT(toggle()));
connect(PATRadioBtnShortcut, SIGNAL(activated()), ui->PATRadioBtn, SLOT(toggle()));
connect(SCATRadioBtnShortcut, SIGNAL(activated()), ui->SCATRadioBtn, SLOT(toggle()));
connect(VATRadioBtnShortcut, SIGNAL(activated()), ui->VATRadioBtn, SLOT(toggle()));
connect(EATCheckBoxShortcut, SIGNAL(activated()), ui->EATCheckBox, SLOT(toggle()));
connect(IMATCheckBoxShortcut, SIGNAL(activated()), ui->IMATCheckBox, SLOT(toggle()));
connect(PAATCheckBoxShortcut, SIGNAL(activated()), ui->PAATCheckBox, SLOT(toggle()));
connect(PATCheckBoxShortcut, SIGNAL(activated()), ui->PATCheckBox, SLOT(toggle()));
connect(SCATCheckBoxShortcut, SIGNAL(activated()), ui->SCATCheckBox, SLOT(toggle()));
connect(VATCheckBoxShortcut, SIGNAL(activated()), ui->VATCheckBox, SLOT(toggle()));
connect(drawPointsModeShortcut, SIGNAL(activated()), ui->drawPointsBtn, SLOT(click()));
connect(erasePointsModeShortcut, SIGNAL(activated()), ui->eraserBtn, SLOT(click()));
// Actions
connect(parentMain()->ui->actionOpen, SIGNAL(triggered()), this, SLOT(actionOpen_triggered()));
connect(parentMain()->ui->actionSave, SIGNAL(triggered()), this, SLOT(actionSave_triggered()));
connect(parentMain()->ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs_triggered()));
connect(parentMain()->ui->actionImportTracingData, SIGNAL(triggered()), this, SLOT(actionImportTracingData_triggered()));
connect(parentMain()->ui->actionShow_History, SIGNAL(triggered()), this, SLOT(actionShow_History_triggered()));
connect(parentMain()->ui->actionUndo, SIGNAL(triggered()), this, SLOT(actionUndo_triggered()));
connect(parentMain()->ui->actionRedo, SIGNAL(triggered()), this, SLOT(actionRedo_triggered()));
}
MainWindow *viewAxialCoronalLoRes::parentMain()
{
return static_cast<MainWindow *>(this->parent());
}
void viewAxialCoronalLoRes::readSettings()
{
QSettings settings;
ui->glWidgetAxial->readSettings(settings);
ui->glWidgetCoronal->readSettings(settings);
}
void viewAxialCoronalLoRes::writeSettings()
{
QSettings settings;
ui->glWidgetAxial->writeSettings(settings);
ui->glWidgetCoronal->writeSettings(settings);
}
bool viewAxialCoronalLoRes::loadImage(QuaZip *zip)
{
nifti_image *fatUpperImage = NULL;
nifti_image *fatLowerImage = NULL;
nifti_image *waterUpperImage = NULL;
nifti_image *waterLowerImage = NULL;
try
{
// Load NIFTI file
QString fatUpperPath = "fatUpper.nii";
QString fatLowerPath = "fatLower.nii";
QString waterUpperPath = "waterUpper.nii";
QString waterLowerPath = "waterLower.nii";
// Load the NIFTI files
fatUpperImage = nifti_image_read_qt(zip, fatUpperPath);
fatLowerImage = nifti_image_read_qt(zip, fatLowerPath);
waterUpperImage = nifti_image_read_qt(zip, waterUpperPath);
waterLowerImage = nifti_image_read_qt(zip, waterLowerPath);
if (!fatUpperImage || !fatLowerImage || !waterUpperImage || !waterLowerImage)
EXCEPTION("Unable to load SDI image", "The SDI image you are trying to load may be corrupted. One of the NIFTI images is missing.");
QuaZipFile configFile(zip);
if (!zip->setCurrentFile("config.xml"))
EXCEPTION("Unable to load SDI image", "The SDI image you are trying to load may be corrupted. Unable to find the config file.");
if (!configFile.open(QIODevice::ReadOnly) || !subConfig->load(&configFile))
EXCEPTION("Unable to load SDI image", "The SDI image you are trying to load may be corrupted. Unable to open and load config file.");
if (!fatImage->setImage(fatUpperImage, fatLowerImage))
EXCEPTION("Unable to merge upper and lower image", "Unable to merge upper and lower fat images in NIFTImage class.");
if (!waterImage->setImage(waterUpperImage, waterLowerImage))
EXCEPTION("Unable to merge upper and lower image", "Unable to merge upper and lower water images in NIFTImage class.");
if (!fatImage->compatible(waterImage))
EXCEPTION("Fat and water image are incompatible", "The fat and water image are incompatible in some way. Please check the NIFTI file format of the files and try again.");
parentMain()->setWindowTitle(QCoreApplication::applicationName() + " - " + zip->getZipName());
// The settings box is disabled to prevent moving stuff before anything is loaded
setEnableSettings(true);
// Initialize the tracing data to be the same size as the image and all zeros (no traces)
// Also initialize each layer of time to be the same size as Z dim (one for each slice)
for (auto &layer : tracingData->layers)
layer.load(fatImage->getXDim(), fatImage->getYDim(), fatImage->getZDim());
ui->glWidgetAxial->imageLoaded();
ui->glWidgetCoronal->imageLoaded();
// Setup the default controls in the GUI
setupDefaults();
return true;
}
catch (const Exception &e)
{
// Show a message box for this exception and free the four nifti images if they are allocated.
// Since this is an open dialog box, we do not want to stop the application so the exception is caught here
qWarning() << e.message();
if (fatUpperImage) nifti_image_free(fatUpperImage);
if (fatLowerImage) nifti_image_free(fatLowerImage);
if (waterUpperImage) nifti_image_free(waterUpperImage);
if (waterLowerImage) nifti_image_free(waterLowerImage);
}
catch (...)
{
// This is an exception that cannot be handled in this function and so it is rethrown to be handled elsewhere
if (fatUpperImage) nifti_image_free(fatUpperImage);
if (fatLowerImage) nifti_image_free(fatLowerImage);
if (waterUpperImage) nifti_image_free(waterUpperImage);
if (waterLowerImage) nifti_image_free(waterLowerImage);
throw;
}
return false;
}
void viewAxialCoronalLoRes::setEnableSettings(bool enable)
{
ui->settingsWidget->setEnabled(enable);
// Home Tab Shortcuts
upShortcut->setEnabled(enable);
downShortcut->setEnabled(enable);
leftShortcut->setEnabled(enable);
rightShortcut->setEnabled(enable);
// Axial Display Tab Shortcuts
fatRadioBtnShortcut->setEnabled(enable);
waterRadioBtnShortcut->setEnabled(enable);
fatFracRadioBtnShortcut->setEnabled(enable);
waterFracRadioBtnShortcut->setEnabled(enable);
fatWaterRadioBtnShortcut->setEnabled(enable);
waterFatRadioBtnShortcut->setEnabled(enable);
resetViewShortcut->setEnabled(enable);
// Tracing Tab Shortcuts
EATRadioBtnShortcut->setEnabled(enable);
IMATRadioBtnShortcut->setEnabled(enable);
PAATRadioBtnShortcut->setEnabled(enable);
PATRadioBtnShortcut->setEnabled(enable);
SCATRadioBtnShortcut->setEnabled(enable);
VATRadioBtnShortcut->setEnabled(enable);
EATCheckBoxShortcut->setEnabled(enable);
IMATCheckBoxShortcut->setEnabled(enable);
PAATCheckBoxShortcut->setEnabled(enable);
PATCheckBoxShortcut->setEnabled(enable);
SCATCheckBoxShortcut->setEnabled(enable);
VATCheckBoxShortcut->setEnabled(enable);
drawPointsModeShortcut->setEnabled(enable);
erasePointsModeShortcut->setEnabled(enable);
}
void viewAxialCoronalLoRes::setupDefaults()
{
// The default slice that it will go to is half of the zDim
QVector4D defaultLocation = QVector4D(Location::NoChange, floor(fatImage->getYDim() / 2), floor(fatImage->getZDim() / 2), Location::NoChange);
// In the OpenGL widget, set the default location
ui->glWidgetAxial->setLocation(defaultLocation);
ui->glWidgetCoronal->setLocation(defaultLocation);
// -------------------------------------------- Setup Home Tab --------------------------------------------
// Set the range of the slice spin box to be 0 to the height of the fatImage (this is upper + lower z-height)
ui->axialSliceSpinBox->setRange(0, fatImage->getZDim() - 1);
// Set the value of the slice spin box to be what the defaultSlice is.
ui->axialSliceSpinBox->setValue(defaultLocation.z());
// Set the range of the slice slider to be 0 to the height of the fatImage (this is upper + lower z-height)
ui->axialSliceSlider->setRange(0, fatImage->getZDim() - 1);
// Set the value of the slice slider to be what the defaultSlice is.
ui->axialSliceSlider->setValue(defaultLocation.z());
// Coronal slice spin box range is 0 to 1 minus the maximum Y dimension. Set value to default location
ui->coronalSliceSpinBox->setRange(0, fatImage->getYDim() - 1);
ui->coronalSliceSpinBox->setValue(defaultLocation.y());
// Coronal slice slider range is 0 to 1 minus the maximum Y dimension. Set value to default location
ui->coronalSliceSlider->setRange(0, fatImage->getYDim() - 1);
ui->coronalSliceSlider->setValue(defaultLocation.y());
// Saggital slice spin box range is 0 to 1 minus the maximum X dimension. Set value to default location
ui->saggitalSliceSpinBox->setRange(0, fatImage->getXDim() - 1);
ui->saggitalSliceSpinBox->setValue(defaultLocation.x());
// Saggital slice slider range is 0 to 1 minus the maximum X dimension. Set value to default location
ui->saggitalSliceSlider->setRange(0, fatImage->getXDim() - 1);
ui->saggitalSliceSlider->setValue(defaultLocation.x());
// ---------------------------------------- Setup Axial Display Tab ----------------------------------------
// Set the brightness slider value to the default brightness
ui->brightnessSlider->setValue(int(ui->glWidgetAxial->getBrightness() * 100.0f));
// Set the brightness spin box value to the default brightness
ui->brightnessSpinBox->setValue(int(ui->glWidgetAxial->getBrightness() * 100.0f));
// Set the contrast slider value to the default contrast
ui->contrastSlider->setValue(int(ui->glWidgetAxial->getContrast() * 100.0f));
// Set the contrast spin box value to the default contrast
ui->contrastSpinBox->setValue(int(ui->glWidgetAxial->getContrast() * 100.0f));
// Set the primary colormap value to the current color map and set the opacity
ui->primColorMapComboBox->setCurrentIndex((int)ui->glWidgetAxial->getPrimColorMap());
ui->primOpacitySlider->setValue(int(ui->glWidgetAxial->getPrimOpacity() * 100.0f));
ui->primOpacitySpinBox->setValue(int(ui->glWidgetAxial->getPrimOpacity() * 100.0f));
// Set the secondary colormap value to the current color map and set the opacity
ui->secdColorMapComboBox->setCurrentIndex((int)ui->glWidgetAxial->getSecdColorMap());
ui->secdOpacitySlider->setValue(int(ui->glWidgetAxial->getSecdOpacity() * 100.0f));
ui->secdOpacitySpinBox->setValue(int(ui->glWidgetAxial->getSecdOpacity() * 100.0f));
// Read the current display type for the axial slice widget and check
// the appropiate radio button for the current axial view
switch (ui->glWidgetAxial->getDisplayType())
{
case SliceDisplayType::FatOnly: ui->fatRadioBtn->setChecked(true); break;
case SliceDisplayType::WaterOnly: ui->waterRadioBtn->setChecked(true); break;
case SliceDisplayType::FatFraction: ui->fatFracRadioBtn->setChecked(true); break;
case SliceDisplayType::WaterFraction: ui->waterFracRadioBtn->setChecked(true); break;
case SliceDisplayType::FatWater: ui->fatWaterRadioBtn->setChecked(true); break;
case SliceDisplayType::WaterFat: ui->waterFatRadioBtn->setChecked(true); break;
}
// Enable the secondary image box if FatWater or WaterFat selected, otherwise disable
ui->secondaryImageBox->setEnabled((ui->glWidgetAxial->getDisplayType() == SliceDisplayType::FatWater || ui->glWidgetAxial->getDisplayType() == SliceDisplayType::WaterFat));
// ------------------------------------------- Setup Tracing Tab -------------------------------------------
ui->EATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::EAT));
ui->IMATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::IMAT));
ui->PAATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::PAAT));
ui->PATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::PAT));
ui->SCATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::SCAT));
ui->VATCheckBox->setChecked(ui->glWidgetAxial->getTracingLayerVisible(TracingLayer::VAT));
// Set the current radio button based on default layer to be drawing with
switch (ui->glWidgetAxial->getTracingLayer())
{
case TracingLayer::EAT: ui->EATRadioBtn->setChecked(true); break;
case TracingLayer::IMAT: ui->IMATRadioBtn->setChecked(true); break;
case TracingLayer::PAAT: ui->PAATRadioBtn->setChecked(true); break;
case TracingLayer::PAT: ui->PATRadioBtn->setChecked(true); break;
case TracingLayer::SCAT: ui->SCATRadioBtn->setChecked(true); break;
case TracingLayer::VAT: ui->VATRadioBtn->setChecked(true); break;
}
switch (ui->glWidgetAxial->getDrawMode())
{
case DrawMode::Points: ui->drawPointsBtn->setChecked(true); break;
case DrawMode::Erase: ui->eraserBtn->setChecked(true); break;
}
ui->drawModeStackedWidget->setCurrentIndex((int)ui->glWidgetAxial->getDrawMode());
switch (ui->glWidgetAxial->getEraserBrushWidth())
{
case 1: ui->eraserBrushWidthComboBox->setCurrentIndex(0); break; // 1px
case 2: ui->eraserBrushWidthComboBox->setCurrentIndex(1); break; // 2px
case 4: ui->eraserBrushWidthComboBox->setCurrentIndex(2); break; // 4px
case 6: ui->eraserBrushWidthComboBox->setCurrentIndex(3); break; // 6px
case 8: ui->eraserBrushWidthComboBox->setCurrentIndex(4); break; // 8px
default:
qWarning() << "Unknown eraser brush width combo selected: " << ui->glWidgetAxial->getEraserBrushWidth();
}
}
void viewAxialCoronalLoRes::actionOpen_triggered()
{
// Start dialog to select location to load the subject image
QString filename = QFileDialog::getOpenFileName(this, "Open Subject Image", parentMain()->defaultOpenPath, "Subject Image (*.sdi)");
if (filename.isNull())
return; // If they hit cancel, do nothing
QFileInfo fileInfo(filename);
if (!fileInfo.exists() || !fileInfo.isFile())
{
qWarning() << "Selected file for opening subject image either does not exist or is not a file: " << filename;
return;
}
// Open QuaZip file with the specified filename
QuaZip *imageZip = new QuaZip(filename);
if (!imageZip->open(QuaZip::mdUnzip))
{
qWarning() << "Unable to open SDI file at " << filename << ": " << imageZip->getZipError();
delete imageZip;
return;
}
if (loadImage(imageZip))
{
// Since the NIFTI files were successfully opened, the default path in the FileChooser dialog next time will be this path
parentMain()->defaultOpenPath = fileInfo.absolutePath();
// Since load was successful, if there was existing tracing data zip, delete it
// Note: The user already approved this since a confirm prompt occurs in loadTracingData
if (parentMain()->imageZip)
delete parentMain()->imageZip;
parentMain()->imageZip = imageZip;
parentMain()->ui->statusBar->showMessage(QObject::tr("Successfully loaded file in %1").arg(imageZip->getZipName()), 4000);
imageZip->close();
}
else
delete imageZip;
}
void viewAxialCoronalLoRes::actionSave_triggered()
{
if (!parentMain()->tracingResultsZip)
{
actionSaveAs_triggered();
return;
}
if (!parentMain()->tracingResultsZip->open(QuaZip::mdCreate))
{
qWarning() << "Unable to open SDT file at " << parentMain()->tracingResultsZip->getZipName()
<< ": " << parentMain()->tracingResultsZip->getZipError();
return;
}
if (ui->glWidgetAxial->saveTracingData(parentMain()->tracingResultsZip))
parentMain()->ui->statusBar->showMessage(QObject::tr("Successfully saved file in %1").arg(parentMain()->tracingResultsZip->getZipName()), 4000);
parentMain()->tracingResultsZip->close();
}
void viewAxialCoronalLoRes::actionSaveAs_triggered()
{
// Start dialog to select location to save the tracing results
QString filename = QFileDialog::getSaveFileName(this, "Save File As", parentMain()->defaultSavePath, "Tracing Results (*.sdt)");
if (filename.isNull())
return; // If they hit cancel, do nothing
QFileInfo fileInfo(filename);
// If the file exists and is not a file, then throw an error
if (fileInfo.exists() && !fileInfo.isFile())
{
qWarning() << filename << "is not a valid file";
return;
}
// Open QuaZip file with the specified filename
QuaZip *tracingResultsZip = new QuaZip(filename);
if (!tracingResultsZip->open(QuaZip::mdCreate))
{
qWarning() << "Unable to open SDT file at " << filename << ": " << tracingResultsZip->getZipError();
delete tracingResultsZip;
return;
}
if (ui->glWidgetAxial->saveTracingData(tracingResultsZip))
{
// Since the NIFTI files were successfully saved, the default path in the dialog next time will be this path
parentMain()->defaultSavePath = fileInfo.absolutePath();
// Since save was successful, if there was existing tracing data zip, delete it
// Note: The user already approved this since a confirm prompt occurs in saveTracingData
if (parentMain()->tracingResultsZip)
delete parentMain()->tracingResultsZip;
// Set new tracing results zip
parentMain()->tracingResultsZip = tracingResultsZip;
parentMain()->ui->statusBar->showMessage(QObject::tr("Successfully saved file at %1").arg(tracingResultsZip->getZipName()), 4000);
tracingResultsZip->close();
}
else
{
qWarning() << "Unable to save tracing data in path: " << filename;
delete tracingResultsZip;
}
}
void viewAxialCoronalLoRes::actionImportTracingData_triggered()
{
// Start dialog to select location to load the tracing results
QString filename = QFileDialog::getOpenFileName(this, "Import Tracing Data", parentMain()->defaultSavePath, "Tracing Results (*.sdt)");
if (filename.isNull())
return; // If they hit cancel, do nothing
QFileInfo fileInfo(filename);
if (!fileInfo.exists() || !fileInfo.isFile())
{
qWarning() << "Selected file for saving the tracing results either does not exist or is not a file: " << filename;
return;
}
// Open QuaZip file with the specified filename
QuaZip *tracingResultsZip = new QuaZip(filename);
if (!tracingResultsZip->open(QuaZip::mdUnzip))
{
qWarning() << "Unable to open SDT file at " << filename << ": " << tracingResultsZip->getZipError();
delete tracingResultsZip;
return;
}
if (ui->glWidgetAxial->loadTracingData(tracingResultsZip))
{
// Since the NIFTI files were successfully loaded, the default path in the dialog next time will be this path
parentMain()->defaultSavePath = fileInfo.absolutePath();
// Since load was successful, if there was existing tracing data zip, delete it
// Note: The user already approved this since a confirm prompt occurs in loadTracingData
if (parentMain()->tracingResultsZip)
delete parentMain()->tracingResultsZip;
parentMain()->tracingResultsZip = tracingResultsZip;
parentMain()->ui->statusBar->showMessage(QObject::tr("Successfully loaded tracing results in %1").arg(filename), 4000);
tracingResultsZip->close();
}
else
delete tracingResultsZip;
}
void viewAxialCoronalLoRes::actionUndo_triggered()
{
parentMain()->ui->statusBar->showMessage(QObject::tr("Undid \"%1\"").arg(undoStack->undoText()), 4000);
undoStack->undo();
}
void viewAxialCoronalLoRes::actionRedo_triggered()
{
parentMain()->ui->statusBar->showMessage(QObject::tr("Redid \"%1\"").arg(undoStack->redoText()), 4000);
undoStack->redo();
}
void viewAxialCoronalLoRes::actionShow_History_triggered()
{
// If the undoView does not exist or is not visible, then create a new undoView to display
if (!undoView || !undoView->isVisible())
{
// If the old one exists, then delete it and create a new one
if (undoView)
{
undoView->close();
delete undoView;
}
// Create new QUndoView based on undoStack
undoView = new QUndoView(undoStack, this);
undoView->setWindowFlags(Qt::Tool);
undoView->setWindowTitle(tr("History"));
undoView->setWindowModality(Qt::NonModal);
undoView->show();
undoView->setAttribute(Qt::WA_QuitOnClose, false);
}
}
void viewAxialCoronalLoRes::upShortcut_triggered()
{
const int value = ui->glWidgetAxial->getLocation().y() + 1;
if (value >= fatImage->getYDim())
return;
// Add a SliceChangeCommand to change the coronal slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, value, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::downShortcut_triggered()
{
const int value = ui->glWidgetAxial->getLocation().y() - 1;
if (value < 0)
return;
// Add a SliceChangeCommand to change the coronal slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, value, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::leftShortcut_triggered()
{
const int value = ui->glWidgetAxial->getLocation().z() - 1;
if (value < 0)
return;
// Add a SliceChangeCommand to change the axial slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, Location::NoChange, value, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::rightShortcut_triggered()
{
const int value = ui->glWidgetAxial->getLocation().z() + 1;
if (value >= fatImage->getZDim())
return;
// Add a SliceChangeCommand to change the axial slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, Location::NoChange, value, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_axialSliceSlider_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().z())
return;
// Add a SliceChangeCommand to change the axial slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, Location::NoChange, value, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_axialSliceSpinBox_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().z())
return;
// Add a SliceChangeCommand to change the axial slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, Location::NoChange, value, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_coronalSliceSlider_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().y())
return;
// Add a SliceChangeCommand to change the coronal slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, value, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_coronalSliceSpinBox_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().y())
return;
// Add a SliceChangeCommand to change the coronal slice
undoStack->push(new LocationChangeCommand(QVector4D(Location::NoChange, value, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_saggitalSliceSlider_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().x())
return;
// Add a SliceChangeCommand to change the saggital slice
undoStack->push(new LocationChangeCommand(QVector4D(value, Location::NoChange, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_saggitalSliceSpinBox_valueChanged(int value)
{
// If the new value is equal to the current slice, then do nothing
if (value == ui->glWidgetAxial->getLocation().x())
return;
// Add a SliceChangeCommand to change the saggital slice
undoStack->push(new LocationChangeCommand(QVector4D(value, Location::NoChange, Location::NoChange, Location::NoChange), ui->glWidgetAxial, ui->glWidgetCoronal,
ui->axialSliceSlider, ui->axialSliceSpinBox, ui->coronalSliceSlider,
ui->coronalSliceSpinBox, ui->saggitalSliceSlider, ui->saggitalSliceSpinBox));
}
void viewAxialCoronalLoRes::on_brightnessSlider_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getBrightness())
return;
// Add a BrightnessChangeCommand to change the brightness
undoStack->push(new BrightnessChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->brightnessSlider, ui->brightnessSpinBox));
}
void viewAxialCoronalLoRes::on_brightnessSpinBox_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getBrightness())
return;
// Add a BrightnessChangeCommand to change the brightness
undoStack->push(new BrightnessChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->brightnessSlider, ui->brightnessSpinBox));
}
void viewAxialCoronalLoRes::on_brightnessThresSpinBox_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getBrightnessThreshold())
return;
// Add a BrightnessThresChangeCommand to change the brightness threshold
undoStack->push(new BrightnessThresChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->brightnessThresSpinBox));
}
void viewAxialCoronalLoRes::on_contrastSlider_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getContrast())
return;
// Add a ContrastChangeCommand to change the contrast
undoStack->push(new ContrastChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->contrastSlider, ui->contrastSpinBox));
}
void viewAxialCoronalLoRes::on_contrastSpinBox_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getContrast())
return;
// Add a ContrastChangeCommand to change the contrast
undoStack->push(new ContrastChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->contrastSlider, ui->contrastSpinBox));
}
void viewAxialCoronalLoRes::on_primColorMapComboBox_currentIndexChanged(int index)
{
// If the index is out of the acceptable bounds for the ColorMap, then do nothing
if (index == (int)ui->glWidgetAxial->getPrimColorMap() || index < (int)ColorMap::Autumn || index >= (int)ColorMap::Count)
return;
// Add a ColorMapChangeCommand to change the color map
undoStack->push(new PrimColorMapChangeCommand((ColorMap)index, ui->glWidgetAxial, ui->primColorMapComboBox));
}
void viewAxialCoronalLoRes::on_primOpacitySlider_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getPrimOpacity())
return;
// Add a PrimOpacityChangeCommand to change the primary opacity
undoStack->push(new PrimOpacityChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->primOpacitySlider, ui->primOpacitySpinBox));
}
void viewAxialCoronalLoRes::on_primOpacitySpinBox_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getPrimOpacity())
return;
// Add a PrimOpacityChangeCommand to change the primary opacity
undoStack->push(new PrimOpacityChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->primOpacitySlider, ui->primOpacitySpinBox));
}
void viewAxialCoronalLoRes::on_secdColorMapComboBox_currentIndexChanged(int index)
{
// If the index is out of the acceptable bounds for the ColorMap, then do nothing
if (index == (int)ui->glWidgetAxial->getSecdColorMap() || index < (int)ColorMap::Autumn || index >= (int)ColorMap::Count)
return;
// Add a ColorMapChangeCommand to change the color map
undoStack->push(new SecdColorMapChangeCommand((ColorMap)index, ui->glWidgetAxial, ui->secdColorMapComboBox));
}
void viewAxialCoronalLoRes::on_secdOpacitySlider_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getSecdOpacity())
return;
// Add a SecdOpacityChangeCommand to change the secondary opacity
undoStack->push(new SecdOpacityChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->secdOpacitySlider, ui->secdOpacitySpinBox));
}
void viewAxialCoronalLoRes::on_secdOpacitySpinBox_valueChanged(int value)
{
// If the new value is equal to the current value, then do nothing
if (value / 100.0f == ui->glWidgetAxial->getSecdOpacity())
return;
// Add a SecdOpacityChangeCommand to change the secondary opacity
undoStack->push(new SecdOpacityChangeCommand(value / 100.0f, ui->glWidgetAxial, ui->secdOpacitySlider, ui->secdOpacitySpinBox));
}
void viewAxialCoronalLoRes::changeSliceView(SliceDisplayType newType)
{
if (newType == ui->glWidgetAxial->getDisplayType())
return; // If old and new type are same, do nothing
QRadioButton *newBtn = NULL;
switch (newType)
{
case SliceDisplayType::FatOnly: newBtn = ui->fatRadioBtn; break;
case SliceDisplayType::WaterOnly: newBtn = ui->waterRadioBtn; break;
case SliceDisplayType::FatFraction: newBtn = ui->fatFracRadioBtn; break;
case SliceDisplayType::WaterFraction: newBtn = ui->waterFracRadioBtn; break;
case SliceDisplayType::FatWater: newBtn = ui->fatWaterRadioBtn; break;
case SliceDisplayType::WaterFat: newBtn = ui->waterFatRadioBtn; break;
}
QRadioButton *oldBtn = NULL;
switch (ui->glWidgetAxial->getDisplayType())
{
case SliceDisplayType::FatOnly: oldBtn = ui->fatRadioBtn; break;
case SliceDisplayType::WaterOnly: oldBtn = ui->waterRadioBtn; break;
case SliceDisplayType::FatFraction: oldBtn = ui->fatFracRadioBtn; break;
case SliceDisplayType::WaterFraction: oldBtn = ui->waterFracRadioBtn; break;
case SliceDisplayType::FatWater: oldBtn = ui->fatWaterRadioBtn; break;
case SliceDisplayType::WaterFat: oldBtn = ui->waterFatRadioBtn; break;
}
// Enable the secondary image box if FatWater or WaterFat selected, otherwise disable
parentMain()->ui->statusBar->showMessage(QObject::tr("Change slice view to %1").arg(newBtn->text()), 4000);
ui->secondaryImageBox->setEnabled((newType == SliceDisplayType::FatWater || newType == SliceDisplayType::WaterFat));
undoStack->push(new SliceViewChangeCommand(newType, ui->glWidgetAxial, oldBtn, newBtn));
}
void viewAxialCoronalLoRes::on_fatRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::FatOnly);
}
void viewAxialCoronalLoRes::on_waterRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::WaterOnly);
}
void viewAxialCoronalLoRes::on_fatFracRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::FatFraction);
}
void viewAxialCoronalLoRes::on_waterFracRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::WaterFraction);
}
void viewAxialCoronalLoRes::on_fatWaterRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::FatWater);
}
void viewAxialCoronalLoRes::on_waterFatRadioBtn_toggled(bool checked)
{
if (checked)
changeSliceView(SliceDisplayType::WaterFat);
}
void viewAxialCoronalLoRes::on_resetViewBtn_clicked()
{
undoStack->push(new ResetViewCommand(ui->glWidgetAxial, ui->glWidgetCoronal));
}
void viewAxialCoronalLoRes::changeTracingLayer(TracingLayer newLayer)
{
if (newLayer == ui->glWidgetAxial->getTracingLayer())
return; // If old and new layer are same, do nothing
QRadioButton *newBtn = NULL;
switch (newLayer)
{
case TracingLayer::EAT: newBtn = ui->EATRadioBtn; break;
case TracingLayer::IMAT: newBtn = ui->IMATRadioBtn; break;
case TracingLayer::PAAT: newBtn = ui->PAATRadioBtn; break;
case TracingLayer::PAT: newBtn = ui->PATRadioBtn; break;
case TracingLayer::SCAT: newBtn = ui->SCATRadioBtn; break;
case TracingLayer::VAT: newBtn = ui->VATRadioBtn; break;
}
QRadioButton *oldBtn = NULL;
switch (ui->glWidgetAxial->getTracingLayer())
{
case TracingLayer::EAT: oldBtn = ui->EATRadioBtn; break;
case TracingLayer::IMAT: oldBtn = ui->IMATRadioBtn; break;
case TracingLayer::PAAT: oldBtn = ui->PAATRadioBtn; break;
case TracingLayer::PAT: oldBtn = ui->PATRadioBtn; break;
case TracingLayer::SCAT: oldBtn = ui->SCATRadioBtn; break;
case TracingLayer::VAT: oldBtn = ui->VATRadioBtn; break;
}
parentMain()->ui->statusBar->showMessage(QObject::tr("Change tracing layer to %1").arg(newBtn->text()), 4000);
undoStack->push(new TracingLayerChangeCommand(newLayer, ui->glWidgetAxial, oldBtn, newBtn));
}
void viewAxialCoronalLoRes::on_EATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::EAT);
}
void viewAxialCoronalLoRes::on_IMATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::IMAT);
}
void viewAxialCoronalLoRes::on_PAATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::PAAT);
}
void viewAxialCoronalLoRes::on_PATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::PAT);
}
void viewAxialCoronalLoRes::on_SCATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::SCAT);
}
void viewAxialCoronalLoRes::on_VATRadioBtn_toggled(bool checked)
{
if (checked)
changeTracingLayer(TracingLayer::VAT);
}
void viewAxialCoronalLoRes::on_EATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 EAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::EAT, checked, ui->glWidgetAxial, ui->EATCheckBox));
}
void viewAxialCoronalLoRes::on_IMATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 IMAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::IMAT, checked, ui->glWidgetAxial, ui->IMATCheckBox));
}
void viewAxialCoronalLoRes::on_PAATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 PAAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::PAAT, checked, ui->glWidgetAxial, ui->PAATCheckBox));
}
void viewAxialCoronalLoRes::on_PATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 PAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::PAT, checked, ui->glWidgetAxial, ui->PATCheckBox));
}
void viewAxialCoronalLoRes::on_SCATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 SCAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::SCAT, checked, ui->glWidgetAxial, ui->SCATCheckBox));
}
void viewAxialCoronalLoRes::on_VATCheckBox_toggled(bool checked)
{
parentMain()->ui->statusBar->showMessage(QObject::tr("%1 VAT tracing layer").arg(checked ? "Showing" : "Hiding"), 4000);
undoStack->push(new TracingLayerVisibleChangeCommand(TracingLayer::VAT, checked, ui->glWidgetAxial, ui->VATCheckBox));
}
void viewAxialCoronalLoRes::changeDrawMode(DrawMode newMode)
{
if (newMode == ui->glWidgetAxial->getDrawMode())
return; // If old and new draw mode are the same, do nothing
QPushButton *newBtn = NULL;
QString newModeStr;
switch (newMode)
{
case DrawMode::Points: newBtn = ui->drawPointsBtn; newModeStr = "Draw Points"; break;
case DrawMode::Erase: newBtn = ui->eraserBtn; newModeStr = "Erase"; break;
}
QPushButton *oldBtn = NULL;
switch (ui->glWidgetAxial->getDrawMode())
{
case DrawMode::Points: oldBtn = ui->drawPointsBtn; break;
case DrawMode::Erase: oldBtn = ui->eraserBtn; break;
}
parentMain()->ui->statusBar->showMessage(QObject::tr("Change draw mode to %1").arg(newModeStr), 4000);
undoStack->push(new DrawModeChangeCommand(newMode, ui->glWidgetAxial, ui->drawModeStackedWidget, oldBtn, newBtn, newModeStr));
}
void viewAxialCoronalLoRes::on_drawPointsBtn_toggled(bool checked)
{
if (checked)
changeDrawMode(DrawMode::Points);
}
void viewAxialCoronalLoRes::on_eraserBtn_toggled(bool checked)
{
if (checked)
changeDrawMode(DrawMode::Erase);
}
void viewAxialCoronalLoRes::on_eraserBrushWidthComboBox_currentIndexChanged(int index)
{
switch (index)
{
case 0: ui->glWidgetAxial->setEraserBrushWidth(1); break; // 1px