X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOWxGimmickView.cpp;h=359223cedda9d4ba2850a4041363c792e9fe3a4b;hb=refs%2Fheads%2Forigin;hp=f13c5e01823351ee46f29f898654879d85e07d42;hpb=bf3660569b1baa8be10fc708f595efc66afe3334;p=creaImageIO.git diff --git a/src/creaImageIOWxGimmickView.cpp b/src/creaImageIOWxGimmickView.cpp index f13c5e0..359223c 100644 --- a/src/creaImageIOWxGimmickView.cpp +++ b/src/creaImageIOWxGimmickView.cpp @@ -1,3 +1,31 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Santé) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + + #include #include #include @@ -113,6 +141,7 @@ namespace creaImageIO // Sets the current directory to the home dir mCurrentDirectory = std2wx(gimmick->GetHomeDirectory()); + // Connect the AddProgress callback gimmick->ConnectAddProgressObserver ( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) ); @@ -170,6 +199,7 @@ namespace creaImageIO mBottomPanel->SetSizer(mbottom_sizer); // Splitting + /// \TODO fix warning: unused variable hsize int hsize = size.GetHeight(); int top_minsize = 450; @@ -323,10 +353,10 @@ namespace creaImageIO /// By default if out_infos is empty, we dont' provide informations, we return only vtkImageData /// if out_infos has only one entry "all" we provide all database informations void WxGimmickView::getSelectedFiles(std::vector &outG, std::vector< std::string> i_attr, - bool mult, const std::string out_model) + bool mult, const std::string out_model) { // First we select the files - std::vector files; + std::vector files; std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())); GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files); @@ -501,7 +531,8 @@ namespace creaImageIO new wxProgressDialog(_T("Adding file(s)"), _T(""), 1000, - this, +// this, + NULL, wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -513,7 +544,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } @@ -535,6 +566,7 @@ namespace creaImageIO if (FD->ShowModal()==wxID_OK) { + time(&mstart); std::string dirname = wx2std (FD->GetPath()); bool recurse = isNeedRecursive(dirname); if (recurse) @@ -550,7 +582,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding directory"), _T(""), NumberFilesToAdd(dirname,recurse), - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | wxPD_SMOOTH | // wxPD_ESTIMATED_TIME | @@ -562,7 +597,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } mViewer->StartPlayer(); @@ -600,7 +635,7 @@ namespace creaImageIO bool WxGimmickView::isNeedRecursive(std::string i_name) { boost::filesystem::directory_iterator iter(i_name), end_iter; - bool bfindir = false; + //bool bfindir = false; for(; iter != end_iter; ++iter) { if(boost::filesystem::is_directory(*iter)) @@ -825,13 +860,18 @@ namespace creaImageIO //================================================= void WxGimmickView::AddDir(std::string dirName) { - mProgressDialog = new wxProgressDialog(_T("Adding directory"),_T(""),1000,this,wxPD_ELAPSED_TIME |wxPD_CAN_ABORT ); + mProgressDialog = new wxProgressDialog(_T("Adding directory"),_T(""),1000, + +//EED this, + NULL, + + wxPD_ELAPSED_TIME |wxPD_CAN_ABORT ); mCurrentDirectory = crea::std2wx(dirName); mGimmick->AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),dirName,true); mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } @@ -923,7 +963,7 @@ namespace creaImageIO void WxGimmickView::OnTools(wxCommandEvent& event) { mViewer->StopPlayer(); - + wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(550,350)); wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL); @@ -945,16 +985,16 @@ namespace creaImageIO if (dial->GetReturnCode() == wxID_OK) { #if defined(BUILD_BRUKER) - if (nb->GetSelection()==0)//Selection: Bruker Image Reader + if (nb->GetSelection()==0)//Selection: Bruker Image Reader { std::string inputDir = crea::wx2std(gimmickTools->getInputDir()); std::string outputDir = crea::wx2std(gimmickTools->getOutputDir()); - + bool addToDB = gimmickTools->getAddToDBCheckBoxValue(); if (inputDir.compare("")!=0 && outputDir.compare("")!=0) { - if ( wxMessageBox(_T("Depending on the amount of Data the process can take between 1 and 5 minutes. Do you want to continue?"), + if ( wxMessageBox(_T("Depending on the amount of Data the process can take several minutes. Do you want to continue?"), _T("Please confirm"), wxICON_QUESTION | wxYES_NO) == wxYES ) { Bruker2Dicom b2d; @@ -963,17 +1003,28 @@ namespace creaImageIO b2d.SetConvertModeToDicom(); b2d.verbose=false; b2d.Execute(); - if (addToDB) { - mProgressDialog = new wxProgressDialog(_T("Adding directory"),_T(""),1000,this,wxPD_ELAPSED_TIME |wxPD_CAN_ABORT ); + std::cout <<"after addToDB" << std::endl; + mProgressDialog = new wxProgressDialog(_T("Adding directory"),_T(""),1000, + +//EED this, + NULL, + + wxPD_ELAPSED_TIME |wxPD_CAN_ABORT ); + std::cout <<"after new wxProgressDialog" << std::endl; mCurrentDirectory = gimmickTools->getOutputDir(); + std::cout <<"after gimmickTools->getOutputDir[" <AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),outputDir,true); + std::cout <<"after mGimmick->AddDir" << std::endl; mProgressDialog->Pulse(_T("Updating view...")); - + std::cout <<"after mProgressDialog->Pulse" << std::endl; UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + std::cout <<"after UpdateTreeViewLevel" << std::endl; + killProgress(); + std::cout <<"after delete mProgressDialog" << std::endl; DisplayAddSummary(); + std::cout <<"after dDisplayAddSummary" << std::endl; } } } @@ -1082,7 +1133,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding drive"), _T(""), 1000, - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -1092,7 +1146,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); mViewer->StartPlayer(); } @@ -1156,7 +1210,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding file(s)"), _T(""), 1000, - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -1164,7 +1221,7 @@ namespace creaImageIO mGimmick->AddFiles(storage,i_filenames); mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(storage,1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } } @@ -1191,10 +1248,14 @@ namespace creaImageIO // std::cout << "OnAddProgress "<Pulse(s)) - { - p.SetStop(); - } + + if(mProgressDialog != 0) + { + if (!mProgressDialog->Pulse(s)) + { + p.SetStop(); + } + } // std::cout << "OnAddProgress ok"<GetAddProgress(); - std::stringstream mess; - mess << "Dirs \tscanned\t: " << p.GetNumberScannedDirs() << "\n"; - mess << "Files\tscanned\t: " << p.GetNumberScannedFiles() << "\n"; - mess << "Files\thandled\t: " << p.GetNumberHandledFiles() << "\n\n"; - mess << "Files\tadded \t: " << p.GetNumberAddedFiles() << "\n\n"; + std::stringstream mess(mGimmick->getSummary()); + time_t end; + time(&end); + mess << "time to scan :" << difftime(end,mstart) << "sec"; wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this); } @@ -1282,6 +1341,13 @@ namespace creaImageIO } } + void WxGimmickView::killProgress() + { + mProgressDialog->Resume(); + mProgressDialog->Destroy(); + mProgressDialog = 0; + } + //================================================= //=================================================