#include "OpenImageDialog.h"
+wxDlgTransformByDimensionBySpacingByPixel::wxDlgTransformByDimensionBySpacingByPixel()
+{
+}
+
+wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingByPixel()
+{
+}
+
+
+void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *parent , wxString message,int &typeOfTransformation,bool &dlgWxOK)
+{
+ wxDialog* dial = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190));
+ wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
+ wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxString lstOptOperation[3];
+ lstOptOperation[0]=_T("By Dimension");
+ lstOptOperation[1]=_T("By Spacing");
+ lstOptOperation[2]=_T("By Pixel");
+ wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 3 , lstOptOperation, 3, wxRA_SPECIFY_COLS);
+
+ dialSizer->Add( new wxStaticText(dial,-1,message) , 0, wxGROW );
+ // dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
+ dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
+ dialSizer->Add(radioOpts,0,wxGROW);
+ dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
+ dialSizer->Add(buttonsSizer,0,wxGROW);
+ dial->SetSizer(dialSizer, true);
+ dial->Layout();
+ dial->ShowModal();
+
+ typeOfTransformation = -1;
+ dlgWxOK = false;
+
+ if (dial->GetReturnCode() == wxID_OK)
+ {
+ typeOfTransformation = radioOpts->GetSelection();
+ dlgWxOK = true;
+ }
+}
+
+//---------------------------------------------------------
+
+
+
/**
** Begin of the threshold panel
**/
ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
{
- _colorLayerImageView = new ColorLayerImageView();
-
- _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
-
+ _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
+ _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
- _thresholdGo = true;
- _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
+ _colorLayerImageView = new ColorLayerImageView();
+ _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
+ _thresholdGo = true;
+ _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
_cb_ShowHide->SetValue(_thresholdGo);
_cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Slice Fix/Dinamic") );
_colorLayerImageView = colorLayerImageView;
}
+// This is the new spacing of the background image (1,1,1)
+void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3])
+{
+ _spcBase[0] = spc[0];
+ _spcBase[1] = spc[1];
+ _spcBase[2] = spc[2];
+
+ _spcBase[0] = 1;
+ _spcBase[1] = 1;
+ _spcBase[2] = 1;
+}
+
+// This is the Original spacing of the background image
+void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3])
+{
+ _spcOrg[0] = spc[0];
+ _spcOrg[1] = spc[1];
+ _spcOrg[2] = spc[2];
+}
+
+// This is the size in pixels of the background image
+void ColorLayerImageViewPanel::SetBaseDimension(int dim[3])
+{
+ _dimBase[0] = dim[0];
+ _dimBase[1] = dim[1];
+ _dimBase[2] = dim[2];
+}
+
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
{
// EED ???
// creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
// w.ShowModal();
+ 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);
- _sl_SliceImage->SetRange( 0 , ext[5]-ext[4] );
-
+ 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
+
_colorLayerImageView->onThreshold();
_colorLayerImageView->GetwxVtkBaseView()->Refresh();
}
-
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
{