]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuViewerMPR.cxx
BUG MACOS
[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::setMarImage(marImageData* marimagedata){
44           wxwidget->setMarImage(marimagedata, 1);
45
46
47   }
48   void wxWidgetMPR::ConfigureVTK(){
49                 wxwidget->ConfigureVTK();
50         }
51 //--------------------------------------------------------------------------
52   wxWidgetMPR::~wxWidgetMPR()
53   {
54
55   }
56 //--------------------------------------------------------------------------
57   /*
58         Getting the point
59   */
60   std::vector<int> wxWidgetMPR::GetPoint()
61   {
62           return point;
63   }
64   /*
65         Getting the render
66   */
67   vtkRenderer* wxWidgetMPR::GetRenderer()
68   {
69         if(wxwidget!=NULL)      
70         {
71                 return  wxwidget->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
72         }
73         else
74         {
75                 return NULL;
76         }
77 }
78         
79 //--------------------------------------------------------------------------
80   void wxWidgetMPR::Refresh()
81   { 
82           wxwidget->RefreshView();
83   }
84
85 //--------------------------------------------------------------------------
86   //---------------
87   //Handling events
88   //---------------
89   void wxWidgetMPR::OnRefreshView(wxCommandEvent &event)
90   {
91
92           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
93           {
94             point.clear();
95                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
96                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
97                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
98                 mbbViewerMPR->bbSetOutputPoint( GetPoint() );
99                 mbbViewerMPR->bbSignalOutputModification(std::string("Point"));    
100                 wxwidget->RefreshView();
101           }
102   }
103
104 //--------------------------------------------------------------------------
105   void wxWidgetMPR::OnDClickLeft(wxCommandEvent & event) 
106   {
107         wxwidget->RefreshView();
108   }
109
110 //--------------------------------------------------------------------------
111 //--------------------------------------------------------------------------
112 //--------------------------------------------------------------------------
113
114
115
116
117
118
119
120
121 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerMPR)
122 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerMPR,bbtk::WxBlackBox);
123 void ViewerMPR::Process()
124 {
125 printf("EED ViewerMPR::Process 01\n");  
126         if (wxwidget!=NULL){
127                 wxBusyCursor wait;         
128                 if(marimagedata==NULL){
129                         wxwidget->setMarImage(new marImageData(bbGetInputIn() ));
130                         wxwidget->ConfigureVTK();
131                         
132                         
133 printf("EED ViewerMPR::Process 02\n");  
134                         wxwidget->wxPanel::Refresh();
135                         wxwidget->Show();
136 //                      wxwidget->Refresh();
137                 }
138                 bbSetOutputPoint( wxwidget->GetPoint() );
139                 bbSetOutputRenderer( wxwidget->GetRenderer() );  
140         } // wxwidget
141 }
142
143 void ViewerMPR::CreateWidget(wxWindow* parent)
144 {
145 printf("EED ViewerMPR::CreateWidget \n");       
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::bbUserConstructor()
154 {
155                 marimagedata =  NULL;
156                 wxwidget = NULL;
157                 bbSetInputIn(NULL);
158 }
159 void ViewerMPR::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
160 {
161
162         marimagedata =  NULL;
163                 wxwidget = NULL;
164                 bbSetInputIn(NULL);
165
166 }
167 void ViewerMPR::bbUserDestructor()
168 {
169
170 }
171 }
172 // EO namespace bbcreaMaracasVisu
173
174