_z = 0;
_t = 0;
- _marImageData = NULL;
+ _marImageData = 0;
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
vtkImageData* vtkBaseData::GetImageData()
{
- return _marImageData->GetImageDataT(_t);
+ if(_marImageData){
+ return _marImageData->GetImageDataT(_t);
+ }else{
+ return 0;
+ }
+
}
//-------------------------------------------------------------------
marImageData* vtkBaseData::GetMarImageData()
// maxZ=dim[2];
int ext[6];
+ double *origin;
+
+
vtkImageData* img = _marImageData->GetImageData();
if(img!=NULL){
/*img->GetWholeExtent(ext);
_z=z;*/
img->GetExtent(ext);
+ origin = img->GetOrigin();
if (z > ext[5])
{
- z = ext[5];
+ z = ext[5] + origin[2];
}
if (z < ext[4])
{
- z = ext[4];
+ z = ext[4] + origin[2];
}
_z=z;
double range[2];
- _vtkmprbasedata->GetImageData()->GetScalarRange(range);
- double max = range[1];
+ double max;
+
+ if(_vtkmprbasedata->GetImageData()){
+ _vtkmprbasedata->GetImageData()->GetScalarRange(range);
+ max = range[1];
+ }else{
+ max = 1;
+ }
+
+
+
_ctFunVectorPoint.clear();
_ctFunVectorPoint.push_back(max*0/4);
}
_saggitalColors->RemoveAllInputs();
- _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
+ if(_vtkmprbasedata->GetImageData()){
+ _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
+ }
// _saggitalColors->SetLookupTable(_bwLut);
_saggitalColors->SetLookupTable(_ctfun);
}
_axialColors->RemoveAllInputs();
- _axialColors->SetInput( _vtkmprbasedata->GetImageData() );
+ if(_vtkmprbasedata->GetImageData()){
+ _axialColors->SetInput( _vtkmprbasedata->GetImageData() );
+ }
// _axialColors->SetLookupTable(_hueLut);
_axialColors->SetLookupTable(_ctfun);
_coronalColors = vtkImageMapToColors::New();
}
_coronalColors->RemoveAllInputs();
- _coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
+ if(_vtkmprbasedata->GetImageData()){
+ _coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
+ }
// _coronalColors->SetLookupTable(_satLut);
_coronalColors->SetLookupTable(_ctfun);
_outlineData = vtkOutlineFilter::New();
}
_outlineData->RemoveAllInputs();
- _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+ if(_vtkmprbasedata->GetImageData()){
+ _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+ }
if(_mapOutline==NULL){
_mapOutline = vtkPolyDataMapper::New();
- int ext[6];
- _vtkmprbasedata->GetImageData()->GetExtent(ext);
+ //int ext[6];
+ //_vtkmprbasedata->GetImageData()->GetExtent(ext);
_x=0;
_y=0;
_z=0;
+ _x1 = 0;
+ _x2 = 0;
+ _y1 = 0;
+ _y2 = 0;
+ _z1 = 0;
+ _z2 = 0;
_transformOrientation = NULL;
_marImageData = NULL;
}
if(img !=NULL){
img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
//std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<<std::endl;
- if(_transformOrientation==NULL){
- _transformOrientation=vtkTransform::New();
- }
- _transformOrientation->Identity();
+
+ }
+ if(_transformOrientation==NULL){
+ _transformOrientation=vtkTransform::New();
}
+ _transformOrientation->Identity();
}
//-------------------------------------------------------------------
void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
{
//int dim[3];
int ext[6];
-
+ double* origin;
vtkImageData* img = _marImageData->GetImageData();
if(img!=NULL){
/*img->GetDimensions(dim);
}
_x=x;*/
img->GetExtent(ext);
+ origin = img->GetOrigin();
if (x < ext[0])
{
- x=ext[0];
+ x=ext[0] + origin[0];
}
if (x > ext[1])
{
- x=ext[1];
+ x=ext[1] + origin[0];
}
+
_x=x;
}
}
{
//int dim[3];
int ext[6];
+ double* origin;
vtkImageData* img = _marImageData->GetImageData();
if(img!=NULL){
/*img->GetDimensions(dim);
}
_y=y;*/
img->GetExtent(ext);
+ origin = img->GetOrigin();
if (y<ext[2])
{
- y=ext[2];
+ y=ext[2] + origin[1];
}
if (y > ext[3])
{
- y=ext[3];
+ y=ext[3] + origin[1];
}
_y=y;
}
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
Language: C++
- Date: $Date: 2010/05/03 13:46:48 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2010/08/04 18:45:27 $
+ Version: $Revision: 1.18 $
Copyright: (c) 2002, 2003
License:
}
+ }
+ /**
+ * @pre A wxWindow* object must be provided as a parent for the viewer and the type of layout for the viewer
+ * @post The layout of the viewer is initialized, if no image is provided at first, a default image is
+ * used
+ * @param wxWindow* parent of the window
+ * @param std::vector<int>* vector of the type for the viewer
+ * @param vtkImageData* imagedata of the viewer
+ */
+ wxMaracas_N_ViewersWidget::wxMaracas_N_ViewersWidget(wxWindow *parent, std::vector<int> *nTypeView, vtkImageData* imagedata)
+ : wxPanel( parent, -1){
+ wxwindow1 = NULL;
+ wxwindow2 = NULL;
+ wxwindow3 = NULL;
+ wxwindow4 = NULL;
+ _currentwxw = NULL;
+ mvtkmprbasedata = NULL;
+
+ wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+ this->SetSizer(sizer);
+ this->SetAutoLayout(true);
+
+ this->SetType(nTypeView);
+
+ /*if(imagedata==NULL){
+ double spc[3];
+ spc[0] = 1;
+ spc[1] = 1;
+ spc[2] = 1;
+ int extent[6];
+ extent[0] = 0;
+ extent[1] = 1;
+ extent[2] = 0;
+ extent[3] = 1;
+ extent[4] = 0;
+ extent[5] = 1;
+
+ imagedata = vtkImageData::New();
+ imagedata->SetSpacing(spc);
+ imagedata->SetExtent(extent);
+ imagedata->SetScalarTypeToUnsignedShort();
+ imagedata->AllocateScalars();
+ }*/
+
+ this->UpdateLayout(imagedata);
}
//-------------------------------------------------------------------------
}
//panel->SetDimension()
- sizer->Add( wxwindow , 1, wxEXPAND);
+ sizer->Add( wxwindow , 1, wxGROW);
sizer->Layout();
- _currentwxw = wxwindow;
- _currentwxw->Show(true);
+ //_currentwxw = wxwindow;
+ //_currentwxw->Show(true);
- this->Layout();
- this->Refresh();
+ //this->Layout();
+ //this->Refresh();
}
if (wxwindow2!=NULL) { wxwindow2->SetImage(image); }
if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
if (wxwindow4!=NULL) { wxwindow4->SetImage(image); }
+
+ ConfigureVTK();
+
}
//-----------------------------------------------------------------------------------
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.h,v $
Language: C++
- Date: $Date: 2010/05/03 13:46:48 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2010/08/04 18:45:27 $
+ Version: $Revision: 1.11 $
Copyright: (c) 2002, 2003
License:
// Constructors & Destructors
//------------------------------------------------------------------------------------------------------------
+ /**
+ * @pre A wxWindow* object must be provided as a parent for the viewer
+ * @post The layout of the viewer is initialize, if there is no image or type set,
+ only the panel of the viwer is created with no vtk objects
+ * @param wxWindow* parent of the window
+ * @param vtkImageData* imagedata of the viewer
+ * @param std::vector<int>* vector of the type for the viewer
+ * @deprecated This method will be eliminated in future versions,
+ * @deprecated the viewers will start with a default image if it is not specified,
+ * @deprecated this is in order to create the layout of the viewer,
+ * @deprecated the vtkInteractors* and the object vtkRenderer* use second constructor
+ */
wxMaracas_N_ViewersWidget(wxWindow *parent, vtkImageData* imagedata = NULL, std::vector<int> *nTypeView = NULL);
- ~wxMaracas_N_ViewersWidget();
+ /**
+ * @pre A wxWindow* object must be provided as a parent for the viewer and the type of layout for the viewer
+ * @post The layout of the viewer is initialized, if no image is provided at first, a default image is
+ * used
+ * @param wxWindow* parent of the window
+ * @param std::vector<int>* vector of the type for the viewer
+ * @param vtkImageData* imagedata of the viewer
+ */
+ wxMaracas_N_ViewersWidget(wxWindow *parent, std::vector<int> *nTypeView, vtkImageData* imagedata = NULL);
+ /**
+ * @pre none
+ * @post the viewer window is deleted, all of the interactors and the renderer are deleted
+ */
+ ~wxMaracas_N_ViewersWidget();
//------------------------------------------------------------------------------------------------------------
//EEDx5
double spc[3];
// GetVtkBaseData()->GetImageData()->GetSpacing(spc);
- this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
+//JCP 04/08/10 W/O Image this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
+ vtkImageData* image = this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput();
+ if(image){
+ image->GetSpacing(spc);
+ }else{
+ spc[0] = 1;
+ spc[1] = 1;
+ spc[2] = 1;
+ }
+
X = X / spc[0];
Y = Y / spc[1];
//EEDx5
double spc[3];
// GetVtkBaseData()->GetImageData()->GetSpacing(spc);
- this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
-
+//JCP 04/08/10 W/O Image this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
+ vtkImageData* image = this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput();
+ if(image){
+ image->GetSpacing(spc);
+ }else{
+ spc[0] = 1;
+ spc[1] = 1;
+ spc[2] = 1;
+ }
+//
X=X*spc[0];
Y=Y*spc[1];
Z=Z*spc[2];
//-------------------------------------------------------------------
void wxVtk2DBaseView::ResetView()
{
- double spx,spy,spz;
- int x1,x2,y1,y2,z1,z2;
+ double spx = 0,spy = 0,spz = 0;
+ int x1 = 1,x2 = 1,y1 = 1,y2 = 1,z1 = 1,z2 = 1;
wxVtkBaseView::Configure();
wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
vtkImageData *imageData = GetVtkBaseData()->GetImageData();
- imageData->UpdateInformation();
- imageData->SetUpdateExtent( imageData->GetWholeExtent());
- imageData->Update();
+ if(imageData){
+ imageData->UpdateInformation();
+ imageData->SetUpdateExtent( imageData->GetWholeExtent());
+ imageData->Update();
+ _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
+ imageData->GetSpacing (spx,spy,spz);
+ imageData->GetExtent (x1,x2,y1,y2,z1,z2);
+ }
- _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
- imageData->GetSpacing (spx,spy,spz);
- imageData->GetExtent (x1,x2,y1,y2,z1,z2);
+
_imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
_imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
void wxVtk2DBaseView::GetSpacing(double spc[3]) // virtual
{
vtkImageData *imageData = GetVtkBaseData()->GetImageData();
- imageData->GetSpacing(spc);
+ if(imageData){
+ imageData->GetSpacing(spc);
+ }else{
+ spc[0] = 0;
+ spc[1] = 0;
+ spc[2] = 0;
+ }
}
void wxVtk2DBaseView::setColorTransferFunction(vtkColorTransferFunction* colortable){
double spc[3];
vtkImageData* img = GetVtkmprbasedata()->GetImageData();
if(img!=NULL){
+ double* origin = img->GetOrigin();
+ img->GetExtent(x1,x2,y1,y2,z1,z2);
img->GetSpacing(spc);
+ x1 += origin[0];
+ x2 += origin[0];
+ y1 += origin[1];
+ y2 += origin[1];
+ z1 += origin[2];
+ z2 += origin[2];
x1 = (int)(x1*spc[0]);
y1 = (int)(y1*spc[1]);
z1 = (int)(z1*spc[2]);
z2 = (int)(z2*spc[2]);
_visibleAxis = true;
-
+ }
+
// Axe A
- if(_lineAActor==NULL){
- _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 );
- }
+ if(_lineAActor==NULL){
+ _lineAActor = vtkActor::New();
+ _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
+ _lineAActor->GetProperty()->SetLineWidth(2);
+
+ _ptsA = vtkPoints::New();
+ _ptsA->SetNumberOfPoints(2);
+ _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
+ _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
+
+ _pdA = vtkPolyData::New();
+
+ _lineAMapper = vtkPolyDataMapper::New();
+
+ _lineAMapper->SetInput(_pdA);
+ _lineAMapper->ImmediateModeRenderingOn();
+ _lineAActor->SetMapper(_lineAMapper);
+
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+ }
+
+ vtkCellArray *linesA = vtkCellArray::New();
+ linesA->InsertNextCell(2);
+ linesA->InsertCellPoint(0);
+ linesA->InsertCellPoint(1);
+ _pdA->SetPoints( _ptsA );
+ _pdA->SetLines( linesA );
+ linesA->Delete(); //do not delete lines ??
+// _lineAActor->GetProperty()->BackfaceCullingOn();
+
+
+
+
+// Axe B
+ if(_lineBActor==NULL){
+ _lineBActor = vtkActor::New();
+ _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
+ _lineBActor->GetProperty()->SetLineWidth(2);
+ _lineBMapper = vtkPolyDataMapper::New();
+ _lineBActor->SetMapper(_lineBMapper);
+
+ _ptsB = vtkPoints::New();
+ _ptsB->SetNumberOfPoints(2);
+ _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
+ _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
+// _lineBActor->GetProperty()->BackfaceCullingOn();
+
+ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+ }
+
+ 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 ??
+
+
+ _lineBMapper->SetInput(_pdB);
+ _lineBMapper->ImmediateModeRenderingOn();
- // Axe B
- if(_lineBActor==NULL){
- _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();
- 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==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==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==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) { // YZ
- 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) { // XZ
- 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) { // XY
- 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) { // YZ
+ 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) { // XZ
+ 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) { // XY
+ 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];
+ int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0, x = 0, y = 0, z = 0;
+ double *spc = 0;
+ double *origin = 0;
+
+
+ //GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
+
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]);
+ origin = img->GetOrigin();
+ img->GetExtent(x1,x2,y1,y2,z1,z2);
+ spc = img->GetSpacing();
+ x1 += origin[0];
+ x2 += origin[0];
+ y1 += origin[1];
+ y2 += origin[1];
+ z1 += origin[2];
+ z2 += origin[2];
+ 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());
+ x = (int)(GetVtkmprbasedata()->GetX());
+ y = (int)(GetVtkmprbasedata()->GetY());
+ z = (int)(GetVtkmprbasedata()->GetZ());
x = (int)(x*spc[0]);
y = (int)(y*spc[1]);
//-------------------------------------------------------------------
void wxVtkMPR3DView::Configure(){
+
+
+ vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
_wxvtk3Dbaseview->Configure();
_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
_pointWidget = vtkPointWidget::New();
_myCallback->SetVtkPointWidget(_pointWidget);
_pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
- _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
+
+ if(imageData){
+ _pointWidget->SetInput( imageData );
+ }
_pointWidget->AllOff();
}
_planeWidget = vtkPlaneWidget::New();
_myCallback->SetVtkPlaneWidget(_planeWidget);
- _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
+ if(imageData){
+ _planeWidget->SetInput( imageData );
+ }
_planeWidget->NormalToXAxisOn();
_planeWidget->SetResolution(50);
_planeWidget->SetRepresentationToOutline();
int dim[3];
- GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
+ if(imageData){
+ imageData->GetDimensions(dim);
+ }else{
+ dim[0] = 0;
+ dim[1] = 0;
+ dim[2] = 0;
+ }
int px=(dim[0]/2);
int py=(dim[1]/2);
int pz=(dim[2]/2);
_planeWidget->Off();
_wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
- }else{
-
}
+
_planeWidget->GetPolyData(_vtkplane);
- vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- _probe->SetSource( imageData );
- _contourMapper->SetScalarRange( imageData->GetScalarRange() );
+ if(imageData){
+ _probe->SetSource( imageData );
+ _contourMapper->SetScalarRange( imageData->GetScalarRange() );
+ }
ConfigureFreePlanes();
}
planeWidget->EnabledOff();
planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
- planeWidget->SetInput( image );
+ int xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
+ double xSpacing = 0, ySpacing = 0, zSpacing = 0;
+ if(image){
+ planeWidget->SetInput( image );
+ image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+ image->GetSpacing(xSpacing, ySpacing, zSpacing);
+ }
- int xMin, xMax, yMin, yMax, zMin, zMax;
- image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
- double xSpacing, ySpacing, zSpacing;
- image->GetSpacing(xSpacing, ySpacing, zSpacing);
+
+
+
if (activationkey=='x')
{
void wxVtkMPR3DView::RefreshView() // virtual
{
double spc[3];
- this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
+ vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+
+ if(image){
+ image->GetSpacing(spc);
+ }else{
+ spc[0] = 0;
+ spc[1] = 0;
+ spc[2] = 0;
+ }
+ //this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
//double nx=1,ny=0,nz=0; // JPRx
Refresh();