]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxGimmickView.cpp
#3323 Bug with ToolBar (in wxFrame an not in wxPanel) in MacOs
[creaImageIO.git] / src / creaImageIOWxGimmickView.cpp
index 91185a56339be44eeed9d790087d31952aa4e5e0..a5650ee32978d68830327d8b0de2b66ac7c68a68 100644 (file)
@@ -1,8 +1,34 @@
-#include <creaImageIOPACSConnection.h>
+/*
+# ---------------------------------------------------------------------
+#
+# 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 <creaImageIOWxPACSConnectionPanel.h>
-#include <creaImageIOWxGimmickView.h>
 #include <creaImageIOWxTreeView.h>
-#include <creaImageIOSystem.h>
 #include <creaImageIOWxCustomizeConfigPanel.h>
 #include <creaImageIOWxListenerPanel.h>
 #include <creaImageIOWxEditFieldsPanel.h>
 #include <creaImageIOWxDescriptorPanel.h>
 #include <creaImageIOWxDumpPanel.h>
 #include <creaImageIOWxExportDlg.h>
+#include <creaImageIOWxOutputDlg.h>
+#include <creaImageIOOutputModel.h>
+
+#if defined(_WIN32)
+#pragma warning(disable: 4996)
+#endif
 
 using namespace crea;
 // Icons
@@ -99,39 +131,42 @@ namespace creaImageIO
                               const wxPoint& pos, 
                               const wxSize& size,
                               int min_dim,
-                               int max_dim,
+                   int max_dim,
                               int number_of_threads)
     : wxPanel(parent,id,pos,size),
       GimmickView(gimmick, number_of_threads),
-      mProgressDialog(0),
+      mProgressDialog(NULL),
       mConstructed(false)
   {
-    GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
-                       <<std::endl);
+
+    mViewer = NULL;
+    GimmickDebugMessage(1,"WxGimmickView::WxGimmickView" <<std::endl);
     // Sets the current directory to the home dir
     mCurrentDirectory =  std2wx(gimmick->GetHomeDirectory());
 
      // Connect the AddProgress callback
-    gimmick->ConnectAddProgressObserver 
-     ( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) );
+    gimmick->ConnectAddProgressObserver( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) );
+
 
     // Create the list of icons (mIcon)
     CreateIconList();
 
+
     // Global sizer
     msizer = new wxBoxSizer(wxVERTICAL);
 
     // Create the tool bar
-    CreateToolBar(); 
+    CreateToolBar( );
     msizer->Add( mToolBar, 0, wxGROW, 0);
 
+
     // Split part below toolbar into notebook for views and panel
     // for preview, messages...
     mSplitter = new wxSplitterWindow( this , -1);
 
     // Notebook
-    mNotebook = new wxNotebook(mSplitter,
-                              -1, wxDefaultPosition, wxDefaultSize, 0);
+    mNotebook = new wxNotebook(mSplitter, -1, wxDefaultPosition, wxDefaultSize, 0);
 
     //Gimmick
     mGimmick=gimmick;
@@ -140,6 +175,7 @@ namespace creaImageIO
     mSelectionMinDimension = min_dim;
     
     // Create the views
+      
     CreateTreeViews();
 
     // Bottom panel 
@@ -158,30 +194,31 @@ namespace creaImageIO
 
 
     mbottom_sizer->Add(mViewer,1,wxGROW,1);
+      
+      
     //    mViewer->Show();
 
     mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!"));
     mbottom_sizer->Add(mText,0,wxGROW,0);
-
-         
-         
+       
     mBottomPanel->SetSizer(mbottom_sizer);
 
     // Splitting
+    /// \TODO fix warning: unused variable hsize
     int hsize = size.GetHeight();
 
-    int top_minsize = 450;
-    int bottom_minsize = 50;
+    int top_minsize    = 450;
+    int bottom_minsize         = 50;
 
     mSplitter->SetMinimumPaneSize( bottom_minsize );
-    mSplitter->SplitHorizontally( mNotebook, mBottomPanel, 
-                                 top_minsize);
+    mSplitter->SplitHorizontally( mNotebook, mBottomPanel, top_minsize);
 
     msizer->Add( mSplitter, 1, wxGROW, 0);
 
-    mProgressDialog=0;
+    mProgressDialog=NULL;
     SetSizer( msizer );     
     SetAutoLayout(true);
     Layout();
     //mListener=new Listener();
     //mListener->ConnectObserver(boost::bind( &WxGimmickView::OnDriveMount, this, _1 ) );
@@ -199,28 +236,66 @@ namespace creaImageIO
   {
        // stop the viewer before application exit.
     mViewer->StopPlayer();
-    GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
-                       <<std::endl);
+    GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView" <<std::endl);
        delete mIcon;
        delete mViewer;
+       mIcon   = NULL;
+       mViewer = NULL;
     //if(mListener->IsAlive())   {        mListener->Delete();    }
   }
   //======================================================================
-  
+
+
+
+void WxGimmickView::AddBtnTool(wxPanel *panel, wxBoxSizer *sizerH, int id, wxString label, int idBitmap, wxString tooltip )
+{
+    wxBoxSizer      *sizer;
+    wxBitmapButton  *btn;
+    wxBitmap        bitmap;
+    
+    bitmap            = mIcon->GetBitmap(idBitmap);
+    btn               = new wxBitmapButton(mToolBar, id, bitmap, wxDefaultPosition, wxSize(50,50) , wxBU_BOTTOM );
+    btn->SetToolTip( tooltip );
+    sizer             = new wxBoxSizer(wxVERTICAL);
+    sizer->Add(btn,1,wxGROW,0);
+    sizer->Add(new wxStaticText(mToolBar,-1,label) , 0, wxALL | wxALIGN_CENTER, 3);
+    sizerH->Add( sizer ,1,wxGROW,0);
+}
+
   //======================================================================
   /// Creates the tool bar
   void WxGimmickView::CreateToolBar()
   {
+      mToolBar                      = new wxPanel(this,-1, wxDefaultPosition, wxSize(80,80) );
+      wxBoxSizer *sizerH             = new wxBoxSizer(wxHORIZONTAL);
+   
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDFILES_ID     , _T("Add file(s)")     , Icon_page_down        , _T("Add one or more file to database")                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDDIR_ID       , _T("Add folder")      , Icon_folder_down      , _T("Add the content of a folder to database")             );
+      AddBtnTool(mToolBar, sizerH, TOOL_ADDDATABASE_ID  , _T("Open database")   , Icon_database_add     , _T("Open a local or distant database")                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_REMOVE_ID       , _T("Remove")          , Icon_remove           , _T("Remove selected items")                               );
+      AddBtnTool(mToolBar, sizerH, TOOL_SYNCHRONIZE_ID  , _T("Synchronize")     , Icon_synchronize      , _T("Synchronizes the database with disk")                 );
+      AddBtnTool(mToolBar, sizerH, TOOL_HELP_ID         , _T("Help")            , Icon_help             , _T("Open help window")                                    );
+      AddBtnTool(mToolBar, sizerH, TOOL_SETTINGS_ID     , _T("System settings") , Icon_settings         , _T("Allows the modification of various system settings")  );
+      AddBtnTool(mToolBar, sizerH, TOOL_TOOLS_ID        , _T("Tools")           , Icon_tools            , _T("Applies tools to images")                             );
+      AddBtnTool(mToolBar, sizerH, TOOL_CREATEDB_ID     , _T("Create database") , Icon_create_database  , _T("Create DB from an Attributes Descriptor file")        );
+  #if defined(BUILD_PACS)
+      AddBtnTool(mToolBar, sizerH, TOOL_PACS_ID         , _T("PACS Connection,"), Icon_create_database  , _T("Echo, Find and Get to a PACS")                        );
+  #endif
+      mToolBar->SetSizer( sizerH );
+      mToolBar->Layout();
+      
+/* EED 2021-12-17
+   The wxToolBar depends from wxFrame, in this code it is not the case.   In Mac Os is not working !
+   Change the mechanisme from wcToolBar to normal Buttons
     long style = wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT;
-    mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
-                            style);
+    mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,style);
 
-    mToolAddFile = mToolBar->AddTool( TOOL_ADDFILES_ID, 
+    mToolAddFile = mToolBar->AddTool( TOOL_ADDFILES_ID,
                                      _T("Add file(s)"),
                                      mIcon->GetBitmap(Icon_page_down),
                                      _T("Add one or more file to database")
                                      );
-    mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID, 
+    mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID,
                                      _T("Add folder"),
                                      mIcon->GetBitmap(Icon_folder_down),
                                      _T("Add the content of a folder to database")
@@ -268,8 +343,9 @@ namespace creaImageIO
                                      );
 #endif
     //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
+       mToolBar->Realize();
 
-    mToolBar->Realize();
+ */
   }
   //======================================================================
 
@@ -279,8 +355,7 @@ namespace creaImageIO
   void WxGimmickView::CreateTreeView( TreeHandler* h)
   {
     std::string name(h->GetTree().GetAttribute("Name"));
-    GimmickMessage(2,"Creating the tree view for '"<<
-                  name<<"'"<<std::endl);
+    GimmickMessage(2,"Creating the tree view for '"<<  name<<"'"<<std::endl);
     // Create the WxTreeView
     WxTreeView* view = new WxTreeView(h, this, mNotebook, -1);
 
@@ -298,18 +373,116 @@ namespace creaImageIO
   {
        std::vector<std::string> 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<vtkImageData*>& s, int dim)
   {
        std::vector<std::string> 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<OutStrGimmick> &outG, std::vector< std::string> i_attr, 
+                                       bool mult, const std::string out_model)
+  {
+       // First we select the 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);
+
+       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;
+//EED 01/09/2014
+          if (i_dim_out==2)
+               {
+                       Oattr.mult=true;
+               } // i_dim_out
+
+
+       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<std::string> 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<std::string>& s)
   {
@@ -372,7 +545,15 @@ namespace creaImageIO
   void WxGimmickView::OnAddFiles(wxCommandEvent& event)
   {
     mViewer->StopPlayer();
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
     long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
+#else
+    long style = wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE;
+#endif
+
+
     std::string wc("*");
     wxFileDialog* FD = new wxFileDialog( 0, 
                                         _T("Select file"),
@@ -400,7 +581,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 +594,7 @@ namespace creaImageIO
        mProgressDialog->Pulse(_T("Updating view..."));
 
        UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-       delete mProgressDialog;
+       killProgress();
        DisplayAddSummary();    
 
       }
@@ -434,6 +616,7 @@ namespace creaImageIO
     
     if (FD->ShowModal()==wxID_OK)
     {
+                       time(&mstart);
        std::string dirname = wx2std (FD->GetPath());
        bool recurse =  isNeedRecursive(dirname);
        if (recurse)
@@ -449,7 +632,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 +647,7 @@ namespace creaImageIO
                mProgressDialog->Pulse(_T("Updating view..."));
 
                UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();
          }
     mViewer->StartPlayer();
@@ -483,7 +669,7 @@ namespace creaImageIO
                {
                        if (recursive) 
                        {
-                               nb += NumberFilesToAdd(itr->string(), recursive);
+                               nb += NumberFilesToAdd(itr->path().string(), recursive);
                        }
                }
                else
@@ -499,7 +685,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))
@@ -514,9 +700,7 @@ namespace creaImageIO
   //=================================================
   void WxGimmickView::OnSelectionChange(const std::vector<tree::Node*>& sel, bool isSelection, int selection, bool needProcess)
   {      
-    GimmickDebugMessage(5,
-                       "WxGimmickView::OnSelectionChange"
-                       <<std::endl);
+       GimmickDebugMessage(5,"WxGimmickView::OnSelectionChange"<<std::endl);
     wxBusyCursor busy;
        bool valid=true;
        
@@ -525,9 +709,7 @@ namespace creaImageIO
                valid= ValidateSelected(NULL,
                                mSelectionMinDimension,
                                mSelectionMaxDimension );
-       }
-       else if(needProcess)
-       {
+       } else if(needProcess) {
                ResetExtent();
                std::vector<tree::Node*>::const_iterator i;
                for(i=sel.begin();i!=sel.end()&&valid;++i)
@@ -535,16 +717,12 @@ namespace creaImageIO
                        valid= ValidateSelected((*i),
                                mSelectionMinDimension,
                                mSelectionMaxDimension );
-               }
-       }
-       else if(isSelection)
-       {
+               } // for
+       } else if(isSelection) {
                valid= ValidateSelected(sel.front(),
                                mSelectionMinDimension,
                                mSelectionMaxDimension );
-       }
-       else
-       {
+       } else {
                ResetExtent();
                std::vector<tree::Node*>::const_iterator i;
                for(i=sel.begin();i!=sel.end()&&valid;++i)
@@ -552,18 +730,22 @@ namespace creaImageIO
                        valid= ValidateSelected((*i),
                                mSelectionMinDimension,
                                mSelectionMaxDimension );
-               }
-       }
+               } // for 
+       } // if sel.size 
        mText->SetLabel(crea::std2wx(GetMessage()));
-    /*if(valid)
-      {
-       ReadImageThreaded(sel);
-      }
-    else
-      {
-                 ClearSelection();
-      }*/
-       ReadImageThreaded(sel);
+/*
+       if(valid)
+    {
+               ReadImageThreaded(sel);
+    } else {
+               ClearSelection();
+    }
+*/
+         
+         
+//EED1 2018-08  
+//     ReadImageThreaded(sel);
+
    }
 
   //==================================================
@@ -572,9 +754,7 @@ namespace creaImageIO
   ///Reads Images (Threaded)
   void WxGimmickView::ReadImageThreaded(const std::vector<tree::Node*>& sel)
   {    
-   GimmickDebugMessage(5,
-                      "ReadImageThreaded"
-                      <<std::endl);
+   GimmickDebugMessage(5,  "ReadImageThreaded"   <<std::endl);
    int maxprio = GetMaximalPriority();
    int prio = maxprio + 2000;
 
@@ -635,17 +815,15 @@ namespace creaImageIO
                RequestReading(*iterDown,prio,-1,ph);
                //              AddEntryToMap(*iterDown);
                prio--;
-               if (prio == maxprio) break;
-       }
-   }
-   else
-   {
+               if (prio == maxprio) { break; }
+       } // for
+   } else {
           pointers.clear();
           //ImagePointerHolder* ph=new ImagePointerHolder(GetDefaultImage());
           boost::shared_ptr<ImagePointerHolder> ph(new ImagePointerHolder(GetDefaultImage()));
           pointers.push_back(ph);
           mViewer->SetImageVector(pointers);
-   }
+   } // if
   }
 
   //==================================================
@@ -656,15 +834,16 @@ namespace creaImageIO
   //==================================================
    void  WxGimmickView::OnInternalIdle()
    {
-     if (!mConstructed) return;
+       if (!mConstructed) return;
      static bool first_time = true;
+        
      if (false)
      {
        first_time = false;
      }
    //   GimmickMessage(1,"WxGimmickView : Refresh viewer"<<std::endl);
        //  mViewer->StartPlayer();
-     if(mViewer)
+     if(mViewer!=NULL)
      {
         mViewer->RefreshIfNecessary();
      }
@@ -672,9 +851,11 @@ namespace creaImageIO
 #else
   void WxGimmickView::UpdateWindowUI(long flags)
   {
-         if(mViewer)
+         if(mViewer!=NULL)
      {
-        mViewer->RefreshIfNecessary();
+// EED 2018-08-23
+// GL Conflict because window is not showing the fist time
+//EED        mViewer->RefreshIfNecessary();
      }
   }
 #endif
@@ -724,13 +905,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 +1008,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 +1030,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 +1048,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[" <<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;                                            
                                        }       
                                }
                        }
@@ -981,7 +1178,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 +1191,7 @@ namespace creaImageIO
                mProgressDialog->Pulse(_T("Updating view..."));
                
                UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();
                mViewer->StartPlayer();  
          }
@@ -1019,9 +1219,9 @@ namespace creaImageIO
   //========================================================================
   void WxGimmickView::CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
   {
-    wxDialogdial= new wxDialog (this,-1,crea::std2wx("Edit Fields for node "+node->GetLabel()),wxDefaultPosition, wxSize(350,155));
-    wxBoxSizer *siz = new wxBoxSizer(wxVERTICAL);
-    WxEditFieldsPanel* ef = new WxEditFieldsPanel(dial, dial, this, node, names, keys);
+    wxDialog           *dial= new wxDialog (this,-1,crea::std2wx("Edit Fields for node "+node->GetLabel()),wxDefaultPosition, wxSize(350,155));
+    wxBoxSizer         *siz = new wxBoxSizer(wxVERTICAL);
+    WxEditFieldsPanel  *ef  = new WxEditFieldsPanel(dial, dial, this, node, names, keys);
 
     siz->Add( ef,1,wxGROW  ,0); 
     dial->SetSizer(siz);
@@ -1055,7 +1255,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 +1266,7 @@ namespace creaImageIO
                mGimmick->AddFiles(storage,i_filenames);
                mProgressDialog->Pulse(_T("Updating view..."));
                UpdateTreeViewLevel(storage,1);
-               delete mProgressDialog;
+               killProgress();
                DisplayAddSummary();    
        }
   }
@@ -1090,10 +1293,14 @@ 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 != NULL)
+       {
+               if (!mProgressDialog->Pulse(s)) 
+                 {
+               p.SetStop();
+                 }
+       }
     //  std::cout << "OnAddProgress ok"<<std::endl;
   }
   //=================================================
@@ -1101,12 +1308,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);
   }
 
@@ -1181,9 +1386,30 @@ namespace creaImageIO
        }
   }
 
+  void WxGimmickView::killProgress()
+  {
+               mProgressDialog->Resume();
+               mProgressDialog->Destroy();
+               mProgressDialog = NULL;
+  }
+
    //=================================================
 
    //=================================================
+
+BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
+    EVT_BUTTON(TOOL_CREATEDB_ID, WxGimmickView::OnCreateDB)
+    EVT_BUTTON(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
+    EVT_BUTTON(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir)
+    EVT_BUTTON(TOOL_ADDDATABASE_ID, WxGimmickView::OnAddDB)
+    EVT_BUTTON(TOOL_REMOVE_ID, WxGimmickView::OnRemove)
+    EVT_BUTTON(TOOL_SYNCHRONIZE_ID, WxGimmickView::OnSynchronize)
+    EVT_BUTTON(TOOL_SETTINGS_ID, WxGimmickView::OnSettings)
+    EVT_BUTTON(TOOL_TOOLS_ID, WxGimmickView::OnTools)
+END_EVENT_TABLE()
+
+
+/*
   BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
     EVT_TOOL(TOOL_CREATEDB_ID, WxGimmickView::OnCreateDB)
     EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
@@ -1194,6 +1420,7 @@ namespace creaImageIO
     EVT_TOOL(TOOL_SETTINGS_ID, WxGimmickView::OnSettings)
     EVT_TOOL(TOOL_TOOLS_ID, WxGimmickView::OnTools)
   END_EVENT_TABLE()
+*/
   //=================================================
 
 } // EO namespace creaImageIO