]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuViewerNV.cxx
bdce092c9dd96fa61f88503c2ae4ecdf6d9aec48
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuViewerNV.cxx
1 #include "bbmaracasvisuViewerNV.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 namespace bbcreaMaracasVisu
4 {
5
6
7 BEGIN_EVENT_TABLE( bbwxMaracas_N_ViewersWidget, wxPanel )
8         EVT_MENU( 12121, bbwxMaracas_N_ViewersWidget::OnRefreshView )
9         EVT_MENU( 12122, bbwxMaracas_N_ViewersWidget::OnDClickLeft  )
10 END_EVENT_TABLE( );
11
12
13 //-------------------------------------------------------------
14 //-------------------------------------------------------------
15 //-------------------------------------------------------------
16
17 bbwxMaracas_N_ViewersWidget::bbwxMaracas_N_ViewersWidget(ViewerNV* box,
18                                                                                                                  wxWindow *parent, 
19                                                                                                                  vtkImageData* imagedata, 
20                                                                                                                  std::vector<int> *nTypeView)
21 :wxMaracas_N_ViewersWidget(parent,imagedata,nTypeView)
22 {
23         mbbViewerNV=box;
24 }
25
26 //-------------------------------------------------------------
27 bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget()
28 {
29 }
30             
31 //-------------------------------------------------------------
32 void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
33 {
34         wxMaracas_N_ViewersWidget::OnRefreshView(event);
35         mbbViewerNV->bbSignalOutputModification(std::string("Point"));    
36
37 }
38
39 //-------------------------------------------------------------
40 void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
41 {
42         wxMaracas_N_ViewersWidget::OnDClickLeft(event);
43         mbbViewerNV->bbSignalOutputModification(std::string("Point"));    
44 }
45
46 //-------------------------------------------------------------
47 //-------------------------------------------------------------
48 //-------------------------------------------------------------
49
50
51
52
53 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerNV)
54 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox);
55 //-------------------------------------------------------------
56 void ViewerNV::Process()
57 {       
58
59         vtkImageData* img = bbGetInputIn();
60         std::vector<int> type = bbGetInputnTypeView();
61         
62         if(img != NULL && mwxwidget != NULL){// && !enter){
63                 
64                 if(!compareVectors(type, currenttype)){
65                         mwxwidget->SetType(&type);
66                         mwxwidget->UpdateLayout(img);
67                 }else if (img != currentimg){           
68                         mwxwidget->SetImage(img);
69                 }
70                 currenttype = type;
71                 currentimg = img;
72                 
73
74                 point.clear();
75                 point.push_back((int)mwxwidget->GetX());
76                 point.push_back((int)mwxwidget->GetY());
77                 point.push_back((int)mwxwidget->GetZ());
78                 bbSetOutputPoint(point);
79
80         //    WxBlackBox::Process(); 
81 //              mwxwidget->SetImage(img );
82                 wxVtkBaseView *wvbv1 = mwxwidget->GetwxVtkBaseView(1);
83                 wxVtkBaseView *wvbv2 = mwxwidget->GetwxVtkBaseView(2);
84                 wxVtkBaseView *wvbv3 = mwxwidget->GetwxVtkBaseView(3);
85                 wxVtkBaseView *wvbv4 = mwxwidget->GetwxVtkBaseView(4);
86
87                 //wxwidget->RefreshView();
88
89                 bbSetOutputwxVtkBaseView1( wvbv1 );
90                 bbSetOutputwxVtkBaseView2( wvbv2 );
91                 bbSetOutputwxVtkBaseView3( wvbv3 );
92                 bbSetOutputwxVtkBaseView4( wvbv4 );
93                 if (wvbv1!=NULL) { bbSetOutputRenderer1( wvbv1->GetRenderer() ); }
94                 if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
95                 if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
96                 if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
97         }       
98 }
99
100 //-------------------------------------------------------------
101 void ViewerNV::CreateWidget(wxWindow* parent)
102 {
103     bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
104         mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );    
105         bbtkDebugDecTab("Core",9);
106     bbSetOutputWidget( mwxwidget );     
107
108         
109         this->bbSignalOutputModification();
110         //Process();
111 }
112
113 //-------------------------------------------------------------
114 void ViewerNV::bbUserConstructor()
115 {
116
117                 mwxwidget = NULL;
118                 bbSetInputIn(NULL);
119
120                 std::vector<int> vecNTypeViwer;
121                 vecNTypeViwer.push_back(5);
122                 vecNTypeViwer.push_back(0);
123                 vecNTypeViwer.push_back(1);
124                 vecNTypeViwer.push_back(3);
125                 bbSetInputnTypeView(vecNTypeViwer);
126
127
128                 bbSetOutputwxVtkBaseView1( NULL );
129                 bbSetOutputwxVtkBaseView2( NULL );
130                 bbSetOutputwxVtkBaseView3( NULL );
131                 bbSetOutputwxVtkBaseView4( NULL );
132                 bbSetOutputRenderer1( NULL );
133                 bbSetOutputRenderer2( NULL );
134                 bbSetOutputRenderer3( NULL );
135                 bbSetOutputRenderer4( NULL );
136 }
137
138 //-------------------------------------------------------------
139 void ViewerNV::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
140 {
141
142                 mwxwidget = NULL;
143                 
144 }
145
146 //-------------------------------------------------------------
147 void ViewerNV::bbUserDestructor()
148 {
149 std::cout << "ViewerNV destroy "<<this<<" vs "<<GetThisPointer<void>()<<std::endl;
150
151 }
152
153 bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> currenttype){
154
155         bool ret = true;
156
157         if(type.size()==currenttype.size()){
158                 for(int i = 0; i < type.size() && ret; i++){
159                         if(type[i]!=currenttype[i]){
160                                 ret = false;
161                         }
162                 }
163         }else{
164                 ret=false;
165         }
166         return ret;
167
168
169 }
170
171 }
172 // EO namespace bbcreaMaracasVisu
173
174