2 #include "wxVtkClipping3DViewCntrlPanel.h"
3 #include "wx/colordlg.h"
4 #include "vtkTriangleFilter.h"
5 #include "vtkPolyDataConnectivityFilter.h"
6 #include "vtkClosePolyData.h"
7 #include "vtkSTLWriter.h"
8 #include "HistogramDialog.h"
9 #include "marDicomBase.h"
11 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
14 wxPanel *panel = this;
15 _wxvtkclipping3Dview = wxvtkclipping3Dview;
18 // wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
19 // wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
21 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
22 _surfB = new wxRadioButton(panel,-1,_T("B"));
23 _surfC = new wxRadioButton(panel,-1,_T("C"));
24 _surfD = new wxRadioButton(panel,-1,_T("D"));
27 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
28 //wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
29 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
31 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
32 //wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
34 _color = new wxButton(panel,-1,_T(""));
35 _visible = new wxCheckBox(panel,-1,_T("Vis"));
36 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
38 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
39 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
42 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
43 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
47 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
48 vtkimagedata->GetScalarRange( range );
49 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
50 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
53 _isoValue->SetTickFreq(25,0);
55 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
56 _isoValueSpin->SetRange(1,8);
57 _isoValueSpin->SetValue(5);
58 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
60 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
61 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
63 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
64 //wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
67 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
68 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
70 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
71 //Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
74 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
75 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
79 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
80 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
81 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
82 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
83 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
84 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
85 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
86 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
87 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
90 // ckVolum->Enable(false);
91 ckBoxSurface->SetValue(false);
94 //ckBoxVolume->SetValue(false);
97 _color->SetSize(40,20);
98 _opacity->SetSize(370,20);
99 // ckBoxX->SetValue(true);
100 // ckBoxY->SetValue(true);
101 // ckBoxZ->SetValue(true);
102 _surfA->SetValue(true);
103 _wireFrameRep->SetValue(false);
104 _surfaceRep->SetValue(true);
105 _visible->SetValue(false);
106 // _positionX->SetSize(400,20);
107 // _positionY->SetSize(400,20);
108 // _positionZ->SetSize(400,20);
110 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
111 //Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
112 //Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
114 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
115 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
116 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
117 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
118 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
120 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
121 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
123 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
124 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
125 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
128 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
129 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
132 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
133 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
134 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
135 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
136 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
137 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
140 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
141 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
142 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
143 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
144 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
145 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
146 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
147 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
149 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
150 //sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
151 //sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
152 //sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
153 //sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
154 //sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
155 //sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
156 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
159 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
160 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
161 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
162 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
163 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
164 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
165 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
166 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
167 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
168 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
169 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
170 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
171 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
174 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
175 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
176 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
177 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
178 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
181 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
182 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
183 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
184 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
186 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
189 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
190 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
191 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
194 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
195 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
196 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
198 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
199 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
200 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
202 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
203 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
204 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
206 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
207 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
208 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
209 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
210 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
211 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
212 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
214 panel->SetSize(300,60);
215 panel->SetAutoLayout(true);
216 panel->SetSizer(sizer);
219 panel->SetEventHandler((wxEvtHandler*)this);
222 //-------------------------------------------------------------------
223 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
226 //-------------------------------------------------------------------
227 void wxVtkClipping3DViewCntrlPanel::Refresh()
229 // wxPanel::Refresh();
231 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
232 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
233 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
236 //-------------------------------------------------------------------
237 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
240 if (_surfA->GetValue()==true)
244 if (_surfB->GetValue()==true)
248 if (_surfC->GetValue()==true)
252 if (_surfD->GetValue()==true)
260 //-------------------------------------------------------------------
261 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
263 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
264 _wxvtkclipping3Dview->Refresh();
266 //-------------------------------------------------------------------
267 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
269 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
270 _wxvtkclipping3Dview->Refresh();
272 //-------------------------------------------------------------------
273 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
275 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
276 _wxvtkclipping3Dview->Refresh();
280 //-------------------------------------------------------------------
281 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
283 int idTissue=GetIdTissue();
288 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
290 tmpActor->GetProperty()->GetColor( rgb );
291 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
292 _color->SetBackgroundColour(colour);
295 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
298 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
300 // Representation Type WireFrame / Surface
301 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
302 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
305 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
306 _isoValue->SetValue(isoValue);
311 //-------------------------------------------------------------------
312 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
314 int idTissue=GetIdTissue();
317 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
319 _wxvtkclipping3Dview->Refresh();
321 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
322 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
327 //-------------------------------------------------------------------
328 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
330 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
331 _wxvtkclipping3Dview->Refresh();
333 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
334 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
336 //-------------------------------------------------------------------
337 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
339 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
340 _wxvtkclipping3Dview->Refresh();
342 //-------------------------------------------------------------------
343 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
345 //_wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
346 this->BoundingBoxChanged(event.IsChecked());
347 _wxvtkclipping3Dview->Refresh();
349 //-------------------------------------------------------------------
350 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
352 int idTissue=GetIdTissue();
355 // EED 17 Janvier 2007
356 wxColourDialog dlgColour(this);
357 // dlgColour.ShowModal();
358 if( dlgColour.ShowModal( ) == wxID_OK )
361 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
362 float r=dlgColour.GetColourData().GetColour().Red()/255;
363 float g=dlgColour.GetColourData().GetColour().Green()/255;
364 float b=dlgColour.GetColourData().GetColour().Blue()/255;
365 tmpActor->GetProperty()->SetColor( r , g , b );
366 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
368 _wxvtkclipping3Dview->Refresh();
370 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
371 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
375 //-------------------------------------------------------------------
376 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
378 int idTissue=GetIdTissue();
381 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
383 _wxvtkclipping3Dview->Refresh();
385 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
386 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
389 //-------------------------------------------------------------------
390 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
392 int idTissue=GetIdTissue();
396 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
397 float opacity=_opacity->GetValue();
398 tmpActor->GetProperty()->SetOpacity( opacity/100 );
400 _wxvtkclipping3Dview->Refresh();
402 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
403 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
407 //----------------------------------------------------------------------------
408 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
410 int value = _isoValue->GetValue();
411 int delta= (int)pow( (double)4 ,(double) _isoValueSpin->GetValue() );
412 int min=value - delta/2;
413 int max=value + delta/2;
419 _isoValue->SetRange(min,max);
423 //------------------------------------------------------------------------
424 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
428 int idTissue=GetIdTissue();
431 int isoValue=_isoValue->GetValue();
432 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
434 // tmpStr.Printf("%d",isoValue);
436 _wxvtkclipping3Dview->Refresh();
438 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
439 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
443 //-------------------------------------------------------------------
444 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
447 int idTissue=GetIdTissue();
454 wxString dirSTL = wxGetHomeDir( ) ;
455 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
457 if( dialog.ShowModal( ) == wxID_OK )
461 // ------------------------------------------------------------------------
462 // 1. GENERATE STL FILES
463 // ------------------------------------------------------------------------
464 // const char* fileprefix = "c:\\Creatis\\";
465 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
466 std::string filename;
468 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
470 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
473 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
474 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
475 pdcf->SetInput( filtro->GetOutput() );
476 vtkClosePolyData *cpd = vtkClosePolyData::New();
477 cpd->SetInput( pdcf->GetOutput() );
479 // 1.2 se escribe a disco el archivo stl de la superficie interna
481 vtkSTLWriter *writer = vtkSTLWriter::New();
482 writer->SetInput( cpd->GetOutput() );
484 writer->SetFileName(filename.c_str());
485 writer->SetFileTypeToASCII();
497 //EED 30 Janvier 2007
498 //-------------------------------------------------------------------
499 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
501 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
502 if (dialog.ShowModal() == wxID_OK)
504 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
505 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
506 float rescalaSlope = 1;
507 float rescalaIntercept = 0;
508 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
509 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
511 vtkimagedata->GetDimensions(dim);
519 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
520 marRAW2Files marraw2;
521 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
525 //EED 22 Fevrier 2007
526 //-------------------------------------------------------------------
527 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
530 int /*i=0,*/ xi,yi,r,g,b; // JPRx
531 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
532 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
533 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
534 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
535 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
536 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
537 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
538 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
539 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
541 //use for update in the refresh
543 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
544 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
549 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
550 if (dialog.ShowModal() == wxID_OK)
552 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
558 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
562 int tfSize=gtf->size();
566 hDlg->erasePointsTransferenceFunction();
571 hDlg->addPointToTransferenceFunction(g,in*100);
577 int ctfSize=rctf->size();
583 double gr=(*greyctf)[i];
587 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
591 //setting variables if the user wants to do refresh
594 //hDlg->setClipping3DView(_wxvtkclipping3Dview);
596 hDlg->setVolume(newvol);
597 hDlg->setVolumeMapper(volumeMapper);
600 // when the user had changed the transference Function
602 if(hDlg->ShowModal()== wxID_OK )
604 // -- vtkPiecewiseFunction --
605 tfun->RemoveAllPoints();
609 int nTFPoints=hDlg->getSizeTransferenceFunction();
613 hDlg->getTransferenceFunctionPoint(i,xi,yi);
614 tfun->AddPoint( xi , yi/100.0 );
616 itf->push_back(yi/100.0);
619 // -- vtkColorTransferFunction --
620 ctfun->RemoveAllPoints ();
627 int nCTFpoints=hDlg->getSizeBarColor();
631 hDlg->getDataBarColorPoint(i,xi,r,g,b);
632 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
633 rctf->push_back(r/255.0);
634 gctf->push_back(g/255.0);
635 bctf->push_back(b/255.0);
636 greyctf->push_back(xi);
639 //---------------------------------
640 // Refreshing and sending the event
641 //---------------------------------
642 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
643 _wxvtkclipping3Dview->Refresh();
644 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
645 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
648 volumeMapper->Update();
652 if(hDlg->getRefreshed())
655 //--Transference Function----
656 tfun->RemoveAllPoints();
661 double grey1=(*gtf)[i];
662 double in2=(*itf)[i];
663 tfun->AddPoint( grey1 , in2 );
666 // -- vtkColorTransferFunction --
667 ctfun->RemoveAllPoints ();
670 size=greyctf->size();
673 double grey2=(*greyctf)[i];
674 double red =(*rctf)[i];
675 double green =(*gctf)[i];
676 double blue = (*bctf)[i];
677 ctfun->AddRGBPoint(grey2,red,green,blue);
680 //---------------------------------
681 // Refreshing and sending the event
682 //---------------------------------
683 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
684 _wxvtkclipping3Dview->Refresh();
685 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
686 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
689 volumeMapper->Update();
700 //-------------------------------------------------------------------
701 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
703 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
704 if (dialog.ShowModal() == wxID_OK)
706 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
707 _wxvtkclipping3Dview->Refresh();
708 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
709 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);