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