Program: wxMaracas
Module: $RCSfile: wxMPRWidget.cxx,v $
Language: C++
- Date: $Date: 2008/11/14 16:16:32 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2009/05/07 15:35:46 $
+ Version: $Revision: 1.13 $
Copyright: (c) 2002, 2003
License:
#include "matrix.h"
#include <string>
+#include <stdio.h>
+
#include "pPlotter/HistogramDialog.h"
int wxSphereView::GetIdOfImage(double radio)
{
int id=0;
- int dim[3];
- _imageSphere->GetDimensions(dim);
+ int dim[3];
+ _imageSphere->GetDimensions(dim);
int sizeMaxList = dim[2];
// Search in list >> alpha beta radio
int i,size=_lstId.size();
unsigned short *pOrig;
int dimRes[3],dimOrig[3];
double i,j;
+ int ext[6];
+ _imageSphere->GetExtent(ext);
_imageSphere->GetDimensions(dimRes);
- _imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
+ //JCP 24 - 04 -09
+ //_imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
+ _imageSphere->SetExtent(ext);
+ //JCP 24 - 04 -09
d2x=dimRes[0]/2;
d2y=dimRes[1]/2;
// double deltaTMP=_delta;
GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstyleplane2D );
vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
+
camera->SetViewUp ( 0 , 1 , 0 );
- camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
camera->SetPosition ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 10000 );
+
+ camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
camera->SetClippingRange(0.01, 100000);
camera->ComputeViewPlaneNormal();
camera->SetParallelScale( _sizeIma/3.0 );
void wxVtkMPR2DView::Configure(){
wxVtk2DBaseView::Configure();
-
_interactorstylemprview = new vtkInteractorStyleMPRView();
GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstylemprview );
GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
double spc[3];
- GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
- x1 = (int)(x1*spc[0]);
- y1 = (int)(y1*spc[1]);
- z1 = (int)(z1*spc[2]);
-
- x2 = (int)(x2*spc[0]);
- y2 = (int)(y2*spc[1]);
- z2 = (int)(z2*spc[2]);
-
- _visibleAxis = true;
-
-// Axe A
- _ptsA = vtkPoints::New();
- _ptsA->SetNumberOfPoints(2);
- _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
- vtkCellArray *linesA;
- linesA = vtkCellArray::New();
- linesA->InsertNextCell(2);
- linesA->InsertCellPoint(0);
- linesA->InsertCellPoint(1);
- _pdA = vtkPolyData::New();
- _pdA->SetPoints( _ptsA );
- _pdA->SetLines( linesA );
- linesA->Delete(); //do not delete lines ??
- _lineAActor = vtkActor::New();
- _lineAMapper = vtkPolyDataMapper::New();
- _lineAMapper->SetInput(_pdA);
- _lineAMapper->ImmediateModeRenderingOn();
- _lineAActor->SetMapper(_lineAMapper);
- _lineAActor->GetProperty()->BackfaceCullingOn();
- _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
- _lineAActor->GetProperty()->SetLineWidth(2);
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
-
-// Axe B
- _ptsB = vtkPoints::New();
- _ptsB->SetNumberOfPoints(2);
- _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
- _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
- vtkCellArray *linesB;
- linesB = vtkCellArray::New();
- linesB->InsertNextCell(2);
- linesB->InsertCellPoint(0);
- linesB->InsertCellPoint(1);
- _pdB = vtkPolyData::New();
- _pdB->SetPoints( _ptsB );
- _pdB->SetLines( linesB );
- linesB->Delete(); //do not delete lines ??
- _lineBActor = vtkActor::New();
- _lineBMapper = vtkPolyDataMapper::New();
- _lineBMapper->SetInput(_pdB);
- _lineBMapper->ImmediateModeRenderingOn();
- _lineBActor->SetMapper(_lineBMapper);
- _lineBActor->GetProperty()->BackfaceCullingOn();
- _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
- _lineBActor->GetProperty()->SetLineWidth(2);
- _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+ vtkImageData* img = GetVtkmprbasedata()->GetImageData();
+ if(img!=NULL){
+ img->GetSpacing(spc);
+ x1 = (int)(x1*spc[0]);
+ y1 = (int)(y1*spc[1]);
+ z1 = (int)(z1*spc[2]);
+
+ x2 = (int)(x2*spc[0]);
+ y2 = (int)(y2*spc[1]);
+ z2 = (int)(z2*spc[2]);
+
+ _visibleAxis = true;
+
+ // Axe A
+ _ptsA = vtkPoints::New();
+ _ptsA->SetNumberOfPoints(2);
+ _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
+ _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
+ vtkCellArray *linesA;
+ linesA = vtkCellArray::New();
+ linesA->InsertNextCell(2);
+ linesA->InsertCellPoint(0);
+ linesA->InsertCellPoint(1);
+ _pdA = vtkPolyData::New();
+ _pdA->SetPoints( _ptsA );
+ _pdA->SetLines( linesA );
+ linesA->Delete(); //do not delete lines ??
+ _lineAActor = vtkActor::New();
+ _lineAMapper = vtkPolyDataMapper::New();
+ _lineAMapper->SetInput(_pdA);
+ _lineAMapper->ImmediateModeRenderingOn();
+ _lineAActor->SetMapper(_lineAMapper);
+// _lineAActor->GetProperty()->BackfaceCullingOn();
+ _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
+ _lineAActor->GetProperty()->SetLineWidth(2);
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+
+ // Axe B
+ _ptsB = vtkPoints::New();
+ _ptsB->SetNumberOfPoints(2);
+ _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
+ _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
+ vtkCellArray *linesB;
+ linesB = vtkCellArray::New();
+ linesB->InsertNextCell(2);
+ linesB->InsertCellPoint(0);
+ linesB->InsertCellPoint(1);
+ _pdB = vtkPolyData::New();
+ _pdB->SetPoints( _ptsB );
+ _pdB->SetLines( linesB );
+ linesB->Delete(); //do not delete lines ??
+ _lineBActor = vtkActor::New();
+ _lineBMapper = vtkPolyDataMapper::New();
+ _lineBMapper->SetInput(_pdB);
+ _lineBMapper->ImmediateModeRenderingOn();
+ _lineBActor->SetMapper(_lineBMapper);
+// _lineBActor->GetProperty()->BackfaceCullingOn();
+ _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
+ _lineBActor->GetProperty()->SetLineWidth(2);
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
- vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
- if (_direction==0) {
- camera->SetViewUp ( 0 , -1 , 0 );
- camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
- camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
- camera->SetParallelScale( (z2-z1)/3.0 );
- }
-
- if (_direction==1) {
- camera->SetViewUp ( 0 , 0 , -1 );
- camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
- camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
+
+ vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
+
+//EED 17Avril2009
+/*
+ if (_direction==0) {
+ camera->SetViewUp ( 0 , -1 , 0 );
+ camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
+ camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
+ camera->SetParallelScale( (z2-z1)/3.0 );
+ }
- if (_direction==2) {
- camera->SetViewUp ( 0 , -1 , 0 );
- camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
- camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
- camera->SetParallelScale( (x2-x1)/3.0 );
- }
+ if (_direction==1) {
+ camera->SetViewUp ( 0 , 0 , -1 );
+ camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
+ camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+ if (_direction==2) {
+ camera->SetViewUp ( 0 , -1 , 0 );
+ camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
+ camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+ */
+ if (_direction==0) {
+ camera->SetViewUp ( 0 , 1 , 0 );
+ camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 );
+ camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
+ camera->SetParallelScale( (z2-z1)/3.0 );
+ }
+
+ if (_direction==1) {
+ camera->SetViewUp ( 0 , 0 , -1 );
+ camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
+ camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+
+ if (_direction==2) {
+ camera->SetViewUp ( 0 , 1 , 0 );
+ camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000);
+ camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
+ camera->SetParallelScale( (x2-x1)/3.0 );
+ }
+
+
+
+ }
// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
// _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
int x1,x2,y1,y2,z1,z2;
GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
double spc[3];
- GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
- x1 = (int)(x1*spc[0]);
- y1 = (int)(y1*spc[1]);
- z1 = (int)(z1*spc[2]);
+
+ vtkImageData* img = GetVtkmprbasedata()->GetImageData();
+ if(img!=NULL){
+ img->GetSpacing(spc);
+ x1 = (int)(x1*spc[0]);
+ y1 = (int)(y1*spc[1]);
+ z1 = (int)(z1*spc[2]);
- x2 = (int)(x2*spc[0]);
- y2 = (int)(y2*spc[1]);
- z2 = (int)(z2*spc[2]);
+ x2 = (int)(x2*spc[0]);
+ y2 = (int)(y2*spc[1]);
+ z2 = (int)(z2*spc[2]);
- int x = (int)(GetVtkmprbasedata()->GetX());
- int y = (int)(GetVtkmprbasedata()->GetY());
- int z = (int)(GetVtkmprbasedata()->GetZ());
+ int x = (int)(GetVtkmprbasedata()->GetX());
+ int y = (int)(GetVtkmprbasedata()->GetY());
+ int z = (int)(GetVtkmprbasedata()->GetZ());
- x = (int)(x*spc[0]);
- y = (int)(y*spc[1]);
- z = (int)(z*spc[2]);
+ x = (int)(x*spc[0]);
+ y = (int)(y*spc[1]);
+ z = (int)(z*spc[2]);
- if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
+ if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
- if (_direction==0) {
- _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
- _ptsA->SetPoint(0, -x2, y1 , z );
- _ptsA->SetPoint(1, -x2, y2 , z );
- _ptsB->SetPoint(0, -x2, y , z1);
- _ptsB->SetPoint(1, -x2, y , z2);
- }
- if (_direction==1) {
- _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
- _ptsA->SetPoint(0, x1 , y2 , z );
- _ptsA->SetPoint(1, x2 , y2 , z );
- _ptsB->SetPoint(0, x , y2 , z1);
- _ptsB->SetPoint(1, x , y2 , z2);
- }
- if (_direction==2) {
- _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
- _ptsA->SetPoint(0, x1 , y , -z2 );
- _ptsA->SetPoint(1, x2 , y , -z2 );
- _ptsB->SetPoint(0, x , y1, -z2 );
- _ptsB->SetPoint(1, x , y2, -z2 );
+ if (_direction==0) {
+ _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
+ _ptsA->SetPoint(0, -x2, y1 , z );
+ _ptsA->SetPoint(1, -x2, y2 , z );
+ _ptsB->SetPoint(0, -x2, y , z1);
+ _ptsB->SetPoint(1, -x2, y , z2);
+ }
+ if (_direction==1) {
+ _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
+ _ptsA->SetPoint(0, x1 , y2 , z );
+ _ptsA->SetPoint(1, x2 , y2 , z );
+ _ptsB->SetPoint(0, x , y2 , z1);
+ _ptsB->SetPoint(1, x , y2 , z2);
+ }
+ if (_direction==2) {
+ _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
+ _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
+ // _ptsA->SetPoint(0, x1 , y , -z2 );
+ // _ptsA->SetPoint(1, x2 , y , -z2 );
+ // _ptsB->SetPoint(0, x , y1, -z2 );
+ // _ptsB->SetPoint(1, x , y2, -z2 );
+
+ _ptsA->SetPoint(0, x1 , y , z2 );
+ _ptsA->SetPoint(1, x2 , y , z2 );
+ _ptsB->SetPoint(0, x , y1, z2 );
+ _ptsB->SetPoint(1, x , y2, z2 );
+ }
+ _backX=x;
+ _backY=y;
+ _backZ=z;
}
- _backX=x;
- _backY=y;
- _backZ=z;
+ wxVtkBaseView::Refresh();
}
- wxVtkBaseView::Refresh();
}
//-------------------------------------------------------------------
int wxVtkMPR2DView::GetActualSlice() // virtual
wxPanel *panel = this;
_wxvtkmpr3Dview = wxvtkmpr3Dview;
- int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
+ /*int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
- int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
+ int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();*/
+
+ int maxX = 1;
+ int maxY = 1;
+ int maxZ = 1;
+
wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,_T("X "));
_positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
ckBoxX->SetValue(false);
ckBoxY->SetValue(false);
ckBoxZ->SetValue(false);
- _ckBoxXYZ->SetValue(true);
+ _ckBoxXYZ->SetValue(false);
_ckBoxPlane->SetValue(false);
_positionX->SetSize(400,20);
panel->SetEventHandler((wxEvtHandler*)this);
+ //this->UpdateControlPanel();
+
+}
+void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel()
+{
+
+ vtkMPRBaseData* basedata = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData();
+ if(basedata != NULL){
+
+ /*int maxX = basedata->GetMaxPositionX();
+ int maxY = basedata->GetMaxPositionY();
+ int maxZ = basedata->GetMaxPositionZ();*/
+ int x0,x1,y0,y1,z0,z1;
+
+ basedata->GetDimensionExtention(&x0,&x1,&y0,&y1,&z0,&z1);
+ /*int maxX = x1-x0;//basedata->GetMaxPositionX();
+ int maxY = y1-y0;//basedata->GetMaxPositionY();
+ int maxZ = z1-z0;//basedata->GetMaxPositionZ();*/
+
+
+
+ //std::cout<<"wxVtkMPR3DViewCntrlPanel::UpdateControlPanel() maxX="<<maxX<<" maxY="<<maxY<<" maxZ="<<maxZ<<std::endl;
+ /*_positionX->SetRange(0,maxX);
+ _positionY->SetRange(0,maxY);
+ _positionZ->SetRange(0,maxZ);*/
+ _positionX->SetRange(x0,x1);
+ _positionY->SetRange(y0,y1);
+ _positionZ->SetRange(z0,z1);
+
+ _positionX->SetValue((x0+x1)/2);
+ _positionY->SetValue((y0+y1)/2);
+ _positionZ->SetValue((z0+z1)/2);
+
+ _positionX->Update();
+ _positionY->Update();
+ _positionZ->Update();
+ this->Update();
+ }
+
}
//-------------------------------------------------------------------
wxVtkMPR3DViewCntrlPanel::~wxVtkMPR3DViewCntrlPanel()
std::vector<double> *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
std::vector<double> *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
+ printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfun %p\n", this, ctfun);
+ printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorPoint %p\n", this, ctfunVectorPoint);
+ printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorRed %p\n", this, ctfunVectorRed);
+ printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorGreen %p\n", this, ctfunVectorGreen);
+ printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorBlue %p\n", this, ctfunVectorBlue);
+
+
//void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
_wxvtkmpr3Dview->Refresh();
wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
- _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+
+ try{
+ _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
+ }catch(char* e){
+ std::cout<<e<<std::endl;
+ }
}
//-------------------------------------------------------------------
std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+
+
//use for update in the refresh
/*
vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
{
_wxvtk3Dbaseview = wxvtk3Dbaseview;
_vtkmpr3Ddataviewer = NULL;
- _wxvtkmpr3DviewCntrlPanel = NULL;
+ _wxvtkmpr3DviewCntrlPanel = NULL;
+ _myCallback=NULL;
+ _pointWidget=NULL;
+ _planeWidget=NULL;
+ _vtkplane=NULL;
+ _probe=NULL;
+ _contourMapper=NULL;
+}
+void wxVtkMPR3DView::RemoveActor(vtkActor* actor){
+
+ _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
+
+
+}
+void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
+ if(ext == NULL){
+
+ _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
+ _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
+ }else{
+ /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
+ double y = (spc[1])*(origin[1]+(double)ext[3]);
+ double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
+ /*double x0=(spc[0])*((double)ext[0]+origin[0]);
+ double x1=(spc[0])*((double)ext[1]+origin[0]);
+ double y0=(spc[1])*((double)ext[2]+origin[1]);
+ double y1=(spc[1])*((double)ext[3]+origin[1]);
+ double z0=(spc[2])*((double)ext[4]+origin[2]);
+ double z1=(spc[2])*((double)ext[5]+origin[2]);*/
+ double x0=(spc[0])*((double)ext[0]);
+ double x1=(spc[0])*((double)ext[1]);
+ double y0=(spc[1])*((double)ext[2]);
+ double y1=(spc[1])*((double)ext[3]);
+ double z0=(spc[2])*((double)ext[4]);
+ double z1=(spc[2])*((double)ext[5]);
+
+ _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
+ //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
+ _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
+ }
}
+void wxVtkMPR3DView::Configure(){
+
+ _wxvtk3Dbaseview->Configure();
+ _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
+
+//EED ?????? 07Mai2009
+// _wxvtk3Dbaseview->GetRenderer()->Clear();
+
+
+ // Actors are added to the renderer.
+ vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
+// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
+// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
+// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
+
+
+ // An initial camera view is created. The Dolly() method moves
+ // the camera towards the FocalPoint, thereby enlarging the image.
+ _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
+ this->ResetCamera();
+
+
+ // Set a background color for the renderer and set the size of the
+ // render window (expressed in pixels).
+ _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
+ _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
+
+ // Note that when camera movement occurs (as it does in the Dolly()
+ // method), the clipping planes often need adjusting. Clipping planes
+ // consist of two planes: near and far along the view direction. The
+ // near plane clips out objects in front of the plane; the far plane
+ // clips out objects behind the plane. This way only what is drawn
+ // between the planes is actually rendered.
+ _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
+
+
+ // vtkPointWidget
+ if(_myCallback!=NULL){
+ _myCallback->Delete();
+
+ }
+ _myCallback = vtkmyPWCallback_3DPointWidget::New();
+ _myCallback->SetWxVtkMPR3DView(this);
+
+ if(_pointWidget!=NULL){
+ _pointWidget->Delete();
+ }
+ _pointWidget = vtkPointWidget::New();
+ _myCallback->SetVtkPointWidget(_pointWidget);
+ _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
+
+ _pointWidget->AllOff();
+
+ _pointWidget->PlaceWidget();
+// _pointWidget->SetPosition( x,y,z );
+
+//EED01 29Mars2009
+// MACOS probleme vtk-window out of wx-window
+// _pointWidget->On();
+
+ _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+
+// PlaneWidget
+ if(_planeWidget!=NULL){
+ _planeWidget->Delete();
+ }
+ _planeWidget = vtkPlaneWidget::New();
+ _myCallback->SetVtkPlaneWidget(_planeWidget);
+ _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
+ _planeWidget->NormalToXAxisOn();
+ _planeWidget->SetResolution(50);
+ _planeWidget->SetRepresentationToOutline();
+ int dim[3];
+ GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
+ int px=(dim[0]/2);
+ int py=(dim[1]/2);
+ int pz=(dim[2]/2);
+ int dd=20;
+ _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
+
+ if(_vtkplane==NULL){
+ _vtkplane = vtkPolyData::New();
+
+ _probe = vtkProbeFilter::New();
+ _probe->SetInput(_vtkplane);
+
+ _contourMapper = vtkPolyDataMapper::New();
+
+ _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+
+ _contourPlaneActor = vtkActor::New();
+ _contourPlaneActor->SetMapper(_contourMapper);
+
+ _contourPlaneActor->VisibilityOff();
+
+ _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
+
+ _planeWidget->Off();
+ _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
+
+ }else{
+
+ }
+ _planeWidget->GetPolyData(_vtkplane);
+
+
+ vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+ _probe->SetSource( imageData );
+
+
+ _contourMapper->SetScalarRange( imageData->GetScalarRange() );
+
+
+
+
+}
//-------------------------------------------------------------------
wxVtkMPR3DView::~wxVtkMPR3DView()
{
return _wxvtkmpr3DviewCntrlPanel;
}
//-------------------------------------------------------------------
-vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
+vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
{
return _vtkmpr3Ddataviewer;
}
//-------------------------------------------------------------------
-wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview()
+wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
{
+ if(_wxvtk3Dbaseview==NULL){
+ throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
+ }
return _wxvtk3Dbaseview;
}
//-------------------------------------------------------------------
-void wxVtkMPR3DView::Configure(){
- _wxvtk3Dbaseview->Configure();
-
- // Actors are added to the renderer.
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetOutlineActor() );
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
-// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
-
-
- // An initial camera view is created. The Dolly() method moves
- // the camera towards the FocalPoint, thereby enlarging the image.
- _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
- _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
- _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
-
- // Set a background color for the renderer and set the size of the
- // render window (expressed in pixels).
- _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
- _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
-
- // Note that when camera movement occurs (as it does in the Dolly()
- // method), the clipping planes often need adjusting. Clipping planes
- // consist of two planes: near and far along the view direction. The
- // near plane clips out objects in front of the plane; the far plane
- // clips out objects behind the plane. This way only what is drawn
- // between the planes is actually rendered.
- _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
-
-
-
- // vtkPointWidget
- _myCallback = vtkmyPWCallback_3DPointWidget::New();
- _myCallback->SetWxVtkMPR3DView(this);
-
- _pointWidget = vtkPointWidget::New();
- _myCallback->SetVtkPointWidget(_pointWidget);
- _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _pointWidget->AllOff();
- _pointWidget->PlaceWidget();
-// _pointWidget->SetPosition( x,y,z );
- _pointWidget->On();
- _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-
-
-// PlaneWidget
- _planeWidget = vtkPlaneWidget::New();
- _myCallback->SetVtkPlaneWidget(_planeWidget);
- _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
- _planeWidget->NormalToXAxisOn();
- _planeWidget->SetResolution(50);
- _planeWidget->SetRepresentationToOutline();
- int dim[3];
- GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
- int px=(dim[0]/2);
- int py=(dim[1]/2);
- int pz=(dim[2]/2);
- int dd=20;
- _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
- _vtkplane = vtkPolyData::New();
- _planeWidget->GetPolyData(_vtkplane);
-
- vtkProbeFilter *probe = vtkProbeFilter::New();
- probe->SetInput(_vtkplane);
- vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- probe->SetSource( imageData );
-
- vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
- contourMapper->SetInput( probe->GetPolyDataOutput() );
-
- contourMapper->SetScalarRange( imageData->GetScalarRange() );
- _contourPlaneActor = vtkActor::New();
- _contourPlaneActor->SetMapper(contourMapper);
- _contourPlaneActor->VisibilityOff();
-
- _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
- _planeWidget->Off();
- _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
-}
//-------------------------------------------------------------------
void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
}
}
//-------------------------------------------------------------------
-wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()
+wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
{
+ if(_wxvtk3Dbaseview==NULL){
+ throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
+ }
return _wxvtk3Dbaseview;
}
//-------------------------------------------------------------------
VisibleActor(3, false );
_boxWidgetS1->HandlesOn ();
- _boxWidgetS1->On();
+
+//EED 29Mars2009
+// _boxWidgetS1->On();
+
_boxWidgetS1->Off();
_boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
_boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
_boxWidgetVolume->HandlesOn ();
- _boxWidgetVolume->On();
+
+//EED 29Mars2009
+// _boxWidgetVolume->On();
+
_boxWidgetVolume->Off();
{
_imageData=NULL;
_histogrammeVector=NULL;
+ _wxvtk3Dbaseview=NULL;
+ _wxvtkbaseView=NULL;
CreateInterface();
CreateModel();
Create3DViewObjects();
wxPanelCuttingImageData::~wxPanelCuttingImageData()
{
- delete _modelCube;
- delete _modelSphere;
- delete _modelCylinder;
- _vtkcube -> Delete();
- _vtksphere -> Delete();
- _vtkcylinder -> Delete();
- _cubeMapper -> Delete();
- _sphereMapper -> Delete();
- _cylinderMapper -> Delete();
- _cubeActor -> Delete();
- _sphereActor -> Delete();
- _cylinderActor -> Delete();
-// _xyplot->RemoveAllInputs();
- _xyplot -> Delete();
- _histogrammeVector->Delete();
+ delete _modelCube;
+ delete _modelSphere;
+ delete _modelCylinder;
+ _vtkcube -> Delete();
+ _vtksphere -> Delete();
+ _vtkcylinder -> Delete();
+ _cubeMapper -> Delete();
+ _sphereMapper -> Delete();
+ _cylinderMapper -> Delete();
+ _cubeActor -> Delete();
+ _sphereActor -> Delete();
+ _cylinderActor -> Delete();
+// _xyplot->RemoveAllInputs();
+ _xyplot -> Delete();
+ _histogrammeVector->Delete();
+ _renplotter->Delete();
+
+ if(_wxvtkbaseView!=NULL){
+ delete _wxvtkbaseView;
+ }
+ //delete _vtkclipping3Ddataviewer;
+
- delete _wxvtkbaseView;
+ //fclose(file);
}
_wxvtkbaseView = new wxVtkBaseView(this);
_wxvtkbaseView->Configure();
- vtkRenderer *ren = vtkRenderer::New();
+ _renplotter = vtkRenderer::New();
vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
- renWin->AddRenderer( ren );
- ren->AddActor2D( _xyplot );
+ renWin->AddRenderer( _renplotter );
+ _renplotter->AddActor2D( _xyplot );
return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
}
_infoPixHi = new wxStaticText(this,-1,_T("############"));
- wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
+
_typeFig->Append(_T("Cylindre"));
_typeFig->Append(_T("Cube"));
// wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
+
+
+ wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
- infoSuVo.Printf(_T("%d") , totalSubVolume);
+ infoSuVo.Printf(_T("%ld") , totalSubVolume);
infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
- infoPixLe.Printf(_T("%d pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
- infoPixHi.Printf(_T("%d pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
+ infoPixLe.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
+ infoPixHi.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
_infoToVo->SetLabel(infoToVo);
_infoSuVo->SetLabel(infoSuVo);
_vtkmprbasedata = NULL;
- _voxelSize = voxelSize;
- _framePanelCutting = NULL;
+
+ _framePanelCutting = NULL;
_panelCutting = NULL;
- _marImageData = marimageData;
- _vtkmprbasedata = new vtkMPRBaseData();
- _vtkmprbasedata->SetMarImageData(_marImageData);
- wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
-
- wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
- wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
- sizer -> Add( pnlSplitter ,1,wxGROW ,0);
+ _marImageData=NULL;
+
+ if(marimageData!=NULL){
+ _marImageData = marimageData;
+ _voxelSize = voxelSize;
+ _vtkmprbasedata = new vtkMPRBaseData();
+ _vtkmprbasedata->SetMarImageData(_marImageData);
+
+
+
+
+ wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
+ pnlSplitter -> SetMinimumPaneSize( 2 );
+
+ wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
+ wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
+ pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
- int ww,hh;
- wxWindow *pp=this;
- while (pp->GetParent()!=NULL) pp=pp->GetParent();
- pp->GetSize(&ww,&hh);
+ sizer -> Add( pnlSplitter ,1,wxGROW ,0);
- pnlSplitter -> SetMinimumPaneSize( 2 );
+ }
- pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
+ //int ww,hh;
+ //wxWindow *pp=this;
+ //while (pp->GetParent()!=NULL) pp=pp->GetParent();
+ //pp->GetSize(&ww,&hh);
+
this -> SetAutoLayout( true );
this -> SetSizer(sizer);
// sizer -> Fit( this );
-
_refreshAPage=0;
_refreshBPage=0;
}
+void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize){
+
+ if(_marImageData!=NULL){
+ _marImageData->removeImageData(0);
+ _marImageData->AddImageData(img);
+ }else{
+ _marImageData = new marImageData(img);
+ }
+
+ _voxelSize = voxelsize;
+
+ if(_vtkmprbasedata==NULL){
+ _vtkmprbasedata = new vtkMPRBaseData();
+ _vtkmprbasedata->SetMarImageData(_marImageData);
+
+ wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
+ pnlSplitter -> SetMinimumPaneSize( 2 );
+ wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
+ wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
+ pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
+
+ this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0);
+ }
+
+
+
+}
//----------------------------------------------------------------------------
wxMPRWidget::~wxMPRWidget( )
//----------------------------------------------------------------------------
void wxMPRWidget::OnCutImagaData(wxCommandEvent &event)
{
- if (_btnCutImageData->GetValue()==true){
+ if (_btnCutImageData->GetValue()==true){
+
_framePanelCutting = new wxFrame(this,-1,_T("Cutting Module"),wxDefaultPosition,wxDefaultSize,wxCAPTION|wxSTAY_ON_TOP| wxRESIZE_BORDER );
+
_framePanelCutting->SetSize(550,400);
- _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
- _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
+
+ _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
+ if(_wxvtk3Dbaseview_Clipping3D_BB!=NULL){
+ _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
+ }
_panelCutting->SetVtkMPRBaseData( GetVtkMPRBaseData() );
_panelCutting->SetVtkClipping3DDataViewer( this->_wxvtkclipping3Dview_BB->GetVtkClipping3DDataViewer() );
_panelCutting->Configure( );
// _framePanelCutting->FitInside();
*/
_framePanelCutting->Show();
+
+
} else {
if (_framePanelCutting!=NULL){
- _panelCutting->RemoveActors();
- _framePanelCutting->Close();
- _framePanelCutting = NULL;
- _panelCutting = NULL;
+ _panelCutting->RemoveActors();
+ _framePanelCutting->Destroy();
+ _framePanelCutting=NULL;
+ _panelCutting=NULL;
}
}
}
if (_vtkmprbasedata!=NULL)
{
+ _vtkmprbasedata->Configure();
x=_vtkmprbasedata -> GetMaxPositionX()/2;
y=_vtkmprbasedata -> GetMaxPositionY()/2;
- z=_vtkmprbasedata -> GetMaxPositionZ()/2;
+ z=_vtkmprbasedata -> GetMaxPositionZ()/2;
+ _vtkmprbasedata->SetX( x );
+ _vtkmprbasedata->SetY( y );
+ _vtkmprbasedata->SetZ( z );
+
}
if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
- if (_vtkmprbasedata!=NULL)
- {
- _vtkmprbasedata->SetX( x );
- _vtkmprbasedata->SetY( y );
- _vtkmprbasedata->SetZ( z );
- }
+
if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
{
_wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
}
-
- RefreshView(true);
+
+//EED 29Mars2009
+// RefreshView(true);
+
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
-vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
+vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
return _vtkmprbasedata;
}
//----------------------------------------------------------------------------