]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuViewerMPR.cxx
#3093 creaMaracasVisu Feature New Normal - Contour Information in pixels and image...
[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 );     
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   {
69           wxwidget->setImageData(img);
70   }
71
72   void wxWidgetMPR::ConfigureVTK()
73   {
74                 wxwidget->ConfigureVTK();
75   }
76
77 //--------------------------------------------------------------------------
78   wxWidgetMPR::~wxWidgetMPR()
79   {
80
81   }
82 //--------------------------------------------------------------------------
83   /*
84         Getting the point
85   */
86   std::vector<int> wxWidgetMPR::GetPoint()
87   {
88           return point;
89   }
90   /*
91         Getting the render
92   */
93   vtkRenderer* wxWidgetMPR::GetRenderer()
94   {
95         if(wxwidget!=NULL)      
96         {
97                 return  wxwidget->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
98         }
99         else
100         {
101                 return NULL;
102         }
103 }
104         
105 //--------------------------------------------------------------------------
106   void wxWidgetMPR::Refresh()
107   { 
108           wxwidget->RefreshView();
109   }
110
111 //--------------------------------------------------------------------------
112   //---------------
113   //Handling events
114   //---------------
115   void wxWidgetMPR::OnRefreshView(wxCommandEvent &event)
116   {
117   printf("EED wxWidgetMPR::OnRefreshView 01\n");
118           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
119           {
120                   printf("EED wxWidgetMPR::OnRefreshView 02\n");
121             point.clear();
122                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
123                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
124                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
125                 mbbViewerMPR->bbSetOutputPoint( GetPoint() );
126                 mbbViewerMPR->bbSignalOutputModification(std::string("Point"));    
127                 wxwidget->RefreshView();
128           }
129   }
130
131 //--------------------------------------------------------------------------
132   void wxWidgetMPR::OnDClickLeft(wxCommandEvent & event) 
133   {
134         wxwidget->RefreshView();
135   }
136
137 //--------------------------------------------------------------------------
138 //--------------------------------------------------------------------------
139 //--------------------------------------------------------------------------
140
141
142
143
144
145
146
147
148 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerMPR)
149 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerMPR,bbtk::WxBlackBox);
150 void ViewerMPR::Process()
151 {
152         if (wxwidget!=NULL){
153                 wxBusyCursor wait;         
154                 vtkImageData* img = bbGetInputIn();
155                 if(img!=NULL && img != _img){
156                         _img = img;
157                         wxwidget->setImageData(_img);
158                         wxwidget->ConfigureVTK();
159                         
160 //                      wxwidget->wxPanel::Refresh();
161                         wxwidget->Refresh();
162 //                      wxwidget->Show();
163
164                 }       
165                         
166                 
167                 bbSetOutputPoint( wxwidget->GetPoint() );
168                 bbSetOutputRenderer( wxwidget->GetRenderer() );  
169         } // wxwidget
170 }
171
172 void ViewerMPR::CreateWidget(wxWindow* parent)
173 {
174         bbtkDebugMessageInc("Core",9,"ViewerMPR::CreateWidget() " <<std::endl);
175         //JCP 10 - 03 - 09 marImageData *marimagedata = new marImageData(bbGetInputIn() );
176         bbtkDebugDecTab("Core",9);
177         wxwidget = new wxWidgetMPR(this , parent);//JCP  10 - 03 - 09,marimagedata);
178         bbSetOutputWidget( wxwidget );
179 }
180
181 void ViewerMPR::bbUserSetDefaultValues()
182 {               
183                 _img = NULL;
184                 wxwidget = NULL;
185                 bbSetInputIn(NULL);
186 }
187
188         
189         //-----------------------------------------------------------------     
190         void ViewerMPR::bbUserInitializeProcessing()
191         {
192         }
193         
194         //-----------------------------------------------------------------     
195         void ViewerMPR::bbUserFinalizeProcessing()
196         {
197         }
198         
199         //-----------------------------------------------------------------     
200         
201 }
202 // EO namespace bbcreaMaracasVisu
203
204