From: Eduardo DAVILA Date: Wed, 4 Oct 2017 09:46:09 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/changeWx28to30' into vtk7itk4wx3 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=26b4c3303c14bfef570ad5671627ba5e01519f83;hp=-c;p=creaImageIO.git Merge remote-tracking branch 'origin/changeWx28to30' into vtk7itk4wx3 --- 26b4c3303c14bfef570ad5671627ba5e01519f83 diff --combined src/creaImageIOWxAnySimpleDlg.cpp index a8db5f7,5a71335..4a31cbe --- a/src/creaImageIOWxAnySimpleDlg.cpp +++ b/src/creaImageIOWxAnySimpleDlg.cpp @@@ -29,19 -29,13 +29,19 @@@ #include "creaImageIOWxAnySimpleDlg.h" #include "creaImageIOWxGimmickReaderDialog.h" -#include + +#if ITK_VERSION_MAJOR < 4 // : WARNING: deprecated in ITK 4.0 +# include +# include +#else // ITK_VERSION_MAJOR < 4 +# include +#endif // ITK_VERSION_MAJOR < 4 + #include #include #include #include #include -#include #include #include #include @@@ -94,7 -88,12 +94,12 @@@ namespace creaImageI void WxAnySimpleDlg::OnReadFile(wxCommandEvent& event) { int resultShowModal; + //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 + #if wxMAJOR_VERSION <= 2 wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition); + #else + wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxFD_OPEN |wxFD_MULTIPLE, wxDefaultPosition); + #endif resultShowModal = fileDlg->ShowModal(); if ( resultShowModal==wxID_OK ) @@@ -108,28 -107,25 +113,28 @@@ std::string name = crea::wx2std(wxArray[i]); // FOR THE MOMENT ONLY short 3D et short 4D readImg(name); - } - } - else { + } // for + } else { // TO DO WARNING MESSAGES - } - } + } // if + } // if SetReturnCode( resultShowModal ); // Close(); EndModal( resultShowModal ); } + +///////////////////////////////////////////////////////////////////// +// // +////////////////////////////////////////////////////////////////////// void WxAnySimpleDlg::setExts(std::vector i_exts) { m_exts = i_exts; } - ///////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////// - void WxAnySimpleDlg::OnReadDirectory(wxCommandEvent &event) { int resultShowModal; @@@ -141,55 -137,33 +146,55 @@@ if ( resultShowModal==wxID_OK ) { std::string path = crea::wx2std(dirDlg->GetPath()); + +/* typedef boost::filesystem::directory_iterator dir_it; dir_it itr(path); dir_it end_itr; - /*if (boost::filesystem::exists(path)) - {*/ +// if (boost::filesystem::exists(path)) +// { for(;itr != end_itr; ++itr) { - bvalid = m_exts.size() == 0? true : false; - std::vector::iterator it = m_exts.begin(); - std::string ext = itr->path().filename().string().substr(itr->path().filename().string().find_last_of(".")); - for(; it != m_exts.end(); it++) - { - if(ext == (*it) ) - { - bvalid = true; - break; - } - } +//EED +// All files have the same extention +// bvalid = m_exts.size() == 0? true : false; +// std::vector::iterator it = m_exts.begin(); +// std::string ext = itr->path().filename().string().substr(itr->path().filename().string().find_last_of(".")); +// for(; it != m_exts.end(); it++) +// { +// if(ext == (*it) ) +// { +// bvalid = true; +// break; +// } +// } // for +bvalid=true; if (!boost::filesystem::is_directory(itr->status()) && bvalid) { - readImg(itr->path().string().c_str()); - } - } - } +printf("EED WxAnySimpleDlg::OnReadDirectory Each file %s \n", itr->path().string().c_str() ); + readImg( itr->path().string().c_str() ); + } // if + } // for itr +*/ + + typedef vector vec; // store paths + vec v; // so we can sort them later + copy(boost::filesystem::directory_iterator(path), boost::filesystem::directory_iterator(), back_inserter(v)); + sort(v.begin(), v.end()); // sort, since directory iteration + // is not ordered on some file systems + for (vec::const_iterator it (v.begin()); it != v.end(); ++it) + { + readImg( it->string().c_str() ); + } // for + + + + + } // if OK SetReturnCode( resultShowModal ); // Close(); EndModal( resultShowModal ); + } ////////////////////////////////////////////////////////////////////// @@@ -261,11 -235,9 +266,11 @@@ return imageIO->GetNumberOfDimensions(); } + void WxAnySimpleDlg::readImg(const std::string &i_name) { size_t dims = getNumberOfDimensions(i_name); + //const std::type_info *type= &getType(i_name); switch(dims) { @@@ -372,7 -344,6 +377,7 @@@ } else { + printf("EED WxAnySimpleDlg::readImg Not type found for DIM 3 \n"); //????FCY, so what the type???? } break; @@@ -515,7 -486,6 +520,7 @@@ } else { + printf("EED WxAnySimpleDlg::readImg Not type found for DIM 4 \n"); //????FCY, so what the type???? } break; @@@ -548,11 -518,7 +553,11 @@@ { typedef itk::Image TImage; typedef itk::GDCMImageIO GDCMType; +#if ITK_VERSION_MAJOR < 4 typedef itk::DICOMSeriesFileNames dicnames; +#else // ITK_VERSION_MAJOR < 4 + typedef itk::GDCMSeriesFileNames dicnames; +#endif // ITK_VERSION_MAJOR < 4 GDCMType::Pointer gdcmIO = GDCMType::New(); dicnames::Pointer generator = dicnames::New(); diff --combined src/creaImageIOWxSimpleDlg.cpp index 2e9a9c5,09f7e02..297ac11 --- a/src/creaImageIOWxSimpleDlg.cpp +++ b/src/creaImageIOWxSimpleDlg.cpp @@@ -69,7 -69,12 +69,12 @@@ namespace creaImageI void WxSimpleDlg::OnReadFile(wxCommandEvent& event) { int resultShowModal; + //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 + #if wxMAJOR_VERSION <= 2 wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition); + #else + wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxFD_OPEN |wxFD_MULTIPLE, wxDefaultPosition); + #endif resultShowModal = fileDlg->ShowModal(); if ( resultShowModal==wxID_OK ) @@@ -232,14 -237,12 +237,14 @@@ first->GetDimensions(dim); if (dim[2]==1) { - vtkImageData *out; - out = vtkImageData::New(); - out->SetScalarType(first->GetScalarType()); - out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents()); + vtkImageData *out = vtkImageData::New(); int ext[6]; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 first->GetWholeExtent(ext); +#else + first->GetExtent(ext); +#endif if(ext[5] == 0) { ext[5] = getImagesSelected().size()-1; @@@ -256,18 -259,8 +261,18 @@@ } out->SetSpacing(spac); out->SetDimensions(dim[0], dim[1], getImagesSelected().size() ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + + out->SetScalarType(first->GetScalarType()); + out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents()); out->AllocateScalars(); out->Update(); +#else + out->AllocateScalars(first->GetScalarType(),first->GetNumberOfScalarComponents()); +#endif + + unsigned long imsize = dim[0] * dim[1]; imsize = imsize * dim[2]; // deal with multiframes here // differents formats char , short, etc... diff --combined src/creaImageIOWxViewer.cpp index a6e3d98,784b1c7..ee2258a --- a/src/creaImageIOWxViewer.cpp +++ b/src/creaImageIOWxViewer.cpp @@@ -85,7 -85,7 +85,7 @@@ namespace creaImageI mLastImageShown = NULL; // previewer - mInteractor = new crea::creawxVTKRenderWindowInteractor(this,-1); + mInteractor = new crea::wxVTKRenderWindowInteractor(this,-1); mInteractor->UseCaptureMouseOn(); mViewer = vtkImageViewer2::New(); @@@ -207,40 -207,20 +207,40 @@@ <SetInput(im); +#else + mViewer->SetInputData(im); +#endif mViewer->SetSlice( 0 ); int x1,x2,y1,y2,z1,z2; double spx,spy,spz; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 im->Update(); +#else + // ... +#endif + //std::cout << "in WxViewer::ShowImage PrintSelf() ="; //im->PrintSelf(std::cout, vtkIndent(2)); im->GetSpacing(spx,spy,spz); //im->GetExtent (x1,x2,y1,y2,z1,z2); // JPR + + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 im->GetWholeExtent (x1,x2,y1,y2,z1,z2); +#else + im->GetExtent (x1,x2,y1,y2,z1,z2); +#endif + + /* std::cout << "in WxViewer::ShowImage GetWholeExtent ext ="; std::cout << " [x1]=" << x1;