00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "wxQuantificationWidgetCT.h"
00021 #include "../marDictionary.h"
00022 #include "vtkPolyDataWriter.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031 BEGIN_EVENT_TABLE( wxQuantificationWidgetCT, wxPanel )
00032 EVT_BUTTON(ID_BUTTON_CONTOUR , wxQuantificationWidgetCT::OnContour_BT )
00033 EVT_BUTTON(ID_BUTTON_CLEAN , wxQuantificationWidgetCT::OnClean_BT )
00034 EVT_BUTTON(ID_BUTTON_CLEAN_ALL , wxQuantificationWidgetCT::OnCleanAll_BT )
00035 EVT_CHECKBOX(ID_CHECKBOX_HEALTHY, wxQuantificationWidgetCT::OnHealthySlice_CB )
00036 EVT_CHECKBOX(ID_CHECKBOX_SHOW_SURFACE, wxQuantificationWidgetCT::OnShowSurface_CB )
00037 EVT_CHECKBOX(ID_CHECKBOX_VISIBLE_RINGS, wxQuantificationWidgetCT::OnVisibleRing_CB )
00038 EVT_CHECKBOX(ID_CHECKBOX_PERPENDICULAR, wxQuantificationWidgetCT::OnPerpendicular_CB )
00039
00040 EVT_RADIOBUTTON(ID_RADIOBUTTON_GREYSCALE, wxQuantificationWidgetCT::OnGreyScale_RB )
00041 EVT_RADIOBUTTON(ID_RADIOBUTTON_COLOR, wxQuantificationWidgetCT::OnColor_RB )
00042
00043 EVT_COMMAND_SCROLL(ID_SLIDER_SLICE, wxQuantificationWidgetCT::OnSliderSliceScroll )
00044
00045 EVT_COMMAND_SCROLL(ID_SLIDER_OPACITY, wxQuantificationWidgetCT::OnSliderOpacityScroll )
00046 EVT_COMMAND_SCROLL_THUMBRELEASE(ID_SLIDER_ISOVALUE, wxQuantificationWidgetCT::OnSliderIsovalueScroll )
00047
00048 END_EVENT_TABLE( );
00049
00050
00051
00052
00053 wxQuantificationWidgetCT::wxQuantificationWidgetCT(wxWindow* parent, wxWindowID id,
00054 const wxPoint& pos, const wxSize& size, long style,
00055 const wxString& name)
00056 : wxQuantificationWidget_base( parent, id, pos, size, style, name )
00057 {
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 _bak_ActualSlice=-1;
00091 _bak_ActualSlice2=-1;
00092
00093 _mar = NULL;
00094
00095 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00096 sizer->Add( CreatePanelPrincipal(this), 1, wxALL|wxEXPAND, 0 );
00097 sizer->Add( CreatePanelStatus(this) , 0, wxALL|wxEXPAND, 0 );
00098
00099 SetSizer(sizer);
00100 Layout();
00101
00102
00103
00104 }
00105
00106
00107
00108
00109
00110 wxQuantificationWidgetCT::~wxQuantificationWidgetCT( ){
00111 _3DWorld->Delete( );
00112 delete _contourViewer;
00113 delete _lineViewer;
00114 delete _pointViewer;
00115
00116
00117 for (int i = 0; i < _manContours.size(); i++)
00118 {
00119 delete _manContours[i];
00120 _manContours[i] = NULL;
00121 }
00122 delete _imageviewer2D_1;
00123 }
00124
00125 wxWindow* wxQuantificationWidgetCT::CreatePanelPrincipal(wxWindow *parent)
00126 {
00127 wxPanel *panel = new wxPanel(parent,-1);
00128 _splitPanelPrincipal = new wxSplitterWindow(panel, -1);
00129 _splitPanelPrincipal->SetMinimumPaneSize(50);
00130
00131 wxWindow *principal_Left = CreatePanel_Left(_splitPanelPrincipal) ;
00132 wxWindow *principal_Right = CreatePanel_Right(_splitPanelPrincipal);
00133
00134 _splitPanelPrincipal->SplitVertically(principal_Left , principal_Right,600 );
00135
00136
00137 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00138 sizer->Add( _splitPanelPrincipal, 1,wxGROW,0 );
00139 panel->SetSizer(sizer);
00140 panel->Layout();
00141 return panel;
00142 }
00143
00144
00145 wxWindow* wxQuantificationWidgetCT::CreatePanel_Left(wxWindow *parent)
00146 {
00147 wxPanel *panel = new wxPanel(parent,-1);
00148 _splitpanel_left = new wxSplitterWindow(panel, -1);
00149 _splitpanel_left->SetMinimumPaneSize(50);
00150
00151 _3DWorld = new vtk3DQuantSurfaceWidget( _splitpanel_left, ID_QUANTIF3D );
00152 _3DWorld->SetInterfaceVtkPanelWidgets(NULL);
00153 wxWindow *controlPanel3D = CreateControlPanel3D(_splitpanel_left);
00154
00155 _splitpanel_left->SplitHorizontally(_3DWorld , controlPanel3D,0 );
00156
00157
00158 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00159 sizer->Add( _splitpanel_left, 1,wxGROW,0 );
00160 panel->SetSizer(sizer);
00161 panel->Layout();
00162 return panel;
00163 }
00164
00165
00166
00167 wxWindow* wxQuantificationWidgetCT::CreateControlPanel3D(wxWindow *parent)
00168 {
00169 wxPanel *panel = new wxPanel(parent,-1);
00170 marDictionary marDict;
00171
00172 _cb_HealthySlice = new wxCheckBox( panel, ID_CHECKBOX_HEALTHY, wxString( marDict.GetString(205) , wxConvUTF8));
00173 _cb_HealthySlice->SetValue(true);
00174 _cb_Perpendicular = new wxCheckBox( panel, ID_CHECKBOX_PERPENDICULAR, wxString(marDict.GetString(210), wxConvUTF8));
00175 _cb_Perpendicular->SetValue(true);
00176
00177 _rb_GreyScale = new wxRadioButton( panel, ID_RADIOBUTTON_GREYSCALE, wxString(marDict.GetString(230), wxConvUTF8), wxDefaultPosition,wxDefaultSize,wxRB_GROUP );
00178 _rb_GreyScale->SetValue(true);
00179
00180 _rb_Color = new wxRadioButton( panel, ID_RADIOBUTTON_COLOR, wxString(marDict.GetString(235), wxConvUTF8), wxDefaultPosition,wxDefaultSize );
00181 _rb_Color->SetValue(false);
00182
00183 _cb_VisibleRings = new wxCheckBox( panel, ID_CHECKBOX_VISIBLE_RINGS, wxString(marDict.GetString(215), wxConvUTF8));
00184 _cb_VisibleRings->SetValue(true);
00185 _cb_ShowSurface = new wxCheckBox( panel, ID_CHECKBOX_SHOW_SURFACE, wxString(marDict.GetString(220), wxConvUTF8));
00186 _cb_ShowSurface->SetValue(true);
00187
00188
00189 _bt_AddContour3D = new wxButton( panel, ID_BUTTON_CONTOUR, wxString(marDict.GetString(245), wxConvUTF8) ,
00190 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
00191 _bt_CleanContour3D = new wxButton( panel, ID_BUTTON_CLEAN, wxString(marDict.GetString(250), wxConvUTF8) ,
00192 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
00193
00194 _bt_CleanAllContours3D = new wxButton( panel, ID_BUTTON_CLEAN_ALL, wxString(marDict.GetString(253), wxConvUTF8) ,
00195 wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
00196
00197
00198 _sl_Slice = new wxSlider( panel, ID_SLIDER_SLICE , 0, 0, 10000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
00199 _sl_Isovalue = new wxSlider( panel, ID_SLIDER_ISOVALUE , 0, 0, 10000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
00200 _sl_Opacity = new wxSlider( panel, ID_SLIDER_OPACITY , 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
00201
00202
00203
00204 _sl_Slice->SetSize(800,16);
00205 _sl_Isovalue->SetSize(300,16);
00206 _sl_Opacity->SetSize(300,16);
00207
00208
00209 _st_Slice = new wxStaticText(panel, -1, wxString(marDict.GetString( 90), wxConvUTF8) );
00210 _st_Isovalue = new wxStaticText(panel, -1, wxString(marDict.GetString(240), wxConvUTF8) );
00211 _st_Opacity = new wxStaticText(panel, -1, wxString(marDict.GetString(225), wxConvUTF8) );
00212
00213 _txt_Position = new wxStaticText(panel, -1, _T(" ") );
00214
00215
00216
00217
00218 wxFlexGridSizer *axe = new wxFlexGridSizer(1);
00219
00220 wxFlexGridSizer *axe1 = new wxFlexGridSizer(10);
00221 wxBoxSizer *axe2 = new wxBoxSizer(wxHORIZONTAL);
00222 wxFlexGridSizer *axe3 = new wxFlexGridSizer(10,0);
00223 wxFlexGridSizer *axe4 = new wxFlexGridSizer(10,0);
00224 wxBoxSizer *axe5 = new wxBoxSizer(wxHORIZONTAL);
00225
00226
00227
00228 axe1->Add(_st_Slice , 10, wxALL|wxEXPAND, 0);
00229 axe1->Add(_sl_Slice , 10, wxALL|wxGROW, 0);
00230 axe1->Add(_txt_Position , 10, wxALL|wxEXPAND, 0);
00231 axe1->AddGrowableCol(1);
00232
00233 axe2->Add(_cb_HealthySlice , 10, wxALL|wxEXPAND, 0);
00234 axe2->Add(_cb_Perpendicular , 10, wxALL|wxEXPAND, 0);
00235 axe2->Add(_cb_VisibleRings , 10, wxALL|wxEXPAND, 0);
00236 axe2->Add(_cb_ShowSurface , 10, wxALL|wxEXPAND, 0);
00237
00238 axe3->Add(_st_Opacity , 1, wxALL|wxEXPAND, 0);
00239 axe3->Add(_sl_Opacity , 10, wxALL|wxGROW, 0);
00240 axe3->Add(_rb_GreyScale , 10, wxALL|wxEXPAND, 0);
00241 axe3->Add(_rb_Color , 10, wxALL|wxEXPAND, 0);
00242 axe3->AddGrowableCol(1);
00243
00244 axe4->Add(_st_Isovalue , 1, wxALL|wxEXPAND, 0);
00245 axe4->Add(_sl_Isovalue , 1, wxALL|wxGROW, 0);
00246 axe4->AddGrowableCol(1);
00247
00248 axe5->Add(_bt_AddContour3D , 1 );
00249 axe5->Add(_bt_CleanContour3D , 1 );
00250 axe5->Add(_bt_CleanAllContours3D , 1 );
00251
00252
00253 axe->Add(axe1, 2, wxALL|wxGROW, 0);
00254 axe->Add(axe2, 2, wxALL, 0);
00255 axe->Add(axe3, 2, wxALL|wxGROW, 0);
00256 axe->Add(axe4, 2, wxALL|wxGROW, 0);
00257 axe->Add(axe5, 2, wxALL, 0);
00258
00259
00260
00261
00262 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00263 sizer->Add( axe, 1,wxALL|wxGROW,5 );
00264 panel->SetSizer(sizer);
00265 panel->Layout();
00266 return panel;
00267
00268 }
00269
00270
00271 wxWindow* wxQuantificationWidgetCT::CreatePanel_Right(wxWindow *parent)
00272 {
00273 wxPanel *panel = new wxPanel(parent,-1);
00274 _splitpanel_right = new wxSplitterWindow(panel, -1);
00275 _splitpanel_right->SetMinimumPaneSize(50);
00276
00277 wxWindow *window2D = CreateView2DPanel(_splitpanel_right);
00278 wxWindow *windowRightDown = CreatePanel_Right_Down(_splitpanel_right);
00279
00280 _splitpanel_right->SplitHorizontally(window2D , windowRightDown,0 );
00281
00282
00283 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00284 sizer->Add( _splitpanel_right, 1,wxGROW,0 );
00285 panel->SetSizer(sizer);
00286 panel->Layout();
00287 return panel;
00288 }
00289
00290
00291
00292 wxWindow* wxQuantificationWidgetCT::CreatePanel_Right_Down(wxWindow *parent)
00293 {
00294 wxPanel *panel = new wxPanel(parent,-1);
00295 _splitpanel_right_down = new wxSplitterWindow(panel, -1);
00296 _splitpanel_right_down->SetMinimumPaneSize(10);
00297
00298 _pl_cntlHealthySick2 = new wxPanelControlsHealthySickSliceCT(_splitpanel_right_down,this);
00299 _wxStenosisPanel = CreateStenosisPanel(_splitpanel_right_down);
00300
00301 _splitpanel_right_down->SplitHorizontally(_pl_cntlHealthySick2,_wxStenosisPanel ,300 );
00302
00303
00304 wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
00305 sizer->Add( _splitpanel_right_down, 1,wxGROW,0 );
00306 panel->SetSizer(sizer);
00307 panel->Layout();
00308 return panel;
00309 }
00310
00311
00312
00313 wxWindow* wxQuantificationWidgetCT::CreatePanelStatus(wxWindow *parent)
00314 {
00315 wxPanel *panel = new wxPanel(parent,-1);
00316
00317
00318
00319 marDictionary marDict;
00320
00321 _st_Label1 = new wxStaticText(panel, -1, wxString(marDict.GetString(380), wxConvUTF8) );
00322 _st_Value1 = new wxStaticText(panel, -1, _T("0.00"));
00323 _st_Label2 = new wxStaticText(panel, -1, wxString(marDict.GetString(390), wxConvUTF8) );
00324 _st_Value2 = new wxStaticText(panel, -1, _T("0.00"));
00325 _st_Label3 = new wxStaticText(panel, -1, wxString(marDict.GetString(400), wxConvUTF8) );
00326 _st_Value3 = new wxStaticText(panel, -1, _T("0.00"));
00327 _st_Label6 = new wxStaticText(panel, -1, wxString(marDict.GetString(405), wxConvUTF8) );
00328 _st_Value6 = new wxStaticText(panel, -1, _T("0.00"));
00329 _st_Label7 = new wxStaticText(panel, -1, wxString(marDict.GetString(410), wxConvUTF8) );
00330 _st_Value7 = new wxStaticText(panel, -1, _T("0.00"));
00331 _st_Label8 = new wxStaticText(panel, -1, wxString(marDict.GetString(415), wxConvUTF8) );
00332 _st_Value8 = new wxStaticText(panel, -1, _T("0.00"));
00333
00334 _st_LabelRef101 = new wxStaticText(panel, -1, wxString(marDict.GetString(385), wxConvUTF8) );
00335 _st_ValueRef101 = new wxStaticText(panel, -1, _T("--"));
00336 _st_LabelRef102 = new wxStaticText(panel, -1, wxString(marDict.GetString(395), wxConvUTF8) );
00337 _st_ValueRef102 = new wxStaticText(panel, -1, _T("--"));
00338 _st_LabelRef103 = new wxStaticText(panel, -1, wxString(marDict.GetString(420), wxConvUTF8) );
00339 _st_ValueRef103 = new wxStaticText(panel, -1, _T("--"));
00340
00341
00342 wxBoxSizer *status = new wxBoxSizer(wxHORIZONTAL);
00343 wxBoxSizer *status0 = new wxBoxSizer(wxVERTICAL);
00344 wxBoxSizer *status1 = new wxBoxSizer(wxVERTICAL);
00345 wxBoxSizer *status2 = new wxBoxSizer(wxVERTICAL);
00346 wxBoxSizer *status3 = new wxBoxSizer(wxVERTICAL);
00347 wxBoxSizer *status6 = new wxBoxSizer(wxVERTICAL);
00348 wxBoxSizer *status7 = new wxBoxSizer(wxVERTICAL);
00349 wxBoxSizer *status8 = new wxBoxSizer(wxVERTICAL);
00350 wxBoxSizer *status9 = new wxBoxSizer(wxVERTICAL);
00351 wxBoxSizer *statusRef1 = new wxBoxSizer(wxVERTICAL);
00352 wxBoxSizer *statusRef2 = new wxBoxSizer(wxVERTICAL);
00353 wxBoxSizer *statusRef3 = new wxBoxSizer(wxVERTICAL);
00354
00355 status1->Add(_st_Label1, 1, wxALL|wxALIGN_CENTER, 5);
00356 status1->Add(_st_Value1, 1, wxALL|wxALIGN_CENTER, 5);
00357 status2->Add(_st_Label2, 1, wxALL|wxALIGN_CENTER, 5);
00358 status2->Add(_st_Value2, 1, wxALL|wxALIGN_CENTER, 5);
00359 status3->Add(_st_Label3, 1, wxALL|wxALIGN_CENTER, 5);
00360 status3->Add(_st_Value3, 1, wxALL|wxALIGN_CENTER, 5);
00361
00362 status6->Add(_st_Label6, 1, wxALL|wxALIGN_CENTER, 5);
00363 status6->Add(_st_Value6, 1, wxALL|wxALIGN_CENTER, 5);
00364 status7->Add(_st_Label7, 1, wxALL|wxALIGN_CENTER, 5);
00365 status7->Add(_st_Value7, 1, wxALL|wxALIGN_CENTER, 5);
00366 status8->Add(_st_Label8, 1, wxALL|wxALIGN_CENTER, 5);
00367 status8->Add(_st_Value8, 1, wxALL|wxALIGN_CENTER, 5);
00368
00369
00370 statusRef1->Add(_st_LabelRef101, 1, wxALL|wxALIGN_CENTER, 5);
00371 statusRef1->Add(_st_ValueRef101, 1, wxALL|wxALIGN_CENTER, 5);
00372 statusRef2->Add(_st_LabelRef102, 1, wxALL|wxALIGN_CENTER, 5);
00373 statusRef2->Add(_st_ValueRef102, 1, wxALL|wxALIGN_CENTER, 5);
00374 statusRef3->Add(_st_LabelRef103, 1, wxALL|wxALIGN_CENTER, 5);
00375 statusRef3->Add(_st_ValueRef103, 1, wxALL|wxALIGN_CENTER, 5);
00376
00377
00378
00379 status->Add(status1 , 1, wxALL|wxEXPAND, 0);
00380 status->Add(statusRef1 , 1, wxALL|wxEXPAND, 0);
00381 status->Add(status2 , 1, wxALL|wxEXPAND, 0);
00382 status->Add(statusRef2 , 1, wxALL|wxEXPAND, 0);
00383 status->Add(status3 , 1, wxALL|wxEXPAND, 0);
00384
00385 status->Add(status6 , 1, wxALL|wxEXPAND, 0);
00386 status->Add(status7 , 1, wxALL|wxEXPAND, 0);
00387 status->Add(status8 , 1, wxALL|wxEXPAND, 0);
00388 status->Add(statusRef3 , 1, wxALL|wxEXPAND, 0);
00389
00390
00391
00392
00393 wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
00394 sizer->Add( status, 1,wxALL|wxEXPAND,0 );
00395 panel->SetSizer(sizer);
00396 panel->Layout();
00397 return panel;
00398 }
00399
00400 wxWindow* wxQuantificationWidgetCT::CreateStenosisPanel(wxWindow *parent){
00401 marDictionary marDict;
00402
00403 wxPanel* panel = new wxPanel(parent);
00404
00405 _st_Label100 = new wxStaticText(panel, -1, (wxChar)(marDict.GetString(255)) );
00406 _st_Label101 = new wxStaticText(panel, -1, (wxChar)(marDict.GetString(260)) );
00407 _st_Value100 = new wxStaticText(panel, -1, _T("-- "));
00408 _st_Value101 = new wxStaticText(panel, -1, _T("-- "));
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 wxFont font(14,wxDEFAULT ,wxNORMAL,wxBOLD);
00423 _st_Value100->SetFont(font);
00424 _st_Value101->SetFont(font);
00425
00426
00427
00428 wxGridSizer* gridSizer1 = new wxFlexGridSizer(1);
00429 gridSizer1->Add(new wxStaticText(panel, -1, _T(" ")) ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00430 gridSizer1->Add(_st_Value100 ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00431 gridSizer1->Add(_st_Label100 ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00432 gridSizer1->Add(new wxStaticText(panel, -1, _T(" ")) ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00433 gridSizer1->Add(_st_Value101 ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00434 gridSizer1->Add(_st_Label101 ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
00435
00436 wxGridSizer* gridSizer = new wxFlexGridSizer(4);
00437 gridSizer->Add(new wxStaticText(panel, -1, _T(" ")) ,15, wxALIGN_LEFT , 50);
00438 gridSizer->Add(new wxStaticText(panel, -1, _T(" ")) ,15, wxALIGN_LEFT , 50);
00439 gridSizer->Add(new wxStaticText(panel, -1, _T(" ")) ,15, wxALIGN_LEFT , 50);
00440 gridSizer->Add(gridSizer1 ,15, wxALIGN_LEFT , 50);
00441
00442 panel->SetAutoLayout(true);
00443 panel->SetSizer(gridSizer);
00444 panel->Layout();
00445
00446
00447 panel->SetSize(400,300);
00448 panel->SetSize( gridSizer->GetMinSize() );
00449
00450 return panel;
00451 }
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751 void wxQuantificationWidgetCT::Set_Data( )
00752 {
00753 _axis_index = -1;
00754 _given_points = 0;
00755 _nClicks = 0;
00756 _quantifing = 0;
00757
00758
00759
00760 _shown = 0;
00761 _quant_shown = 0;
00762
00763 _actual_area = 0.00;
00764 _actual_peri = 0.00;
00765 _actual_darea = 0.00;
00766 _actual_dperi = 0.00;
00767 _actual_dmax = 0.00;
00768 _actual_dmin = 0.00;
00769 _actual_davg = 0.00;
00770 _actual_sten = 0.00;
00771 _actual_partial = 0.00;
00772
00773
00774 }
00775
00776
00777
00778
00779
00780 void wxQuantificationWidgetCT::Forget( )
00781 {
00782 _shown = false;
00783 }
00784
00785
00786 void wxQuantificationWidgetCT::ShowMARACASData( marInterfaceCT* mar )
00787 {
00788 double min, max;
00789 vtkImageData* imagedata;
00790 int nos;
00791 int actualQuant=-1;
00792
00793 wxBusyCursor wait;
00794 _mar = mar;
00795
00796 _mar->prepareQuantification();
00797 nos = _mar->getNumberOfSlices();
00798
00799
00800 for (int i = 0; i < nos; i++)
00801 {
00802 _manContours.push_back(NULL);
00803 }
00804
00805
00806 actualQuant = (int) (nos-1)/2 ;
00807 imagedata = _mar->getSliceImage(actualQuant);
00808
00809 _mar->setActualQuant( actualQuant ) ;
00810 _mar->getMinMax(min, max);
00811
00812
00813 _3DWorld->ShowMARACASDataAndAxeCT( mar );
00814 _3DWorld->InitCameraReset( );
00815
00816
00817
00818 ConfigureVTK( new marImageData(imagedata) );
00819
00820
00821 _sl_Isovalue->SetRange( (int)min, (int)max);
00822 _sl_Isovalue->SetValue( (int)(max/4) );
00823 _sl_Opacity->SetValue( 50 );
00824 Reset_sl_Slider();
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839 _splitPanelPrincipal -> SetSashPosition(600,true);
00840 _splitpanel_left -> SetSashPosition(360,true);
00841 _splitpanel_right -> SetSashPosition(200,true);
00842 _splitpanel_right_down -> SetSashPosition(230,true);
00843 }
00844
00845 void wxQuantificationWidgetCT::Reset_sl_Slider()
00846 {
00847 int nos = _mar->getNumberOfSlices();
00848
00849 _sl_Slice->SetRange(0, nos-1);
00850 _sl_Slice->SetValue( (nos-1)/2 );
00851
00852 }
00853
00854 void wxQuantificationWidgetCT::SetSlider_Isovalue_Opacity(int isovalue,int opacity){
00855 _sl_Isovalue->SetValue(isovalue);
00856 _sl_Opacity->SetValue(opacity);
00857 _3DWorld->SetSurfaceIsoValue( isovalue );
00858 _3DWorld->SetSurfaceOpacity( opacity );
00859 }
00860
00861 void wxQuantificationWidgetCT::OnShowSurface_CB(wxCommandEvent& event)
00862 {
00863 _3DWorld->SetSurfaceVisibility( _cb_ShowSurface->GetValue() );
00864 }
00865
00866 void wxQuantificationWidgetCT::ResetAxis(){
00867 Reset_sl_Slider();
00868 _mar->setActualQuant( _sl_Slice->GetValue() );
00869
00870 _3DWorld->Hide3DHealthySliceActor();
00871 _mar->setHealthySlice( 0,-1,0 );
00872 _mar->setActualQuant( _sl_Slice->GetValue() );
00873
00874 }
00875
00876 void wxQuantificationWidgetCT::RefreshAxis( ){
00877 int actualQuant = _mar->getActualQuant();
00878 vtkImageData* imagedata;
00879 vtkProbeFilter* image3D;
00880 vtkPolyData* vtkPolydata_2Dcontour;
00881
00882
00883
00884
00885
00886 int contours = _mar->getNumberOfContours(actualQuant);
00887
00888 image3D = _mar->get3DSlice ( actualQuant );
00889 imagedata = _mar->getSliceImage ( actualQuant );
00890
00891
00892 _contourViewer->DeleteContours();
00893 _lineViewer->DeleteLines();
00894 _pointViewer->DeletePoints();
00895
00896
00897
00898
00899 _pointViewer->CreateNewPoint(64,64,0);
00900 for (int i = 0; i < contours; i++)
00901 {
00902 ;
00903 vtkPolydata_2Dcontour = _mar->get2Dcontour( actualQuant, i );
00904
00905
00906
00907
00908 if (_cb_VisibleRings->GetValue()==true){
00909
00910 _contourViewer->CreateNewContour(vtkPolydata_2Dcontour, _mar->getContourType(actualQuant, i));
00911
00912
00913 }
00914 }
00915
00916 int puntos = _mar->getPointSize();
00917
00918 for (int j = 0; j < puntos; j++)
00919 {
00920 marPoint *p = _mar->getPoint(j);
00921 _pointViewer->CreateNewPoint(p->getX(),p->getY(),p->getType());
00922 }
00923
00924
00925 _3DWorld->SetImage(image3D);
00926 _3DWorld->Render( );
00927
00928
00929 RefreshView( new marImageData(imagedata) );
00930
00931
00932
00933
00934 showVariables( );
00935
00936
00937
00938
00939 }
00940
00941
00942
00943 void wxQuantificationWidgetCT::MoveSlider(int actualQuant){
00944
00945 if (actualQuant!=_bak_ActualSlice2)
00946 {
00947 _bak_ActualSlice2=actualQuant;
00948 if (_bak_ActualSlice!=-1){
00949 SetManualContour_ReplaceContour();
00950 SetManualContour_2DWorld(false);
00951 }
00952 _mar->setActualQuant( actualQuant );
00953 RefreshAxis();
00954
00955
00956 double *p;
00957 p = _mar->GetExperiment()->getAxis()->getPoints( actualQuant );
00958 double spc[3];
00959 _mar->getDynData()->GetMarImageData()->GetImageData()->GetSpacing(spc);
00960 int nX=0,nY=0,nZ=0;
00961 nX = _mar->getDynData()->GetMarImageData()->GetXOriginal( (int)(p[0]/spc[0]) );
00962 nY = _mar->getDynData()->GetMarImageData()->GetYOriginal( (int)(p[1]/spc[1]) );
00963 nZ = _mar->getDynData()->GetMarImageData()->GetZOriginal( (int)(p[2]/spc[2]) );
00964 char resultText[50],temp[50];
00965 strcpy(resultText," \n (");
00966
00967
00968 sprintf(temp,"%d",(int)nX);
00969
00970 strcat(resultText,temp);
00971 strcat(resultText,",");
00972
00973
00974 sprintf(temp,"%d",(int)nY);
00975
00976 strcat(resultText,temp);
00977 strcat(resultText,",");
00978
00979
00980 sprintf(temp,"%d",(int)nZ);
00981
00982 strcat(resultText,temp);
00983 strcat(resultText,")");
00984 _txt_Position->SetLabel( wxString(resultText, wxConvUTF8) );
00985 }
00986 }
00987
00988 void wxQuantificationWidgetCT::OnSliderSliceScroll(wxScrollEvent& event){
00989 MoveSlider( event.GetPosition() );
00990 }
00991
00992
00993 double wxQuantificationWidgetCT::GetStenosisDiameter(int sickSlice){
00994 double healthyAverageDiameter = _mar->getReferenceAverDiam() ;
00995 marContour *marcontourSick = _mar->getContour( sickSlice, sickSlice );
00996 return doubleStenosis( healthyAverageDiameter , marcontourSick->getMinimumDiameter() );
00997 }
00998
00999 double wxQuantificationWidgetCT::GetStenosisArea( int sickSlice){
01000 double healthyArea = _mar->getReferenceArea();
01001 marContour *marcontourSick = _mar->getContour( sickSlice, sickSlice );
01002 return doubleStenosis( healthyArea , marcontourSick->getArea() );
01003 }
01004
01005
01006
01007
01008
01009
01010
01011
01012 void wxQuantificationWidgetCT::showVariables()
01013 {
01014
01015
01016
01017 int actualQuant;
01018 int healthySlice;
01019 int healthySliceStart;
01020 int healthySliceEnd;
01021
01022 actualQuant = _mar->getActualQuant( );
01023
01024
01025 wxString tmpString;
01026
01027 tmpString.Printf( _T("%.2f mm") , 20); _st_Value1->SetLabel(tmpString);
01028
01029
01030 tmpString.Printf( _T("%.2f mm^2") , 20); _st_Value2->SetLabel(tmpString);
01031 tmpString.Printf( _T("%.2f mm") , 20); _st_Value3->SetLabel(tmpString);
01032
01033 tmpString.Printf( _T("%.2f mm") , 20); _st_Value6->SetLabel(tmpString);
01034 tmpString.Printf( _T("%.2f mm") , 20); _st_Value7->SetLabel(tmpString);
01035 tmpString.Printf( _T("%.2f mm") , 20); _st_Value8->SetLabel(tmpString);
01036
01037 healthySlice = _mar->getHealthySlice( );
01038 healthySliceStart = _mar->getHealthySliceStart( );
01039 healthySliceEnd = _mar->getHealthySliceEnd( );
01040 if ( (healthySlice!=-1) ) {
01041 _st_Value100->SetLabel( strStenosis( GetStenosisArea(actualQuant) ) );
01042 _st_Value101->SetLabel( strStenosis( GetStenosisDiameter(actualQuant) ) );
01043 tmpString.Printf( _T("%.2f mm^2") , _mar->getReferenceArea() ); _st_ValueRef102->SetLabel(tmpString);
01044 tmpString.Printf( _T("%.2f mm") , _mar->getReferenceAverDiam() ); _st_ValueRef103->SetLabel(tmpString);
01045
01046 } else {
01047 _st_Value100->SetLabel(_T("--"));
01048 _st_Value101->SetLabel(_T("--"));
01049 _st_ValueRef101->SetLabel(_T("--"));
01050 _st_ValueRef102->SetLabel(_T("--"));
01051 _st_ValueRef103->SetLabel(_T("--"));
01052 }
01053
01054 int startSlice = _mar->getQuantStart();
01055 int finishSlice = _mar->getQuantFinish();
01056 if ((startSlice!=-1) && (finishSlice!=-1)){
01057 tmpString.Printf( _T("%.2f mm") , _mar->getSubAxisLength() ); _st_ValueRef101->SetLabel(tmpString);
01058 } else {
01059 _st_ValueRef101->SetLabel(_T("--"));
01060 }
01061
01062 }
01063
01064 double wxQuantificationWidgetCT::doubleStenosis(double healthy, double sick){
01065 double result;
01066 if (healthy==0) {
01067 result=-1;
01068 } else {
01069 result = ( (healthy-sick)/healthy) * 100 ;
01070 }
01071
01072 return result;
01073 }
01074
01075 wxString wxQuantificationWidgetCT::strStenosis(double stenosis){
01076 wxString tmpString;
01077 if (stenosis==-1) {
01078 tmpString.Printf(_T("%d"),-1);
01079 } else {
01080 tmpString.Printf(_T("%.2f"), stenosis );
01081 }
01082 return tmpString + _T(" \%");
01083 }
01084
01085 void wxQuantificationWidgetCT::OnSliderIsovalueScroll(wxScrollEvent& event)
01086 {
01087 wxBusyCursor wait;
01088 _3DWorld->SetSurfaceIsoValue( event.GetPosition() );
01089 }
01090
01091 void wxQuantificationWidgetCT::OnSliderOpacityScroll(wxScrollEvent& event)
01092 {
01093 _3DWorld->SetSurfaceOpacity( event.GetPosition() );
01094 }
01095
01096 void wxQuantificationWidgetCT::AddAxisActors(){
01097
01098 marAxis *maraxis = _mar->getAxis( );
01099 if (maraxis!=NULL) _3DWorld->SetAxis( maraxis->Draw( ) );
01100
01101 }
01102
01103 void wxQuantificationWidgetCT::Clean3D( bool eraseAxe )
01104 {
01105 _first_quant = -1;
01106 _last_quant = -1;
01107
01108 _quant_shown = false;
01109
01110 _3DWorld->InitListContourActor( -1,_mar->getNumberOfSlices() );
01111 if (eraseAxe==true) { _3DWorld->RemoveAxis(); }
01112
01113
01114
01115
01116 }
01117
01118 void wxQuantificationWidgetCT::Reload_Axis(bool mask , bool step )
01119 {
01120
01121 }
01122
01123
01124 void wxQuantificationWidgetCT::Show_Max_Min_Diameters()
01125 {
01126
01127 }
01128
01129
01130
01131 int wxQuantificationWidgetCT::Back( )
01132 {
01133 int ret;
01134
01135 ret = _shown;
01136 _shown = 0;
01137 return ret;
01138 }
01139
01140
01141 void wxQuantificationWidgetCT::Set_plane_3D( double x, double y )
01142 {
01143
01144 }
01145
01146
01147
01148
01149
01150 void wxQuantificationWidgetCT::Point_Intensity(double x, double y)
01151 {
01152
01153 }
01154
01155
01156 void wxQuantificationWidgetCT::CleanContour()
01157 {
01158
01159 }
01160
01161
01162
01163
01164 void wxQuantificationWidgetCT::Do_Quant()
01165 {
01166
01167 }
01168
01169
01170
01171 void wxQuantificationWidgetCT::OnContour_BT(wxCommandEvent& event){
01172 int slice=_sl_Slice->GetValue();
01173 _3DWorld->Set3DContourActor( slice , _mar->get3Dcontour(slice, slice) , _cb_VisibleRings->GetValue() ,0 );
01174 }
01175
01176 void wxQuantificationWidgetCT::OnClean_BT(wxCommandEvent& event){
01177 int slice=_sl_Slice->GetValue();
01178 _3DWorld->Erase3DContourActor( slice );
01179 }
01180
01181
01182 void wxQuantificationWidgetCT::OnCleanAll_BT(wxCommandEvent& event){
01183 marDictionary marDict;
01184 char tmp[256];
01185
01186 wxMessageDialog *wxdiag;
01187 strcpy( tmp , marDict.GetString(870) ); strcat(tmp,"\n"); strcat(tmp,marDict.GetString(875));
01188 wxdiag= new wxMessageDialog(this, wxString(tmp, wxConvUTF8), wxString(marDict.GetString(865), wxConvUTF8) , wxOK | wxCANCEL);
01189 if ( wxdiag->ShowModal() == wxID_OK ) {
01190 _3DWorld->InitListContourActor( 0, _mar->getNumberOfSlices() );
01191 }
01192 wxdiag->Destroy();
01193 }
01194
01195
01196
01197
01198
01199
01200 void wxQuantificationWidgetCT::DetectHealthySickSlice( bool minSurf , bool maxSurf ){
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271 }
01272
01273
01274
01275
01276
01277 int wxQuantificationWidgetCT::GetHealthySlice(){
01278 return _mar->getHealthySlice( );
01279 }
01280
01281 void wxQuantificationWidgetCT::SetHealthySlice(int healthySlice){
01282 if (healthySlice==-1) {
01283 healthySlice=_sl_Slice->GetValue();
01284 }
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304 }
01305
01306
01307
01308
01309
01310
01311
01312 void wxQuantificationWidgetCT::OnHealthySlice_CB(wxCommandEvent& event)
01313 {
01314
01315
01316 int healthySlice = _mar->getHealthySlice( );
01317 if (healthySlice!=-1) {
01318 if ( _cb_HealthySlice->GetValue() )
01319 _3DWorld->Show3DHealthySliceActor();
01320 else
01321 _3DWorld->Hide3DHealthySliceActor();
01322 }
01323 }
01324
01325
01326
01327 void wxQuantificationWidgetCT::OnVisibleRing_CB(wxCommandEvent& event){
01328 if ( _cb_VisibleRings->GetValue() ){
01329 _3DWorld->Show3DContourActor();
01330
01331 RefreshAxis();
01332 } else {
01333 _3DWorld->Hide3DContourActor();
01334
01335 }
01336
01337
01338 }
01339
01340 void wxQuantificationWidgetCT::OnPerpendicular_CB(wxCommandEvent& event)
01341 {
01342 if ( _cb_Perpendicular->GetValue() )
01343 _3DWorld->Show3DSliceActor();
01344 else
01345 _3DWorld->Hide3DSliceActor();
01346 }
01347
01348
01349 void wxQuantificationWidgetCT::OnGreyScale_RB(wxCommandEvent& event){
01350 if ( _rb_GreyScale->GetValue() ){
01351 _3DWorld->SetBWLookUp();
01352 }
01353 }
01354
01355 void wxQuantificationWidgetCT::OnColor_RB(wxCommandEvent& event){
01356 if ( _rb_Color->GetValue() ){
01357 _3DWorld->SetColorLookUp();
01358 }
01359 }
01360
01361 void wxQuantificationWidgetCT::CallBackOnLeftDClick( wxMouseEvent& event ){
01362
01363 double pp[3], cp[3];
01364 _3DWorld->GetLast3DClickPoint(pp,cp);
01365
01366 int i,iback,maxPoints;
01367 double *c, cc[3];
01368 double dist,distMin=-1;
01369 iback=-1;
01370
01371 marAxis *maraxis = _mar->getAxis( );
01372 maxPoints = maraxis->getNumberOfSplinePoints();
01373 for ( i=0 ; i<maxPoints ; i++ ){
01374 c = maraxis->getSplinePoint(i);
01375 cc[0]=c[0]-pp[0];
01376 cc[1]=c[1]-pp[1];
01377 cc[2]=c[2]-pp[2];
01378 dist=sqrt( cc[0]*cc[0] + cc[1]*cc[1] + cc[2]*cc[2] );
01379 if ((distMin==-1) || (dist<distMin)) {
01380 iback=i;
01381 distMin=dist;
01382 }
01383 }
01384 _sl_Slice->SetValue(iback);
01385 MoveSlider(iback);
01386
01387 }
01388
01389
01390 void wxQuantificationWidgetCT::CallBackOnMouseWheel( wxMouseEvent& event ){
01391 int slice=_sl_Slice->GetValue();
01392 if (event.GetWheelRotation()>0){ slice++; }
01393 if (event.GetWheelRotation()<0){ slice--; }
01394 if (slice < _sl_Slice->GetMin() ) { slice=_sl_Slice->GetMin(); }
01395 if (slice > _sl_Slice->GetMax() ) { slice=_sl_Slice->GetMax(); }
01396 _sl_Slice->SetValue(slice);
01397 MoveSlider(slice);
01398 }
01399
01400 int wxQuantificationWidgetCT::GetActualSlice(){
01401 return _sl_Slice->GetValue();
01402 }
01403
01404 void wxQuantificationWidgetCT::SetActualSlice(int slice){
01405 _sl_Slice->SetValue(slice);
01406 MoveSlider(slice);
01407 }
01408
01409 int wxQuantificationWidgetCT::GetMaxActualSlice(){
01410 return _sl_Slice->GetMax();
01411 }
01412
01413 int wxQuantificationWidgetCT::GetSizeHealthyRegion(){
01414 return _sizeHealthyRegion;
01415 }
01416
01417 void wxQuantificationWidgetCT::SetSizeHealthyRegion(int size){
01418 _sizeHealthyRegion = size;
01419 }
01420
01421 void wxQuantificationWidgetCT::GetHealthySliceRange(int &healthySliceStart,int &healthySliceEnd){
01422 healthySliceStart = _mar->getHealthySliceStart( );
01423 healthySliceEnd = _mar->getHealthySliceEnd( );
01424
01425 }
01426
01427 void wxQuantificationWidgetCT::Set3DRegionSliceActor( int type, int k1,int k2 ){
01428 _3DWorld->Set3DRegionSliceActor(type,k1,k2);
01429 }
01430
01431 void wxQuantificationWidgetCT::Set3DStartRegionSliceActor( int type, int k){
01432
01433 }
01434
01435 void wxQuantificationWidgetCT::Set3DEndRegionSliceActor( int type, int k){
01436
01437 }
01438
01439 void wxQuantificationWidgetCT::Show3DRegionSliceActor( int type ){
01440 _3DWorld->Show3DRegionSliceActor(type);
01441 }
01442
01443 void wxQuantificationWidgetCT::Show3DStartRegionSliceActor( int type ){
01444 _3DWorld->Show3DStartRegionSliceActor(type);
01445 }
01446
01447 void wxQuantificationWidgetCT::Show3DEndRegionSliceActor( int type ){
01448 _3DWorld->Show3DEndRegionSliceActor(type);
01449 }
01450
01451 void wxQuantificationWidgetCT::Hide3DRegionSliceActor( int type ){
01452 _3DWorld->Hide3DRegionSliceActor(type);
01453 }
01454
01455 void wxQuantificationWidgetCT::Hide3DStartRegionSliceActor( int type ){
01456 _3DWorld->Hide3DStartRegionSliceActor(type);
01457 }
01458
01459 void wxQuantificationWidgetCT::Hide3DEndRegionSliceActor( int type ){
01460 _3DWorld->Hide3DEndRegionSliceActor(type);
01461 }
01462
01463 void wxQuantificationWidgetCT::GetSliceLimites(int type, int &sliceStart, int &sliceEnd){
01464 _3DWorld->GetSliceLimites(type,sliceStart,sliceEnd);
01465 }
01466
01467 int wxQuantificationWidgetCT::GetAnalysisTypeStenosis(){
01468 return _3DWorld->GetAnalysisTypeStenosis();
01469 }
01470
01471 void wxQuantificationWidgetCT::SetAnalysisTypeStenosis(int analysisTypeStenosis){
01472 _3DWorld->SetAnalysisTypeStenosis(analysisTypeStenosis);
01473 }
01474
01475 void wxQuantificationWidgetCT::SetManualContour_2DWorld(bool ok){
01476
01477 if (ok==false){
01478
01479
01480 }
01481 if (ok==true){
01482
01483
01484 }
01485
01486 }
01487
01488
01489 void wxQuantificationWidgetCT::SetManualContour_AddPoint_2DWorld(){
01490 _bak_ActualSlice = _sl_Slice->GetValue();
01491
01492
01493 _mar->EraseContour(_bak_ActualSlice);
01494
01495 _3DWorld->Erase3DContourActor( _bak_ActualSlice );
01496
01497
01498 }
01499
01500 void wxQuantificationWidgetCT::SetManualContour_InsertPoint_2DWorld(){
01501
01502 }
01503
01504 void wxQuantificationWidgetCT::SetManualContour_ErasePoint_2DWorld(){
01505
01506 }
01507
01508 void wxQuantificationWidgetCT::SetManualContour_MovePoint_2DWorld(){
01509
01510 }
01511
01512 void wxQuantificationWidgetCT::SetManualContour_ReplaceContour(){
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525 }
01526
01527 kVolume* wxQuantificationWidgetCT::GetVolumeAxisExtended(int wz1,int wz2)
01528 {
01529
01530 vtkImageData *imagedata;
01531 imagedata=_mar->getSliceImage(wz1);
01532 int dims[3];
01533 imagedata->GetDimensions (dims);
01534 int wx=dims[0];
01535 int wy=dims[1];
01536 int wz = wz2-wz1+1;
01537 kVolume *kvol =new kVolume( kVolume::USHORT, wx, wy, wz,1, 1, 1, malloc(sizeof(unsigned short)*wx*wy*wz ) );
01538 vtkImageData *vol = kvol->castVtk();
01539
01540
01541 int i;
01542 for (i=wz1;i<=wz2;i++)
01543 {
01544
01545 imagedata=_mar->getSliceImage(i);
01546
01547
01548 void *p_imagedata = imagedata->GetScalarPointer(0,0,0);
01549 void *p_vol = vol->GetScalarPointer(0,0,i-wz1);
01550 memcpy( p_vol, p_imagedata , sizeof(unsigned short)*dims[0]*dims[1] );
01551 }
01552 return kvol;
01553 }
01554
01555
01556 wxWindow* wxQuantificationWidgetCT::CreateView2DPanel(wxWindow *parent)
01557 {
01558 wxPanel *panel = new wxPanel(parent,-1);
01559 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
01560
01561 _imageviewer2D_1 = new wxVtk2DBaseView(panel);
01562 wxVTKRenderWindowInteractor *iren = _imageviewer2D_1->GetWxVTKRenderWindowInteractor();
01563 sizer->Add(iren , 1, wxEXPAND, 0);
01564
01565
01566 panel->SetSizer(sizer);
01567 panel->SetAutoLayout(true);
01568 panel->SetSize(400,400);
01569 panel->Layout();
01570 return panel;
01571 }
01572
01573
01574 void wxQuantificationWidgetCT::Refresh()
01575 {
01576 _imageviewer2D_1->Refresh();
01577 }
01578
01579
01580 void wxQuantificationWidgetCT::RefreshView(marImageData *marimagedata)
01581 {
01582 vtkImageData *imagedata= marimagedata->GetImageData();
01583 _imageviewer2D_1->SetActualSlice(0);
01584 imagedata->UpdateInformation();
01585 imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
01586 imagedata->Update();
01587 _data = imagedata;
01588
01589 _vtkbasedata_1->SetMarImageData(marimagedata);
01590 _imageviewer2D_1->ResetView();
01591
01592 int i;
01593 for (i = 0; i < _manContours.size(); i++)
01594 {
01595 if (_manContours[i] !=NULL)
01596 {
01597 _manContours[i]->clear();
01598 }
01599 }
01600
01601 for (i = 0; i < _manContours.size(); i++)
01602 {
01603 if (_manContours[i] !=NULL)
01604 {
01605 _manContours[i]->refreshWall(_imageviewer2D_1);
01606 _manContours[i]->refreshLumen(_imageviewer2D_1);
01607
01608 int j;
01609 for (j = 0; j < _manContours[i]->getNumberOfCalcContours(); j++)
01610 {
01611 _manContours[i]->refreshCalc(j,_imageviewer2D_1);
01612 }
01613
01614 for (j = 0; j < _manContours[i]->getNumberOfHypoContours(); j++)
01615 {
01616 _manContours[i]->refreshHypo(j,_imageviewer2D_1);
01617
01618 }
01619
01620
01621 }
01622
01623
01624
01625 }
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641 CreateManualContours();
01642
01643 }
01644
01645
01646 void wxQuantificationWidgetCT::ConfigureVTK(marImageData *marimagedata)
01647 {
01648 wxBusyCursor wait;
01649
01650 vtkImageData *imagedata=marimagedata->GetImageData();
01651 imagedata->UpdateInformation();
01652 imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
01653 imagedata->Update();
01654 _data = imagedata;
01655 _vtkbasedata_1 = new vtkBaseData();
01656 _vtkbasedata_1->SetMarImageData(marimagedata);
01657 _imageviewer2D_1->SetVtkBaseData( _vtkbasedata_1 );
01658 _imageviewer2D_1->Configure();
01659
01660
01661 _contourViewer = new ContourView();
01662 _contourViewer->SetWxVtkBaseView(_imageviewer2D_1);
01663 _lineViewer = new LineView();
01664 _lineViewer->SetWxVtkBaseView(_imageviewer2D_1);
01665 _pointViewer = new PointView();
01666 _pointViewer->SetWxVtkBaseView(_imageviewer2D_1);
01667 CreateManualContours();
01668 Refresh();
01669 }
01670
01671
01672 void wxQuantificationWidgetCT::OnContourWall()
01673 {
01674 if (_manContours[_mar->getActualQuant()]->getWallController() == NULL)
01675 {
01676 _manContours[_mar->getActualQuant()]->createWallContour(_imageviewer2D_1);
01677 _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(
01678 _manContours[_mar->getActualQuant()]->getWallController() );
01679 }
01680 _manContours[_mar->getActualQuant()]->setWallActive();
01681 _manContours[_mar->getActualQuant()]->setWallVisibility(true);
01682 }
01683
01684
01685 void wxQuantificationWidgetCT::OnContourLumen()
01686 {
01687 if (_manContours[_mar->getActualQuant()]->getLumenController() == NULL)
01688 {
01689 _manContours[_mar->getActualQuant()]->createLumenContour(_imageviewer2D_1);
01690 _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(
01691 _manContours[_mar->getActualQuant()]->getLumenController() );
01692 }
01693 _manContours[_mar->getActualQuant()]->setLumenActive();
01694 }
01695
01696 void wxQuantificationWidgetCT::OnContourHypo()
01697 {
01698
01699
01700
01701 if (_manContours[_mar->getActualQuant()]->getNumberOfHypoContours() > 0)
01702 {
01703
01704 int answer = wxMessageBox(_T("Create new hypodense contour? (answer no, will modify existing ones)"),
01705 _T("Confirm"), wxYES_NO | wxCANCEL, this);
01706
01707 if (answer == wxYES)
01708 {
01709 addManualContours(HYPODENSE);
01710 int tam = _manContours[_mar->getActualQuant()]->getNumberOfHypoContours() - 1;
01711 _manContours[_mar->getActualQuant()] -> setHypoContourActive(tam);
01712
01713 }
01714 else if (answer == wxNO)
01715 {
01716 _manContours[_mar->getActualQuant()] ->setHypoActive();
01717 }
01718 }
01719 else
01720 {
01721 addManualContours(HYPODENSE);
01722 int tam = _manContours[_mar->getActualQuant()]->getNumberOfHypoContours() - 1;
01723 _manContours[_mar->getActualQuant()] -> setHypoContourActive(tam);
01724 }
01725
01726
01727
01728
01729 }
01730
01731
01732 void wxQuantificationWidgetCT::OnContourCalc()
01733 {
01734
01735
01736 if (_manContours[_mar->getActualQuant()]->getNumberOfCalcContours() > 0)
01737 {
01738
01739 int answer = wxMessageBox(_T("Create new calcification contour? (answer no, will modify existing ones)"),
01740 _T("Confirm"), wxYES_NO | wxCANCEL, this);
01741
01742 if (answer == wxYES)
01743 {
01744 addManualContours(CALCIFICATION);
01745 int tam = _manContours[_mar->getActualQuant()]->getNumberOfCalcContours() - 1;
01746 _manContours[_mar->getActualQuant()] -> setCalcContourActive(tam);
01747
01748 }
01749 else if (answer == wxNO)
01750 {
01751 _manContours[_mar->getActualQuant()] ->setCalcActive();
01752 }
01753 }
01754 else
01755 {
01756 addManualContours(CALCIFICATION);
01757 int tam = _manContours[_mar->getActualQuant()]->getNumberOfCalcContours() - 1;
01758 _manContours[_mar->getActualQuant()] -> setCalcContourActive(tam);
01759 }
01760
01761 }
01762
01763
01764
01765
01766 void wxQuantificationWidgetCT::OnReplaceContourWall()
01767 {
01768
01769 int size = _manContours[_mar->getActualQuant()]->getNumberOfWallContourPoints();
01770 double *vx = _manContours[_mar->getActualQuant()]->getXVectorWallPoints();
01771 double *vy = _manContours[_mar->getActualQuant()]->getYVectorWallPoints();
01772
01773
01774 _mar->cleanContours(WALL);
01775 _mar->replaceContour2D(size,vx,vy,WALL);
01776 _manContours[_mar->getActualQuant()]->clearWall();
01777 _manContours[_mar->getActualQuant()]->restartWallContour(_imageviewer2D_1);
01778 RefreshAxis();
01779
01780
01781
01782 }
01783
01784 void wxQuantificationWidgetCT::OnReplaceContourLumen()
01785 {
01786 int size = _manContours[_mar->getActualQuant()]->getNumberOfLumenContourPoints();
01787 double *vx = _manContours[_mar->getActualQuant()]->getXVectorLumenPoints();
01788 double *vy = _manContours[_mar->getActualQuant()]->getYVectorLumenPoints();
01789
01790 _mar->cleanContours(ELUMEN);
01791 _mar->replaceContour2D(size,vx,vy,ELUMEN);
01792 _manContours[_mar->getActualQuant()]->clearLumen();
01793 _manContours[_mar->getActualQuant()]->restartLumenContour(_imageviewer2D_1);
01794 RefreshAxis();
01795
01796 }
01797
01798 void wxQuantificationWidgetCT::OnReplaceContourCalc()
01799 {
01800 int conts = _manContours[_mar->getActualQuant()]->getNumberOfCalcContours();
01801
01802 _mar->cleanContours(CALCIFICATION);
01803 for (int i = 0; i < conts; i++)
01804 {
01805 int size = _manContours[_mar->getActualQuant()]->getNumberOfCalcContourPoints(i);
01806 double *vx = _manContours[_mar->getActualQuant()]->getXVectorCalcPoints(i);
01807 double *vy = _manContours[_mar->getActualQuant()]->getYVectorCalcPoints(i);
01808 _mar->replaceContour2D(size,vx,vy,CALCIFICATION);
01809 }
01810 _manContours[_mar->getActualQuant()]->clearCalc();
01811 _manContours[_mar->getActualQuant()]->restartCalcContours();
01812 RefreshAxis();
01813 }
01814
01815
01816 void wxQuantificationWidgetCT::OnReplaceContourHypo()
01817 {
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831 performXOR();
01832 }
01833
01834
01835 void wxQuantificationWidgetCT::performXOR()
01836 {
01837 if (_manContours [_mar->getActualQuant()]->getWallController() != NULL)
01838 {
01839 int size = _manContours[_mar->getActualQuant()]->getNumberOfWallContourPoints();
01840 double *vx = _manContours[_mar->getActualQuant()]->getXVectorWallPoints();
01841 double *vy = _manContours[_mar->getActualQuant()]->getYVectorWallPoints();
01842
01843 marIsocontour* m = _mar->loadMarIsocontour(size,vx,vy);
01844 std::vector<marIsocontour *> walls;
01845
01846 walls.push_back(m);
01847
01848 double intersection = _mar->performUnion(WALL,walls);
01849 double xor_ = _mar->performXOR(WALL,walls);
01850
01851 xor_ = xor_ / intersection;
01852 wxLogMessage(wxString("Indice XOR (pared): %f", wxConvUTF8), xor_*100);
01853
01854 double and_ = _mar->performAND(WALL,walls);
01855 and_ = and_/ intersection;
01856
01857
01858 wxLogMessage(wxString("Indice AND (pared): %f", wxConvUTF8), and_*100);
01859
01860
01861 wxLogMessage(wxString("Indice Unión (pared): %f", wxConvUTF8), intersection);
01862
01863 double razon = 0;
01864
01865
01866 if (and_ == 0)
01867 {
01868 razon = -1;
01869 }
01870 else
01871 {
01872 razon = xor_ / and_;
01873 }
01874
01875 wxLogMessage(wxString("Razón (pared): %f", wxConvUTF8), razon);
01876 }
01877 else
01878 {
01879 wxLogMessage(wxString("SIN INFORMACION PARED", wxConvUTF8));
01880 }
01881
01882
01883
01884 if (_manContours [_mar->getActualQuant()]->getLumenController() != NULL)
01885 {
01886 int size = _manContours[_mar->getActualQuant()]->getNumberOfLumenContourPoints();
01887 double* vx = _manContours[_mar->getActualQuant()]->getXVectorLumenPoints();
01888 double* vy = _manContours[_mar->getActualQuant()]->getYVectorLumenPoints();
01889 marIsocontour* m = _mar->loadMarIsocontour(size,vx,vy);
01890 std::vector<marIsocontour *> lumen;
01891
01892
01893 lumen.push_back(m);
01894 double intersection = _mar->performUnion(ELUMEN,lumen);
01895 double xor_ = _mar->performXOR(ELUMEN,lumen);
01896 xor_ = xor_ / intersection;
01897 wxLogMessage(wxString("Indice OR (lumen): %f", wxConvUTF8), xor_*100);
01898
01899 double and_ = _mar->performAND(ELUMEN,lumen);
01900 and_ = and_/ intersection;
01901 wxLogMessage(wxString("Indice AND (lumen): %f", wxConvUTF8), and_*100);
01902
01903
01904 wxLogMessage(wxString("Indice Unión (pared): %f", wxConvUTF8), intersection);
01905
01906 double razon = 0;
01907
01908 if (and_ == 0)
01909 {
01910 razon = -1;
01911 }
01912 else
01913 {
01914 razon = xor_ / and_;
01915 }
01916 wxLogMessage(wxString("Razón (lumen): %f", wxConvUTF8), razon);
01917 }
01918 else
01919 {
01920 wxLogMessage(wxString("SIN INFORMACION LUMEN", wxConvUTF8));
01921 }
01922
01923
01924
01925
01926
01927 int conts = _manContours[_mar->getActualQuant()]->getNumberOfCalcContours();
01928
01929 std::vector<marIsocontour *> calc;
01930 for (int i = 0; i < conts; i++)
01931 {
01932 int size = _manContours[_mar->getActualQuant()]->getNumberOfCalcContourPoints(i);
01933 double* vx = _manContours[_mar->getActualQuant()]->getXVectorCalcPoints(i);
01934 double* vy = _manContours[_mar->getActualQuant()]->getYVectorCalcPoints(i);
01935 marIsocontour* m = _mar->loadMarIsocontour(size,vx,vy);
01936 calc.push_back(m);
01937 }
01938
01939 if (conts > 0)
01940 {
01941 double intersection = _mar->performUnion(CALCIFICATION,calc);
01942 double xor_ = _mar->performXOR(CALCIFICATION,calc);
01943 xor_ = xor_ /intersection;
01944
01945 wxLogMessage(wxString("Indice OR (calc): %f", wxConvUTF8), xor_*100);
01946
01947 double and_ = _mar->performAND(CALCIFICATION,calc);
01948 and_ = and_ / intersection;
01949 wxLogMessage(wxString("Indice AND (calc): %f", wxConvUTF8), and_*100);
01950
01951
01952 wxLogMessage(wxString("Indice Unión (pared): %f", wxConvUTF8), intersection);
01953
01954 double razon = 0;
01955
01956 if (and_ == 0)
01957 {
01958 razon = -1;
01959 }
01960 else
01961 {
01962 razon = xor_ / and_;
01963 }
01964
01965 wxLogMessage(wxString("Razón (calc): %f", wxConvUTF8), razon);
01966 }
01967 else
01968 {
01969 wxLogMessage(_T("INFORMACION NO DISPONIBLE PARA CALCIFICACION"));
01970 }
01971
01972 }
01973
01974 void wxQuantificationWidgetCT::performAND()
01975 {
01976
01977 int size = _manContours[_mar->getActualQuant()]->getNumberOfWallContourPoints();
01978 double *vx = _manContours[_mar->getActualQuant()]->getXVectorWallPoints();
01979 double *vy = _manContours[_mar->getActualQuant()]->getYVectorWallPoints();
01980
01981 marIsocontour* m = _mar->loadMarIsocontour(size,vx,vy);
01982 std::vector<marIsocontour *> walls;
01983
01984 walls.push_back(m);
01985
01986
01987
01988
01989 }
01990
01991 void wxQuantificationWidgetCT::getIndex()
01992 {
01993 }
01994
01995
01996 void wxQuantificationWidgetCT::OnSliderDiscontinuityScroll(int percentage)
01997 {
01998 _mar->updateDiscontinuityThreshold(percentage);
01999 RefreshAxis();
02000
02001 }
02002
02003
02004
02005 void wxQuantificationWidgetCT::OnSliderLumenPercentageScroll(int percentage)
02006 {
02007 _mar->updateLumenPercentage(percentage);
02008 _contourViewer->Refresh();
02009 }
02010
02011
02012
02013 void wxQuantificationWidgetCT::OnCalibration()
02014 {
02015
02016 int actual = _mar->getActualQuant();
02017 _mar->ClearContoursPartial(actual - 1);
02018 _mar->setStartIndex(actual);
02019 _mar->setCalibration(true);
02020
02021 wxLogMessage(_T("Contours calibrated"));
02022 _mar->markUpLumen(actual);
02023 RefreshAxis();
02024 }
02025
02026
02027 void wxQuantificationWidgetCT::OnFile()
02028 {
02029
02030 _mar->generateFile();
02031 }
02032
02033
02034 void wxQuantificationWidgetCT::OnShowAll(bool value)
02035 {
02036 OnShowWall(value);
02037 OnShowLumen(value);
02038 OnShowCalc(value);
02039 OnShowHypo(value);
02040 }
02041
02042
02043 void wxQuantificationWidgetCT::OnShowWall(bool value)
02044 {
02045
02046 _manContours[_mar->getActualQuant()]->setWallVisibility(value);
02047 _imageviewer2D_1->Refresh();
02048 _imageviewer2D_1->RefreshView();
02049 }
02050
02051 void wxQuantificationWidgetCT::OnShowLumen(bool value)
02052 {
02053 _manContours[_mar->getActualQuant()]->setLumenVisibility(value);
02054 _imageviewer2D_1->Refresh();
02055 _imageviewer2D_1->RefreshView();
02056 }
02057
02058
02059 void wxQuantificationWidgetCT::OnShowCalc(bool value)
02060 {
02061 _manContours[_mar->getActualQuant()]->setCalcVisibility(value);
02062 _imageviewer2D_1->Refresh();
02063 _imageviewer2D_1->RefreshView();
02064 }
02065
02066
02067 void wxQuantificationWidgetCT::OnShowHypo(bool value)
02068 {
02069 _manContours[_mar->getActualQuant()]->setHypoVisibility(value);
02070 _imageviewer2D_1->Refresh();
02071 _imageviewer2D_1->RefreshView();
02072 }
02073
02074
02075 void wxQuantificationWidgetCT::OnSliderCalcPercentageScroll(int percentage)
02076 {
02077 int actual = _mar->getActualQuant();
02078 _mar->updateCalcPercentage(percentage);
02079 _contourViewer->Refresh();
02080
02081 RefreshAxis();
02082
02083 }
02084
02085
02086
02087 void wxQuantificationWidgetCT::CreateManualContours()
02088 {
02089
02090
02091 for (int i = 0; i < _mar->getNumberOfSlices(); i++)
02092 {
02093 if (_manContours[i] != NULL && _mar->getActualQuant() != i)
02094 {
02095 _manContours[i]->setWallVisibility(false);
02096 _manContours[i]->setLumenVisibility(false);
02097 _manContours[i]->setCalcVisibility(false);
02098 _manContours[i]->setHypoVisibility(false);
02099 _manContours[i]->inactivate();
02100 }
02101 }
02102
02103 _imageviewer2D_1->Refresh();
02104
02105
02106
02107
02108 if (_manContours[_mar->getActualQuant()] == NULL)
02109 {
02110 _manContours[_mar->getActualQuant()] = new manualContourContainer();
02111
02112
02113
02114 }
02115 else
02116 {
02117 _manContours[_mar->getActualQuant()]->setWallVisibility(true);
02118 _manContours[_mar->getActualQuant()]->setLumenVisibility(true);
02119 _manContours[_mar->getActualQuant()]->setCalcVisibility(true);
02120 _manContours[_mar->getActualQuant()]->setHypoVisibility(true);
02121 _imageviewer2D_1->Refresh();
02122 _imageviewer2D_1->RefreshView();
02123 }
02124
02125
02126 }
02127
02128
02129 void wxQuantificationWidgetCT::addManualContours(int type)
02130 {
02131 int tam = 0;
02132
02133 if (type == CALCIFICATION)
02134 {
02135 tam = _manContours[_mar->getActualQuant()]->addCalcificationContour(_imageviewer2D_1);
02136 _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContours[_mar->getActualQuant()]->getCalcController(tam) );
02137 }
02138 else if (type == HYPODENSE)
02139 {
02140 tam = _manContours[_mar->getActualQuant()]->addHypodenseContour(_imageviewer2D_1);
02141 _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContours[_mar->getActualQuant()]->getHypoController(tam) );
02142 }
02143 }
02144
02145
02146
02147
02148
02149