]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxGimmickView.cpp
correction bug Fedora 64 bits
[creaImageIO.git] / src / creaImageIOWxGimmickView.cpp
index f13c5e01823351ee46f29f898654879d85e07d42..fc748e0aa2ebd31f5b5bd8599d286ba40ddbb898 100644 (file)
@@ -113,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 ) );
@@ -323,10 +324,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<OutStrGimmick> &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<std::string> files;
+        std::vector<std::string> files;
        std::string db_name = crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()));
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
 
@@ -513,7 +514,7 @@ namespace creaImageIO
        mProgressDialog->Pulse(_T("Updating view..."));
 
        UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-       delete mProgressDialog;
+       killProgress();
        DisplayAddSummary();    
 
       }
@@ -535,6 +536,7 @@ namespace creaImageIO
     
     if (FD->ShowModal()==wxID_OK)
     {
+                       time(&mstart);
        std::string dirname = wx2std (FD->GetPath());
        bool recurse =  isNeedRecursive(dirname);
        if (recurse)
@@ -562,7 +564,7 @@ namespace creaImageIO
                mProgressDialog->Pulse(_T("Updating view..."));
 
                UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();
          }
     mViewer->StartPlayer();
@@ -831,7 +833,7 @@ namespace creaImageIO
      mProgressDialog->Pulse(_T("Updating view..."));
 
      UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-     delete mProgressDialog;
+     killProgress();
      DisplayAddSummary();
   }
 
@@ -923,7 +925,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);
@@ -949,12 +951,12 @@ namespace creaImageIO
                {
                        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 +965,23 @@ namespace creaImageIO
                                        b2d.SetConvertModeToDicom();
                                        b2d.verbose=false;
                                        b2d.Execute();
-
                                        if (addToDB)
                                        {
+       std::cout <<"after addToDB" << std::endl;
                                                mProgressDialog = new wxProgressDialog(_T("Adding directory"),_T(""),1000,this,wxPD_ELAPSED_TIME |wxPD_CAN_ABORT );
+       std::cout <<"after new wxProgressDialog" << std::endl;                                          
                                                mCurrentDirectory = gimmickTools->getOutputDir();
+       std::cout <<"after gimmickTools->getOutputDir[" <<mCurrentDirectory << std::endl;                                               
                                                mGimmick->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;                                            
                                        }       
                                }
                        }
@@ -1092,7 +1100,7 @@ namespace creaImageIO
                mProgressDialog->Pulse(_T("Updating view..."));
                
                UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();
                mViewer->StartPlayer();  
          }
@@ -1164,7 +1172,7 @@ namespace creaImageIO
                mGimmick->AddFiles(storage,i_filenames);
                mProgressDialog->Pulse(_T("Updating view..."));
                UpdateTreeViewLevel(storage,1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();    
        }
   }
@@ -1191,10 +1199,13 @@ namespace creaImageIO
     //    std::cout << "OnAddProgress "<<mess<<std::endl;
     wxString s(wxString::From8BitData(mess));
     //  std::cout << "Pulse"<<std::endl;
-    if (!mProgressDialog->Pulse(s)) 
-      {
-       p.SetStop();
-      }
+       if(mProgressDialog != 0)
+       {
+               if (!mProgressDialog->Pulse(s)) 
+                 {
+               p.SetStop();
+                 }
+       }
     //  std::cout << "OnAddProgress ok"<<std::endl;
   }
   //=================================================
@@ -1202,12 +1213,10 @@ namespace creaImageIO
   //=================================================
   void WxGimmickView::DisplayAddSummary()
   {
-    const Gimmick::AddProgress& p = mGimmick->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 +1291,13 @@ namespace creaImageIO
        }
   }
 
+  void WxGimmickView::killProgress()
+  {
+               mProgressDialog->Resume();
+               mProgressDialog->Destroy();
+               mProgressDialog = 0;
+  }
+
    //=================================================
 
    //=================================================