]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/wxSurfaceMPR.cxx
#3262 creaMaracasVisu Feature New Normal - Export LookupTable fron ColorLayerImageV...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / wxSurfaceMPR.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 #include <vtkPlanes.h>
27 #include <vtkProperty.h> 
28 #include <vtkPolyData.h> 
29 #include <vtkDataSet.h> 
30
31 #include "wxSurfaceMPR.h"
32 #include <wx/colordlg.h>
33
34
35
36 //-------------------------------------------------------------------
37 //-------------------------------------------------------------------
38 //-------------------------------------------------------------------
39
40 /*
41
42
43 void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
44         if (eventId==vtkCommand::StartInteractionEvent){
45                 _renWin->SetDesiredUpdateRate(10);
46         }
47         if (eventId==vtkCommand::InteractionEvent){
48                 _renWin->SetDesiredUpdateRate(0.001);
49         }
50         if (eventId==vtkCommand::EndInteractionEvent){
51                 vtkPlanes *planes = vtkPlanes::New();
52                 vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
53                 boxwidget->GetPlanes(planes);
54                 _volumeMapper->SetClippingPlanes(planes);
55                 planes -> Delete();
56         }
57 }
58 //-------------------------------------------------------------------
59 void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
60         _renWin = renWin;
61 }
62 //-------------------------------------------------------------------
63 void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
64         _volumeMapper = volumeMapper;
65 }
66
67
68 //-------------------------------------------------------------------
69 //-------------------------------------------------------------------
70 //-------------------------------------------------------------------
71
72 void boxSurfaceObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
73         vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
74         boxwidget->GetPlanes(_planes);
75         _actor->VisibilityOn();
76 }
77 //-------------------------------------------------------------------
78 void boxSurfaceObserver::SetPlanes(vtkPlanes *planes){
79         _planes = planes;
80 }
81 //-------------------------------------------------------------------
82 void boxSurfaceObserver::SetActor(vtkActor *actor){
83         _actor = actor;
84 }
85
86 */
87
88 //-------------------------------------------------------------------
89 //-------------------------------------------------------------------
90 //-------------------------------------------------------------------
91
92
93 /*
94 vtkMPR3DData::vtkMPR3DData()
95 {
96         _colour[0]= new wxColour(255,127, 64);
97         _colour[1]= new wxColour(255,255,250);
98         _colour[2]= new wxColour(  0,255,000);
99         _colour[3]= new wxColour(  0,  0,255);
100         _visiblePosition[0]=true;
101         _visiblePosition[1]=true;
102         _visiblePosition[2]=true;
103 }
104 //-------------------------------------------------------------------
105 vtkMPR3DData::~vtkMPR3DData()
106 {
107         int i;
108         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
109                 _tissueExtractor[i]             ->Delete();
110                 _tissueNormals[i]               ->Delete();
111                 _tissueStripper[i]              ->Delete();
112                 _tissueMapper[i]                ->Delete();
113                 delete _colour[i];
114                 _tissuePlanes[i]                ->Delete();
115                 _tissueClipper[i]               ->Delete();
116         }
117         _outlineData            ->Delete();
118         _mapOutline                     ->Delete();
119         _outline                        ->Delete();
120
121         // Volume
122         _tfun                           ->Delete();
123         _ctfun                          ->Delete();
124         _compositeFunction      ->Delete();
125         _volumeMapper           ->Delete();
126         _volumeProperty         ->Delete();
127         _newvol                         ->Delete();
128 }
129 //-------------------------------------------------------------------
130 vtkActor* vtkMPR3DData::GetOutlineActor()
131 {
132         return _outline;
133 }
134 //-------------------------------------------------------------------
135 vtkPolyDataMapper* vtkMPR3DData::GetTissueMapper(int id)
136 {
137         return _tissueMapper[id];
138 }
139 //-------------------------------------------------------------------
140 vtkPlanes* vtkMPR3DData::GetTissuePlanes(int id)
141 {
142         return _tissuePlanes[id];
143 }
144 //-------------------------------------------------------------------
145 vtkStripper* vtkMPR3DData::GetTissueStripper(int id)
146 {
147         return _tissueStripper[id];
148 }
149 //-------------------------------------------------------------------
150 vtkImageActor* vtkMPR3DData::GetImageActor(int id)
151 {
152         vtkImageActor *tmpVtkActor=NULL;
153         if (id==0){
154                 tmpVtkActor = GetvtkActor_saggital();
155         }
156         if (id==1){
157                 tmpVtkActor = GetvtkActor_coronal();
158         }
159         if (id==2){
160                 tmpVtkActor = GetvtkActor_axial();
161         }
162         return tmpVtkActor;
163 }
164 //-------------------------------------------------------------------
165 void vtkMPR3DData::Configure()
166 {
167         int i;
168
169         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
170
171                 _tissueExtractor[i] = vtkContourFilter::New();
172                 _tissueExtractor[i]->SetInput((vtkDataSet *) GetImageData() );
173                 _tissueExtractor[i]->SetValue(0, 0);
174             _tissueNormals[i] = vtkPolyDataNormals::New();
175                 _tissueNormals[i]->SetInput(_tissueExtractor[i]->GetOutput());
176                 _tissueNormals[i]->SetFeatureAngle(60.0);
177                 _tissueStripper[i] = vtkStripper::New();
178                 _tissueStripper[i]->SetInput(_tissueNormals[i]->GetOutput());
179
180                 if (i==0){
181                         _tissuePlanes[i]  = vtkPlanes::New();
182                         _tissueClipper[i] = vtkClipPolyData::New();
183                         _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
184                         _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
185                         _tissueClipper[i]->InsideOutOn( );
186
187                         _tissueMapper[i] = vtkPolyDataMapper::New();
188                         _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
189                 } else {
190                         _tissueMapper[i] = vtkPolyDataMapper::New();
191                         _tissueMapper[i]->SetInput(_tissueStripper[i]->GetOutput());
192 //                      _tissueMapper[i]->ScalarVisibilityOff();
193
194                 }
195
196         }
197
198
199
200   // An outline provides context around the data.
201   //
202         _outlineData = vtkOutlineFilter::New();
203     _outlineData->SetInput((vtkDataSet *) GetImageData() );
204         _mapOutline = vtkPolyDataMapper::New();
205     _mapOutline->SetInput(_outlineData->GetOutput());
206         _outline = vtkActor::New();
207     _outline->SetMapper(_mapOutline);
208     _outline->GetProperty()->SetColor(0,0,0);
209
210   // Now we are creating three orthogonal planes passing through the
211   // volume. Each plane uses a different texture map and therefore has
212   // diferent coloration.
213
214
215   // Volume
216   _tfun = vtkPiecewiseFunction::New();
217
218 //      _tfun->AddPoint(70.0, 0.0);
219 //      _tfun->AddPoint(599.0, 0);
220 //      _tfun->AddPoint(600.0, 0);
221 //      _tfun->AddPoint(1195.0, 0);
222 //      _tfun->AddPoint(1200, .2);
223 //      _tfun->AddPoint(1300, .3);
224 //      _tfun->AddPoint(2000, .3);
225 //      _tfun->AddPoint(4095.0, 1.0);
226
227         _tfun->AddPoint(70      , 0.0);
228         _tfun->AddPoint(599     , 0.0);
229         _tfun->AddPoint(600     , 0.0);
230         _tfun->AddPoint(1110, 0.0);
231         _tfun->AddPoint(1111, 1.0);
232         _tfun->AddPoint(1300, 1.0);
233         _tfun->AddPoint(2000, 1.0);
234         _tfun->AddPoint(4095, 1.0);
235
236   _ctfun = vtkColorTransferFunction::New();
237
238 //    _ctfun->AddRGBPoint(0.0, 0.5, 0.0, 0.0);
239 //      _ctfun->AddRGBPoint(600.0, 1.0, 0.5, 0.5);
240 //      _ctfun->AddRGBPoint(1280.0, 0.9, 0.2, 0.3);
241 //      _ctfun->AddRGBPoint(1960.0, 0.81, 0.27, 0.1);
242 //      _ctfun->AddRGBPoint(4095.0, 0.5, 0.5, 0.5);
243
244         _ctfun->AddRGBPoint(0.0         , 0.5   , 0.0   , 0.0 );
245         _ctfun->AddRGBPoint(600.0       , 1.0   , 0.5   , 0.5 );
246         _ctfun->AddRGBPoint(1130.0      , 0.9   , 0.2   , 0.3 );
247         _ctfun->AddRGBPoint(1131.0      , 0.3   , 0.9   , 0.9 );
248         _ctfun->AddRGBPoint(1135.0      , 0.3   , 0.8   , 0.8 );
249         _ctfun->AddRGBPoint(1960.0      , 0.1   , 0.27  , 0.71);
250         _ctfun->AddRGBPoint(4095.0      , 0.5   , 0.5   , 0.5 );
251
252   _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
253   
254   _volumeMapper = vtkVolumeRayCastMapper::New();
255         _volumeMapper->SetInput( GetImageData() );
256         _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
257
258   _volumeProperty = vtkVolumeProperty::New();
259         _volumeProperty->SetColor(_ctfun);
260         _volumeProperty->SetScalarOpacity(_tfun);
261         _volumeProperty->SetInterpolationTypeToLinear();
262         _volumeProperty->ShadeOn();
263
264   _newvol = vtkVolume::New();
265         _newvol->SetMapper(_volumeMapper);
266         _newvol->SetProperty(_volumeProperty);
267
268         vtkMPRBaseData::Configure();
269
270 }
271
272
273 //-------------------------------------------------------------------
274 void vtkMPR3DData::SetIsovalue(int idTissue, int isoValue)
275 {
276         _tissueExtractor[idTissue]->SetValue(0, isoValue);
277 }
278
279 //-------------------------------------------------------------------
280 wxColour* vtkMPR3DData::GetColour(int idColour)
281 {
282         return _colour[idColour];
283 }
284 //-------------------------------------------------------------------
285 void vtkMPR3DData::SetVisiblePosition(int idPosition, bool visible)
286 {
287         _visiblePosition[idPosition]=visible;
288 }
289 //-------------------------------------------------------------------
290 bool vtkMPR3DData::GetVisiblePosition(int idPosition)
291 {
292         return _visiblePosition[idPosition];
293 }
294 //-------------------------------------------------------------------
295 vtkVolume* vtkMPR3DData::GetVolumeActor()
296 {
297    return _newvol;
298 }
299 //-------------------------------------------------------------------
300 vtkVolumeRayCastMapper* vtkMPR3DData::GetVolumeMapper(){
301         return _volumeMapper;
302 }
303
304 */
305
306 //-------------------------------------------------------------------
307 //-------------------------------------------------------------------
308 //-------------------------------------------------------------------
309
310 /*
311
312 wxVtkMPR3DView::wxVtkMPR3DView(wxWindow *parent)
313 :wxVtk3DBaseView( parent )
314 {
315         int i;
316         for (i=0; i<VTKMPRDATA_MAXTISSUE; i++){
317                 _visibleTissue[i]=true;
318         }
319         _visibleVolume=true;
320
321 }
322
323 //-------------------------------------------------------------------
324 wxVtkMPR3DView::~wxVtkMPR3DView(){
325         int i;
326         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
327                 _tissue[i]->Delete();
328         }
329
330         _boxWidget              -> Delete();
331         _observerV              -> Delete();
332         _boxWidgetS1    -> Delete();
333         _observerS1             -> Delete();
334
335 }
336 //-------------------------------------------------------------------
337 void wxVtkMPR3DView::SetVisibleTissue(int idTissue, bool visible){
338         _visibleTissue[idTissue]=visible;
339 }
340 //-------------------------------------------------------------------
341 bool wxVtkMPR3DView::GetVisibleTissue(int idTissue){
342         return _visibleTissue[idTissue];
343 }
344 //-------------------------------------------------------------------
345 vtkActor* wxVtkMPR3DView::GetTissueActor(int id){
346         return _tissue[id];
347 }
348 //-------------------------------------------------------------------
349 void wxVtkMPR3DView::Configure(){
350         vtkMPR3DData *vtkmpr3Ddata = (vtkMPR3DData*)GetVtkmprbasedata();
351         wxVtk3DBaseView::Configure();
352         // vtkActor tissue
353         int i;
354         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
355                 // tissue
356                 _tissue[i] = vtkActor::New();
357                 _tissue[i]->SetMapper(vtkmpr3Ddata->GetTissueMapper(i));
358
359 //              wxColour* cc=_vtkmprdata->GetColour(i); 
360 //              float cr=cc->Red(),cg=cc->Green(),cb=cc->Blue();
361 //              _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255   , cb/255   );
362 //              _tissue[i]->GetProperty()->SetSpecular(.3);
363 //              _tissue[i]->GetProperty()->SetSpecularPower(20);
364
365                 if (i==0) _tissue[i]->GetProperty()->SetColor(1, 0   , 0   );
366                 if (i==2) _tissue[i]->GetProperty()->SetColor(0.85, 0.85   , 0.85   );
367                 if (i==3) _tissue[i]->GetProperty()->SetColor(0, 1   ,  0  );
368                 if (i==4) _tissue[i]->GetProperty()->SetColor(0, 0   , 1   );
369
370                 if (i==0){
371                   _tissue[i]->VisibilityOff();
372                   _tissue[i]->SetScale(1.01, 1.01, 1.01);
373                 }
374         }
375
376   // Volume (RayCast)
377         GetRenderer()->AddVolume( vtkmpr3Ddata->GetVolumeActor()  );    // RayCast
378         GetRenderer()->SetBackground(0.5, 0.5, 0.5);
379
380   // Actors are added to the renderer. 
381   GetRenderer()->AddActor( vtkmpr3Ddata->GetOutlineActor() );                   
382   GetRenderer()->AddActor( vtkmpr3Ddata->GetImageActor(0)  );   // _saggital
383   GetRenderer()->AddActor( vtkmpr3Ddata->GetImageActor(1)  );   // _axial
384   GetRenderer()->AddActor( vtkmpr3Ddata->GetImageActor(2)  );   // _coronal
385
386
387
388         // Box Volume
389         
390   // The SetInteractor method is how 3D widgets are associated with the
391   // render window interactor. Internally, SetInteractor sets up a bunch
392   // of callbacks using the Command/Observer mechanism (AddObserver()).
393   _boxWidget = vtkBoxWidget::New();
394         _boxWidget->SetInteractor( GetWxVTKRenderWindowInteractor() );
395         _boxWidget->SetPlaceFactor(1.0);
396
397   // Place the interactor initially. The output of the reader is used to
398   // place the box widget.
399
400         _observerV = boxVolumeObserver::New();
401         _observerV->SetRenWin( GetRenWin() );
402         _observerV->SetVolumeMapper( vtkmpr3Ddata->GetVolumeMapper() );
403
404         _boxWidget->SetInput( vtkmpr3Ddata->GetImageData() );
405         _boxWidget->PlaceWidget();
406         _boxWidget->InsideOutOn();
407         _boxWidget->AddObserver( vtkCommand::StartInteractionEvent      , _observerV );
408         _boxWidget->AddObserver( vtkCommand::InteractionEvent           , _observerV );
409         _boxWidget->AddObserver( vtkCommand::EndInteractionEvent        , _observerV );
410         _boxWidget->On();
411
412         vtkProperty *outlineProperty = _boxWidget->GetOutlineProperty();
413         outlineProperty->SetRepresentationToWireframe();
414         outlineProperty->SetAmbient(1.0);
415         outlineProperty->SetAmbientColor(1, 1, 1);
416         outlineProperty->SetLineWidth(3);
417
418         vtkProperty *selectedOutlineProperty = _boxWidget->GetSelectedOutlineProperty();
419         selectedOutlineProperty->SetRepresentationToWireframe();
420         selectedOutlineProperty->SetAmbient(1.0);
421         selectedOutlineProperty->SetAmbientColor(1, 0, 0);
422         selectedOutlineProperty->SetLineWidth(3);
423
424 //--
425         // Box Surface
426
427   // Place the interactor initially. The output of the reader is used to
428   // place the box widget.
429
430 //      _observerV = boxVolumeObserver::New();
431 //      _observerV->SetRenWin( _renWin );
432 //      _observerV->SetVolumeMapper( _vtkmprdata->GetVolumeMapper() );
433
434         _observerS1 = boxSurfaceObserver::New();
435         _observerS1->SetPlanes( vtkmpr3Ddata->GetTissuePlanes(0) );
436         _observerS1->SetActor( _tissue[0] );
437
438   _boxWidgetS1 = vtkBoxWidget::New();
439         _boxWidgetS1->SetInteractor( GetWxVTKRenderWindowInteractor() );
440         _boxWidgetS1->SetPlaceFactor(1.25);
441
442
443         _boxWidgetS1->SetInput( vtkmpr3Ddata->GetTissueStripper(0)->GetOutput() );
444 //      _boxWidgetS1->SetInput( vtkmpr3Ddata->GetGlyph(0)->GetOutput() );
445         _boxWidgetS1->PlaceWidget();
446         _boxWidgetS1->InsideOutOff();
447 //      _boxWidgetS1->AddObserver( vtkCommand::StartInteractionEvent , _observerV );
448 //      _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent          , _observerV );
449 //      _boxWidgetS1->AddObserver( vtkCommand::EndInteractionEvent       , _observerV );
450 //      _boxWidgetS1->AddObserver( vtkCommand::EndInteractionEvent       , _observerS1 );
451         _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent          , _observerS1 );
452
453 //      vtkProperty *outlinePropertyS1 = _boxWidgetS1->GetOutlineProperty();
454 //      outlinePropertyS1->SetRepresentationToWireframe();
455 //      outlinePropertyS1->SetAmbient(1.0);
456 //      outlinePropertyS1->SetAmbientColor(0, 0, 1);
457 //      outlinePropertyS1->SetLineWidth(3);
458
459 //      vtkProperty *selectedOutlinePropertyS1 = _boxWidgetS1->GetSelectedOutlineProperty();
460 //      selectedOutlinePropertyS1->SetRepresentationToWireframe();
461 //      selectedOutlinePropertyS1->SetAmbient(1.0);
462 //      selectedOutlinePropertyS1->SetAmbientColor(1, 0, 0);
463 //      selectedOutlinePropertyS1->SetLineWidth(3);
464
465
466         // vtkActor tissue
467         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
468                 GetRenderer()->AddActor( _tissue[i] );                  
469         }
470
471         _boxWidgetS1->On();
472
473 //--
474
475   // Turn off bone for this example.
476 //  _bone->VisibilityOff();
477
478
479   // An initial camera view is created.  The Dolly() method moves 
480   // the camera towards the FocalPoint, thereby enlarging the image.
481   GetRenderer()->SetActiveCamera(GetCamera());
482   GetRenderer()->ResetCamera ();
483   GetCamera()->Dolly(1.5);
484
485   // Set a background color for the renderer and set the size of the
486   // render window (expressed in pixels).
487   GetRenderer()->SetBackground(1,1,1);
488   GetRenWin()->SetSize(400, 400);
489
490   // Note that when camera movement occurs (as it does in the Dolly()
491   // method), the clipping planes often need adjusting. Clipping planes
492   // consist of two planes: near and far along the view direction. The 
493   // near plane clips out objects in front of the plane; the far plane
494   // clips out objects behind the plane. This way only what is drawn
495   // between the planes is actually rendered.
496   GetRenderer()->ResetCameraClippingRange();
497
498 }
499
500
501 //-------------------------------------------------------------------
502 void wxVtkMPR3DView::VisibleActor(int idTissue, bool visTissue, bool visGuide){
503         if (visTissue!=GetVisibleTissue(idTissue)){
504                 if (visTissue==false){
505                         GetRenderer()->RemoveActor( GetTissueActor(idTissue)  );        
506                 } else {
507                         GetRenderer()->AddActor( GetTissueActor(idTissue)  );   
508                 }
509                 SetVisibleTissue(idTissue,visTissue);
510         }
511
512         if (visGuide==true){
513                 _boxWidgetS1->On();
514         } else {
515                 _boxWidgetS1->Off();
516         }
517
518 }
519 //-------------------------------------------------------------------
520 void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
521         vtkMPR3DData *vtkmpr3Ddata = (vtkMPR3DData*)GetVtkmprbasedata();
522         if (visible!=vtkmpr3Ddata->GetVisiblePosition(idPosition)){
523                 if (visible==false){
524                         GetRenderer()->RemoveActor( vtkmpr3Ddata->GetImageActor(idPosition)  ); 
525                 } else {
526                         GetRenderer()->AddActor( vtkmpr3Ddata->GetImageActor(idPosition)  );    
527                 }
528                 vtkmpr3Ddata->SetVisiblePosition(idPosition,visible);
529         }
530 }
531
532 //-------------------------------------------------------------------
533
534 void wxVtkMPR3DView::VisibleVolumeActor( bool visVolume,bool visGuide){
535         vtkMPR3DData *vtkmpr3Ddata = (vtkMPR3DData*)GetVtkmprbasedata();
536         if (visVolume!=_visibleVolume){
537                 if (visVolume==false){
538                         GetRenderer()->RemoveActor( vtkmpr3Ddata->GetVolumeActor()  );  
539                 } else {
540                         GetRenderer()->AddActor( vtkmpr3Ddata->GetVolumeActor() );      
541                 }
542                 _visibleVolume=visVolume;
543         }
544         if (visGuide==true){
545                 _boxWidget->On();
546         } else {
547                 _boxWidget->Off();
548         }
549 }
550
551 */
552
553 //-------------------------------------------------------------------
554 //-------------------------------------------------------------------
555 //-------------------------------------------------------------------
556
557
558 /*
559 wxSurfaceMPR::wxSurfaceMPR(wxWindow *parent,  vtkImageData *imagedata, const wxString& title)
560                                 : wxFrame( parent, -1, title) {
561
562         _vtkmpr3Ddata = new vtkMPR3DData(); 
563         _vtkmpr3Ddata->SetImageData(imagedata);
564
565         wxPanel *MPRPanel               = CreateMPRPanel(this,_vtkmpr3Ddata);
566         wxPanel *controlPanel   = CreateControlPanel(this);
567
568     wxFlexGridSizer *sizer  = new wxFlexGridSizer(2);
569         sizer->Add(MPRPanel );
570         sizer->Add(controlPanel );
571         this->SetSizer(sizer);
572         this->SetAutoLayout(true);
573         this->SetSize(800,900);
574 }
575
576 //-------------------------------------------------------------------
577 wxPanel* wxSurfaceMPR::CreateMPRPanel(wxWindow *parent, vtkMPR3DData *vtkmpr3Ddata){
578         wxPanel *panel=new wxPanel(parent,-1);
579
580         _vtkmprview[1] = new wxVtkMPR3DView(panel);
581         _vtkmprview[1]->SetVtkmprbasedata(vtkmpr3Ddata);
582         wxVTKRenderWindowInteractor *iren1 = _vtkmprview[1]->GetWxVTKRenderWindowInteractor();  
583
584         _vtkmprview[2] = new wxVtkMPR3DView(panel);
585         _vtkmprview[2]->SetVtkmprbasedata(vtkmpr3Ddata);
586         wxVTKRenderWindowInteractor *iren2 = _vtkmprview[2]->GetWxVTKRenderWindowInteractor();  
587
588         _vtkmprview[3] = new wxVtkMPR3DView(panel);
589         _vtkmprview[3]->SetVtkmprbasedata(vtkmpr3Ddata);
590         wxVTKRenderWindowInteractor *iren3 = _vtkmprview[3]->GetWxVTKRenderWindowInteractor();  
591
592         _vtkmprview[0] = new wxVtkMPR3DView(panel);
593         _vtkmprview[0]->SetVtkmprbasedata(vtkmpr3Ddata);
594         wxVTKRenderWindowInteractor *iren0 = _vtkmprview[0]->GetWxVTKRenderWindowInteractor();  
595
596     wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
597     wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
598     wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
599         sizerH1->Add(iren0 , 1, wxEXPAND, 0);
600
601         sizerH1->Add(iren1 , 1, wxEXPAND, 0);
602         sizerH2->Add(iren2 , 1, wxEXPAND, 0);
603         sizerH2->Add(iren3 , 1, wxEXPAND, 0);
604
605         sizerV->Add(sizerH1, 1, wxEXPAND, 0);
606         sizerV->Add(sizerH2, 1, wxEXPAND, 0);
607
608         panel->SetAutoLayout(true);
609         panel->SetSizer(sizerV);
610         panel->SetSize(900,900);
611         panel->Layout();
612
613
614         return panel;
615 }
616
617 //-------------------------------------------------------------------
618
619 wxPanel* wxSurfaceMPR::CreateControlPanel(wxWindow *parent){
620         wxPanel *panel=new wxPanel(parent,-1);
621
622 // position 
623         wxPanel *panel1 =new wxPanel(panel,-1);
624         wxStaticText *text_space1 = new wxStaticText(panel1,-1,"    ");
625         wxStaticText *text1_box1  = new wxStaticText(panel1,-1,"x  ");
626         wxStaticText *text2_box1  = new wxStaticText(panel1,-1,"y  ");
627         wxStaticText *text3_box1  = new wxStaticText(panel1,-1,"z  ");
628         _sl1_box1 = new wxSlider( panel1, -1, 0, 0, _vtkmpr3Ddata->GetMaxPositionX(), wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
629         _sl2_box1 = new wxSlider( panel1, -1, 0, 0, _vtkmpr3Ddata->GetMaxPositionY(), wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
630         _sl3_box1 = new wxSlider( panel1, -1, 0, 0, _vtkmpr3Ddata->GetMaxPositionZ(), wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
631
632         _sl1_box1->SetSize(250,20);
633         _sl2_box1->SetSize(250,20);
634         _sl3_box1->SetSize(250,20);
635
636     wxFlexGridSizer *sizerBox1 = new wxFlexGridSizer(3);
637         // line 1
638         sizerBox1->Add(text_space1);
639         sizerBox1->Add(text1_box1);
640         sizerBox1->Add( _sl1_box1);
641         // line 2
642         sizerBox1->Add(text_space1);
643         sizerBox1->Add(text2_box1);
644         sizerBox1->Add( _sl2_box1);
645         // line 3
646         sizerBox1->Add(text_space1);
647         sizerBox1->Add(text3_box1);
648         sizerBox1->Add( _sl3_box1);
649         panel1->SetSizer(sizerBox1);
650         panel1->SetAutoLayout(true);
651         panel1->SetSize(250,80);
652
653
654 // Layers
655         wxPanel *panel2 =new wxPanel(panel,-1);
656         wxStaticText *text_space2 = new wxStaticText(panel2,-1,"   ");
657         wxStaticText *text_             = new wxStaticText(panel2,-1,"  ");
658                                   _btnA         = new wxButton(panel2,-1,"A");
659                                   _btnB         = new wxButton(panel2,-1,"B");
660                                   _btnC         = new wxButton(panel2,-1,"C");
661                                   _btnD         = new wxButton(panel2,-1,"D");
662                       _text_A   = new wxStaticText(panel2,-1,"000000");
663                       _text_B   = new wxStaticText(panel2,-1,"000000");
664                       _text_C   = new wxStaticText(panel2,-1,"000000");
665                       _text_D   = new wxStaticText(panel2,-1,"000000");
666         wxStaticText *text_A    = new wxStaticText(panel2,-1,"A ");
667         wxStaticText *text_B    = new wxStaticText(panel2,-1,"B ");
668         wxStaticText *text_C    = new wxStaticText(panel2,-1,"C ");
669         wxStaticText *text_D    = new wxStaticText(panel2,-1,"D ");
670         _slA1_box2 = new wxSlider( panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
671         _slA2_box2 = new wxSlider( panel2, -1, 0, 0,  60, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
672         _slA3_box2 = new wxSlider( panel2, -1, 0, 0,  50, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
673         _slB1_box2 = new wxSlider( panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
674         _slB2_box2 = new wxSlider( panel2, -1, 0, 0,  60, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
675         _slB3_box2 = new wxSlider( panel2, -1, 0, 0,  50, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
676         _slC1_box2 = new wxSlider( panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
677         _slC2_box2 = new wxSlider( panel2, -1, 0, 0,  60, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
678         _slC3_box2 = new wxSlider( panel2, -1, 0, 0,  50, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
679         _slD1_box2 = new wxSlider( panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
680         _slD2_box2 = new wxSlider( panel2, -1, 0, 0,  60, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
681         _slD3_box2 = new wxSlider( panel2, -1, 0, 0,  50, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  );
682
683         _chk1_box1 = new wxCheckBox(panel2, -1, "Visible X");
684         _chk2_box1 = new wxCheckBox(panel2, -1, "Visible Y");
685         _chk3_box1 = new wxCheckBox(panel2, -1, "Visible Z");
686
687         _chkA_box2              = new wxCheckBox(panel2, -1, "Vis.");
688         _chkB_box2              = new wxCheckBox(panel2, -1, "Vis.");
689         _chkC_box2              = new wxCheckBox(panel2, -1, "Vis.");
690         _chkD_box2              = new wxCheckBox(panel2, -1, "Vis.");
691         _chkAA_box2             = new wxCheckBox(panel2, -1, ".");
692         _chkBB_box2             = new wxCheckBox(panel2, -1, ".");
693         _chkCC_box2             = new wxCheckBox(panel2, -1, ".");
694         _chkDD_box2             = new wxCheckBox(panel2, -1, ".");
695         _chkViewA_box2  = new wxCheckBox(panel2, -1, "A");
696         _chkViewB_box2  = new wxCheckBox(panel2, -1, "B");
697         _chkViewC_box2  = new wxCheckBox(panel2, -1, "C");
698         _chkViewD_box2  = new wxCheckBox(panel2, -1, "D");
699
700         _chk1_box1->SetValue(true);
701         _chk2_box1->SetValue(true);
702         _chk3_box1->SetValue(true);
703         _chkA_box2->SetValue(true);
704         _chkB_box2->SetValue(true);
705         _chkC_box2->SetValue(true);
706         _chkD_box2->SetValue(true);
707         _chkAA_box2->SetValue(true);
708         _chkBB_box2->SetValue(true);
709         _chkCC_box2->SetValue(true);
710         _chkDD_box2->SetValue(true);
711         _chkViewA_box2->SetValue(true);
712         _chkViewB_box2->SetValue(true);
713         _chkViewC_box2->SetValue(true);
714         _chkViewD_box2->SetValue(true);
715
716         _slA1_box2->SetSize(250,20);
717         _slA2_box2->SetSize(150,20);
718         _slA3_box2->SetSize(150,20);
719         _slB1_box2->SetSize(250,20);
720         _slB2_box2->SetSize(150,20);
721         _slB3_box2->SetSize(150,20);
722         _slC1_box2->SetSize(250,20);
723         _slC2_box2->SetSize(150,20);
724         _slC3_box2->SetSize(150,20);
725         _slD1_box2->SetSize(250,20);
726         _slD2_box2->SetSize(150,20);
727         _slD3_box2->SetSize(150,20);
728         _btnA->SetSize(20,20);
729         _btnB->SetSize(20,20);
730         _btnC->SetSize(20,20);
731         _btnD->SetSize(20,20);
732
733         _btnA->SetBackgroundColour( *(_vtkmpr3Ddata->GetColour(0))  );
734         _btnB->SetBackgroundColour( *(_vtkmpr3Ddata->GetColour(1))  );
735         _btnC->SetBackgroundColour( *(_vtkmpr3Ddata->GetColour(2))  );
736         _btnD->SetBackgroundColour( *(_vtkmpr3Ddata->GetColour(3))  );
737
738
739     wxFlexGridSizer *sizerPanel2A = new wxFlexGridSizer(5);
740     // line A2
741         sizerPanel2A->Add(text_space2);
742         sizerPanel2A->Add(text_A);
743         sizerPanel2A->Add(_slA2_box2);
744         sizerPanel2A->Add(_slA3_box2);
745         sizerPanel2A->Add(_text_A);
746     // line B2
747         sizerPanel2A->Add(text_space2);
748         sizerPanel2A->Add(text_B);
749         sizerPanel2A->Add(_slB2_box2);
750         sizerPanel2A->Add(_slB3_box2);
751         sizerPanel2A->Add(_text_B);
752     // line C2
753         sizerPanel2A->Add(text_space2);
754         sizerPanel2A->Add(text_C);
755         sizerPanel2A->Add(_slC2_box2);
756         sizerPanel2A->Add(_slC3_box2);
757         sizerPanel2A->Add(_text_C);
758     // line D2
759         sizerPanel2A->Add(text_space2);
760         sizerPanel2A->Add(text_D);
761         sizerPanel2A->Add(_slD2_box2);
762         sizerPanel2A->Add(_slD3_box2);
763         sizerPanel2A->Add(_text_D);
764
765
766     wxFlexGridSizer *sizerPanel2B = new wxFlexGridSizer(5);
767     // line A1
768         sizerPanel2B->Add(text_space2);
769         sizerPanel2B->Add(_btnA);
770         sizerPanel2B->Add(_slA1_box2);
771         sizerPanel2B->Add(_chkA_box2);
772         sizerPanel2B->Add(_chkAA_box2);
773     // line B1
774         sizerPanel2B->Add(text_space2);
775         sizerPanel2B->Add(_btnB);
776         sizerPanel2B->Add(_slB1_box2);
777         sizerPanel2B->Add(_chkB_box2);
778         sizerPanel2B->Add(_chkBB_box2);
779     // line C1
780         sizerPanel2B->Add(text_space2);
781         sizerPanel2B->Add(_btnC);
782         sizerPanel2B->Add(_slC1_box2);
783         sizerPanel2B->Add(_chkC_box2);
784         sizerPanel2B->Add(_chkCC_box2);
785     // line D1
786         sizerPanel2B->Add(text_space2);
787         sizerPanel2B->Add(_btnD);
788         sizerPanel2B->Add(_slD1_box2);
789         sizerPanel2B->Add(_chkD_box2);
790         sizerPanel2B->Add(_chkDD_box2);
791
792     wxFlexGridSizer *sizerPanel2C = new wxFlexGridSizer(4);
793         sizerPanel2C->Add(_chkViewA_box2);
794         sizerPanel2C->Add(_chkViewB_box2);
795         sizerPanel2C->Add(_chkViewC_box2);
796         sizerPanel2C->Add(_chkViewD_box2);
797
798     wxFlexGridSizer *sizerPanel2D = new wxFlexGridSizer(2);
799         sizerPanel2D->Add(text_space2);
800         sizerPanel2D->Add(_chk1_box1);
801         sizerPanel2D->Add(text_space2);
802         sizerPanel2D->Add(_chk2_box1);
803         sizerPanel2D->Add(text_space2);
804         sizerPanel2D->Add(_chk3_box1);
805
806     wxFlexGridSizer *sizerPanel2 = new wxFlexGridSizer(1);
807         sizerPanel2->Add(sizerPanel2A);
808         sizerPanel2->Add(text_space2);
809         sizerPanel2->Add(sizerPanel2C);
810         sizerPanel2->Add(text_space2);
811         sizerPanel2->Add(sizerPanel2D);
812         sizerPanel2->Add(text_space2);
813         sizerPanel2->Add(sizerPanel2B);
814
815         panel2->SetSizer(sizerPanel2);
816         panel2->SetAutoLayout(true);
817         panel2->SetSize(350,320);
818
819 // cut1
820         wxPanel *panel3 = new wxPanel(panel,-1);
821         wxStaticText *text_space3 = new wxStaticText(panel3,-1,"    ");
822         _chk_box3 = new wxCheckBox(panel3, -1, "Vis.");
823         _chk_box33 = new wxCheckBox(panel3, -1, "Vis.");
824         _chk_box3->SetValue(true);
825         _chk_box33->SetValue(true);
826     wxFlexGridSizer *sizerPanel3 = new wxFlexGridSizer(3);
827         // line 1
828         sizerPanel3->Add(text_space3);
829         sizerPanel3->Add(_chk_box3);
830         sizerPanel3->Add(_chk_box33);
831         panel3->SetSizer(sizerPanel3);
832         panel3->SetAutoLayout(true);
833         panel3->SetSize(250,100);
834
835 //      _sl1_box3 = new wxSlider( panel3, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
836 //      _sl2_box3 = new wxSlider( panel3, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
837 //      _sl3_box3 = new wxSlider( panel3, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
838 //      wxStaticText *text1_box3 = new wxStaticText(panel3,-1,"A");
839 //      wxStaticText *text2_box3 = new wxStaticText(panel3,-1,"B");
840 //      wxStaticText *text3_box3 = new wxStaticText(panel3,-1,"Dist");
841 //  wxFlexGridSizer *sizerPanel3 = new wxFlexGridSizer(3);
842 //      // line 1
843 //      sizerPanel3->Add(text_space3);
844 //      sizerPanel3->Add(_chk_box3);
845 //      sizerPanel3->Add(text_space3);
846 //      // line 2
847 //      sizerPanel3->Add(text_space3);
848 //      sizerPanel3->Add(text1_box3);
849 //      sizerPanel3->Add(_sl1_box3);
850 //      // line 3
851 //      sizerPanel3->Add(text_space3);
852 //      sizerPanel3->Add(text2_box3);
853 //      sizerPanel3->Add(_sl2_box3);
854 //      // line 4
855 //      sizerPanel3->Add(text_space3);
856 //      sizerPanel3->Add(text3_box3);
857 //      sizerPanel3->Add(_sl3_box3);
858 //      panel3->SetSizer(sizerPanel3);
859 //      panel3->SetAutoLayout(true);
860 //      panel3->SetSize(250,100);
861 //  // cut2
862 //
863 //      wxPanel *panel4 = new wxPanel(panel,-1);
864 //      _chk_box4 = new wxCheckBox(panel4, -1, "Vis.");
865 //      _slA_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
866 //      _slB_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
867 //      _sl1_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
868 //      _sl2_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
869 //      _sl3_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
870 //      _sl4_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
871 //      _sl5_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
872 //      _sl6_box4 = new wxSlider( panel4, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
873 //      wxStaticText *text_space4 = new wxStaticText(panel3,-1,"    ");
874 //      wxStaticText *textA_box4 = new wxStaticText(panel4,-1,"A");
875 //      wxStaticText *textB_box4 = new wxStaticText(panel4,-1,"B");
876 //      wxStaticText *text1_box4 = new wxStaticText(panel4,-1,"D1");
877 //      wxStaticText *text2_box4 = new wxStaticText(panel4,-1,"D2");
878 //      wxStaticText *text3_box4 = new wxStaticText(panel4,-1,"D3");
879 //      wxStaticText *text4_box4 = new wxStaticText(panel4,-1,"D4");
880 //      wxStaticText *text5_box4 = new wxStaticText(panel4,-1,"D5");
881 //      wxStaticText *text6_box4 = new wxStaticText(panel4,-1,"D6");
882 //  wxFlexGridSizer *sizerPanel4 = new wxFlexGridSizer(3);
883 //      // line 1
884 //      sizerPanel4->Add(text_space4);
885 //      sizerPanel4->Add(_chk_box4);
886 //      sizerPanel4->Add(text_space4);
887 //      // line 2
888 //      sizerPanel4->Add(text_space4);
889 //      sizerPanel4->Add(textA_box4);
890 //      sizerPanel4->Add(_slA_box4);
891 //      // line 3
892 //      sizerPanel4->Add(text_space4);
893 //      sizerPanel4->Add(textB_box4);
894 //      sizerPanel4->Add(_slB_box4);
895 //      // line 4
896 //      sizerPanel4->Add(text_space4);
897 //      sizerPanel4->Add(text1_box4);
898 //      sizerPanel4->Add(_sl1_box4);
899 //      // line 5
900 //      sizerPanel4->Add(text_space4);
901 //      sizerPanel4->Add(text2_box4);
902 //      sizerPanel4->Add(_sl2_box4);
903 //      // line 6
904 //      sizerPanel4->Add(text_space4);
905 //      sizerPanel4->Add(text3_box4);
906 //      sizerPanel4->Add(_sl3_box4);
907 //      // line 7
908 //      sizerPanel4->Add(text_space4);
909 //      sizerPanel4->Add(text4_box4);
910 //      sizerPanel4->Add(_sl4_box4);
911 //      // line 8
912 //      sizerPanel4->Add(text_space4);
913 //      sizerPanel4->Add(text5_box4);
914 //      sizerPanel4->Add(_sl5_box4);
915 //      // line 9
916 //      sizerPanel4->Add(text_space4);
917 //      sizerPanel4->Add(text6_box4);
918 //      sizerPanel4->Add(_sl6_box4);
919 //      //
920 //      panel4->SetSizer(sizerPanel4);
921 //      panel4->SetAutoLayout(true);
922 //      panel4->SetSize(250,300);
923
924
925
926 // All
927     wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
928
929         sizer->Add(new wxStaticText(panel,-1,"Position") );
930         sizer->Add(panel1);
931         sizer->Add(new wxStaticText(panel,-1,"Layer") );
932         sizer->Add(panel2);
933         sizer->Add(new wxStaticText(panel,-1,"Cut 1") );
934         sizer->Add(panel3);
935 //      sizer->Add(new wxStaticText(panel,-1,"Cut 2") );
936 //      sizer->Add(panel4);
937
938         panel->SetSizer(sizer);
939         panel->SetAutoLayout(true);
940         panel->SetSize(350,750);
941
942
943         // Position 
944         Connect(_sl1_box1->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnPositionX );
945         Connect(_sl2_box1->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnPositionY );
946         Connect(_sl3_box1->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnPositionZ );
947         Connect(_chk1_box1->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleX );
948         Connect(_chk2_box1->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleY );
949         Connect(_chk3_box1->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleZ );
950  
951
952         // Opacity
953         Connect(_slA1_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE   , (wxObjectEventFunction) &wxSurfaceMPR::OnOpacity0 );
954         Connect(_slB1_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE   , (wxObjectEventFunction) &wxSurfaceMPR::OnOpacity1 );
955         Connect(_slC1_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE   , (wxObjectEventFunction) &wxSurfaceMPR::OnOpacity2 );
956         Connect(_slD1_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE   , (wxObjectEventFunction) &wxSurfaceMPR::OnOpacity3 );
957         Connect(_btnA->GetId()       , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxSurfaceMPR::OnBtnColourA );
958         Connect(_btnB->GetId()       , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxSurfaceMPR::OnBtnColourB );
959         Connect(_btnC->GetId()       , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxSurfaceMPR::OnBtnColourC );
960         Connect(_btnD->GetId()       , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxSurfaceMPR::OnBtnColourD );
961
962
963
964         // Isovalue
965         Connect(_slA2_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue0 );
966         Connect(_slA3_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue0 );
967         Connect(_slB2_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue1 );
968         Connect(_slB3_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue1 );
969         Connect(_slC2_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue2 );
970         Connect(_slC3_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue2 );
971         Connect(_slD2_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue3 );
972         Connect(_slD3_box2->GetId()  , wxEVT_SCROLL_THUMBRELEASE  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue3 );
973         Connect(_slA2_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_0 );
974         Connect(_slA3_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_0 );
975         Connect(_slB2_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_1 );
976         Connect(_slB3_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_1 );
977         Connect(_slC2_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_2 );
978         Connect(_slC3_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_2 );
979         Connect(_slD2_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_3 );
980         Connect(_slD3_box2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSurfaceMPR::OnIsoValue_3 );
981
982         Connect(_chkA_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueA );
983         Connect(_chkB_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueB );
984         Connect(_chkC_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueC );
985         Connect(_chkD_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueD );
986         Connect(_chkAA_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueA );
987         Connect(_chkBB_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueB );
988         Connect(_chkCC_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueC );
989         Connect(_chkDD_box2->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleTissueD );
990
991         Connect(_chk_box3->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleVolume );
992         Connect(_chk_box33->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxSurfaceMPR::OnVisibleVolume );
993
994         return panel;
995 }
996
997
998 */
999
1000
1001 /*
1002
1003 //------------------------------------------------------------------------
1004
1005 void wxSurfaceMPR::Refresh(){
1006         _vtkmprview[0]->Refresh();
1007         _vtkmprview[1]->Refresh();
1008         _vtkmprview[2]->Refresh();
1009         _vtkmprview[3]->Refresh();
1010 }
1011
1012
1013 //------------------------------------------------------------------------
1014 void wxSurfaceMPR::OnPositionX(wxScrollEvent& event){
1015         _vtkmpr3Ddata->SetPositionX( _sl1_box1->GetValue() );
1016     Refresh();
1017 }
1018 //------------------------------------------------------------------------
1019 void wxSurfaceMPR::OnPositionY(wxScrollEvent& event){
1020         _vtkmpr3Ddata->SetPositionY( _sl2_box1->GetValue() );
1021     Refresh();
1022 }
1023 //------------------------------------------------------------------------
1024 void wxSurfaceMPR::OnPositionZ(wxScrollEvent& event){
1025         _vtkmpr3Ddata->SetPositionZ( _sl3_box1->GetValue() );
1026     Refresh();
1027 }
1028 //------------------------------------------------------------------------
1029 void wxSurfaceMPR::OpacityTissue(int idView, int idTissue, int opacity){
1030         vtkActor *tmpActor;
1031         tmpActor = _vtkmprview[ idView ]->GetTissueActor(idTissue);
1032         tmpActor->GetProperty()->SetOpacity((float) opacity/100 );
1033         _vtkmprview[idView]->Refresh();
1034 }
1035 //------------------------------------------------------------------------
1036 void wxSurfaceMPR::OnOpacity0(wxScrollEvent& event){
1037         int opacity = _slA1_box2->GetValue();
1038         if (_chkViewA_box2->GetValue()==true){OpacityTissue(0,0, opacity ); }
1039         if (_chkViewB_box2->GetValue()==true){OpacityTissue(1,0, opacity ); }
1040         if (_chkViewC_box2->GetValue()==true){OpacityTissue(2,0, opacity ); }
1041         if (_chkViewD_box2->GetValue()==true){OpacityTissue(3,0, opacity ); }
1042 }
1043 //------------------------------------------------------------------------
1044 void wxSurfaceMPR::OnOpacity1(wxScrollEvent& event){
1045         int opacity = _slB1_box2->GetValue();
1046         if (_chkViewA_box2->GetValue()==true){OpacityTissue(0,1, opacity ); }
1047         if (_chkViewB_box2->GetValue()==true){OpacityTissue(1,1, opacity ); }
1048         if (_chkViewC_box2->GetValue()==true){OpacityTissue(2,1, opacity ); }
1049         if (_chkViewD_box2->GetValue()==true){OpacityTissue(3,1, opacity ); }
1050 }
1051 //------------------------------------------------------------------------
1052 void wxSurfaceMPR::OnOpacity2(wxScrollEvent& event){
1053         int opacity = _slC1_box2->GetValue();
1054         if (_chkViewA_box2->GetValue()==true){OpacityTissue(0,2, opacity ); }
1055         if (_chkViewB_box2->GetValue()==true){OpacityTissue(1,2, opacity ); }
1056         if (_chkViewC_box2->GetValue()==true){OpacityTissue(2,2, opacity ); }
1057         if (_chkViewD_box2->GetValue()==true){OpacityTissue(3,2, opacity ); }
1058 }
1059 //------------------------------------------------------------------------
1060 void wxSurfaceMPR::OnOpacity3(wxScrollEvent& event){
1061         int opacity = _slD1_box2->GetValue();
1062         if (_chkViewA_box2->GetValue()==true){OpacityTissue(0,3, opacity ); }
1063         if (_chkViewB_box2->GetValue()==true){OpacityTissue(1,3, opacity ); }
1064         if (_chkViewC_box2->GetValue()==true){OpacityTissue(2,3, opacity ); }
1065         if (_chkViewD_box2->GetValue()==true){OpacityTissue(3,3, opacity ); }
1066 }
1067 //------------------------------------------------------------------------
1068 void wxSurfaceMPR::OnIsoValue0(wxScrollEvent& event){
1069         int isoValue=_slA2_box2->GetValue() * 50 + _slA3_box2->GetValue();
1070         _vtkmpr3Ddata->SetIsovalue(0,isoValue);
1071         wxString tmpStr;
1072         tmpStr.Printf("%d",isoValue);
1073         _text_A->SetLabel(tmpStr);
1074     Refresh();
1075 }
1076 //------------------------------------------------------------------------
1077 void wxSurfaceMPR::OnIsoValue1(wxScrollEvent& event){
1078         int isoValue=_slB2_box2->GetValue() * 50 + _slB3_box2->GetValue();
1079         _vtkmpr3Ddata->SetIsovalue(1,isoValue);
1080         wxString tmpStr;
1081         tmpStr.Printf("%d",isoValue);
1082         _text_B->SetLabel(tmpStr);
1083     Refresh();
1084 }
1085 //------------------------------------------------------------------------
1086 void wxSurfaceMPR::OnIsoValue2(wxScrollEvent& event){
1087         int isoValue=_slC2_box2->GetValue() * 50 + _slC3_box2->GetValue();
1088         _vtkmpr3Ddata->SetIsovalue(2,isoValue);
1089         wxString tmpStr;
1090         tmpStr.Printf("%d",isoValue);
1091         _text_C->SetLabel(tmpStr);
1092     Refresh();
1093 }
1094 //------------------------------------------------------------------------
1095 void wxSurfaceMPR::OnIsoValue3(wxScrollEvent& event){
1096         int isoValue=_slD2_box2->GetValue() * 50 + _slD3_box2->GetValue();
1097         _vtkmpr3Ddata->SetIsovalue(3,isoValue);
1098         wxString tmpStr;
1099         tmpStr.Printf("%d",isoValue);
1100         _text_D->SetLabel(tmpStr);
1101     Refresh();
1102 }
1103
1104
1105
1106 //------------------------------------------------------------------------
1107 void wxSurfaceMPR::OnIsoValue_0(wxScrollEvent& event){
1108         int isoValue=_slA2_box2->GetValue() * 50 + _slA3_box2->GetValue();
1109         wxString tmpStr;
1110         tmpStr.Printf("%d",isoValue);
1111         _text_A->SetLabel(tmpStr);
1112 }
1113 //------------------------------------------------------------------------
1114 void wxSurfaceMPR::OnIsoValue_1(wxScrollEvent& event){
1115         int isoValue=_slB2_box2->GetValue() * 50 + _slB3_box2->GetValue();
1116         wxString tmpStr;
1117         tmpStr.Printf("%d",isoValue);
1118         _text_B->SetLabel(tmpStr);
1119 }
1120 //------------------------------------------------------------------------
1121 void wxSurfaceMPR::OnIsoValue_2(wxScrollEvent& event){
1122         int isoValue=_slC2_box2->GetValue() * 50 + _slC3_box2->GetValue();
1123         wxString tmpStr;
1124         tmpStr.Printf("%d",isoValue);
1125         _text_C->SetLabel(tmpStr);
1126 }
1127 //------------------------------------------------------------------------
1128 void wxSurfaceMPR::OnIsoValue_3(wxScrollEvent& event){
1129         int isoValue=_slD2_box2->GetValue() * 50 + _slD3_box2->GetValue();
1130         wxString tmpStr;
1131         tmpStr.Printf("%d",isoValue);
1132         _text_D->SetLabel(tmpStr);
1133 }
1134
1135
1136 //------------------------------------------------------------------------
1137 void wxSurfaceMPR::OnBtnColourA(wxCommandEvent& event){
1138   wxColourDialog dlgColour(this);
1139   dlgColour.ShowModal();
1140 }
1141 //------------------------------------------------------------------------
1142 void wxSurfaceMPR::OnBtnColourB(wxCommandEvent& event){
1143   wxColourDialog dlgColour(this);
1144   dlgColour.ShowModal();
1145 }
1146 //------------------------------------------------------------------------
1147 void wxSurfaceMPR::OnBtnColourC(wxCommandEvent& event){
1148   wxColourDialog dlgColour(this);
1149   dlgColour.ShowModal();
1150 }
1151 //------------------------------------------------------------------------
1152 void wxSurfaceMPR::OnBtnColourD(wxCommandEvent& event){
1153   wxColourDialog dlgColour(this);
1154   dlgColour.ShowModal();
1155 }
1156 //------------------------------------------------------------------------
1157 void wxSurfaceMPR::VisibleActor(int idView, int idTissue, bool visTissue, bool visGuide){
1158         _vtkmprview[idView]->VisibleActor(idTissue, visTissue, visGuide);
1159         _vtkmprview[idView]->Refresh();
1160 }
1161 //------------------------------------------------------------------------
1162 void wxSurfaceMPR::VisibleImageActor(int idView, int idTissue, bool visible){
1163         _vtkmprview[idView]->VisibleImageActor(idTissue, visible);
1164         _vtkmprview[idView]->Refresh();
1165 }
1166 //------------------------------------------------------------------------
1167 void wxSurfaceMPR::OnVisibleX(wxCommandEvent& event){
1168         bool visible = _chk1_box1->GetValue();
1169         if (_chkViewA_box2->GetValue()==true){VisibleImageActor(0,0, visible ); }
1170         if (_chkViewB_box2->GetValue()==true){VisibleImageActor(1,0, visible ); }
1171         if (_chkViewC_box2->GetValue()==true){VisibleImageActor(2,0, visible ); }
1172         if (_chkViewD_box2->GetValue()==true){VisibleImageActor(3,0, visible ); }
1173 }
1174 //------------------------------------------------------------------------
1175 void wxSurfaceMPR::OnVisibleY(wxCommandEvent& event){
1176         bool visible = _chk2_box1->GetValue();
1177         if (_chkViewA_box2->GetValue()==true){VisibleImageActor(0,1, visible ); }
1178         if (_chkViewB_box2->GetValue()==true){VisibleImageActor(1,1, visible ); }
1179         if (_chkViewC_box2->GetValue()==true){VisibleImageActor(2,1, visible ); }
1180         if (_chkViewD_box2->GetValue()==true){VisibleImageActor(3,1, visible ); }
1181 }
1182 //------------------------------------------------------------------------
1183 void wxSurfaceMPR::OnVisibleZ(wxCommandEvent& event){
1184         bool visible = _chk3_box1->GetValue();
1185         if (_chkViewA_box2->GetValue()==true){VisibleImageActor(0,2, visible ); }
1186         if (_chkViewB_box2->GetValue()==true){VisibleImageActor(1,2, visible ); }
1187         if (_chkViewC_box2->GetValue()==true){VisibleImageActor(2,2, visible ); }
1188         if (_chkViewD_box2->GetValue()==true){VisibleImageActor(3,2, visible ); }
1189 }
1190 //------------------------------------------------------------------------
1191 void wxSurfaceMPR::OnVisibleTissueA(wxCommandEvent& event){
1192         bool visiTissue = _chkA_box2->GetValue();
1193         bool visGuide = _chkAA_box2->GetValue();
1194         if (_chkViewA_box2->GetValue()==true){VisibleActor(0,0, visiTissue, visGuide ); }
1195         if (_chkViewB_box2->GetValue()==true){VisibleActor(1,0, visiTissue, visGuide ); }
1196         if (_chkViewC_box2->GetValue()==true){VisibleActor(2,0, visiTissue, visGuide ); }
1197         if (_chkViewD_box2->GetValue()==true){VisibleActor(3,0, visiTissue, visGuide ); }
1198 }
1199 //------------------------------------------------------------------------
1200 void wxSurfaceMPR::OnVisibleTissueB(wxCommandEvent& event){
1201         bool visiTissue = _chkA_box2->GetValue();
1202         bool visGuide = _chkAA_box2->GetValue();
1203         if (_chkViewA_box2->GetValue()==true){VisibleActor(0,1, visiTissue, visGuide ); }
1204         if (_chkViewB_box2->GetValue()==true){VisibleActor(1,1, visiTissue, visGuide ); }
1205         if (_chkViewC_box2->GetValue()==true){VisibleActor(2,1, visiTissue, visGuide ); }
1206         if (_chkViewD_box2->GetValue()==true){VisibleActor(3,1, visiTissue, visGuide ); }
1207 }
1208 //------------------------------------------------------------------------
1209 void wxSurfaceMPR::OnVisibleTissueC(wxCommandEvent& event){
1210         bool visiTissue = _chkA_box2->GetValue();
1211         bool visGuide = _chkAA_box2->GetValue();
1212         if (_chkViewA_box2->GetValue()==true){VisibleActor(0,2, visiTissue, visGuide ); }
1213         if (_chkViewB_box2->GetValue()==true){VisibleActor(1,2, visiTissue, visGuide ); }
1214         if (_chkViewC_box2->GetValue()==true){VisibleActor(2,2, visiTissue, visGuide ); }
1215         if (_chkViewD_box2->GetValue()==true){VisibleActor(3,2, visiTissue, visGuide ); }
1216 }
1217 //------------------------------------------------------------------------
1218 void wxSurfaceMPR::OnVisibleTissueD(wxCommandEvent& event){
1219         bool visiTissue = _chkA_box2->GetValue();
1220         bool visGuide = _chkAA_box2->GetValue();
1221         if (_chkViewA_box2->GetValue()==true){VisibleActor(0,3, visiTissue, visGuide ); }
1222         if (_chkViewB_box2->GetValue()==true){VisibleActor(1,3, visiTissue, visGuide ); }
1223         if (_chkViewC_box2->GetValue()==true){VisibleActor(2,3, visiTissue, visGuide ); }
1224         if (_chkViewD_box2->GetValue()==true){VisibleActor(3,3, visiTissue, visGuide ); }
1225 }
1226 //------------------------------------------------------------------------
1227 void wxSurfaceMPR::VisibleVolumeActor(int idView, bool visVolume, bool visGuide){
1228         _vtkmprview[idView]->VisibleVolumeActor( visVolume,visGuide);
1229         _vtkmprview[idView]->Refresh();
1230 }
1231 //------------------------------------------------------------------------
1232 void wxSurfaceMPR::OnVisibleVolume(wxCommandEvent& event){
1233         bool visVolume = _chk_box3->GetValue();
1234         bool visGuide = _chk_box33->GetValue();
1235         if (_chkViewA_box2->GetValue()==true){VisibleVolumeActor(0, visVolume, visGuide); }
1236         if (_chkViewB_box2->GetValue()==true){VisibleVolumeActor(1, visVolume, visGuide); }
1237         if (_chkViewC_box2->GetValue()==true){VisibleVolumeActor(2, visVolume, visGuide); }
1238         if (_chkViewD_box2->GetValue()==true){VisibleVolumeActor(3, visVolume, visGuide); }
1239 }
1240
1241 //------------------------------------------------------------------------
1242 void wxSurfaceMPR::ConfigureVTK(){
1243         _vtkmprview[0]->Configure();
1244         _vtkmprview[1]->Configure();
1245         _vtkmprview[2]->Configure();
1246         _vtkmprview[3]->Configure();
1247 }
1248
1249
1250 */