]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxGimmickView.cpp
move directory
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.cpp
index f187decb48c5390a4f478b819300b3fda1609714..0cab09e7fb79d2a49630e6922e13b093f0831421 100644 (file)
@@ -8,6 +8,8 @@
 #include <creaImageIOWxEditFieldsPanel.h>
 #include <creaImageIOWxAttributeSelectionPanel.h>
 #include <creaImageIOWxDescriptorPanel.h>
+#include <creaImageIOWxDumpPanel.h>
+#include <creaImageIOWxExportDlg.h>
 
 using namespace crea;
 // Icons
@@ -30,9 +32,13 @@ using namespace crea;
 #if defined(BUILD_BRUKER)
        #include "bruker2dicom.h"
 #endif
+
+
+#include <creaImageIOGimmick.h>
 #ifdef _DEBUG
 #define new DEBUG_NEW
 #endif
+
 namespace creaImageIO
 {
    
@@ -49,7 +55,7 @@ namespace creaImageIO
         TOOL_SETTINGS_ID    = 7,
         TOOL_TOOLS_ID       = 8,
         TOOL_CREATEDB_ID    = 9,
-               TOOL_PACS_ID                    = 10
+        TOOL_PACS_ID        = 10
     };
   //======================================================================
 
@@ -87,7 +93,7 @@ namespace creaImageIO
 
   //======================================================================
   // CTor
-  WxGimmickView::WxGimmickView(Gimmick* gimmick,
+       WxGimmickView::WxGimmickView(boost::shared_ptr<Gimmick> gimmick,
                               wxWindow *parent, 
                               const wxWindowID id,
                               const wxPoint& pos, 
@@ -106,34 +112,32 @@ namespace creaImageIO
     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
-    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+    msizer = new wxBoxSizer(wxVERTICAL);
 
     // Create the tool bar
     CreateToolBar(); 
-    sizer->Add( mToolBar ,0, wxGROW  ,0);
+    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);
+                              -1, wxDefaultPosition, wxDefaultSize, 0);
 
     //Gimmick
     mGimmick=gimmick;
 
-      
-    mSelectionMaxDimension= max_dim;
-    mSelectionMinDimension= min_dim;
+    mSelectionMaxDimension = max_dim;
+    mSelectionMinDimension = min_dim;
     
     // Create the views
     CreateTreeViews();
@@ -141,7 +145,7 @@ namespace creaImageIO
     // Bottom panel 
     mBottomPanel = new wxPanel(mSplitter,-1);
     
-    wxBoxSizer *bottom_sizer = new wxBoxSizer(wxVERTICAL); //HORIZONTAL);
+    mbottom_sizer = new wxBoxSizer(wxVERTICAL); //HORIZONTAL);
     
     
     // Previewer
@@ -153,15 +157,15 @@ namespace creaImageIO
        mViewer->StartPlayer();
 
 
-    bottom_sizer->Add(mViewer,1,wxGROW,1);
+    mbottom_sizer->Add(mViewer,1,wxGROW,1);
     //    mViewer->Show();
 
     mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Welcome to Gimmick!"));
-    bottom_sizer->Add(mText,0,wxGROW,0);
+    mbottom_sizer->Add(mText,0,wxGROW,0);
 
          
          
-    mBottomPanel->SetSizer(bottom_sizer);
+    mBottomPanel->SetSizer(mbottom_sizer);
 
     // Splitting
     int hsize = size.GetHeight();
@@ -173,17 +177,17 @@ namespace creaImageIO
     mSplitter->SplitHorizontally( mNotebook, mBottomPanel, 
                                  top_minsize);
 
-    sizer->Add( mSplitter,1,wxGROW  ,0);
+    msizer->Add( mSplitter, 1, wxGROW, 0);
 
     mProgressDialog=0;
-    SetSizer( sizer );     
+    SetSizer( msizer );     
     SetAutoLayout(true);
     Layout();
-    mListener=new Listener();
-    mListener->ConnectObserver(boost::bind( &WxGimmickView::OnDriveMount , this, _1 ) );
-    mListener->Create();
-    mListener->Run();
-    mListener->Pause();
+    //mListener=new Listener();
+    //mListener->ConnectObserver(boost::bind( &WxGimmickView::OnDriveMount, this, _1 ) );
+    //mListener->Create();
+   // mListener->Run();
+   // mListener->Pause();
 
     mConstructed = true;
   }
@@ -197,10 +201,9 @@ namespace creaImageIO
     mViewer->StopPlayer();
     GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
                        <<std::endl);
-    if(mListener->IsAlive())
-    {
-        mListener->Delete();
-    }
+       delete mIcon;
+       delete mViewer;
+    //if(mListener->IsAlive())   {        mListener->Delete();    }
   }
   //======================================================================
   
@@ -279,7 +282,7 @@ namespace creaImageIO
     GimmickMessage(2,"Creating the tree view for '"<<
                   name<<"'"<<std::endl);
     // Create the WxTreeView
-    WxTreeView* view = new WxTreeView(h,this,mNotebook,-1);
+    WxTreeView* view = new WxTreeView(h, this, mNotebook, -1);
 
     // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
     // ALREADY IN THE MAP
@@ -295,7 +298,15 @@ namespace creaImageIO
   {
        std::vector<std::string> files;
        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
-       ReadImagesNotThreaded(s,files,dim);
+       ReadImagesNotThreaded(s, files, dim);
+  }
+
+  //======================================================================
+  void WxGimmickView::GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim)
+  {
+       std::vector<std::string> files;
+       GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetSelectedAsString(files);
+       ReadImagesNotThreadedInVector(s, files, dim);
   }
   //======================================================================
 
@@ -324,17 +335,17 @@ namespace creaImageIO
 
     wxIcon icons[20];
     // should correspond to Icon_xxx enum
-    icons[Icon_accept] = wxIcon(accept_xpm);
-    icons[Icon_add] = wxIcon(add_xpm);
-    icons[Icon_folder_down] = wxIcon(folder_down_xpm);
-    icons[Icon_page_down] = wxIcon(page_down_xpm);
-    icons[Icon_remove] = wxIcon(remove_xpm);
-    icons[Icon_database_add] = wxIcon(database_add_xpm);
-    icons[Icon_help] = wxIcon(help_xpm);
-    icons[Icon_synchronize] = wxIcon(synchronize_xpm);
+    icons[Icon_accept]          = wxIcon(accept_xpm);
+    icons[Icon_add]             = wxIcon(add_xpm);
+    icons[Icon_folder_down]     = wxIcon(folder_down_xpm);
+    icons[Icon_page_down]       = wxIcon(page_down_xpm);
+    icons[Icon_remove]          = wxIcon(remove_xpm);
+    icons[Icon_database_add]    = wxIcon(database_add_xpm);
+    icons[Icon_help]            = wxIcon(help_xpm);
+    icons[Icon_synchronize]     = wxIcon(synchronize_xpm);
     icons[Icon_create_database] = wxIcon(create_database_xpm);
-    icons[Icon_settings] = wxIcon(settings_xpm);
-    icons[Icon_tools] = wxIcon(tools_xpm);
+    icons[Icon_settings]        = wxIcon(settings_xpm);
+    icons[Icon_tools]           = wxIcon(tools_xpm);
 
     //   unsigned int NbIcons = 8;
     // Make an image list containing small icons
@@ -391,8 +402,8 @@ namespace creaImageIO
                               1000,
                               this,
                               wxPD_ELAPSED_TIME |
-                              //                              wxPD_ESTIMATED_TIME | 
-                              //                              wxPD_REMAINING_TIME |
+                              // wxPD_ESTIMATED_TIME |
+                              // wxPD_REMAINING_TIME |
                               wxPD_CAN_ABORT );
 
        // TO DO : select the current tree handler
@@ -423,15 +434,13 @@ namespace creaImageIO
     
     if (FD->ShowModal()==wxID_OK)
     {
-
-       
        std::string dirname = wx2std (FD->GetPath());
        bool recurse =  isNeedRecursive(dirname);
        if (recurse)
        {
-             recurse = wxMessageBox(_T("Recurse into sub-directories ?"),  _T("Scan directory"),        wxYES_NO,this ) == wxYES ? true : false;
+             recurse = wxMessageBox(_T("Recurse into sub-directories ?"), _T("Scan directory"), wxYES_NO,this ) == wxYES ? true : false;
        }
-               
+
                wxBusyCursor busy;
                wxString title(_T("Adding directory"));
                if (recurse) 
@@ -443,24 +452,24 @@ namespace creaImageIO
                                        this,
                                        wxPD_ELAPSED_TIME | 
                                        wxPD_SMOOTH |
-                                       //                             wxPD_ESTIMATED_TIME | 
-                                       //                             wxPD_REMAINING_TIME |
+                                       // wxPD_ESTIMATED_TIME |
+                                       // wxPD_REMAINING_TIME |
                                        wxPD_CAN_ABORT );
-               
+
                mCurrentDirectory = FD->GetPath();  
                mGimmick->AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),dirname,recurse);
                mProgressDialog->Pulse(_T("Updating view..."));
-               
+
                UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
                delete mProgressDialog;
                DisplayAddSummary();
-
          }
     mViewer->StartPlayer();
+       delete FD;
   }
 
 
-   //=================================================
+  //=================================================
   // Determines number of files potentially to add to database
    int WxGimmickView::NumberFilesToAdd(const std::string &dirpath, bool recursive)
   {
@@ -483,10 +492,9 @@ namespace creaImageIO
                }
          }
        return nb;
-
   }
 
-    //=================================================
+   //=================================================
    // Test a directory to know if contains sub-directory to analyze
   bool WxGimmickView::isNeedRecursive(std::string i_name)
   {
@@ -556,8 +564,6 @@ namespace creaImageIO
                  ClearSelection();
       }*/
        ReadImageThreaded(sel);
-
-    
    }
 
   //==================================================
@@ -646,6 +652,7 @@ namespace creaImageIO
 
   //==================================================
 
+#if defined(WIN32)
   //==================================================
    void  WxGimmickView::OnInternalIdle()
    {
@@ -662,7 +669,15 @@ namespace creaImageIO
         mViewer->RefreshIfNecessary();
      }
   }
-
+#else
+  void WxGimmickView::UpdateWindowUI(long flags)
+  {
+         if(mViewer)
+     {
+        mViewer->RefreshIfNecessary();
+     }
+  }
+#endif
    //==================================================
 
   //==================================================
@@ -675,7 +690,7 @@ namespace creaImageIO
        mViewer->RefreshIfNecessary();
        ResetExtent();
   }
-  
+
   //=================================================
  
   //=================================================
@@ -683,17 +698,20 @@ namespace creaImageIO
   {
        //TODO Select current tree handler       
      wxBusyCursor busy;
-     GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->RemoveSelected();
+        std::string remove;
+        mGimmick->GetSetting(SETTINGS_REMOVE_PATIENT_DISPLAY,remove);
+        GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->RemoveSelected(remove);
+        mGimmick->UpdateSetting(SETTINGS_REMOVE_PATIENT_DISPLAY,remove);
      ClearSelection();
   }
   //=================================================
 
-  
+
   //=================================================
   void WxGimmickView::AddIgnoreFile(tree::Node* toRemove)
   {
      mGimmick->RemoveFile(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),toRemove);
-     GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->UpdateLevel(1);
+   //  GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->UpdateLevel(1);
   }
 
   //=================================================
@@ -735,6 +753,7 @@ namespace creaImageIO
 
     if (dialog.ShowModal() == wxID_OK)
     {
+                       wxBusyCursor busy;
         int sel=dialog.GetSelection();
        bool repair=false;
        bool checkAttributes=false;
@@ -763,6 +782,7 @@ namespace creaImageIO
     dial->SetSizer(siz);
     dial->ShowModal();
   }
+
   //=================================================
   void WxGimmickView::OnImportExport(wxCommandEvent &Event)
   {
@@ -856,7 +876,6 @@ namespace creaImageIO
                                        }       
                                }
                        }
-
                        else
                        {
                                wxMessageBox(_T("One or both of the directory fields are empty"),_T("Empty Fields"),wxOK,this);
@@ -865,9 +884,9 @@ namespace creaImageIO
        delete gimmickTools;
 #endif
        }
-
        mViewer->StartPlayer();
   }
+
   //=================================================
 
   void WxGimmickView::CreateSettingsDialog(wxNotebook* nb, wxDialog* dial)
@@ -899,7 +918,7 @@ namespace creaImageIO
          nb->AddPage( pacs, crea::std2wx("Connect to PACS") );
 
          //Third page: CD/DVD Watch
-         WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused());
+         WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this,true);//, mListener->IsPaused());
          nb->AddPage( cdWatch, crea::std2wx("CD/DVD") );
 
          //Fourth page: Selection of attributes to show
@@ -1009,6 +1028,46 @@ namespace creaImageIO
     dial->ShowModal();  
   }
 
+ //========================================================================
+  void WxGimmickView::DumpTags(std::string i_filename)
+  {
+    WxDumpPanel* pan= new WxDumpPanel (this,i_filename);
+    pan->ShowModal();  
+  }
+
+  //========================================================================
+  void WxGimmickView::ExportToStorage(const std::vector<std::string> i_filenames)
+  {
+       std::vector<std::string> storages;
+       Gimmick::TreeHandlerMapType::iterator it = mGimmick->GetTreeHandlerMap().begin();
+       for(;it != mGimmick->GetTreeHandlerMap().end(); it++)
+       {
+               storages.push_back(it->first);
+       }
+
+    WxExportDlg* exp= new WxExportDlg(this,storages);
+       if ( exp->ShowModal() ==ID_EXPORT_OK)
+       {
+               std::string storage = exp->GetStorage();
+               mProgressDialog = 
+           new wxProgressDialog(_T("Adding file(s)"),
+                              _T(""),
+                              1000,
+                              this,
+                              wxPD_ELAPSED_TIME |
+                              // wxPD_ESTIMATED_TIME |
+                              // wxPD_REMAINING_TIME |
+                              wxPD_CAN_ABORT );
+               mGimmick->AddFiles(storage,i_filenames);
+               mProgressDialog->Pulse(_T("Updating view..."));
+               UpdateTreeViewLevel(storage,1);
+               delete mProgressDialog;
+               DisplayAddSummary();    
+       }
+  }
+
+
+
   //========================================================================
   void WxGimmickView::OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val)
   {
@@ -1137,4 +1196,3 @@ namespace creaImageIO
 
 } // EO namespace creaImageIO
 
-