X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOWxGimmickView.cpp;h=e7dcfcf63918959ff5d1291ac5620a10b0477159;hb=3213e0d7adb70f52d723a5b7065f4780b6c9e451;hp=91185a56339be44eeed9d790087d31952aa4e5e0;hpb=3a22e19184c369b130d4caa992a8e98e50c7a0ee;p=creaImageIO.git diff --git a/src/creaImageIOWxGimmickView.cpp b/src/creaImageIOWxGimmickView.cpp index 91185a5..e7dcfcf 100644 --- a/src/creaImageIOWxGimmickView.cpp +++ b/src/creaImageIOWxGimmickView.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include using namespace crea; // Icons @@ -111,6 +113,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 ) ); @@ -298,18 +301,117 @@ namespace creaImageIO { std::vector files; GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files); - ReadImagesNotThreaded(s, files, dim); + //ReadImagesNotThreaded(s, files, dim); + + + std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())); + // ReadImagesNotThreadedInfosInVector(db_name,output, files,dim,1); } + + //====================================================================== void WxGimmickView::GetSelectedImagesInVector(std::vector& s, int dim) { std::vector files; + std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())); GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files); + ReadImagesNotThreadedInVector(s, files, dim); } + + + /// 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) + { + // First we select the files + std::vector files; + std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())); + GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files); + + std::string asking; + std::string dim; + bool bsingle = isSingle(files.front()); + int i_dim_out; + mGimmick->GetSetting(SETTINGS_OUTPUT_ASK, asking); + mGimmick->GetSetting(SETTINGS_OUTPUT_DIM, dim); + + if (asking == "true") + { + // display the output dialog box + // get dim + int idim; + sscanf(dim.c_str(),"%d",&idim); + WxOutputDlg *dlg = new WxOutputDlg(this,files, idim -1, bsingle); + if (dlg->ShowModal() == wxID_OK) + { + dim = dlg->getDim(); + mGimmick->UpdateSetting(SETTINGS_OUTPUT_ASK, dlg->getAsking()); + mGimmick->UpdateSetting(SETTINGS_OUTPUT_DIM, dim); + } + else + { + return; + } + } + else + { + } + sscanf(dim.c_str(),"%d",&i_dim_out); + + + // Next we create the structure for dicom output infos + OutputAttr Oattr; + Oattr.db = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())); + if(i_attr.empty()) + { + // We don't send informations! + } + else if( i_attr.size() == 1 && i_attr.front() == "ALL") + { + // we send all database + Oattr.inside.push_back("ALL"); + } + else if( (i_attr.size() == 1 && i_attr.front() != "ALL") + || (i_attr.size() >1) ) + { + mGimmick->fillVectInfos(i_attr, Oattr); + } + else + { + // nothing + } + + // Next we create model and sort files + std::vector sort_files(files); + double zspacing = 1; + if( !out_model.empty() ) + { + /* OutputModel mod(out_model); + mGimmick->isAttributeExist(db_name, mod); + mod.sort(files, sort_files); + */} + + if ( sort_files.size() > 1 && ( (bsingle && i_dim_out == 1) || (!bsingle && i_dim_out ==3) ) ) + { + OutputModel *mod = new OutputModel(); + zspacing = mod->orderFilesWithZspacing(sort_files); + delete mod; + } + // Now we read and create the waiting output (vtkImageData * or OutGimmickData *) + readImages(outG, sort_files, Oattr, i_dim_out, zspacing); + } + + + + + //====================================================================== + //====================================================================== + //====================================================================== void WxGimmickView::GetSelectedFiles(std::vector& s) { @@ -400,7 +502,8 @@ namespace creaImageIO new wxProgressDialog(_T("Adding file(s)"), _T(""), 1000, - this, +// this, + NULL, wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -412,7 +515,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } @@ -434,6 +537,7 @@ namespace creaImageIO if (FD->ShowModal()==wxID_OK) { + time(&mstart); std::string dirname = wx2std (FD->GetPath()); bool recurse = isNeedRecursive(dirname); if (recurse) @@ -449,7 +553,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding directory"), _T(""), NumberFilesToAdd(dirname,recurse), - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | wxPD_SMOOTH | // wxPD_ESTIMATED_TIME | @@ -461,7 +568,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } mViewer->StartPlayer(); @@ -724,13 +831,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(); } @@ -822,7 +934,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); @@ -844,16 +956,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; @@ -862,17 +974,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; } } } @@ -981,7 +1104,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding drive"), _T(""), 1000, - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -991,7 +1117,7 @@ namespace creaImageIO mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); mViewer->StartPlayer(); } @@ -1055,7 +1181,10 @@ namespace creaImageIO new wxProgressDialog(_T("Adding file(s)"), _T(""), 1000, - this, + +//EED this, + NULL, + wxPD_ELAPSED_TIME | // wxPD_ESTIMATED_TIME | // wxPD_REMAINING_TIME | @@ -1063,7 +1192,7 @@ namespace creaImageIO mGimmick->AddFiles(storage,i_filenames); mProgressDialog->Pulse(_T("Updating view...")); UpdateTreeViewLevel(storage,1); - delete mProgressDialog; + killProgress(); DisplayAddSummary(); } } @@ -1090,10 +1219,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); } @@ -1181,6 +1312,13 @@ namespace creaImageIO } } + void WxGimmickView::killProgress() + { + mProgressDialog->Resume(); + mProgressDialog->Destroy(); + mProgressDialog = 0; + } + //================================================= //=================================================