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