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"));
26 wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
27 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
28 wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
30 _color = new wxButton(panel,-1,_T(""));
31 _visible = new wxCheckBox(panel,-1,_T("Vis"));
32 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
34 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
35 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
38 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
39 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
43 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
44 vtkimagedata->GetScalarRange( range );
45 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
46 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
49 _isoValue->SetTickFreq(25,0);
51 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
52 _isoValueSpin->SetRange(1,8);
53 _isoValueSpin->SetValue(5);
54 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
56 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
57 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
59 wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
62 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
63 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
64 Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
67 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
68 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
72 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
73 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
74 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
75 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
76 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
77 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
78 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
79 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
80 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
83 // ckVolum->Enable(false);
84 ckBoxSurface->SetValue(false);
85 ckBoxVolume->SetValue(false);
86 _color->SetSize(40,20);
87 _opacity->SetSize(370,20);
88 // ckBoxX->SetValue(true);
89 // ckBoxY->SetValue(true);
90 // ckBoxZ->SetValue(true);
91 _surfA->SetValue(true);
92 _wireFrameRep->SetValue(false);
93 _surfaceRep->SetValue(true);
94 _visible->SetValue(false);
95 // _positionX->SetSize(400,20);
96 // _positionY->SetSize(400,20);
97 // _positionZ->SetSize(400,20);
99 Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
100 Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
102 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
103 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
104 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
105 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
106 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
108 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
109 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
111 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
112 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
113 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
116 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
117 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
120 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
121 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
122 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
123 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
124 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
125 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
128 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
129 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
130 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
131 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
132 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
133 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
134 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
135 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
137 sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
138 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
139 sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
140 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
141 sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
142 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
143 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
146 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
147 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
148 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
149 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
150 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
151 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
152 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
153 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
154 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
155 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
156 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
157 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
158 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
161 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
162 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
163 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
164 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
165 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
168 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
169 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
170 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
171 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
173 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
176 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
177 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
178 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
181 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
182 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
183 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
185 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
186 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
187 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
189 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
190 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
191 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
193 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
194 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
195 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
196 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
197 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
198 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
199 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
201 panel->SetSize(300,60);
202 panel->SetAutoLayout(true);
203 panel->SetSizer(sizer);
206 panel->SetEventHandler((wxEvtHandler*)this);
209 //-------------------------------------------------------------------
210 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
213 //-------------------------------------------------------------------
214 void wxVtkClipping3DViewCntrlPanel::Refresh()
216 // wxPanel::Refresh();
218 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
219 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
220 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
223 //-------------------------------------------------------------------
224 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
227 if (_surfA->GetValue()==true)
231 if (_surfB->GetValue()==true)
235 if (_surfC->GetValue()==true)
239 if (_surfD->GetValue()==true)
247 //-------------------------------------------------------------------
248 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
250 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
251 _wxvtkclipping3Dview->Refresh();
253 //-------------------------------------------------------------------
254 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
256 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
257 _wxvtkclipping3Dview->Refresh();
259 //-------------------------------------------------------------------
260 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
262 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
263 _wxvtkclipping3Dview->Refresh();
267 //-------------------------------------------------------------------
268 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
270 int idTissue=GetIdTissue();
275 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
277 tmpActor->GetProperty()->GetColor( rgb );
278 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
279 _color->SetBackgroundColour(colour);
282 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
285 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
287 // Representation Type WireFrame / Surface
288 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
289 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
292 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
293 _isoValue->SetValue(isoValue);
298 //-------------------------------------------------------------------
299 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
301 int idTissue=GetIdTissue();
304 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
306 _wxvtkclipping3Dview->Refresh();
308 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
309 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
314 //-------------------------------------------------------------------
315 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
317 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
318 _wxvtkclipping3Dview->Refresh();
320 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
321 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
323 //-------------------------------------------------------------------
324 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
326 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
327 _wxvtkclipping3Dview->Refresh();
329 //-------------------------------------------------------------------
330 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
332 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
333 _wxvtkclipping3Dview->Refresh();
335 //-------------------------------------------------------------------
336 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
338 int idTissue=GetIdTissue();
341 // EED 17 Janvier 2007
342 wxColourDialog dlgColour(this);
343 // dlgColour.ShowModal();
344 if( dlgColour.ShowModal( ) == wxID_OK )
347 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
348 float r=dlgColour.GetColourData().GetColour().Red()/255;
349 float g=dlgColour.GetColourData().GetColour().Green()/255;
350 float b=dlgColour.GetColourData().GetColour().Blue()/255;
351 tmpActor->GetProperty()->SetColor( r , g , b );
352 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
354 _wxvtkclipping3Dview->Refresh();
356 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
357 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
361 //-------------------------------------------------------------------
362 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
364 int idTissue=GetIdTissue();
367 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
369 _wxvtkclipping3Dview->Refresh();
371 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
372 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
375 //-------------------------------------------------------------------
376 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
378 int idTissue=GetIdTissue();
382 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
383 float opacity=_opacity->GetValue();
384 tmpActor->GetProperty()->SetOpacity( opacity/100 );
386 _wxvtkclipping3Dview->Refresh();
388 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
389 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
393 //----------------------------------------------------------------------------
394 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
396 int value = _isoValue->GetValue();
397 int delta= (int)pow( (double)4 ,(double) _isoValueSpin->GetValue() );
398 int min=value - delta/2;
399 int max=value + delta/2;
405 _isoValue->SetRange(min,max);
409 //------------------------------------------------------------------------
410 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
414 int idTissue=GetIdTissue();
417 int isoValue=_isoValue->GetValue();
418 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
420 // tmpStr.Printf("%d",isoValue);
422 _wxvtkclipping3Dview->Refresh();
424 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
425 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
429 //-------------------------------------------------------------------
430 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
433 int idTissue=GetIdTissue();
440 wxString dirSTL = wxGetHomeDir( ) ;
441 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
443 if( dialog.ShowModal( ) == wxID_OK )
447 // ------------------------------------------------------------------------
448 // 1. GENERATE STL FILES
449 // ------------------------------------------------------------------------
450 // const char* fileprefix = "c:\\Creatis\\";
451 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
452 std::string filename;
454 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
456 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
459 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
460 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
461 pdcf->SetInput( filtro->GetOutput() );
462 vtkClosePolyData *cpd = vtkClosePolyData::New();
463 cpd->SetInput( pdcf->GetOutput() );
465 // 1.2 se escribe a disco el archivo stl de la superficie interna
467 vtkSTLWriter *writer = vtkSTLWriter::New();
468 writer->SetInput( cpd->GetOutput() );
470 writer->SetFileName(filename.c_str());
471 writer->SetFileTypeToASCII();
483 //EED 30 Janvier 2007
484 //-------------------------------------------------------------------
485 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
487 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
488 if (dialog.ShowModal() == wxID_OK)
490 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
491 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
492 float rescalaSlope = 1;
493 float rescalaIntercept = 0;
494 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
495 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
497 vtkimagedata->GetDimensions(dim);
505 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
506 marRAW2Files marraw2;
507 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
511 //EED 22 Fevrier 2007
512 //-------------------------------------------------------------------
513 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
516 int /*i=0,*/ xi,yi,r,g,b; // JPRx
517 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
518 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
519 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
520 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
521 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
522 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
523 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
524 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
525 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
527 //use for update in the refresh
529 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
530 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
535 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
536 if (dialog.ShowModal() == wxID_OK)
538 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
544 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
548 int tfSize=gtf->size();
552 hDlg->erasePointsTransferenceFunction();
557 hDlg->addPointToTransferenceFunction(g,in*100);
563 int ctfSize=rctf->size();
569 double gr=(*greyctf)[i];
573 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
577 //setting variables if the user wants to do refresh
580 //hDlg->setClipping3DView(_wxvtkclipping3Dview);
582 hDlg->setVolume(newvol);
583 hDlg->setVolumeMapper(volumeMapper);
586 // when the user had changed the transference Function
588 if(hDlg->ShowModal()== wxID_OK )
590 // -- vtkPiecewiseFunction --
591 tfun->RemoveAllPoints();
595 int nTFPoints=hDlg->getSizeTransferenceFunction();
599 hDlg->getTransferenceFunctionPoint(i,xi,yi);
600 tfun->AddPoint( xi , yi/100.0 );
602 itf->push_back(yi/100.0);
605 // -- vtkColorTransferFunction --
606 ctfun->RemoveAllPoints ();
613 int nCTFpoints=hDlg->getSizeBarColor();
617 hDlg->getDataBarColorPoint(i,xi,r,g,b);
618 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
619 rctf->push_back(r/255.0);
620 gctf->push_back(g/255.0);
621 bctf->push_back(b/255.0);
622 greyctf->push_back(xi);
625 //---------------------------------
626 // Refreshing and sending the event
627 //---------------------------------
628 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
629 _wxvtkclipping3Dview->Refresh();
630 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
631 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
634 volumeMapper->Update();
642 if(hDlg->getRefreshed())
645 //--Transference Function----
646 tfun->RemoveAllPoints();
651 double grey1=(*gtf)[i];
652 double in2=(*itf)[i];
653 tfun->AddPoint( grey1 , in2 );
656 // -- vtkColorTransferFunction --
657 ctfun->RemoveAllPoints ();
660 size=greyctf->size();
663 double grey2=(*greyctf)[i];
664 double red =(*rctf)[i];
665 double green =(*gctf)[i];
666 double blue = (*bctf)[i];
667 ctfun->AddRGBPoint(grey2,red,green,blue);
670 //---------------------------------
671 // Refreshing and sending the event
672 //---------------------------------
673 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
674 _wxvtkclipping3Dview->Refresh();
675 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
676 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
679 volumeMapper->Update();
690 //-------------------------------------------------------------------
691 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
693 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
694 if (dialog.ShowModal() == wxID_OK)
696 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
697 _wxvtkclipping3Dview->Refresh();
698 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
699 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);