]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuViewerMPR.cxx
.
[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
90           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
91           {
92             point.clear();
93                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
94                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
95                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
96                 mbbViewerMPR->bbSetOutputPoint( GetPoint() );
97                 mbbViewerMPR->bbSignalOutputModification(std::string("Point"));    
98                 wxwidget->RefreshView();
99           }
100   }
101
102 //--------------------------------------------------------------------------
103   void wxWidgetMPR::OnDClickLeft(wxCommandEvent & event) 
104   {
105         wxwidget->RefreshView();
106   }
107
108 //--------------------------------------------------------------------------
109 //--------------------------------------------------------------------------
110 //--------------------------------------------------------------------------
111
112
113
114
115
116
117
118
119 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerMPR)
120 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerMPR,bbtk::WxBlackBox);
121 void ViewerMPR::Process()
122 {
123         if (wxwidget!=NULL){
124                 wxBusyCursor wait;         
125                 vtkImageData* img = bbGetInputIn();
126                 if(img!=NULL && img != _img){
127                         _img = img;
128                         wxwidget->setImageData(_img);
129                         wxwidget->ConfigureVTK();
130                         
131 //                      wxwidget->wxPanel::Refresh();
132                         wxwidget->Refresh();
133 //                      wxwidget->Show();
134
135                 }       
136                         
137                 
138                 bbSetOutputPoint( wxwidget->GetPoint() );
139                 bbSetOutputRenderer( wxwidget->GetRenderer() );  
140         } // wxwidget
141 }
142
143 void ViewerMPR::CreateWidget(wxWindow* parent)
144 {
145         bbtkDebugMessageInc("Core",9,"ViewerMPR::CreateWidget() " <<std::endl);
146         //JCP 10 - 03 - 09 marImageData *marimagedata = new marImageData(bbGetInputIn() );
147         bbtkDebugDecTab("Core",9);
148         wxwidget = new wxWidgetMPR(this , parent);//JCP  10 - 03 - 09,marimagedata);
149         bbSetOutputWidget( wxwidget );
150 }
151
152 void ViewerMPR::bbUserSetDefaultValues()
153 {               
154                 _img = NULL;
155                 wxwidget = NULL;
156                 bbSetInputIn(NULL);
157 }
158
159         
160         //-----------------------------------------------------------------     
161         void ViewerMPR::bbUserInitializeProcessing()
162         {
163         }
164         
165         //-----------------------------------------------------------------     
166         void ViewerMPR::bbUserFinalizeProcessing()
167         {
168         }
169         
170         //-----------------------------------------------------------------     
171         
172 }
173 // EO namespace bbcreaMaracasVisu
174
175