]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/wxQuantificationWidget.cxx
b8a0a1f2d61006b9db3913ac6b22cbf1bae33edb
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / wxQuantificationWidget.cxx
1
2
3 /*=========================================================================
4
5  Program:   wxMaracas
6  Module:    $RCSfile: wxQuantificationWidget.cxx,v $
7  Language:  C++
8  Date:      $Date: 2009/05/14 13:54:57 $
9  Version:   $Revision: 1.1 $
10  
11   Copyright: (c) 2002, 2003
12   License:
13   
14    This software is distributed WITHOUT ANY WARRANTY; without even
15    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16    PURPOSE.  See the above copyright notice for more information.
17    
18 =========================================================================*/
19
20 #include "wxQuantificationWidget.h"
21 #include "../marDictionary.h"
22 //#include "../wxMaracasMPR.h"
23
24
25 //#include <matrix.h>
26 //#include <wx/notebook.h>
27
28
29
30 //------------------------------------------------------------------------
31 //------------------------------------------------------------------------
32 //------------------------------------------------------------------------
33 BEGIN_EVENT_TABLE( wxQuantificationWidget, wxPanel )
34         EVT_BUTTON(ID_BUTTON_CONTOUR            , wxQuantificationWidget::OnContour_BT                                          )
35         EVT_BUTTON(ID_BUTTON_CLEAN                      , wxQuantificationWidget::OnClean_BT                                            )
36         EVT_BUTTON(ID_BUTTON_CLEAN_ALL          , wxQuantificationWidget::OnCleanAll_BT                                         )
37         EVT_BUTTON(ID_BUTTON_SAVE_CONTOURS3D, wxQuantificationWidget::OnSaveContours3D_BT                               )
38
39 //      EVT_BUTTON(ID_BUTTON_HEALTHY,   wxQuantificationWidget::OnHealthySlice_BT                                       )
40
41         // PS ->     EVT_BUTTON(ID_BUTTON_CALCULATED, wxQuantificationWidget::OnCalculated_BT           )
42         // PS ->     EVT_BUTTON(ID_BUTTON_PAUSE,      wxQuantificationWidget::OnPause_BT                        )
43         // PS ->     EVT_BUTTON(ID_BUTTON_DELETE,     wxQuantificationWidget::OnDelete_BT                       )
44         // PS ->     EVT_BUTTON(ID_BUTTON_POINT,      wxQuantificationWidget::OnSetPoint_BT                     )
45
46         EVT_CHECKBOX(ID_CHECKBOX_HEALTHY,                       wxQuantificationWidget::OnHealthySlice_CB               )
47         EVT_CHECKBOX(ID_CHECKBOX_SHOW_SURFACE,          wxQuantificationWidget::OnShowSurface_CB                )
48         EVT_CHECKBOX(ID_CHECKBOX_VISIBLE_RINGS,         wxQuantificationWidget::OnVisibleRing_CB                )
49         EVT_CHECKBOX(ID_CHECKBOX_PERPENDICULAR,         wxQuantificationWidget::OnPerpendicular_CB              )
50
51         EVT_RADIOBUTTON(ID_RADIOBUTTON_GREYSCALE,       wxQuantificationWidget::OnGreyScale_RB                  )
52         EVT_RADIOBUTTON(ID_RADIOBUTTON_COLOR,           wxQuantificationWidget::OnColor_RB                              )
53
54         EVT_COMMAND_SCROLL(ID_SLIDER_SLICE,                     wxQuantificationWidget::OnSliderSliceScroll             )
55
56         EVT_COMMAND_SCROLL(ID_SLIDER_OPACITY,           wxQuantificationWidget::OnSliderOpacityScroll   )
57         EVT_COMMAND_SCROLL_THUMBRELEASE(ID_SLIDER_ISOVALUE, wxQuantificationWidget::OnSliderIsovalueScroll      )
58 END_EVENT_TABLE( );
59
60
61 //--------------------------------------------------------------------------------
62 // Constructor
63 //--------------------------------------------------------------------------------
64 wxQuantificationWidget::wxQuantificationWidget(wxWindow* parent, wxWindowID id,
65                                                const wxPoint& pos, const wxSize& size, long style,
66                                                const wxString& name)
67 : wxQuantificationWidget_base( parent, id, pos, size, style, name )
68 {
69     panel_splitter               = new wxSplitterWindow( this                   , -1, wxDefaultPosition, wxSize(400,400 ), wxSP_3D | wxSP_LIVE_UPDATE | wxCLIP_CHILDREN );
70 //      panel_left                       = new wxPanel(panel_splitter                   , -1, wxDefaultPosition, wxSize(400,400));
71         panel_right                      = new wxPanel(panel_splitter                   , -1, wxDefaultPosition, wxSize(400,400));
72
73     panel_splitter_left  = new wxSplitterWindow( panel_splitter                 , -1, wxDefaultPosition, wxSize(400,400 ), wxSP_3D | wxSP_LIVE_UPDATE | wxCLIP_CHILDREN );
74         panel_left_up            = new wxPanel(panel_splitter_left              , -1, wxDefaultPosition, wxSize(200,200));
75         panel_left_down          = new wxPanel(panel_splitter_left              , -1, wxDefaultPosition, wxSize(200,200));
76
77
78     panel_splitter_right = new wxSplitterWindow( panel_right    , -1, wxDefaultPosition, wxSize(400,400 ), wxSP_3D | wxSP_LIVE_UPDATE | wxCLIP_CHILDREN );
79         panel_right_up           = new wxPanel(panel_splitter_right             , -1, wxDefaultPosition, wxSize(200,200));
80         panel_right_down         = new wxPanel(panel_splitter_right             , -1, wxDefaultPosition, wxSize(200,200));
81
82
83
84         // maracas
85         _mar = NULL;
86         SetSizeHealthyRegion( 5 );
87
88 //EEDxx 2.6
89 //      this->SetBackgroundColour(*wxLIGHT_GREY);
90
91         _3DWorld = new vtk3DQuantSurfaceWidget( panel_left_up, ID_QUANTIF3D );
92         _3DWorld->SetInterfaceVtkPanelWidgets(this);
93
94         _2DWorld = new vtk2DQuantSliceWidget( panel_right_up, -1 );
95         _2DWorld->SetSize(800,800);
96         _2DWorld->SetInterfaceVtkPanelWidgets(this);
97         
98         
99         this->Set_control();
100         this->Do_layout();
101         this->Set_Data();
102         _bak_ActualSlice=-1;
103
104         Refresh();
105
106 //EED Borrame
107 //startTimeRI = clock();
108
109 }
110
111
112 //--------------------------------------------------------------------------------
113 // Destructor
114 // ----------------------------------------------------------------------------
115 wxQuantificationWidget::~wxQuantificationWidget( )
116 {
117 //EEDx15
118         _3DWorld->Delete( );
119 //      delete _2DWorld;
120 }
121 // ----------------------------------------------------------------------------
122 wxPanel* wxQuantificationWidget::CreateStenosisPanel(){
123         marDictionary marDict;
124
125         wxPanel* panel = new wxPanel(panel_right_down);
126
127         _st_Label100 = new wxStaticText(panel, -1, wxString(marDict.GetString(255), wxConvUTF8) ); // "Stenosis (area)"
128         _st_Label101 = new wxStaticText(panel, -1, wxString(marDict.GetString(260), wxConvUTF8) ); // "Stenosis (diameter)"
129 //      _st_Label102 = new wxStaticText(panel, -1, "                          < Area (mm^2) > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
130 //      _st_Label103 = new wxStaticText(panel, -1, "                       < Perimeter (mm) > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
131 //      _st_Label104 = new wxStaticText(panel, -1, "        < Diameter (mm) from Area > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
132 //      _st_Label105 = new wxStaticText(panel, -1, "  < Diameter (mm) from Perimeter > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
133 //      _st_Label106 = new wxStaticText(panel, -1, "          < Minimum Diameter (mm) > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
134 //      _st_Label107 = new wxStaticText(panel, -1, "          < Maximum Diameter (mm) > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
135 //      _st_Label108 = new wxStaticText(panel, -1, "          < Avarege Diameter (mm) > Stenosis :  ",wxPoint(0,0),wxDefaultSize,wxALIGN_RIGHT );
136
137         _st_Value100 = new wxStaticText(panel, -1, _T("--                ") );
138         _st_Value101 = new wxStaticText(panel, -1, _T("--                ") );
139 //      _st_Value102 = new wxStaticText(panel, -1, "--");
140 //      _st_Value103 = new wxStaticText(panel, -1, "--");
141 //      _st_Value104 = new wxStaticText(panel, -1, "--");
142 //      _st_Value105 = new wxStaticText(panel, -1, "--");
143 //      _st_Value106 = new wxStaticText(panel, -1, "--");
144 //      _st_Value107 = new wxStaticText(panel, -1, "--");
145 //      _st_Value108 = new wxStaticText(panel, -1, "--");
146
147 //EEDxx 2.6
148 //      wxStaticText *_st_LabelBlanc = new wxStaticText(panel, -1, "                 ");
149 //      _st_LabelBlanc->SetBackgroundColour(*wxLIGHT_GREY);
150
151 //EEDxx 2.6
152 //      panel->SetBackgroundColour(wxColour(100,0,100));
153 //      _st_Label100->SetBackgroundColour(*wxLIGHT_GREY);
154 //      _st_Label101->SetBackgroundColour(*wxLIGHT_GREY);
155
156
157
158
159 //      _st_Label102->SetBackgroundColour(*wxLIGHT_GREY);
160 //      _st_Label103->SetBackgroundColour(*wxLIGHT_GREY);
161 //      _st_Label104->SetBackgroundColour(*wxLIGHT_GREY);
162 //      _st_Label105->SetBackgroundColour(*wxLIGHT_GREY);
163 //      _st_Label106->SetBackgroundColour(*wxLIGHT_GREY);
164 //      _st_Label107->SetBackgroundColour(*wxLIGHT_GREY);
165 //      _st_Label108->SetBackgroundColour(*wxLIGHT_GREY);
166
167
168 //EEDxx 2.6
169 //      _st_Value100->SetBackgroundColour(*wxLIGHT_GREY);
170 //      _st_Value101->SetBackgroundColour(*wxLIGHT_GREY);
171
172
173 //      _st_Value102->SetBackgroundColour(*wxLIGHT_GREY);
174 //      _st_Value103->SetBackgroundColour(*wxLIGHT_GREY);
175 //      _st_Value104->SetBackgroundColour(*wxLIGHT_GREY);
176 //      _st_Value105->SetBackgroundColour(*wxLIGHT_GREY);
177 //      _st_Value106->SetBackgroundColour(*wxLIGHT_GREY);
178 //      _st_Value107->SetBackgroundColour(*wxLIGHT_GREY);
179 //      _st_Value108->SetBackgroundColour(*wxLIGHT_GREY);
180
181         wxFont font(14,wxDEFAULT ,wxNORMAL,wxBOLD);
182 //      _st_Label100->SetFont(font);
183 //      _st_Label101->SetFont(font);
184         _st_Value100->SetFont(font);
185         _st_Value101->SetFont(font);
186
187
188
189         wxGridSizer*  gridSizer1        = new wxFlexGridSizer(1);
190         gridSizer1->Add( new wxStaticText(panel, -1, _T("                 "))   ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
191         gridSizer1->Add(_st_Value100    ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
192         gridSizer1->Add(_st_Label100    ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
193         gridSizer1->Add( new wxStaticText(panel, -1, _T("                 "))   ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
194         gridSizer1->Add(_st_Value101    ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
195         gridSizer1->Add(_st_Label101    ,15, wxALL|wxEXPAND|wxALIGN_CENTRE_HORIZONTAL, 0);
196
197
198
199 //      gridSizer->Add(_st_LabelBlanc);
200 //      gridSizer->Add(_st_LabelBlanc);
201 //      gridSizer->Add(_st_LabelBlanc);
202 //      gridSizer->Add(_st_LabelBlanc);
203 //      gridSizer->Add(_st_Label102);
204 //      gridSizer->Add(_st_Value102);
205 //      gridSizer->Add(_st_LabelBlanc);
206 //      gridSizer->Add(_st_LabelBlanc);
207 //      gridSizer->Add(_st_Label103);
208 //      gridSizer->Add(_st_Value103);
209 //      gridSizer->Add(_st_LabelBlanc);
210 //      gridSizer->Add(_st_LabelBlanc);
211 //      gridSizer->Add(_st_Label104);
212 //      gridSizer->Add(_st_Value104);
213 //      gridSizer->Add(_st_LabelBlanc);
214 //      gridSizer->Add(_st_LabelBlanc);
215 //      gridSizer->Add(_st_Label105);
216 //      gridSizer->Add(_st_Value105);
217 //      gridSizer->Add(_st_LabelBlanc);
218 //      gridSizer->Add(_st_LabelBlanc);
219 //      gridSizer->Add(_st_Label106);
220 //      gridSizer->Add(_st_Value106);
221 //      gridSizer->Add(_st_LabelBlanc);
222 //      gridSizer->Add(_st_LabelBlanc);
223 //      gridSizer->Add(_st_Label107);
224 //      gridSizer->Add(_st_Value107);
225 //      gridSizer->Add(_st_LabelBlanc);
226 //      gridSizer->Add(_st_LabelBlanc);
227 //      gridSizer->Add(_st_Label108);
228 //      gridSizer->Add(_st_Value108);
229
230         wxGridSizer*  gridSizer         = new wxFlexGridSizer(4);
231         gridSizer->Add( new wxStaticText(panel, -1, _T("                 "))    ,15, wxALIGN_LEFT , 50);
232         gridSizer->Add( new wxStaticText(panel, -1, _T("                 "))    ,15, wxALIGN_LEFT , 50);
233         gridSizer->Add( new wxStaticText(panel, -1, _T("                 "))    ,15, wxALIGN_LEFT , 50);
234         gridSizer->Add(gridSizer1               ,15, wxALIGN_LEFT , 50);
235
236         panel->SetAutoLayout(true);
237         panel->SetSizer(gridSizer);
238         panel->Layout();
239
240 //EEDxx 2.6
241 //      panel->SetBackgroundColour(*wxLIGHT_GREY);
242
243         panel->SetSize(400,300);
244         panel->SetSize( gridSizer->GetMinSize() );
245
246         return panel;
247 }
248
249 //--------------------------------------------------------
250
251 void wxQuantificationWidget::Set_control(){
252         marDictionary marDict;
253         
254         // wxChart
255
256         // EED 
257         //_Chart = new wxChart( this, ID_QUANTIF3D );
258         //_Chart->SetMaxWidthHeight(500,300);
259         //_Chart->SetBackgroundColour(*wxWHITE);
260
261          _wxStenosisPanel = CreateStenosisPanel();
262
263         //wxButton
264         // PS ->   _bt_Point = new wxButton( this, ID_BUTTON_POINT, "Point...",
265         // PS ->                             wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
266 //      _bt_Healthy = new wxButton( panel_left, ID_BUTTON_HEALTHY, "Healthy Slice",
267 //              wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
268
269
270
271         // PS ->   _bt_ContourCalculated = new wxButton( this, ID_BUTTON_CALCULATED, "Contour calculated",
272         // PS ->                                         wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
273         // PS ->   _bt_Pause = new wxButton( this, ID_BUTTON_PAUSE, "Pause",
274         // PS ->                             wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
275         // PS ->   _bt_Delete = new wxButton( this, ID_BUTTON_DELETE, "Delete Quantification",
276         // PS ->                              wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
277
278
279         
280
281         _cb_HealthySlice        = new wxCheckBox( panel_left_down, ID_CHECKBOX_HEALTHY, wxString(marDict.GetString(205), wxConvUTF8)); // "Healthy slice"
282         _cb_HealthySlice->SetValue(true);
283 //EEDxx 2.6
284 //      _cb_HealthySlice->SetBackgroundColour(*wxLIGHT_GREY);
285         _cb_Perpendicular       = new wxCheckBox( panel_left_down, ID_CHECKBOX_PERPENDICULAR, wxString(marDict.GetString(210), wxConvUTF8)); //"Perpendicular section"
286         _cb_Perpendicular->SetValue(true);
287 //EEDxx 2.6
288 //      _cb_Perpendicular->SetBackgroundColour(*wxLIGHT_GREY);
289
290         _rb_GreyScale           = new wxRadioButton( panel_left_down, ID_RADIOBUTTON_GREYSCALE, wxString(marDict.GetString(230), wxConvUTF8), wxDefaultPosition,wxDefaultSize,wxRB_GROUP  ); //"greyscale    "
291         _rb_GreyScale->SetValue(true);
292 //EEDxx 2.6
293 //      _rb_GreyScale->SetBackgroundColour(*wxLIGHT_GREY);
294
295         _rb_Color                       = new wxRadioButton( panel_left_down, ID_RADIOBUTTON_COLOR, wxString(marDict.GetString(235), wxConvUTF8), wxDefaultPosition,wxDefaultSize );//"color    "
296         _rb_Color->SetValue(false);
297 //EEDxx 2.6
298 //      _rb_Color->SetBackgroundColour(*wxLIGHT_GREY);
299
300         _cb_VisibleRings        = new wxCheckBox( panel_left_down, ID_CHECKBOX_VISIBLE_RINGS, wxString(marDict.GetString(215), wxConvUTF8));//"Visible rings"
301         _cb_VisibleRings->SetValue(true);
302 //EEDxx 2.6
303 //      _cb_VisibleRings->SetBackgroundColour(*wxLIGHT_GREY);
304         _cb_ShowSurface         = new wxCheckBox( panel_left_down, ID_CHECKBOX_SHOW_SURFACE, wxString(marDict.GetString(220), wxConvUTF8));//"Show Surface"
305         _cb_ShowSurface->SetValue(true);
306 //EEDxx 2.6
307 //      _cb_ShowSurface->SetBackgroundColour(*wxLIGHT_GREY);
308
309         
310         _bt_AddContour3D                = new wxButton( panel_left_down, ID_BUTTON_CONTOUR, wxString(marDict.GetString(245), wxConvUTF8) ,//"Add mark contour"
311                                        wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
312         _bt_CleanContour3D              = new wxButton( panel_left_down, ID_BUTTON_CLEAN, wxString(marDict.GetString(250), wxConvUTF8) ,//"Erase mark contours"
313                                      wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
314
315         _bt_CleanAllContours3D  = new wxButton( panel_left_down, ID_BUTTON_CLEAN_ALL, wxString(marDict.GetString(253), wxConvUTF8) ,//"Erase all mark contours"
316                                      wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
317
318         _bt_SaveContours3D      = new wxButton( panel_left_down, ID_BUTTON_SAVE_CONTOURS3D, wxString(marDict.GetString(248), wxConvUTF8) ,//"Save contours 3D"
319                                      wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
320
321         //wxSlider
322         _sl_Slice    = new wxSlider( panel_left_down, ID_SLIDER_SLICE   , 0, 0, 10000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
323         _sl_Isovalue = new wxSlider( panel_left_down, ID_SLIDER_ISOVALUE, 0, 0, 10000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
324         _sl_Opacity  = new wxSlider( panel_left_down, ID_SLIDER_OPACITY , 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
325 //EEDxx 2.6
326 //      _sl_Slice->SetBackgroundColour(*wxLIGHT_GREY);
327 //      _sl_Isovalue->SetBackgroundColour(*wxLIGHT_GREY);
328 //      _sl_Opacity->SetBackgroundColour(*wxLIGHT_GREY);
329
330         // size
331         _sl_Slice->SetSize(1800,16);
332         _sl_Isovalue->SetSize(300,16);
333         _sl_Opacity->SetSize(300,16);
334         
335         // Text
336         _st_Slice        = new wxStaticText(panel_left_down, -1, wxString(marDict.GetString(90), wxConvUTF8) ); //"Slice "
337         _st_Isovalue = new wxStaticText(panel_left_down, -1, wxString(marDict.GetString(240), wxConvUTF8) ); //"Isovalue"
338         _st_Opacity  = new wxStaticText(panel_left_down, -1, wxString(marDict.GetString(225), wxConvUTF8) ); //"Opacity "
339 //EEDxx 2.6
340 //      _st_Slice->SetBackgroundColour(*wxLIGHT_GREY);
341 //      _st_Isovalue->SetBackgroundColour(*wxLIGHT_GREY);
342 //      _st_Opacity->SetBackgroundColour(*wxLIGHT_GREY);
343         
344         
345 //      _st_Label0 = new wxStaticText(this, -1, "Partial Axis Lenght");
346 //      _st_Value0 = new wxStaticText(this, -1, "0.00");
347 //      _st_Label0->SetBackgroundColour(*wxLIGHT_GREY);
348 //      _st_Value0->SetBackgroundColour(*wxLIGHT_GREY);
349         _st_Label1 = new wxStaticText(this, -1, wxString(marDict.GetString(380), wxConvUTF8) ); //"Total Axis Lenght"
350         _st_Value1 = new wxStaticText(this, -1, _T("0.00"));
351
352 //EEDxx 2.6
353 //      _st_Label1->SetBackgroundColour(*wxLIGHT_GREY);
354 //      _st_Value1->SetBackgroundColour(*wxLIGHT_GREY);
355
356         _st_Label2 = new wxStaticText(this, -1, wxString(marDict.GetString(390), wxConvUTF8) );//"Area"
357         _st_Value2 = new wxStaticText(this, -1, _T("0.00"));
358 //EEDxx 2.6
359 //      _st_Label2->SetBackgroundColour(*wxLIGHT_GREY);
360 //      _st_Value2->SetBackgroundColour(*wxLIGHT_GREY);
361
362         _st_Label3 = new wxStaticText(this, -1, wxString(marDict.GetString(400), wxConvUTF8) );//"Perimeter"
363         _st_Value3 = new wxStaticText(this, -1, _T("0.00") );
364 //EEDxx 2.6
365 //      _st_Label3->SetBackgroundColour(*wxLIGHT_GREY);
366 //      _st_Value3->SetBackgroundColour(*wxLIGHT_GREY);
367
368
369 //      _st_Label4 = new wxStaticText(this, -1, "Diameter from area");
370 //      _st_Value4 = new wxStaticText(this, -1, "0.00");
371 //      _st_Label4->SetBackgroundColour(*wxLIGHT_GREY);
372 //      _st_Value4->SetBackgroundColour(*wxLIGHT_GREY);
373 //      _st_Label5 = new wxStaticText(this, -1, "Diameter from perimeter");
374 //      _st_Value5 = new wxStaticText(this, -1, "0.00");
375 //      _st_Label5->SetBackgroundColour(*wxLIGHT_GREY);
376 //      _st_Value5->SetBackgroundColour(*wxLIGHT_GREY);
377         _st_Label6 = new wxStaticText(this, -1, wxString(marDict.GetString(405), wxConvUTF8) );//"Minimum Diameter"
378         _st_Value6 = new wxStaticText(this, -1, _T("0.00"));
379 //EEDxx 2.6
380 //      _st_Label6->SetBackgroundColour(*wxLIGHT_GREY);
381 //      _st_Value6->SetBackgroundColour(*wxLIGHT_GREY);
382         _st_Label7 = new wxStaticText(this, -1, wxString(marDict.GetString(410), wxConvUTF8) );//"Maximum Diameter"
383         _st_Value7 = new wxStaticText(this, -1, _T("0.00"));
384 //EEDxx 2.6
385 //      _st_Label7->SetBackgroundColour(*wxLIGHT_GREY);
386 //      _st_Value7->SetBackgroundColour(*wxLIGHT_GREY);
387         _st_Label8 = new wxStaticText(this, -1, wxString(marDict.GetString(415), wxConvUTF8) );//"Average Diameter"
388         _st_Value8 = new wxStaticText(this, -1, _T("0.00"));
389 //EEDxx 2.6
390 //      _st_Label8->SetBackgroundColour(*wxLIGHT_GREY);
391 //      _st_Value8->SetBackgroundColour(*wxLIGHT_GREY);
392         // EED -> _st_Label9 = new wxStaticText(this, -1, "Stenosis");
393         // EED -> _st_Value9 = new wxStaticText(this, -1, "0.00");
394         // EED -> _st_Label9->SetBackgroundColour(*wxLIGHT_GREY);
395         // EED -> _st_Value9->SetBackgroundColour(*wxLIGHT_GREY);
396
397         _st_LabelRef101 = new wxStaticText(this, -1, wxString(marDict.GetString(385), wxConvUTF8) );//"Seg. Length"
398         _st_ValueRef101 = new wxStaticText(this, -1, _T("--"));
399 //EEDxx 2.6
400 //      _st_LabelRef101->SetBackgroundColour(*wxLIGHT_GREY);
401 //      _st_ValueRef101->SetBackgroundColour(*wxLIGHT_GREY);
402         _st_LabelRef102 = new wxStaticText(this, -1, wxString(marDict.GetString(395), wxConvUTF8) );//"Ref. Area"
403         _st_ValueRef102 = new wxStaticText(this, -1, _T("--"));
404 //EEDxx 2.6
405 //      _st_LabelRef102->SetBackgroundColour(*wxLIGHT_GREY);
406 //      _st_ValueRef102->SetBackgroundColour(*wxLIGHT_GREY);
407         _st_LabelRef103 = new wxStaticText(this, -1, wxString(marDict.GetString(420), wxConvUTF8) );//"Ref. Average Diam."
408         _st_ValueRef103 = new wxStaticText(this, -1, _T("--"));
409 //EEDxx 2.6
410 //      _st_LabelRef103->SetBackgroundColour(*wxLIGHT_GREY);
411 //      _st_ValueRef103->SetBackgroundColour(*wxLIGHT_GREY);
412
413         _pl_cntlHealthySick2 = new wxPanelControlsHealthySickSlice2(panel_right_down,this);
414
415 //EEDxx 2.6
416 //   panel_left->SetBackgroundColour(*wxLIGHT_GREY);
417 //      panel_right_up->SetBackgroundColour(*wxLIGHT_GREY);
418 //      panel_right_down->SetBackgroundColour(*wxLIGHT_GREY);
419 //      panel_splitter_right->SetBackgroundColour(*wxLIGHT_GREY);
420 //      panel_splitter->SetBackgroundColour(*wxLIGHT_GREY);
421  
422 }
423
424 //--------------------------------------------------------
425
426 void wxQuantificationWidget::Do_layout()
427 {
428         
429         //Do the layout:
430         
431         wxBoxSizer                      *sizer_principal        = new wxBoxSizer(wxVERTICAL);
432         wxBoxSizer                      *status                         = new wxBoxSizer(wxHORIZONTAL);
433
434 //EEDxx 2.6     
435 //      wxFlexGridSizer         *medium_right_up        = new wxFlexGridSizer(1,0);
436         wxBoxSizer                      *medium_right_up        = new wxBoxSizer(wxVERTICAL);
437
438         wxFlexGridSizer         *medium_right_down      = new wxFlexGridSizer(1,0);
439
440
441         wxBoxSizer                      *medium_left_up         = new wxBoxSizer(wxVERTICAL);
442         wxBoxSizer                      *medium_right           = new wxBoxSizer(wxVERTICAL);
443 //      wxFlexGridSizer         *autoQuantif            = new wxFlexGridSizer(1,0);
444
445
446 //      wxStaticBoxSizer        *axe                            = new wxStaticBoxSizer(new wxStaticBox(panel_left_down, -1, _T("")), wxVERTICAL);
447         wxFlexGridSizer         *axe                            = new wxFlexGridSizer(1);
448         axe->AddGrowableCol(0);
449
450         wxFlexGridSizer         *axe1                           = new wxFlexGridSizer(10,0);
451         wxBoxSizer                      *axe2                           = new wxBoxSizer(wxHORIZONTAL);
452         wxFlexGridSizer         *axe3                           = new wxFlexGridSizer(10,0);
453         wxFlexGridSizer         *axe4                           = new wxFlexGridSizer(10,0);
454         wxBoxSizer                      *axe5                           = new wxBoxSizer(wxHORIZONTAL);
455         wxBoxSizer                      *axe6                           = new wxBoxSizer(wxHORIZONTAL);
456         
457         wxBoxSizer                      *status0                        = new wxBoxSizer(wxVERTICAL);
458         wxBoxSizer                      *status1                        = new wxBoxSizer(wxVERTICAL);
459         wxBoxSizer                      *status2                        = new wxBoxSizer(wxVERTICAL);
460         wxBoxSizer                      *status3                        = new wxBoxSizer(wxVERTICAL);
461 //      wxBoxSizer                      *status4                        = new wxBoxSizer(wxVERTICAL);
462 //      wxBoxSizer                      *status5                        = new wxBoxSizer(wxVERTICAL);
463         wxBoxSizer                      *status6                        = new wxBoxSizer(wxVERTICAL);
464         wxBoxSizer                      *status7                        = new wxBoxSizer(wxVERTICAL);
465         wxBoxSizer                      *status8                        = new wxBoxSizer(wxVERTICAL);
466         wxBoxSizer                      *status9                        = new wxBoxSizer(wxVERTICAL);
467         wxBoxSizer                      *statusRef1                     = new wxBoxSizer(wxVERTICAL);
468         wxBoxSizer                      *statusRef2                     = new wxBoxSizer(wxVERTICAL);
469         wxBoxSizer                      *statusRef3                     = new wxBoxSizer(wxVERTICAL);
470         
471
472         axe1->Add(_st_Slice                                     , 10, wxALL|wxEXPAND, 0);
473         axe1->Add(_sl_Slice                                     , 10, wxALL|wxGROW, 0);
474         axe1->AddGrowableCol(1);
475
476         axe2->Add(_cb_HealthySlice                      , 10, wxALL|wxEXPAND, 0);
477         axe2->Add(_cb_Perpendicular                     , 10, wxALL|wxEXPAND, 0);
478         axe2->Add(_cb_VisibleRings                      , 10, wxALL|wxEXPAND, 0);
479         axe2->Add(_cb_ShowSurface                       , 10, wxALL|wxEXPAND, 0);
480
481         axe3->Add(_st_Opacity                           ,  1, wxALL|wxEXPAND, 0);
482         axe3->Add(_sl_Opacity                           , 10, wxALL|wxGROW, 0);
483         axe3->Add(_rb_GreyScale                         , 10, wxALL|wxEXPAND, 0);
484         axe3->Add(_rb_Color                                     , 10, wxALL|wxEXPAND, 0);
485         axe3->AddGrowableCol(1);
486
487         axe4->Add(_st_Isovalue                          ,  1, wxALL|wxEXPAND, 0);
488         axe4->Add(_sl_Isovalue                          ,  1, wxALL|wxGROW, 0);
489         axe4->AddGrowableCol(1);
490
491         axe5->Add(_bt_AddContour3D                      ,  1                            );
492         axe5->Add(_bt_CleanContour3D            ,  1                            );
493         axe6->Add(_bt_CleanAllContours3D        ,  1                            );
494         axe6->Add(_bt_SaveContours3D            ,  1                            );
495
496
497 //      status0->Add(_st_Label0, 1, wxALL|wxALIGN_CENTER, 5);
498 //      status0->Add(_st_Value0, 1, wxALL|wxALIGN_CENTER, 5);
499         status1->Add(_st_Label1, 1, wxALL|wxALIGN_CENTER, 5);
500         status1->Add(_st_Value1, 1, wxALL|wxALIGN_CENTER, 5);
501         status2->Add(_st_Label2, 1, wxALL|wxALIGN_CENTER, 5);
502         status2->Add(_st_Value2, 1, wxALL|wxALIGN_CENTER, 5);
503         status3->Add(_st_Label3, 1, wxALL|wxALIGN_CENTER, 5);
504         status3->Add(_st_Value3, 1, wxALL|wxALIGN_CENTER, 5);
505 //      status4->Add(_st_Label4, 1, wxALL|wxALIGN_CENTER, 5);
506 //      status4->Add(_st_Value4, 1, wxALL|wxALIGN_CENTER, 5);
507 //      status5->Add(_st_Label5, 1, wxALL|wxALIGN_CENTER, 5);
508 //      status5->Add(_st_Value5, 1, wxALL|wxALIGN_CENTER, 5);
509         status6->Add(_st_Label6, 1, wxALL|wxALIGN_CENTER, 5);
510         status6->Add(_st_Value6, 1, wxALL|wxALIGN_CENTER, 5);
511         status7->Add(_st_Label7, 1, wxALL|wxALIGN_CENTER, 5);
512         status7->Add(_st_Value7, 1, wxALL|wxALIGN_CENTER, 5);
513         status8->Add(_st_Label8, 1, wxALL|wxALIGN_CENTER, 5);
514         status8->Add(_st_Value8, 1, wxALL|wxALIGN_CENTER, 5);
515         // EED -> status9->Add(_st_Label9, 1, wxALL|wxALIGN_CENTER, 5);
516         // EED -> status9->Add(_st_Value9, 1, wxALL|wxALIGN_CENTER, 5);
517         
518         statusRef1->Add(_st_LabelRef101, 1, wxALL|wxALIGN_CENTER, 5);
519         statusRef1->Add(_st_ValueRef101, 1, wxALL|wxALIGN_CENTER, 5);
520         statusRef2->Add(_st_LabelRef102, 1, wxALL|wxALIGN_CENTER, 5);
521         statusRef2->Add(_st_ValueRef102, 1, wxALL|wxALIGN_CENTER, 5);
522         statusRef3->Add(_st_LabelRef103, 1, wxALL|wxALIGN_CENTER, 5);
523         statusRef3->Add(_st_ValueRef103, 1, wxALL|wxALIGN_CENTER, 5);
524
525
526 //      status->Add(status0             , 1, wxALL|wxEXPAND, 0);
527         status->Add(status1             , 1, wxALL|wxEXPAND, 0);
528         status->Add(statusRef1  , 1, wxALL|wxEXPAND, 0);
529         status->Add(status2             , 1, wxALL|wxEXPAND, 0);
530         status->Add(statusRef2  , 1, wxALL|wxEXPAND, 0);
531         status->Add(status3             , 1, wxALL|wxEXPAND, 0);
532 //      status->Add(status4             , 1, wxALL|wxEXPAND, 0);
533 //      status->Add(status5             , 1, wxALL|wxEXPAND, 0);
534         status->Add(status6             , 1, wxALL|wxEXPAND, 0);
535         status->Add(status7             , 1, wxALL|wxEXPAND, 0);
536         status->Add(status8             , 1, wxALL|wxEXPAND, 0);
537         status->Add(statusRef3  , 1, wxALL|wxEXPAND, 0);
538         // EED -> status->Add(status9, 1, wxALL|wxEXPAND, 0);
539         
540         axe->Add(axe1, 2, wxALL|wxEXPAND, 0);
541         axe->Add(axe2, 2, wxALL|wxEXPAND, 0);   //wxALIGN_CENTER_HORIZONTAL
542         axe->Add(axe3, 2, wxALL|wxEXPAND, 0);
543         axe->Add(axe4, 2, wxALL|wxEXPAND, 0);
544
545 //      axe->Add(axe5, 2, wxALL|wxEXPAND, 0);
546 //      axe->Add(axe6, 2, wxALL|wxEXPAND, 0);
547         axe->Add(axe5);
548         axe->Add(axe6);
549
550         panel_left_down->SetAutoLayout(true);
551         panel_left_down->SetSizer(axe);
552         panel_left_down->Layout();
553
554
555 //EEDxx 2.6 GROW
556 //      medium_right_up->Add(_2DWorld                           , 1, wxALL|wxGROW, 5);
557         medium_right_up->Add(_2DWorld                           , 1, wxALL|wxEXPAND, 5);
558
559         medium_right_down->Add(_wxStenosisPanel         , 1, wxALL, 5);
560         medium_right_down->Add(_pl_cntlHealthySick2     , 1, wxALL, 5);
561
562
563         //medium_right->Add(_Chart                      , 1, wxALL|wxEXPAND     , 0);
564         
565 //      panel_left->SetAutoLayout(true);
566 //      panel_left->SetSizer(medium_left);
567 //      panel_left->Layout();
568
569
570         medium_left_up->Add(_3DWorld                                    , 1, wxEXPAND, 0);
571         panel_left_up->SetAutoLayout(true);
572         panel_left_up->SetSizer(medium_left_up);
573         panel_left_up->Layout();
574
575
576     panel_splitter_left->SplitHorizontally( panel_left_up , panel_left_down );
577     panel_splitter_left->SetMinimumPaneSize( 50 );
578
579
580
581         panel_right_up->SetAutoLayout(true);
582         panel_right_up->SetSizer(medium_right_up);
583         panel_right_up->Layout();
584
585         panel_right_down->SetAutoLayout(true);
586         panel_right_down->SetSizer(medium_right_down);
587         panel_right_down->Layout();
588
589
590         int ww,hh;
591         wxWindow *pp=this;
592         while (pp->GetParent()!=NULL) pp=pp->GetParent();
593         pp->GetSize(&ww,&hh);
594
595     panel_splitter_right->SplitHorizontally( panel_right_up, panel_right_down, (int)(hh*0.4)  );
596     panel_splitter_right->SetMinimumPaneSize( 50 );
597         
598
599 //EEDxx 2.6 GROW
600 //      medium_right->Add(panel_splitter_right,1 ,wxGROW,0      );
601         medium_right->Add(panel_splitter_right,1 ,wxALL|wxEXPAND,0      );
602         panel_right->SetAutoLayout(true);
603         panel_right->SetSizer(medium_right);
604         panel_right->Layout();
605 //      panel_right->FitInside();
606
607
608     panel_splitter->SplitVertically( panel_splitter_left , panel_right, (int)(ww*0.6) );
609     panel_splitter->SetMinimumPaneSize( 50 );
610
611 //EEDxx 2.6 GROW
612 //      sizer_principal->Add( panel_splitter    , 1     , wxGROW                );
613 //      sizer_principal->Add( status                    , 0     , wxGROW                );
614         sizer_principal->Add( panel_splitter    , 1     , wxALL|wxEXPAND                );
615         sizer_principal->Add( status                    , 0     , wxALL|wxEXPAND                );
616         
617         this->SetSizer(sizer_principal);
618
619 //EEDxx2.4
620 //      FitInside();
621
622
623 }
624
625 //--------------------------------------------------------
626 void wxQuantificationWidget::Set_Data( )
627 {
628         _axis_index                             = -1;
629         _given_points                   = 0;
630         _nClicks                                = 0;
631         _quantifing                             = 0;
632         
633 //EED   _real_first_point_quant = -1;
634 //EED   _real_last_point_quant  = -1;
635         
636         _shown                                  = 0;
637         _quant_shown                    = 0;
638         
639         _actual_area                    = 0.00;
640         _actual_peri                    = 0.00;
641         _actual_darea                   = 0.00;
642         _actual_dperi                   = 0.00;
643         _actual_dmax                    = 0.00;
644         _actual_dmin                    = 0.00;
645         _actual_davg                    = 0.00;
646         _actual_sten                    = 0.00;
647         _actual_partial                 = 0.00;
648         
649         //_actual_total   = _mar->_experiment->GetAxisLength();
650         //_st_Value1->SetLabel(_actual_total);
651         //return( maracas_data::experiment->get_work_axis( )->get_total_length( ) );
652 }
653
654
655 /*EED
656 //--------------------------------------------------------
657 void wxQuantificationWidget::Positionate( )
658 {
659         _given_points = 0;
660         _shown = true;
661         _first_quant = 1;
662 }
663 */
664
665 //--------------------------------------------------------
666 void wxQuantificationWidget::Forget( )
667 {
668         _shown = false;
669 }
670
671 // ----------------------------------------------------------------------------
672 void wxQuantificationWidget::ShowMARACASData( marInterface* mar )
673 {
674         double        min, max;
675         vtkImageData* imagedata;
676         int nos;
677         int actualQuant=-1;
678         
679         wxBusyCursor wait;
680         _mar = mar;
681         _mar->_experiment->prepareQuantification( );
682         nos = _mar->_experiment->getNumberOfSlices( );
683         actualQuant = (int) (nos-1)/2 ;
684         imagedata = _mar->_experiment->getSliceImage( actualQuant );
685         _mar->_experiment->getAxis()->setActualQuant( actualQuant ) ;
686         _mar->_experiment->getDynData( )->getVolume( )->getMinMax( min, max );
687         
688         _3DWorld->ShowMARACASDataAndAxe( mar );
689         _3DWorld->InitCameraReset( );
690         _2DWorld->ConstructVTK( imagedata );
691         
692         // GUI
693         _sl_Isovalue->SetRange( (int)min, (int)max);
694         _sl_Isovalue->SetValue( (int)(max/4) );
695         _sl_Opacity->SetValue( 50 );
696         Reset_sl_Slider();
697
698         _pl_cntlHealthySick2->GetPnlSearStenosis()->GetPanelAutomatic()->SetRange(0,nos-1);
699
700         int ww1,hh1;
701         int ww2,hh2;
702         int wwT,hhT;
703         int ss;
704         this->GetSize(&wwT,&hhT);
705         _wxStenosisPanel->GetSize(&ww1,&hh1);
706         _pl_cntlHealthySick2->GetSize(&ww2,&hh2);
707
708         ss=hhT-(hh1+hh2+85);
709         panel_splitter_right->SetSashPosition(ss,true);
710
711 }
712 //----------------------------------------------------------------------------
713 void wxQuantificationWidget::Reset_sl_Slider()
714 {
715         int nos = _mar->_experiment->getNumberOfSlices( );
716         _sl_Slice->SetRange(0, nos-1);
717         _sl_Slice->SetValue( (nos-1)/2 );
718 //      _pl_cntlHealthySick->Reset_sl_Slider(nos);
719 }
720 //----------------------------------------------------------------------------
721 void wxQuantificationWidget::SetSlider_Isovalue_Opacity(int isovalue,int opacity){
722         _sl_Isovalue->SetValue(isovalue);
723         _sl_Opacity->SetValue(opacity);
724         _3DWorld->SetSurfaceIsoValue( isovalue );
725         _3DWorld->SetSurfaceOpacity( opacity );
726 }
727 //----------------------------------------------------------------------------
728 void wxQuantificationWidget::OnShowSurface_CB(wxCommandEvent& event)
729 {
730     _3DWorld->SetSurfaceVisibility( _cb_ShowSurface->GetValue() );
731 }
732 // ---------------------------------------------------------------------------
733 void wxQuantificationWidget::ResetAxis(){       
734         Reset_sl_Slider();
735         _mar->_experiment->getAxis()->setActualQuant( _sl_Slice->GetValue() );
736
737         _3DWorld->Hide3DHealthySliceActor();
738         _mar->_experiment->getAxis( )->setHealthySlice( 0,-1,0 );
739 }
740 // ---------------------------------------------------------------------------
741 void wxQuantificationWidget::RefreshAxis( ){    
742         int acuatQuant = _mar->_experiment->getAxis()->getActualQuant();
743         vtkImageData* imagedata;
744         vtkProbeFilter* image3D;
745         vtkPolyData* vtkPolydata_2Dcontour;
746         vtkPoints* vtkPoints_2DDiameterMin;
747         vtkPoints* vtkPoints_2DDiameterMax;
748
749         image3D                                 = _mar->_experiment->get3DSlice                 ( acuatQuant );
750         imagedata                               = _mar->_experiment->getSliceImage              ( acuatQuant );
751         vtkPolydata_2Dcontour   = _mar->_experiment->get2Dcontour               ( acuatQuant );
752         vtkPoints_2DDiameterMin = _mar->_experiment->get2DDiameterMin   ( acuatQuant );
753         vtkPoints_2DDiameterMax = _mar->_experiment->get2DDiameterMax   ( acuatQuant );
754
755         _3DWorld->SetImage(image3D);
756         _3DWorld->Render( );
757         _2DWorld->SetImage(imagedata);
758
759         if (_cb_VisibleRings->GetValue()==true){
760                 _2DWorld->SetContour( vtkPolydata_2Dcontour );
761                 _2DWorld->SetDiameterMin( vtkPoints_2DDiameterMin , true );
762                 _2DWorld->SetDiameterMax( vtkPoints_2DDiameterMax , true );
763         }
764         showVariables( );
765
766 // PS ->        marContour * tutu=_mar->_experiment->getAxis()->getContour( event.GetPosition() );
767 //      cnt = _mar->_experiment->generateContour(event.GetPosition(), -1, -1, NULL);
768 // PS ->        tutu=_mar->_experiment->getAxis()->getContour( event.GetPosition() );
769 //      _2DWorld->SetContour( cnt );
770
771
772 }
773 // ----------------------------------------------------------------------------
774 void wxQuantificationWidget::MoveSlider(int actualQuant){
775
776         if (_bak_ActualSlice!=-1){
777                 SetManualContour_ReplaceContour();
778                 SetManualContour_2DWorld(false);
779         }
780
781         _mar->_experiment->getAxis()->setActualQuant( actualQuant );
782         RefreshAxis();
783 }
784 // ----------------------------------------------------------------------------
785 void wxQuantificationWidget::OnSliderSliceScroll(wxScrollEvent& event){
786         MoveSlider( event.GetPosition() );
787 }
788 // ----------------------------------------------------------------------------
789 double wxQuantificationWidget::GetStenosisDiameter(int sickSlice){
790         double healthyAverageDiameter = _mar->_experiment->getReferenceAverDiam() ;
791         marContour *marcontourSick = _mar->_experiment->getContour( sickSlice );
792         return doubleStenosis( healthyAverageDiameter , marcontourSick->getMinimumDiameter() );
793 }
794 // ----------------------------------------------------------------------------
795 double wxQuantificationWidget::GetStenosisArea( int sickSlice){
796         double healthyArea = _mar->_experiment->getReferenceArea();
797         marContour *marcontourSick = _mar->_experiment->getContour( sickSlice );
798         return doubleStenosis( healthyArea , marcontourSick->getArea() );
799 }
800 // ----------------------------------------------------------------------------
801
802
803 /* EED Borrame 
804 // ----------------------------------------------------------------------------
805 double wxQuantificationWidget::GetStenosisTEST1(marContour *marcontourH, marContour *marcontour){
806         double healthy= marcontourH->getMinimumDiameter() * marcontourH->getMaximumDiameter();
807         double sick= marcontour->getMinimumDiameter() * marcontour->getMaximumDiameter();
808         return doubleStenosis( healthy , sick );
809 }
810 // ----------------------------------------------------------------------------
811 double wxQuantificationWidget::GetStenosisTEST2(marContour *marcontourH, marContour *marcontour){
812         double steA = GetStenosisArea(marcontourH,marcontour);
813         double steB = GetStenosisDiameter(marcontourH,marcontour);
814         return sqrt(steA + steB);
815 }
816 // ----------------------------------------------------------------------------
817 double wxQuantificationWidget::GetStenosisTEST3(marContour *marcontourH, marContour *marcontour){
818         return doubleStenosis( marcontourH->getAverageDiameter() , marcontour->getAverageDiameter() );
819 }
820 */
821
822
823
824 // ----------------------------------------------------------------------------
825 void wxQuantificationWidget::showVariables()
826 {
827         marContour* marcontour;
828         int actualQuant;
829         int healthySlice; 
830         int healthySliceStart; 
831         int healthySliceEnd; 
832
833 //                      healthySlice = _sl_Slice->GetValue();
834 //                      _mar->_experiment->getAxis( )->setHealthySlice( healthySlice );
835 //                      _3DWorld->Set3DHealthySliceActor( );
836 //                      _3DWorld->Show3DHealthySliceActor( );   
837         actualQuant = _mar->_experiment->getAxis()->getActualQuant( );
838         marcontour=_mar->_experiment->getContour( actualQuant );
839
840         wxString tmpString;
841 //      tmpString.Printf( "%.2f mm" , marcontour->getPartialAxisLenght());              
842 //      _st_Value0->SetLabel(tmpString);
843         tmpString.Printf( _T("%.2f mm")   , _mar->_experiment->getTotalLength() );               _st_Value1->SetLabel(tmpString);
844
845
846         tmpString.Printf( _T("%.2f mm^2") , marcontour->getArea());                                              _st_Value2->SetLabel(tmpString);
847         tmpString.Printf( _T("%.2f mm")   , marcontour->getPerimeter());                                 _st_Value3->SetLabel(tmpString);
848 //      tmpString.Printf( _T("%.2f mm")   , marcontour->getDiameterFromArea());                  _st_Value4->SetLabel(tmpString);
849 //      tmpString.Printf( _T("%.2f mm")   , marcontour->getDiameterFromPerimeter());     _st_Value5->SetLabel(tmpString);
850         tmpString.Printf( _T("%.2f mm")   , marcontour->getMinimumDiameter());                   _st_Value6->SetLabel(tmpString);
851         tmpString.Printf( _T("%.2f mm")   , marcontour->getMaximumDiameter());                   _st_Value7->SetLabel(tmpString);
852         tmpString.Printf( _T("%.2f mm")   , marcontour->getAverageDiameter());                   _st_Value8->SetLabel(tmpString);
853
854         healthySlice            = _mar->_experiment->getAxis( )->getHealthySlice( );
855         healthySliceStart       = _mar->_experiment->getAxis( )->getHealthySliceStart( );
856         healthySliceEnd         = _mar->_experiment->getAxis( )->getHealthySliceEnd( );
857         if ( (healthySlice!=-1) ) {
858                 _st_Value100->SetLabel( strStenosis( GetStenosisArea(actualQuant)     ) );
859                 _st_Value101->SetLabel( strStenosis( GetStenosisDiameter(actualQuant) ) );
860                 tmpString.Printf( _T("%.2f mm^2") , _mar->_experiment->getReferenceArea() );     _st_ValueRef102->SetLabel(tmpString);
861                 tmpString.Printf( _T("%.2f mm")   , _mar->_experiment->getReferenceAverDiam() ); _st_ValueRef103->SetLabel(tmpString);
862         } else {
863                 _st_Value100->SetLabel(_T("--"));
864                 _st_Value101->SetLabel(_T("--"));
865                 _st_ValueRef101->SetLabel(_T("--"));
866                 _st_ValueRef102->SetLabel(_T("--"));
867                 _st_ValueRef103->SetLabel(_T("--"));
868         }
869
870         int startSlice  = _mar->_experiment->getAxis()->getStartQuant();
871         int finishSlice = _mar->_experiment->getAxis()->getFinishQuant();
872     if ((startSlice!=-1) && (finishSlice!=-1)){
873                 tmpString.Printf( _T("%.2f mm")   , _mar->_experiment->getSubAxisLength() );     _st_ValueRef101->SetLabel(tmpString);
874         } else {
875                 _st_ValueRef101->SetLabel(_T("--"));
876         }
877
878         panel_splitter->SetSashPosition(panel_splitter->GetSashPosition() );
879
880 }
881 // ----------------------------------------------------------------------------
882 double wxQuantificationWidget::doubleStenosis(double healthy, double sick){
883         double result;
884         if (healthy==0) {       
885                 result=-1;      
886         } else {  
887 //EED borrame
888 //              result = (fabs(healthy-sick)/healthy) * 100 ;   
889                 result = (    (healthy-sick)/healthy) * 100 ;   
890         }
891
892         return result;
893 }
894 // ----------------------------------------------------------------------------
895 wxString wxQuantificationWidget::strStenosis(double stenosis){
896
897         wxString tmpString;
898         if (stenosis==-1) {
899                 tmpString.Printf(_T("%d"),-1);  
900         } else {
901                 tmpString.Printf(_T("%.2f"), stenosis );        
902         }
903         return tmpString + _T(" \%");
904 }
905 // ----------------------------------------------------------------------------
906 void wxQuantificationWidget::OnSliderIsovalueScroll(wxScrollEvent& event)
907 {
908         wxBusyCursor wait;
909         _3DWorld->SetSurfaceIsoValue( event.GetPosition() );
910 }
911 // ----------------------------------------------------------------------------
912 void wxQuantificationWidget::OnSliderOpacityScroll(wxScrollEvent& event)
913 {
914         _3DWorld->SetSurfaceOpacity( event.GetPosition() );
915 }
916 //----------------------------------------------------------------------------
917 void wxQuantificationWidget::AddAxisActors(){
918         // Axes ...
919         marAxis *maraxis = _mar->_experiment->getAxis( );
920         if (maraxis!=NULL) _3DWorld->SetAxis( maraxis->Draw( ) );
921         // Other Actors..
922         // ..
923 }
924 //----------------------------------------------------------------------------
925 void wxQuantificationWidget::Clean3D( bool eraseAxe )
926 {
927         _first_quant = -1;
928         _last_quant = -1;
929 //EED   _real_first_point_quant = -1;
930 //EED   _real_last_point_quant = -1;
931         //this->controls(1);
932         _quant_shown = false;
933         
934         _3DWorld->InitListContourActor( -1,_mar->_experiment->getNumberOfSlices() );
935         if (eraseAxe==true) { _3DWorld->RemoveAxis(); }
936
937 /* EED borrame
938         _3DWorld->Hide3DSliceActor( );
939         _3DWorld->Hide3DContourActor( );
940         _3DWorld->Hide3DHealthySliceActor();
941 */
942
943         /*
944         if (_pRenderer3D != 0) _pRenderer3D->RemoveActor(hs_actor);
945         if (_hs_actor != 0)   hs_actor->delete();
946         if (_hs_mapper != 0)  hs_mapper->delete();
947         if (_hs_grid != 0)   hs_grid->delete();
948         if (_hs_points != 0)   hs_points->delete();
949         if (_hs_poly_line != 0)   hs_poly_line->delete();
950         */
951         
952 /* EED
953         int i = 1;
954         int max = _rings_index->GetCount();
955         while  (i <= max) {
956         
957         if (_pRenderer3D != 0)
958     _pRenderer3D->RemoveActor(_cont3DActor(hs_actor[i]));
959         if (_cont3DActor[i] != 0)
960     _cont3DActor[i]->Delete();
961         if (_cont3DMapper[i] != 0)
962     _cont3DMapper[i]->Delete();
963         if (_cont3DGrid[i] != 0)
964     _cont3DGrid[i]->Delete();
965         if (_cont3DPolyLine[i] != 0)
966     _cont3DPolyLine[i]->Delete();
967         if (_cont3DPoints[i] != 0)
968     _cont3DPoints[i]->Delete();
969                 
970                 i++;
971         }
972         //_rings_index = _list;
973 */
974         
975
976 }
977
978 void wxQuantificationWidget::Reload_Axis(bool mask , bool step )
979 {
980 /*  if ( step  ) {
981 this->redoAxisSpline();
982 if ( pRenderer3D != 0 ) {
983 _pRenderer3D->RemoveActor(GetSphereActorName(sphere_quant1));
984 _pRenderer3D->RemoveActor(GetSphereActorName(sphere_quant2));
985 }
986 this->DeleteSphere(sphere_quant1);
987 this->DeleteSphere(sphere_quant2);
988 _given_points = 0;
989 }
990 else if ( mask  ) {
991 this->recalculeAxisSignal()
992 }
993
994   if ( ( mask || step ) && _shown ) {
995   tk_messageBox -icon info -message "$string_table::str_quant_will_be_erased" -type ok
996   catch { renderer_$widgets(work3D) RemoveActor hs_actor_$widgets(work3D) }
997   catch { hs_actor_$widgets(work3D) Delete }
998   catch { hs_mapper_$widgets(work3D) Delete }
999   catch { hs_grid_$widgets(work3D) Delete }
1000   catch { hs_points_$widgets(work3D) Delete }
1001   catch { hs_poly_line_$widgets(work3D) Delete }
1002   foreach i $rings_index {
1003   catch { renderer_$widgets(work3D) RemoveActor cont3DActor_{$widgets(work3D)}_{$i} }
1004   catch { cont3DActor_{$widgets(work3D)}_{$i}    Delete }
1005   catch { cont3DMapper_{$widgets(work3D)}_{$i}   Delete }
1006   catch { cont3DGrid_{$widgets(work3D)}_{$i}     Delete }
1007   catch { cont3DPolyLine_{$widgets(work3D)}_{$i} Delete }
1008   catch { cont3DPoints_{$widgets(work3D)}_{$i}   Delete }
1009   
1010    }
1011    rings_index = list;
1012    _area = 0.00;
1013    _peri = 0.00;
1014    _darea = 0.00;
1015    _dperi = 0.00;
1016    _dmax = 0.00;
1017    _dmin = 0.00;
1018    _davg = 0.00;
1019    _sten = 0.00;
1020    _quant_shown = false;
1021    this->clean_graph();  // old BLT
1022    
1023         _first_quant = 1;
1024         _range(getIntensityRange());
1025         _resample(getVTKSource());
1026         _bounds(resample(GetBounds());
1027         
1028          // Axis
1029          set points [ getAxis_dll ]
1030          set nP [ expr [ llength $points ] / 3 ]
1031          $widgets(sclSlice) configure \
1032          -from 0 \
1033          -to   [ expr [ getNumberOfAxisPoints_dll ] - 1 ] \
1034          -resolution 1
1035          
1036           // Poly-line actor construction...
1037           catch { renderer_$widgets(work3D) RemoveActor axisActor_$widgets(work3D) }
1038           catch { axisActor_$widgets(work3D)    Delete }
1039           catch { axisMapper_$widgets(work3D)   Delete }
1040           catch { axisGrid_$widgets(work3D)     Delete }
1041           catch { axisPolyLine_$widgets(work3D) Delete }
1042           catch { axisPoints_$widgets(work3D)   Delete }
1043           
1044            axisPoints = vtkPoints::New();
1045            axisPolyLine = vtkPolyLine::New();
1046            axisPolyLine->GetPointIds()->SetNumberOfIds( nP);
1047            vox_size = getActualVoxelSize();
1048            
1049                 for { set i 0 } { $i < $nP } { incr i } {
1050                 
1051                  [ axisPolyLine_$widgets(work3D) GetPointIds ] SetId $i $i
1052                  set p [ \
1053                  PointCoord \
1054                  [ lindex $points [ expr $i * 3 + 0 ] ] \
1055                  [ lindex $points [ expr $i * 3 + 1 ] ] \
1056                  [ lindex $points [ expr $i * 3 + 2 ] ] \
1057                  [ lindex $bounds 0 ] \
1058                  [ lindex $bounds 2 ] \
1059                  [ lindex $bounds 4 ] \
1060                  $vox_size $vox_size $vox_size \
1061                  ]
1062                  axisPoints->InsertNextPoint( lindex $p 0 ] [ lindex $p 1 ] [ lindex $p 2 ]
1063                  
1064                   }
1065                   
1066                    axisGrid = vtkUnstructuredGrid::New();
1067                    axisGrid->Allocate( 1, 1);
1068                    axisGrid->InsertNextCell(  [ axisPolyLine->GetCellType(),  ] \
1069                    [ axisPolyLine_$widgets(work3D) GetPointIds ]
1070                    axisGrid->SetPoints(axisPoints);
1071                    
1072                         axisMapper = vtkDataSetMapper::New();
1073                         axisMapper->SetInput(axisGrid);
1074                         axisMapper->ImmediateModeRenderingOn();
1075                         
1076                          axisActor = vtkActor::New();
1077                          axisActor->SetMapper(axisMapper);
1078                          axisActor->GetProperty()->BackfaceCullingOn();
1079                          axisActor->GetProperty()->SetDiffuseColor(1, 0, 0);
1080                          
1081                           _pRenderer3D->AddActor(axisActor);
1082                           
1083                            _pRenderWindow3D->Render();
1084                            _pRenderWindow2D->Render();
1085                            
1086                                 _pRenderer3D->AddActor(outlineActor));
1087                                 
1088                                  this->controls(0);
1089                                  
1090                                   }
1091                                   if ( _given_points == 1 )
1092                                   this->controls(1);
1093                                   
1094                                    if ( _quant_shown )
1095                                    this->update_blt_all_meassures();
1096 */
1097 }
1098
1099
1100 void wxQuantificationWidget::Show_Max_Min_Diameters()
1101 {
1102         
1103 /*
1104 slice = widgets(sclSlice);
1105 wxList *lmax = this->getMaximumLine();
1106 wxList *lmin = this->getMinimumLine();
1107
1108  if ( _pRenderer2D != 0 )
1109         {
1110         _pRenderer2D->RemoveActor(dMin_actor);
1111         _pRenderer2D->RemoveActor(dMax_actor);
1112         }
1113         if ( dMax_actor != 0 )  dMax_actor->Delete();
1114     if ( dMax_mapper != 0 )  dMax_mapper->Delete();
1115     if ( dMax_line != 0 )  dMax_line->Delete();
1116     if ( dMin_actor != 0 )  dMin_actor->Delete();
1117     if ( dMin_mappe != 0 )  dMin_mappe->Delete();
1118     if ( dMax_actor != 0 )  dMax_actor->Delete();
1119     if ( dMin_line != 0 )  dMin_line->Delete();
1120         
1121          
1122           dMax_line = vtkLineSource::New();
1123           dMax_line->SetPoint1( lmax->Getfirst() , lmax->item(1), 0.0 );
1124           dMax_line->SetPoint2( lmax->Item(2), lmax->Item(3), 0.0 );
1125           
1126            dMax_mapper =  vtkPolyDataMapper::New();
1127            dMax_mapper->SetInput(dMax_line->GetOutput());
1128            dMax_mapper->ImmediateModeRenderingOn();
1129            
1130                 dMax_actor = vtkActor::New();
1131                 dMax_actor->SetMapper(dMax_mapper));
1132                 dMax_actor->GetProperty()->SetColor(1.00, 0.00, 0.00);
1133                 
1134                  dMin_line = vtkLineSource::New();
1135                  dMin_line->SetPoint1( lmin->GetFirst(), lmin->Item(1), 0.0);
1136                  dMin_line->SetPoint2( lmin->Item(2),    lmin->Item(3), 0.0);
1137                  
1138                   dMin_mapper = vtkPolyDataMapper::New();
1139                   dMin_mapper->SetInput(dMin_line->GetOutput());
1140                   dMin_mapper->ImmediateModeRenderingOn();
1141                   
1142                    dMin_actor = vtkActor::New();
1143                    dMin_actor->SetMapper(dMin_mapper);
1144                    dMin_actor->GetProperty()->SetColor(0.00, 0.00, 1.00);
1145                    
1146                         array set arr( params(), 0 )
1147                         if ( arr(e_debug_diameters) == 1 )
1148                         {
1149                         _prenderer2D->AddActor(dMax_actor);
1150                         _prenderer2D->AddActor(dMin_actor);
1151                         
1152                          }
1153                          
1154                           //GetRenderWindow Render
1155         */
1156 }
1157
1158
1159
1160 int wxQuantificationWidget::Back( )
1161 {
1162         int ret;
1163         
1164         ret = _shown;
1165         _shown = 0;
1166         return ret;
1167 }
1168
1169
1170 void wxQuantificationWidget::Set_plane_3D( double  x, double y )
1171 {
1172 /*
1173 _pRenderer3D->IsInViewport(0, 0);
1174
1175  busy hold
1176  Update();
1177  
1178   if ( _tmp_world_picker3D != 0)  tmp_world_picker3D->Delete();
1179   
1180    y =[ [ lindex [ $widgets(work3D) configure - height ] 4 ] - y - 1 ]
1181    
1182     _pickWPPos = Pick_point_local_actor $x $y _pRenderer3D _isoActor3D 0.001 ]
1183         
1184          _xc = _pickWPPos->item(1);
1185          _yc = _pickWPPos->item(2);
1186          _zc = _pickWPPos->item(3);
1187          #Chercher le point de l'axe le plus proche au point choisi sur la surface
1188          _indP = axisGrid3D->FindPoint(_xc, _yc, _zc);
1189          _coordsP = axisGrid3D->GetPoint(_indP);
1190          _xc =[lindex _coordsP 0]
1191          _yc =[lindex _coordsP 1]
1192          _zc =[lindex _coordsP 2]
1193          
1194           if ( _indP >= 0 )
1195           {
1196           $widgets(sclSlice) set $indP
1197           this->Set_Plane();
1198           }
1199           
1200            busy release .
1201            update
1202            
1203                 _pRenderWindow3D->Render();
1204         */
1205 }
1206
1207
1208 /* EED
1209 void wxQuantificationWidget::Refresh_Quant( )
1210 {
1211         if ( _real_first_point_quant != -1  &&  _real_last_point_quant  != -1  &&
1212                 _quant_sten->GetCount()  > 0) {
1213                 //_quant_sten = GetStenosisQuant();
1214                 //_sten  =  _quant_sten->Item(_widgets(sclSlice)->get() -
1215                 //                                       _real_first_point_quant  )
1216         }
1217         //this->update_blt_all_meassures();
1218 }
1219 */
1220
1221
1222 void  wxQuantificationWidget::Point_Intensity(double x, double y)
1223 {
1224         //y = [ lindex [ _pRenderWindow3D->Configure(height) ] ->Item(4) ] - y - 1;
1225         
1226         //if ( _tmp_picker != 0 )  _tmp_picker->Delete();
1227         //_tmp_picker = vtkWorldPointPicker::New();
1228         //_pickWP     = tmp_picker2D->Pick(x, y, 0) _pRenderer2D
1229         //_pickWPPos  = tmp_picker2D->GetPickPosition();
1230         
1231         //x = [ lindex [ split [ lindex $pickWPPos 0 ] . ] 0 ]
1232         //y = [ lindex [ split [ lindex $pickWPPos 1 ] . ] 0 ]
1233         //y = GetCutSize()  - y - 1;
1234         //_intensity = GetIntensityCut(x, y);
1235 }
1236
1237
1238 void wxQuantificationWidget::CleanContour()
1239 {
1240 /*  if ( _pRenderer2D != 0 ) {
1241 _pRenderer2D->RemoveActor(_debug2Actor3D);
1242 _pRenderer2D->RemoveActor(_debug1Actor3D);
1243 }
1244 if ( _debug2Actor3D != 0 )
1245 _debug2Actor3D->Delete();
1246 //if ( _connMapper3D != 0 )                     _connMapper3D->Delete();
1247 //if ( _isoStrips3D != 0 )                      _isoStrips3D->Delete();
1248 //if ( _cpd23D != 0 )                                   _cpd23D->Delete();
1249 //if ( _conn3D != 0 )                                   _conn3D->Delete();
1250 //if ( _cpd3D != 0 )                                    _cpd3D->Delete();
1251 if ( _debug1Actor3D != 0 )
1252 _debug1Actor3D->Delete();
1253 //if ( _cntVTKMapper3D != 0 )                   _cntVTKMapper3D->Delete();
1254 //if ( _cntVTK3D != 0 )                         _cntVTK3D->Delete();
1255
1256   if ( _pRenderer2D != 0 ) {
1257   _pRenderer2D->RemoveActor(_aPolyLineActor2D);
1258   _pRenderer2D->RemoveActor(_aPolygonActor2D);
1259   }
1260   
1261         if ( _aPolyLineActor2D != 0 )
1262     _aPolyLineActor2D->Delete();
1263         //if ( _aPolyLineMapper2D != 0 )                _aPolyLineMapper2D->Delete();
1264         //if ( _aPolyLineGrid2D != 0 )          _aPolyLineGrid2D->Delete();
1265         //if ( _aPolyLine2D != 0 )                      _aPolyLine2D->Delete();
1266         //if ( _PointsContour2D != 0 )          _PointsContour2D->Delete();
1267         if ( _aPolygonActor2D != 0 )
1268     _aPolygonActor2D->Delete();
1269         //if ( _aPolygonMapper2D != 0 )         _aPolygonMapper2D->Delete();
1270         //if ( _aPolygonGrid2D != 0 )                   _aPolygonGrid2D->Delete();
1271         //if ( _aPolygon2D != 0 )                               _aPolygon2D->Delete();
1272         
1273           if ( _pRenderer2D != 0 ) {
1274           _pRenderer2D->RemoveActor(_dMaxActor2D);
1275           _pRenderer2D->RemoveActor(_dMinActor2D);
1276           }
1277           
1278                 if ( _dMaxActor2D != 0 )
1279                 _dMaxActor2D->Delete();
1280                 //if ( _dMaxMapper2D != 0 )                             _dMaxMapper2D->Delete();
1281                 //if ( _dMaxLine2D != 0 )                                       _dMaxLine2D->Delete();
1282                 if ( _dMinActor2D != 0 )
1283                 _dMinActor2D->Delete();
1284                 //if ( _dMinMapper2D != 0 )                             _dMinMapper2D->Delete();
1285                 //if ( _dMinLine2D != 0 )                                       _dMinLine2D->Delete();
1286                 
1287                   _pRenderWindow3D->Render();
1288         _pRenderWindow2D->Render();*/
1289 }
1290
1291
1292 //-----------------------------------------------------------------
1293 // Button
1294 void wxQuantificationWidget::Do_Quant()
1295 {
1296 /*
1297 if ( _quantifing == 0 )
1298 {
1299 this->Clean_Graph();
1300 this->Clean3D();
1301
1302  _quantifing = 1;
1303  
1304   int f = ( _first_point_quant < _last_point_quant ) ? _first_point_quant : _last_point_quant;
1305   int l = ( _first_point_quant > _last_point_quant ) ? _first_point_quant : _last_point_quant;
1306   
1307    this->Controls(2);
1308    
1309         _quant_x     = _list;
1310         _quant_area  = _list;
1311         _quant_peri  = _list;
1312         _quant_darea = _list;
1313         _quant_dperi = _list;
1314         _quant_dmax  = _list;
1315         _quant_dmin  = _list;
1316         _quant_davg  = _list;
1317         
1318          for ( int i = f; i <= l; i++ )
1319          lappend _quant_x->Append(i);
1320          
1321           update_blt_all_meassures();
1322           
1323            startQuant(f);
1324            int  cont = f;
1325            changeSliceAxis(f);
1326            
1327         wxMessageDialog* Q_recalculate = new wxDialog(this,
1328                 _str_recalculate_contours,
1329                 "Question",
1330                 wxYES_NO|wxNO_DEFAULT|wxCENTRE,
1331                 wxPoint(100, 100));
1332                 
1333                  int recal = 0;
1334                  if (Q_recalculate->ShowModal() ==  wxID_OK)
1335                  recal = 1;
1336                  
1337                   delete Q_recalculate;
1338                   
1339                    this->Clean_Contour();
1340                    $widgets(sclSlice) set cont ;
1341                    planes_window::set_plane
1342                    _quant_shown = 1;
1343                    _params = GetContourParams();
1344                    this->Generate_IsoContour( (GetCutSize()  / 2) (GetCutSize() / 2)
1345                    (_params->Item(5) )
1346                                                                    (_params->Item(6) )
1347                                                                    while ( NextQuant(recal,IsoStrips3D) == 1 && cont <= l )
1348                                                                    {
1349                                                                    if ( _quantifing == 1 )
1350                                                                    {
1351                                                                    if ( _pRenderer2D != 0 )
1352                                                                    {
1353                                                                    _pRenderer2D->RemoveActor(_aPolygonActor2D);
1354                                                                    _pRenderer2D->RemoveActor(_aPolyLineActor2D);
1355                                                                    }
1356                                                                    if ( _aPolygonActor2D != 0 )   _aPolygonActor2D->Delete();
1357                                                                    if ( _aPolygonGrid2D != 0 )    _aPolygonGrid2D->Delete();
1358                                                                    if ( _aPolyLineActor2D != 0 )  _aPolyLineActor2D->Delete();
1359                                                                    if ( _aPolyLineMapper2D != 0 ) _aPolyLineMapper2D->Delete();
1360                                                                    if ( _aPolyLineGrid2D != 0 )   _aPolyLineGrid2D->Delete();
1361                                                                    if ( _aPolyLine2D != 0 )       _aPolyLine2D->Delete();
1362                                                                    if ( _PointsContour2D != 0 )   _PointsContour2D->Delete();
1363                                                                    if ( _aPolygon2D != 0 )        _aPolygon2D->Delete();
1364                                                                    
1365                                                                         _points = GetContourPoints();
1366                                                                         _taille = _points->GetLength() / 2;
1367                                                                         
1368                                                                          aPolygon2D = vtkPolygon::New();
1369                                                                          PointsContour2D = vtkPoints::New();
1370                                                                          
1371                                                                           aPolyLine2D = vtkPolyLine::New();
1372                                                                           _PointIds = aPolyLine2D->GetPointIds();
1373                                                                           _PointIds->SetNumberOfIds(_taille);
1374                                                                           _PointIdsPolygon = aPolygon2D->GetPointIds();
1375                                                                           _PointIdsPolygon->SetNumberOfIds( _taille);
1376                                                                           
1377                                                                            for ( int i =0; i < _taille ; i++ )
1378                                                                            {
1379                                                                            _PointIds->SetId(i, i);
1380                                                                            _PointIdsPolygon->SetId(i, i);
1381                                                                            PointsContour2D->InsertNextPoint( _points->Item( i * 2 ) + 0 ,
1382                                                                            _points->Item(i * 2) + 1, 0);
1383                                                                            }
1384                                                                            
1385                                                                                 aPolyLineGrid2D = vtkUnstructuredGrid::New();
1386                                                                                 aPolyLineGrid2D->Allocate(1, 1);
1387                                                                                 _param1 = aPolyLine2D->GetCellType();
1388                                                                                 _param2 = aPolyLine2D->GetPointIds();
1389                                                                                 aPolyLineGrid2D->InsertNextCell(_param1, _param2);
1390                                                                                 aPolyLineGrid2D->SetPoints(PointsContour2D)
1391                                                                                 
1392                                                                                  aPolyLineMapper2D = vtkDataSetMapper::New();
1393                                                                                  aPolyLineMapper2D->SetInput(aPolyLineGrid2D);
1394                                                                                  
1395                                                                                   aPolyLineActor2D = vtkActor::New();
1396                                                                                   aPolyLineActor2D->SetMapper(aPolyLineMapper2D);
1397                                                                                   _Property1 = aPolyLineActor2D->GetProperty();
1398                                                                                   _Property1->SetColor(0, 1, 0);
1399                                                                                   _Property1->SetLineWidth(2);
1400                                                                                   _Property1->SetPointSize(2);
1401                                                                                   _Property1->BackfaceCullingOff();
1402                                                                                   
1403                                                                                    _pRenderer2D->AddActor(aPolyLineActor2D);
1404                                                                                    
1405                                                                                         aPolygonGrid2D = vtkUnstructuredGrid::New();
1406                                                                                         aPolygonGri2D->Allocate(1, 1);
1407                                                                                         _param1 = aPolygon2D->GetCellType();
1408                                                                                         _param2 = aPolygon2D->GetPointIds();
1409                                                                                         aPolygonGrid2D->InsertNextCell(_param1, _param2);
1410                                                                                         aPolygonGrid2D->SetPoints(PointsContour2D);
1411                                                                                         
1412                                                                                          aPolygonMapper2D = vtkDataSetMapper::New();
1413                                                                                          aPolygonMapper2->SetInput(aPolygonGrid2D);
1414                                                                                          
1415                                                                                           aPolygonActor2D = vtkActor::New();
1416                                                                                           aPolygonActor2D->SetMapper(aPolygonMapper2D);
1417                                                                                           _Property1 = aPolygonActor2D->GetProperty();
1418                                                                                           _Property1->SetColor(0, 1, 0);
1419                                                                                           _Property1->SetLineWidth(2);
1420                                                                                           _Property1->SetPointSize(2);
1421                                                                                           _Property1->BackfaceCullingOff();
1422                                                                                           
1423                                                                                            int arr[] = Params(0);
1424                                                                                            if ( arr(e_debug_fill_area) == 1 )
1425                                                                                            _pRenderer2D->AddActor(aPolygonActor2D)
1426                                                                                            
1427                                                                                                 this->Show_Max_Min_Diameters();
1428                                                                                                 
1429                                                                                                  _pRenderWindow2D->Render();
1430                                                                                                  
1431                                                                                                   this->Draw3D_Contour(cont);
1432                                                                                                   
1433                                                                                                    _values = GetValues(cont);
1434                                                                                                    
1435                                                                                                         _quant_area->Append(_values->Item(1));
1436                                                                                                         _quant_peri->Append(_values->Item(2));
1437                                                                                                         _quant_darea->Append(_values->Item(3));
1438                                                                                                         _quant_dperi->Append(_values->Item(4));
1439                                                                                                         _quant_dmax->Append(_values->Item(5));
1440                                                                                                         _quant_dmin->Append(_values->Item(6));
1441                                                                                                         _quant_davg->Append(_values->Item(7));
1442                                                                                                         
1443                                                                                                          this->update_blt_all_meassures();
1444                                                                                                          
1445                                                                                                           _area  = _values->Item(1);
1446                                                                                                           _peri  = _values->Item(2);
1447                                                                                                           _darea = _values->Item(3);
1448                                                                                                           _dperi = _values->Item(4);
1449                                                                                                           _dmax  = _values->Item(5);
1450                                                                                                           _dmin  = _values->Item(6);
1451                                                                                                           _davg  = _values->Item(7);
1452                                                                                                           
1453                                                                                                            cont++;
1454                                                                                                            
1455                                                                                                                 this->Clean_contour();
1456                                                                                                                 
1457                                                                                                                  $widgets(sclSlice) set $cont;
1458                                                                                                                  this->Set_Plane;
1459                                                                                                                  _params = GetContourParams();
1460                                                                                                                  this->Generate_IsoContour [  [ GetCutSize() / 2 ]
1461                                                                                                                  [ GetCutSize() / 2 ]
1462                                                                                                                  [ _params->Item(5) ]
1463                                                                                                                  [ _params->Item(6) ];
1464                                                                                                                  update();
1465                                                                                                                  
1466                                                                                                                   }
1467                                                                                                                   else if ( _quantifing == 2 )
1468                                                                                                                   {
1469                                                                                                                   while ( _quantifing == 2 )
1470                                                                                                                   update();
1471                                                                                                                   }
1472                                                                                                                   else if ( _quantifing == 3 )
1473                                                                                                                   {
1474                                                                                                                   $widgets(btnPause) configure -text $string_table::str_pause
1475                                                                                                                   break;
1476                                                                                                                   }
1477                                                                                                                   
1478                                                                                                                    }
1479                                                                                                                    FinishQuant();
1480                                                                                                                    this->Clean_contour();
1481                                                                                                                    _quantifing = 0;
1482                                                                                                                    
1483                                                                                                                         }
1484                                                                                                                         else
1485                                                                                                                         {
1486                                                                                                                         _quantifing = 2;
1487                                                                                                                         wxMessageDialog* Q_stop = new wxDialog(this,
1488                                                                                                                         _str_stop_quantification,
1489                                                                                                                         "Question",
1490                                                                                                                         wxYES_NO|wxNO_DEFAULT|wxCENTRE,
1491                                                                                                                         wxPoint(100, 100));
1492                                                                                                                         
1493                                                                                                                          _quantifing = 1;
1494                                                                                                                          if (Q_stop->ShowModal() ==  wxID_OK)
1495                                                                                                                          _quantifing = 3;
1496                                                                                                                          delete Q_stop;
1497                                                                                                                          }
1498 */
1499 }
1500
1501
1502 //-----------------------------------------------------------------
1503 void wxQuantificationWidget::OnContour_BT(wxCommandEvent& event){
1504         int slice=_sl_Slice->GetValue();
1505         _3DWorld->Set3DContourActor( slice , _mar->_experiment->get3Dcontour(slice) , _cb_VisibleRings->GetValue() ,0 );
1506 }
1507 //-----------------------------------------------------------------
1508 void wxQuantificationWidget::OnClean_BT(wxCommandEvent& event){
1509         int slice=_sl_Slice->GetValue();
1510         _3DWorld->Erase3DContourActor( slice );
1511 }
1512
1513 //-----------------------------------------------------------------
1514 void wxQuantificationWidget::OnCleanAll_BT(wxCommandEvent& event){
1515         marDictionary marDict;
1516         char tmp[256];
1517
1518         wxMessageDialog *wxdiag;
1519         strcpy( tmp , marDict.GetString(870) ); strcat(tmp,"\n"); strcat(tmp,marDict.GetString(875));
1520         wxdiag= new wxMessageDialog(this, wxString(tmp ,wxConvUTF8), wxString(marDict.GetString(865), wxConvUTF8) , wxOK | wxCANCEL);//"This option erase all 3D contours.\n Do you want to continue?","Alert"
1521     if ( wxdiag->ShowModal() == wxID_OK ) {
1522                 _3DWorld->InitListContourActor( 0, _mar->_experiment->getNumberOfSlices() );
1523         }            
1524         wxdiag->Destroy();
1525 }
1526
1527 //-----------------------------------------------------------------
1528 void wxQuantificationWidget::OnSaveContours3D_BT(wxCommandEvent& event)
1529 {
1530         
1531         wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas_contour3D"), wxSAVE );
1532         if (dialog.ShowModal() == wxID_OK)
1533         {               
1534                 std::string pathfilename(  (const char *)(dialog.GetPath().mb_str()) );
1535 //              std::string directory(  (const char *)(dialog.GetDirectory().mb_str()) );
1536 //              std::string filename(  (const char *)(dialog.GetFilename().mb_str())  );
1537 //              std::string pathfilename        = directory + "/" + filename;
1538 //              printf("EED> wxQuantificationWidget::OnSaveContours3D_BT  > %s\n",pathfilename.c_str());
1539                 FILE *ff;
1540                 ff=fopen(pathfilename.c_str(), "w+");
1541                   _mar->_experiment->getAxis()->SaveExisting3DContours(ff);
1542                 fclose(ff);
1543         }
1544         
1545 }
1546
1547 // PS -> void wxQuantificationWidget::OnContour_BT(wxCommandEvent& event)
1548 // PS -> {
1549 // PS -> 
1550 // PS -> 
1551 // PS ->   int index;
1552 // PS -> 
1553 // PS ->   vtkPolyData* cnt;
1554 // PS ->   //marContour* cnt;
1555 // PS -> //  vtkUnstructuredGrid* allData;
1556 // PS -> 
1557 // PS ->   index = _sl_Slice->GetValue( );
1558 // PS -> //  this->CleanContour( );
1559 // PS ->   cnt = _mar->_experiment->generateContour(index, -1, -1, NULL);
1560 // PS -> //     allData = cnt->Draw( );
1561 // PS -> //  _2DWorld->SetContour( allData );
1562 // PS ->   _2DWorld->SetContour( cnt );
1563 // PS -> 
1564 // PS ->   _first_quant = 0;
1565 // PS -> 
1566 // PS ->   /*planes_window::show_max_min_diameters
1567 // PS -> 
1568 // PS ->        [ $widgets(image2D) GetRenderWindow ] Render
1569 // PS -> 
1570 // PS ->        planes_window::draw3D_contour $index
1571 // PS -> 
1572 // PS ->        set quant_data [ getValues_dll $index ]
1573 // PS ->        set actual_area  [ change_float_precision [ lindex $quant_data 0 ] 2 ]
1574 // PS ->        set actual_peri  [ change_float_precision [ lindex $quant_data 1 ] 2 ]
1575 // PS ->        set actual_darea [ change_float_precision [ lindex $quant_data 2 ] 2 ]
1576 // PS ->        set actual_dperi [ change_float_precision [ lindex $quant_data 3 ] 2 ]
1577 // PS ->        set actual_dmax  [ change_float_precision [ lindex $quant_data 4 ] 2 ]
1578 // PS ->        set actual_dmin  [ change_float_precision [ lindex $quant_data 5 ] 2 ]
1579 // PS ->        set actual_davg  [ change_float_precision [ lindex $quant_data 6 ] 2 ]
1580 // PS ->        set i [ lsearch -exact $actual_quant_x $index ]
1581 // PS ->        if { $i != -1 } {
1582 // PS -> 
1583 // PS ->                set actual_quant_area  [ lreplace $actual_quant_area  $i $i $actual_area ]
1584 // PS ->                set actual_quant_peri  [ lreplace $actual_quant_peri  $i $i $actual_peri ]
1585 // PS ->                set actual_quant_darea [ lreplace $actual_quant_darea $i $i $actual_darea ]
1586 // PS ->                set actual_quant_dperi [ lreplace $actual_quant_dperi $i $i $actual_dperi ]
1587 // PS ->                set actual_quant_dmax  [ lreplace $actual_quant_dmax  $i $i $actual_dmax ]
1588 // PS ->                set actual_quant_dmin  [ lreplace $actual_quant_dmin  $i $i $actual_dmin ]
1589 // PS ->                set actual_quant_davg  [ lreplace $actual_quant_davg  $i $i $actual_davg ]
1590 // PS ->                if { [ llength $actual_quant_sten ] > 0 } {
1591 // PS -> 
1592 // PS ->                        set actual_quant_sten [ getStenosisQuant_dll ]
1593 // PS ->                        set actual_sten [ change_float_precision [ lindex $actual_quant_sten [ expr $index - $real_first_point_quant ] ] 2 ]
1594 // PS -> 
1595 // PS ->                }
1596 // PS -> 
1597 // PS ->        }
1598 // PS ->        planes_window::update_blt_all_meassures*/
1599 // PS -> }
1600
1601
1602 // PS -> void wxQuantificationWidget::OnClean_BT(wxCommandEvent& event)
1603 // PS -> {
1604 // PS -> /*  this->CleanContour();*/
1605 // PS -> }
1606
1607
1608
1609 //------------------------------------------------------------------------
1610 void wxQuantificationWidget::DetectHealthySickSlice( bool minSurf , bool maxSurf ){     
1611         wxBusyCursor wait;
1612         double          stenosis;
1613         double          areaB;
1614         int                     iSlice;
1615         int                     startslice;
1616         int                     endslice;
1617         double          maxStenosis                     =       -9999999;
1618         double          maxArea                         =       -9999999;
1619         int                     sickSlice                       =       0;
1620         int                     healthySlice            =       0;
1621         int                     sizeHealthyRegion       =       GetSizeHealthyRegion();
1622         int                     analysisTypeStenosis=   GetAnalysisTypeStenosis();
1623
1624
1625 //FILE *ff;
1626 //ff = fopen("c:/temp/MaracasStadistics.txt","a+");
1627 //long int endtime = clock();
1628 //double sg = (double)(endtime-startTimeRI) / (double)CLK_TCK;
1629 //fprintf(ff,"EED %p wxQuantificationWidget::DetectHealthySickSlice > RI_t = %f \n",this,sg);
1630 //fclose(ff);
1631
1632
1633 //startTimeCalcule = clock();
1634
1635         GetSliceLimites(0,startslice,endslice);
1636
1637     if (startslice>endslice){
1638                 int temp=endslice;
1639                 endslice=startslice;
1640                 startslice=temp;
1641         }
1642
1643         int backSlice;
1644         if (minSurf==false) { backSlice = _sl_Slice->GetValue(); }
1645
1646         for (iSlice=startslice; iSlice<=endslice;iSlice++){
1647
1648                 if (minSurf==true){
1649                         // this is equal to the minimum surface/diameter
1650                         if (analysisTypeStenosis==1 ){ stenosis = GetStenosisDiameter(iSlice);  }
1651                         if (analysisTypeStenosis==2 ){ stenosis = GetStenosisArea(iSlice);              }
1652                 }
1653
1654                 if (maxSurf==true){
1655                         areaB = _mar->_experiment->getAverageArea(iSlice-sizeHealthyRegion,iSlice+sizeHealthyRegion);
1656                 }
1657
1658                 if ((stenosis>maxStenosis) &&(minSurf==true)){
1659                         maxStenosis=stenosis;
1660                         sickSlice=iSlice;
1661                 }
1662                 if ((areaB>maxArea) && (maxSurf==true)){
1663                         maxArea=areaB;
1664                         healthySlice=iSlice;
1665                 }
1666                 MoveSlider( iSlice );
1667                 _sl_Slice->SetValue( iSlice );
1668         }
1669
1670 //ff = fopen("c:/temp/MaracasStadistics.txt","a+");
1671 //endtime = clock();
1672 //sg = (double)(endtime-startTimeCalcule) / (double)CLK_TCK;
1673 //fprintf(ff,"EED %p wxQuantificationWidget::DetectHealthySickSlice > t = %f   ( %d , %d , %d )\n",this,sg,startslice,endslice, endslice-startslice);
1674 //fclose(ff);
1675
1676         if (minSurf==true){
1677                 MoveSlider( sickSlice );
1678                 _sl_Slice->SetValue( sickSlice );
1679         }
1680
1681         if (maxSurf==true){
1682                 MoveSlider( healthySlice );
1683                 _sl_Slice->SetValue( healthySlice );
1684         }
1685
1686 }
1687
1688
1689 /*EED Borrame 
1690 //------------------------------------------------------------------------
1691 void wxQuantificationWidget::AutoQuantification(){      
1692         int             analysisTypeStenosis    =       GetAnalysisTypeStenosis();
1693         int             slice                                   =       _sl_Slice->GetValue();
1694         int             healthySlice                    =       _mar->_experiment->getAxis()->getHealthySlice( );
1695         int             healthySliceStart               =       _mar->_experiment->getAxis()->getHealthySliceStart( );
1696         int             healthySliceEnd                 =       _mar->_experiment->getAxis()->getHealthySliceEnd( );
1697         double  maxStenosis                             =       -9999999;
1698         double  ste                                             =       0;
1699
1700         if (healthySlice !=-1 ) {
1701                 int iSickSlice,startslice,endslice;
1702                 GetSliceLimites(0,startslice,endslice);
1703             if (startslice>endslice){
1704                         int temp=endslice;
1705                         endslice=startslice;
1706                         startslice=temp;
1707                 }
1708                 for (iSickSlice=startslice; iSickSlice<=endslice;iSickSlice++){
1709                         if (analysisTypeStenosis==1 ){ ste = GetStenosisDiameter(iSickSlice);   }
1710                         if (analysisTypeStenosis==2 ){ ste = GetStenosisArea(iSickSlice);               }
1711                         if (ste>maxStenosis){
1712                                 maxStenosis=ste;
1713                                 slice=iSickSlice;
1714                         }
1715                         MoveSlider( iSickSlice );
1716                         _sl_Slice->SetValue( iSickSlice );
1717                 }
1718                 MoveSlider( slice );
1719                 _sl_Slice->SetValue( slice );
1720         } else {
1721                 wxMessageBox( "Set an healthy slice.\n \n ","DxMM : MARACAS", wxOK | wxCENTRE | wxICON_INFORMATION, this);
1722         }
1723 }
1724 */
1725
1726 //------------------------------------------------------------------------
1727 int wxQuantificationWidget::GetHealthySlice(){  
1728         return _mar->_experiment->getAxis()->getHealthySlice( );
1729 }
1730 //------------------------------------------------------------------------
1731 void wxQuantificationWidget::SetHealthySlice(int healthySlice){ 
1732         if (healthySlice==-1) {
1733                 healthySlice=_sl_Slice->GetValue();
1734         }
1735         int sizeHealthyRegion   = GetSizeHealthyRegion();
1736         int maxSlider                   = GetMaxActualSlice();
1737         int healthySliceStart   = healthySlice - sizeHealthyRegion;
1738         int healthySliceEnd             = healthySlice + sizeHealthyRegion;
1739         if (healthySliceStart < 0)         { healthySliceStart = 0;                     }
1740         if (healthySliceEnd   < 0)         { healthySliceEnd   = 0;                     }
1741         if (healthySliceStart > maxSlider) { healthySliceStart = maxSlider; }
1742         if (healthySliceEnd   > maxSlider) { healthySliceEnd   = maxSlider; }
1743         _mar->_experiment->getAxis()->setHealthySlice( healthySliceStart, healthySlice , healthySliceEnd);
1744
1745         _3DWorld->Set3DHealthySliceActor(  );
1746         _3DWorld->Show3DHealthySliceActor();
1747         _cb_HealthySlice->SetValue(true);       
1748         _3DWorld->InitListContourActor( 1, _mar->_experiment->getNumberOfSlices() );
1749         int iHealthySlice;
1750         for ( iHealthySlice=healthySliceStart ; iHealthySlice<=healthySliceEnd ; iHealthySlice++){
1751                 _3DWorld->Set3DContourActor( iHealthySlice , _mar->_experiment->get3Dcontour(iHealthySlice) , true ,1);
1752         }
1753         showVariables();
1754 }
1755
1756 /* EED borrame
1757 //------------------------------------------------------------------------
1758 void wxQuantificationWidget::OnHealthySlice_BT(wxCommandEvent& event){  
1759         SetHealthySlice( _sl_Slice->GetValue() );
1760 }
1761 */
1762
1763 // PS -> void wxQuantificationWidget::OnCalculated_BT(wxCommandEvent& event)
1764 // PS -> {
1765 // PS ->     /*
1766 // PS ->     _index = ( $widgets(sclSlice) get )
1767 // PS -> 
1768 // PS ->     this->Clean_Contour();
1769 // PS ->        _points = GetContourPoints();
1770 // PS ->        _taille = _points->Item(2) / 2;
1771 // PS -> 
1772 // PS ->     if ( _taille > 0 )
1773 // PS ->        {
1774 // PS ->         aPolygon2D = vtkPolygon::New();
1775 // PS ->         PointsContour2D = vtkPoints::New();
1776 // PS ->                aPolyLine2D = vtkPolyLine::New();
1777 // PS -> 
1778 // PS ->                _PointIds = aPolyLine2D->GetPointIds();
1779 // PS ->                _PointIds->SetNumberOfIds(_taille);
1780 // PS ->         _PointIdsPolygon = aPolygon2D->GetPointIds();
1781 // PS ->                _PointIdsPolygon->SetNumberOfIds(_taille);
1782 // PS -> 
1783 // PS ->         for (int i=0; i< _taille ; i++ )
1784 // PS ->                {
1785 // PS ->             _PointIds->SetId(i, i);
1786 // PS ->             _PointIdsPolygon->SetId(i, i);
1787 // PS ->             PointsContour2D->InsertNextPoint( _points->Item(i * 2  + 0),
1788 // PS ->                                   _points->Item(i * 2  + 1),  0 );
1789 // PS -> 
1790 // PS ->         }
1791 // PS -> 
1792 // PS ->         aPolyLineGrid2D = vtkUnstructuredGrid::New();
1793 // PS ->                aPolyLineGrid2D->Allocate(1, 1);
1794 // PS ->         _param1 = aPolyLine2D->GetCellType();
1795 // PS ->         _param2 = aPolyLine2D->GetPointIds();
1796 // PS ->         aPolyLineGrid2D->InsertNextCell(_param1, _param2);
1797 // PS ->         aPolyLineGrid2D->SetPoints(PointsContour2D);
1798 // PS -> 
1799 // PS ->                aPolyLineMapper2D = vtkDataSetMapper::New();
1800 // PS ->                aPolyLineMapper2D->SetInput(aPolyLineGrid2D);
1801 // PS -> 
1802 // PS ->                aPolyLineActor2D = vtkActor::New();
1803 // PS ->                aPolyLineActor2D->SetMapper(aPolyLineMapper2D);
1804 // PS ->         _Property1 = aPolyLineActor2D->GetProperty();
1805 // PS ->                _Property1->SetColor(0, 1, 0);
1806 // PS ->         _Property1->SetLineWidth(2);
1807 // PS ->         _Property1->SetPointSize(2);
1808 // PS ->         _Property1->BackfaceCullingOff();
1809 // PS -> 
1810 // PS ->         _pRenderer2D->AddActor(aPolyLineActor2D);
1811 // PS -> 
1812 // PS ->                aPolygonGrid2D = vtkUnstructuredGrid::New();
1813 // PS ->                aPolygonGrid2D->Allocate(1, 1);
1814 // PS ->         _param1 = aPolygon2D->GetCellType();
1815 // PS ->         _param2 = aPolygon2D->GetPointIds();
1816 // PS ->         aPolygonGrid2D->InsertNextCell(_param1, _param2);
1817 // PS ->         aPolygonGrid2D->SetPoints(PointsContour2D);
1818 // PS -> 
1819 // PS ->                aPolygonMapper2D = vtkDataSetMapper::New();
1820 // PS ->                aPolygonMapper2D->SetInput(aPolygonGrid2D);
1821 // PS -> 
1822 // PS ->                aPolygonActor2D = vtkActor::New();
1823 // PS ->            aPolygonActor2D->SetMapper(aPolygonMapper2D);
1824 // PS ->                _Property1 = aPolygonActor2D->GetProperty();
1825 // PS ->                _Property1->SetColor(0, 1, 0);
1826 // PS ->         _Property1->SetLineWidth(2);
1827 // PS ->         _Property1->SetPointSize(2);
1828 // PS ->         _Property1->BackfaceCullingOff();
1829 // PS -> 
1830 // PS ->         int arr[] = this->Params(0);
1831 // PS ->                if ( arr(_e_debug_fill_area) == 1 )
1832 // PS ->                        _pRenderer2D->AddActor(aPolygonActor2D);
1833 // PS -> 
1834 // PS ->         _pRenderWindow3D->Render();
1835 // PS ->         _pRenderWindow2D->Render();
1836 // PS -> 
1837 // PS ->     }
1838 // PS ->  */
1839 // PS -> }
1840
1841
1842
1843 // PS -> void wxQuantificationWidget::OnPause_BT(wxCommandEvent& event)
1844 // PS -> {
1845 // PS ->   if ( _quantifing == 1 ) {
1846 // PS ->     _quantifing = 2;
1847 // PS ->     _bt_Pause->SetLabel("Play");
1848 // PS ->     _mar->_experiment->backQuant();
1849 // PS ->   }
1850 // PS ->   else if ( _quantifing == 2 )
1851 // PS ->   {
1852 // PS ->     _quantifing = 1;
1853 // PS ->     _bt_Pause->SetLabel("Pause");
1854 // PS ->   }
1855 // PS -> }
1856
1857
1858 // PS -> void wxQuantificationWidget::OnDelete_BT(wxCommandEvent& event)
1859 // PS -> {
1860 // PS ->        /*
1861 // PS ->        wxMessageDialog* Q_erase = new wxDialog(this,
1862 // PS ->           _str_erase_quant_q,
1863 // PS ->           "Question",
1864 // PS ->           wxYES_NO|wxNO_DEFAULT|wxCENTRE,
1865 // PS ->           wxPoint(100, 100));
1866 // PS -> 
1867 // PS ->    if (Q_erase->ShowModal() ==  wxID_OK)
1868 // PS ->    {
1869 // PS ->       _first_quant = 1;
1870 // PS ->       _real_first_point_quant = -1;
1871 // PS ->       _real_last_point_quant = -1;
1872 // PS ->       this->controls(1);
1873 // PS ->       _quant_shown = false;
1874 // PS -> 
1875 // PS ->          this->clean_graph();
1876 // PS -> 
1877 // PS ->          if (_pRenderer3D != 0) _pRenderer3D->RemoveActor(hs_actor);
1878 // PS ->          if (_hs_actor != 0)   hs_actor->delete();
1879 // PS ->          if (_hs_mapper != 0)  hs_mapper->delete();
1880 // PS ->       if (_hs_grid != 0)   hs_grid->delete();
1881 // PS ->       if (_hs_points != 0)   hs_points->delete();
1882 // PS ->       if (_hs_poly_line != 0)   hs_poly_line->delete();
1883 // PS -> 
1884 // PS ->      foreach i $rings_index
1885 // PS ->                {
1886 // PS -> 
1887 // PS ->             catch { renderer_$widgets(work3D) RemoveActor cont3DActor_{$widgets(work3D)}_{$i} }
1888 // PS ->             catch { cont3DActor_{$widgets(work3D)}_{$i}    Delete }
1889 // PS ->             catch { cont3DMapper_{$widgets(work3D)}_{$i}   Delete }
1890 // PS ->             catch { cont3DGrid_{$widgets(work3D)}_{$i}     Delete }
1891 // PS ->             catch { cont3DPolyLine_{$widgets(work3D)}_{$i} Delete }
1892 // PS ->             catch { cont3DPoints_{$widgets(work3D)}_{$i}   Delete }
1893 // PS -> 
1894 // PS ->         }
1895 // PS ->       _rings_index = _list;
1896 // PS ->          _quant_x     = _list;
1897 // PS ->       _quant_area  = _list;
1898 // PS ->       _quant_peri  = _list;
1899 // PS ->       _quant_darea = _list;
1900 // PS ->       _quant_dperi = _list;
1901 // PS ->       _quant_dmax  = _list;
1902 // PS ->       _quant_dmin  = _list;
1903 // PS ->       _quant_davg  = _list;
1904 // PS ->       _quant_sten  = _list;
1905 // PS -> 
1906 // PS ->       _area = 0.00;
1907 // PS ->       _peri = 0.00;
1908 // PS ->       _darea = 0.00;
1909 // PS ->       _dperi = 0.00;
1910 // PS ->       _dmax  = 0.00;
1911 // PS ->       _dmin  = 0.00;
1912 // PS ->       _davg  = 0.00;
1913 // PS ->       _sten  = 0.00;
1914 // PS ->       _shown = false;
1915 // PS -> 
1916 // PS ->       _pRenderWindow3D->Render();
1917 // PS ->          this->clean_contour();
1918 // PS -> 
1919 // PS ->       wxMessageDialog* Q_extract = new wxDialog(this,
1920 // PS ->                        _str_erase_extracted_contours,
1921 // PS ->                        "Question",
1922 // PS ->                        wxYES_NO|wxNO_DEFAULT|wxCENTRE,
1923 // PS ->                        wxPoint(100, 100));
1924 // PS -> 
1925 // PS ->       if (Q_extract->ShowModal() ==  wxID_OK)
1926 // PS ->                 this->cleanData();
1927 // PS -> 
1928 // PS ->          delete Q_extract;
1929 // PS -> 
1930 // PS ->    }
1931 // PS ->    delete Q_erase;
1932 // PS ->    */
1933 // PS -> }
1934
1935
1936
1937
1938 // PS -> void wxQuantificationWidget::OnSetPoint_BT(wxCommandEvent& event)
1939 // PS -> {
1940 // PS ->     //set slice = [ $widgets(sclSlice) get ]
1941 // PS ->     //this->select_axis_point( 0, 0, $slice
1942 // PS -> }
1943
1944
1945
1946 //--------------------------------------------------------------------
1947 // CheckBox
1948 void wxQuantificationWidget::OnHealthySlice_CB(wxCommandEvent& event)
1949 {
1950         // Visible
1951         /*  if ( _show_hs == 1 ) {
1952     if ( _pRenderer3D != 0 )
1953         _pRenderer3D->AddActor(_hsActor3D);
1954         }
1955         // Hide
1956         else {
1957     if ( _pRenderer3D != 0 )
1958         _pRenderer3D->RemoveActor(_hsActor3D);
1959         }
1960         
1961         _pRenderWindow3D->Render();  // Maj*/
1962
1963         
1964         int healthySlice = _mar->_experiment->getAxis( )->getHealthySlice( );
1965         if (healthySlice!=-1) {
1966                 if ( _cb_HealthySlice->GetValue() )
1967                         _3DWorld->Show3DHealthySliceActor();
1968                 else
1969                         _3DWorld->Hide3DHealthySliceActor();
1970         }
1971 }
1972
1973
1974 //--------------------------------------------------------------------
1975 void wxQuantificationWidget::OnVisibleRing_CB(wxCommandEvent& event){
1976         if ( _cb_VisibleRings->GetValue() ){
1977                 _3DWorld->Show3DContourActor();
1978                 _2DWorld->Show2DContourDiameters();
1979                 RefreshAxis();
1980         } else {
1981                 _3DWorld->Hide3DContourActor();
1982                 _2DWorld->Hide2DContourDiameters();
1983         }
1984
1985         // GetNumberOfAxisPoints()
1986         /*  int noap = _mar->_experiment->getNumberOfAxes();
1987         for (int i= 0; i < noap;  i++ ) {
1988     if ( _show_rings == 0 ) {
1989         if ( _pRenderer3D != 0 )
1990         _pRenderer3D->RemoveActor(_contActor3D[i]);
1991     }
1992     else  {
1993         if ( _pRenderer3D != 0 )
1994         _pRenderer3D->AddActor(_contActor3D[i]);
1995     }
1996         }
1997         _pRenderWindow3D->Render(); // Maj*/
1998 }
1999 //--------------------------------------------------------------------
2000 void wxQuantificationWidget::OnPerpendicular_CB(wxCommandEvent& event)
2001 {
2002         if ( _cb_Perpendicular->GetValue() )
2003                 _3DWorld->Show3DSliceActor();
2004         else
2005                 _3DWorld->Hide3DSliceActor();
2006 }
2007 //--------------------------------------------------------------------
2008 // RadioButton
2009 void wxQuantificationWidget::OnGreyScale_RB(wxCommandEvent& event){
2010         if ( _rb_GreyScale->GetValue() ){
2011                 _3DWorld->SetBWLookUp();
2012         }
2013 }
2014 //--------------------------------------------------------------------
2015 void wxQuantificationWidget::OnColor_RB(wxCommandEvent& event){
2016         if ( _rb_Color->GetValue() ){
2017                 _3DWorld->SetColorLookUp();
2018         }
2019 }
2020 //--------------------------------------------------------------------
2021 void wxQuantificationWidget::CallBackOnLeftDClick( wxMouseEvent& event ){
2022
2023         double pp[3], cp[3];
2024         _3DWorld->GetLast3DClickPoint(pp,cp);
2025
2026         int i,iback,maxPoints;
2027         double *c, cc[3];
2028         double dist,distMin=-1;
2029         iback=-1;
2030             
2031         marAxis *maraxis = _mar->_experiment->getAxis( );
2032         maxPoints = maraxis->getNumberOfSplinePoints();
2033         for ( i=0 ; i<maxPoints ; i++ ){
2034                 c = maraxis->getSplinePoint(i); 
2035                 cc[0]=c[0]-pp[0];
2036                 cc[1]=c[1]-pp[1];
2037                 cc[2]=c[2]-pp[2];
2038                 dist=sqrt( cc[0]*cc[0] + cc[1]*cc[1] + cc[2]*cc[2] );
2039                 if ((distMin==-1) || (dist<distMin)) {
2040                         iback=i;
2041                         distMin=dist;
2042                 }
2043         }
2044         _sl_Slice->SetValue(iback);
2045         MoveSlider(iback);
2046
2047 }
2048
2049 //--------------------------------------------------------------------
2050 void wxQuantificationWidget::CallBackOnMouseWheel( wxMouseEvent& event ){
2051         int slice=_sl_Slice->GetValue();
2052         if (event.GetWheelRotation()>0){ slice++; }
2053         if (event.GetWheelRotation()<0){ slice--; }
2054     if (slice < _sl_Slice->GetMin() ) { slice=_sl_Slice->GetMin(); }
2055     if (slice > _sl_Slice->GetMax() ) { slice=_sl_Slice->GetMax(); }
2056     _sl_Slice->SetValue(slice);
2057         MoveSlider(slice);
2058 }
2059 //--------------------------------------------------------------------
2060 int wxQuantificationWidget::GetActualSlice(){
2061         return _sl_Slice->GetValue();
2062 }
2063 //--------------------------------------------------------------------
2064 int wxQuantificationWidget::GetMaxActualSlice(){
2065         return _sl_Slice->GetMax();
2066 }
2067 //--------------------------------------------------------------------
2068 int  wxQuantificationWidget::GetSizeHealthyRegion(){
2069         return _sizeHealthyRegion;
2070 }
2071 //--------------------------------------------------------------------
2072 void wxQuantificationWidget::SetSizeHealthyRegion(int size){
2073         _sizeHealthyRegion = size;
2074 }
2075 //--------------------------------------------------------------------
2076 void wxQuantificationWidget::GetHealthySliceRange(int &healthySliceStart,int &healthySliceEnd){
2077         healthySliceStart       = _mar->_experiment->getAxis()->getHealthySliceStart( );
2078         healthySliceEnd         = _mar->_experiment->getAxis()->getHealthySliceEnd( );
2079 }
2080 //--------------------------------------------------------------------
2081 void wxQuantificationWidget::Set3DRegionSliceActor( int type, int k1,int k2 ){
2082         _3DWorld->Set3DRegionSliceActor(type,k1,k2);
2083 }
2084 //--------------------------------------------------------------------
2085 void wxQuantificationWidget::Set3DStartRegionSliceActor( int type, int k){
2086         _3DWorld->Set3DStartRegionSliceActor(type,k);
2087 }
2088 //--------------------------------------------------------------------
2089 void wxQuantificationWidget::Set3DEndRegionSliceActor( int type, int k){
2090         _3DWorld->Set3DEndRegionSliceActor(type,k);
2091 }
2092 //--------------------------------------------------------------------
2093 void wxQuantificationWidget::Show3DRegionSliceActor( int type ){
2094         _3DWorld->Show3DRegionSliceActor(type);
2095 }
2096 //--------------------------------------------------------------------
2097 void wxQuantificationWidget::Show3DStartRegionSliceActor( int type ){
2098         _3DWorld->Show3DStartRegionSliceActor(type);
2099 }
2100 //--------------------------------------------------------------------
2101 void wxQuantificationWidget::Show3DEndRegionSliceActor( int type ){
2102         _3DWorld->Show3DEndRegionSliceActor(type);
2103 }
2104 //--------------------------------------------------------------------
2105 void wxQuantificationWidget::Hide3DRegionSliceActor( int type ){
2106         _3DWorld->Hide3DRegionSliceActor(type);
2107 }
2108 //--------------------------------------------------------------------
2109 void wxQuantificationWidget::Hide3DStartRegionSliceActor( int type ){
2110         _3DWorld->Hide3DStartRegionSliceActor(type);
2111 }
2112 //--------------------------------------------------------------------
2113 void wxQuantificationWidget::Hide3DEndRegionSliceActor( int type ){
2114         _3DWorld->Hide3DEndRegionSliceActor(type);
2115 }
2116 //--------------------------------------------------------------------
2117 void wxQuantificationWidget::GetSliceLimites(int type, int &sliceStart, int &sliceEnd){
2118         _3DWorld->GetSliceLimites(type,sliceStart,sliceEnd);
2119 }
2120 //--------------------------------------------------------------------
2121 int wxQuantificationWidget::GetAnalysisTypeStenosis(){
2122         return _3DWorld->GetAnalysisTypeStenosis();
2123 }
2124 //--------------------------------------------------------------------
2125 void wxQuantificationWidget::SetAnalysisTypeStenosis(int analysisTypeStenosis){
2126         _3DWorld->SetAnalysisTypeStenosis(analysisTypeStenosis);
2127 }
2128 //--------------------------------------------------------------------
2129 void wxQuantificationWidget::SetManualContour_2DWorld(bool ok){
2130
2131         if (ok==false){ 
2132                 _2DWorld->SetState(1);
2133                 _2DWorld->EraseManualContour();
2134         }
2135         if (ok==true){  
2136                 _2DWorld->SetState(2);
2137                 _2DWorld->CreateNewManualContour();
2138                 _2DWorld->Render();
2139
2140         }
2141
2142 }
2143 //--------------------------------------------------------------------
2144 void wxQuantificationWidget::SetManualContour_AddPoint_2DWorld(){
2145         _bak_ActualSlice        = _sl_Slice->GetValue();
2146         _2DWorld->Hide2DContourDiameters();
2147         _mar->_experiment->getAxis()->EraseContour(_bak_ActualSlice);
2148         _3DWorld->Erase3DContourActor( _bak_ActualSlice );
2149
2150         _2DWorld->SetStateManualContour(0);
2151 }
2152 //--------------------------------------------------------------------
2153 void wxQuantificationWidget::SetManualContour_InsertPoint_2DWorld(){
2154         _2DWorld->SetStateManualContour(2);
2155 }
2156 //--------------------------------------------------------------------
2157 void wxQuantificationWidget::SetManualContour_ErasePoint_2DWorld(){
2158         _2DWorld->SetStateManualContour(3);
2159 }
2160 //--------------------------------------------------------------------
2161 void wxQuantificationWidget::SetManualContour_MovePoint_2DWorld(){
2162         _2DWorld->SetStateManualContour(4);
2163 }
2164 //--------------------------------------------------------------------
2165 void wxQuantificationWidget::SetManualContour_ReplaceContour(){
2166         if (_bak_ActualSlice!=-1){
2167                 int size                = _2DWorld->GetNumberOfPointsSplineManualContour();
2168                 double *vx              = _2DWorld->GetVectorPointsXManualContour();
2169                 double *vy              = _2DWorld->GetVectorPointsYManualContour();
2170                 _mar->_experiment->getAxis()->replaceContour2D(_bak_ActualSlice,size,vx,vy);
2171                 free(vx);
2172                 free(vy);
2173                 RefreshAxis();
2174                 _bak_ActualSlice=-1;
2175         }
2176 }
2177 //------------------------------------------------------------------------
2178 kVolume* wxQuantificationWidget::GetVolumeAxisExtended(int wz1,int wz2)
2179 {
2180         // Create Volume
2181         vtkImageData *imagedata;
2182         imagedata=_mar->_experiment->getSliceImage(wz1);
2183         int dims[3];
2184         imagedata->GetDimensions (dims);
2185         int wx=dims[0];
2186         int wy=dims[1];
2187         int wz  = wz2-wz1+1;
2188         kVolume *kvol =new kVolume( kVolume::USHORT, wx, wy, wz,1, 1, 1, malloc(sizeof(unsigned short)*wx*wy*wz ) );
2189         vtkImageData *vol = kvol->castVtk();
2190
2191         // Fill Volume
2192         int i;
2193         for (i=wz1;i<=wz2;i++)
2194         {
2195                 // GetImage
2196                 imagedata=_mar->_experiment->getSliceImage(i);
2197
2198                 // InsertImage
2199              void *p_imagedata  = imagedata->GetScalarPointer(0,0,0);
2200                  void *p_vol            = vol->GetScalarPointer(0,0,i-wz1);
2201          memcpy( p_vol, p_imagedata , sizeof(unsigned short)*dims[0]*dims[1] );
2202         }
2203         return kvol;
2204 }
2205
2206
2207 //------------------------------------------------------------------------
2208 void wxQuantificationWidget::OnContourWall()
2209 {
2210 }
2211
2212 //------------------------------------------------------------------------
2213 void wxQuantificationWidget::OnContourLumen()
2214 {
2215 }
2216
2217 //------------------------------------------------------------------------
2218 void wxQuantificationWidget::OnContourHypo()
2219 {
2220 }
2221
2222 //------------------------------------------------------------------------
2223 void wxQuantificationWidget::OnContourCalc()
2224 {
2225 }
2226
2227 //------------------------------------------------------------------------
2228 void wxQuantificationWidget::OnReplaceContourWall()
2229 {
2230 }
2231 //------------------------------------------------------------------------
2232 void wxQuantificationWidget::OnReplaceContourLumen()
2233 {
2234 }
2235 //------------------------------------------------------------------------
2236 void wxQuantificationWidget::OnReplaceContourHypo()
2237 {
2238 }
2239
2240 //------------------------------------------------------------------------
2241 void wxQuantificationWidget::OnReplaceContourCalc() 
2242 {
2243 }
2244
2245
2246 //------------------------------------------------------------------------
2247 void wxQuantificationWidget::OnSliderDiscontinuityScroll(int percentage)
2248 {
2249 }
2250
2251 //------------------------------------------------------------------------
2252 void wxQuantificationWidget::OnSliderLumenPercentageScroll(int percentage)
2253 {
2254 }
2255
2256 //------------------------------------------------------------------------
2257 void wxQuantificationWidget::OnSliderCalcPercentageScroll(int percentage)
2258 {
2259 }
2260
2261 //------------------------------------------------------------------------
2262 void wxQuantificationWidget::OnCalibration() 
2263 {
2264 }
2265 //------------------------------------------------------------------------
2266 void wxQuantificationWidget::OnFile()
2267 {
2268 }
2269
2270 //------------------------------------------------------------------------
2271 void wxQuantificationWidget::OnShowAll(bool value) 
2272 {
2273 }
2274
2275 //------------------------------------------------------------------------
2276 void wxQuantificationWidget::OnShowWall(bool value)
2277 {
2278 }
2279 //------------------------------------------------------------------------
2280 void wxQuantificationWidget::OnShowLumen(bool value)
2281 {
2282 }
2283
2284 //------------------------------------------------------------------------
2285 void wxQuantificationWidget::OnShowCalc(bool value)
2286 {
2287 }
2288
2289 //------------------------------------------------------------------------
2290 void wxQuantificationWidget::OnShowHypo(bool value)
2291 {
2292 }
2293
2294
2295 // EOF - wxQuantificationWidget.cxx
2296
2297
2298