]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuViewerMPR.cxx
14b816ec867ca29b400bc91085214f093e8fd5a2
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuViewerMPR.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 "bbmaracasvisuViewerMPR.h"
27 #include "bbcreaMaracasVisuPackage.h"
28 namespace bbcreaMaracasVisu
29 {
30
31 //--------------------------------------------------------------------------
32 //--------------------------------------------------------------------------
33 //--------------------------------------------------------------------------
34
35
36   //--------------------------------------------------------------------------
37   // wxWidgetMPR
38   //--------------------------------------------------------------------------
39 BEGIN_EVENT_TABLE( wxWidgetMPR, wxPanel )
40         EVT_MENU( 12121, wxWidgetMPR::OnRefreshView )
41         EVT_MENU( 12122, wxWidgetMPR::OnDClickLeft  )
42 END_EVENT_TABLE( );
43
44   //-----------
45   //Constructor
46   //-----------
47   wxWidgetMPR::wxWidgetMPR(ViewerMPR* box,wxWindow* parent, marImageData        *marimagedata)
48           : wxPanel( parent, -1 )
49   {
50                 wxPanel *panel  = this;
51                 mbbViewerMPR    = box;
52
53                 
54                 wxwidget = new wxMPRWidget2( panel, marimagedata , 1 ); 
55
56                 if(marimagedata != NULL){
57                         wxwidget->ConfigureVTK();
58                 }
59                 wxFlexGridSizer *sizer=new wxFlexGridSizer(1);
60                 sizer   -> Add( wxwidget,0,wxGROW ); 
61                 sizer   -> AddGrowableCol(1);
62                 panel   -> SetSizer(sizer);
63                 panel   -> SetAutoLayout(true);
64                 panel   -> Layout();            
65   }
66
67   void wxWidgetMPR::setImageData(vtkImageData* img){
68           wxwidget->setImageData(img, 1);
69   }
70   void wxWidgetMPR::ConfigureVTK(){
71                 wxwidget->ConfigureVTK();
72         }
73 //--------------------------------------------------------------------------
74   wxWidgetMPR::~wxWidgetMPR()
75   {
76
77   }
78 //--------------------------------------------------------------------------
79   /*
80         Getting the point
81   */
82   std::vector<int> wxWidgetMPR::GetPoint()
83   {
84           return point;
85   }
86   /*
87         Getting the render
88   */
89   vtkRenderer* wxWidgetMPR::GetRenderer()
90   {
91         if(wxwidget!=NULL)      
92         {
93                 return  wxwidget->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
94         }
95         else
96         {
97                 return NULL;
98         }
99 }
100         
101 //--------------------------------------------------------------------------
102   void wxWidgetMPR::Refresh()
103   { 
104           wxwidget->RefreshView();
105   }
106
107 //--------------------------------------------------------------------------
108   //---------------
109   //Handling events
110   //---------------
111   void wxWidgetMPR::OnRefreshView(wxCommandEvent &event)
112   {
113   printf("EED wxWidgetMPR::OnRefreshView 01\n");
114           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
115           {
116                   printf("EED wxWidgetMPR::OnRefreshView 02\n");
117             point.clear();
118                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
119                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
120                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
121                 mbbViewerMPR->bbSetOutputPoint( GetPoint() );
122                 mbbViewerMPR->bbSignalOutputModification(std::string("Point"));    
123                 wxwidget->RefreshView();
124           }
125   }
126
127 //--------------------------------------------------------------------------
128   void wxWidgetMPR::OnDClickLeft(wxCommandEvent & event) 
129   {
130         wxwidget->RefreshView();
131   }
132
133 //--------------------------------------------------------------------------
134 //--------------------------------------------------------------------------
135 //--------------------------------------------------------------------------
136
137
138
139
140
141
142
143
144 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerMPR)
145 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerMPR,bbtk::WxBlackBox);
146 void ViewerMPR::Process()
147 {
148         if (wxwidget!=NULL){
149                 wxBusyCursor wait;         
150                 vtkImageData* img = bbGetInputIn();
151                 if(img!=NULL && img != _img){
152                         _img = img;
153                         wxwidget->setImageData(_img);
154                         wxwidget->ConfigureVTK();
155                         
156 //                      wxwidget->wxPanel::Refresh();
157                         wxwidget->Refresh();
158 //                      wxwidget->Show();
159
160                 }       
161                         
162                 
163                 bbSetOutputPoint( wxwidget->GetPoint() );
164                 bbSetOutputRenderer( wxwidget->GetRenderer() );  
165         } // wxwidget
166 }
167
168 void ViewerMPR::CreateWidget(wxWindow* parent)
169 {
170         bbtkDebugMessageInc("Core",9,"ViewerMPR::CreateWidget() " <<std::endl);
171         //JCP 10 - 03 - 09 marImageData *marimagedata = new marImageData(bbGetInputIn() );
172         bbtkDebugDecTab("Core",9);
173         wxwidget = new wxWidgetMPR(this , parent);//JCP  10 - 03 - 09,marimagedata);
174         bbSetOutputWidget( wxwidget );
175 }
176
177 void ViewerMPR::bbUserSetDefaultValues()
178 {               
179                 _img = NULL;
180                 wxwidget = NULL;
181                 bbSetInputIn(NULL);
182 }
183
184         
185         //-----------------------------------------------------------------     
186         void ViewerMPR::bbUserInitializeProcessing()
187         {
188         }
189         
190         //-----------------------------------------------------------------     
191         void ViewerMPR::bbUserFinalizeProcessing()
192         {
193         }
194         
195         //-----------------------------------------------------------------     
196         
197 }
198 // EO namespace bbcreaMaracasVisu
199
200