_dimBase[2] = dim[2];
}
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
+{
+ if (img!=NULL)
+ {
+ _colorLayerImageView->SetImage( img );
+
+ double spc[3];
+ img->GetSpacing(spc);
+
+ int dim[3];
+ int ext[6];
+ img->GetWholeExtent(ext);
+ dim[0] = ext[1]-ext[0];
+ dim[1] = ext[3]-ext[2];
+ dim[2] = ext[5]-ext[4];
+ _sl_SliceImage->SetRange( 0 , dim[2] );
+
+ if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
+ (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
+ )
+ {
+
+ bool transformOkDlg;
+ int typeOfTransformation;
+ wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
+ wxDlgTransformByDimensionBySpacingByPixel dlg;
+ dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg);
+
+ printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
+
+ if (typeOfTransformation==0) // make dimensions equals
+ {
+ printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
+ spc[0]=_spcBase[0]*_dimBase[0]/dim[0];
+ spc[1]=_spcBase[1]*_dimBase[1]/dim[1];
+ spc[2] = 1;
+ }
+
+ if (typeOfTransformation==1) // make spacing equals
+ {
+ spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0];
+ spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1];
+ spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2];
+ }
+
+ if (typeOfTransformation==2) // make spacing = 1
+ {
+ spc[0] = 1;
+ spc[1] = 1;
+ spc[2] = 1;
+ }
+
+ img->SetSpacing(spc);
+ } // spc !_spcBase dim!__dimBase
+
+ if (_colorLayerImageView!=NULL)
+ {
+ _colorLayerImageView->onThreshold();
+ _colorLayerImageView->Refresh();
+ }
+
+
+ }
+}
+
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
{
printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
- _colorLayerImageView->SetImage( diag.getImageData() );
-
- double spc[3];
- diag.getImageData()->GetSpacing(spc);
-
- int dim[3];
- int ext[6];
- diag.getImageData()->GetWholeExtent(ext);
- dim[0] = ext[1]-ext[0];
- dim[1] = ext[3]-ext[2];
- dim[2] = ext[5]-ext[4];
- _sl_SliceImage->SetRange( 0 , dim[2] );
-
- if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
- (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
- )
- {
-
- bool transformOkDlg;
- int typeOfTransformation;
- wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
- wxDlgTransformByDimensionBySpacingByPixel dlg;
- dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg);
-
-printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
-
- if (typeOfTransformation==0) // make dimensions equals
- {
- printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
- spc[0]=_spcBase[0]*_dimBase[0]/dim[0];
- spc[1]=_spcBase[1]*_dimBase[1]/dim[1];
- spc[2] = 1;
- }
-
- if (typeOfTransformation==1) // make spacing equals
- {
- spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0];
- spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1];
- spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2];
- }
-
- if (typeOfTransformation==2) // make spacing = 1
- {
- spc[0] = 1;
- spc[1] = 1;
- spc[2] = 1;
- }
-
- diag.getImageData()->SetSpacing(spc);
- } // spc !_spcBase dim!__dimBase
-
- if (_colorLayerImageView!=NULL)
- {
- _colorLayerImageView->onThreshold();
- _colorLayerImageView->Refresh();
- }
+ SetImage( diag.getImageData() );
}
//----------------------------------------------------------------------------