]> Creatis software - creaImageIO.git/commitdiff
export from storage to storage functionality
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Mon, 25 Jan 2010 16:22:30 +0000 (16:22 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Mon, 25 Jan 2010 16:22:30 +0000 (16:22 +0000)
src2/CMakeLists.txt
src2/creaImageIOGimmick.h
src2/creaImageIOGimmickView.h
src2/creaImageIOWxDescriptorPanel.h
src2/creaImageIOWxExportDlg.cpp [new file with mode: 0644]
src2/creaImageIOWxExportDlg.h [new file with mode: 0644]
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index b9cf63c6427b3d096e7d38b1de34aad2b0259ef4..8908fc5ac833315be6850cfed3b81b7ac9da86e9 100644 (file)
@@ -51,19 +51,20 @@ FILE(GLOB SOURCES_CREAIMAGEIO_IMG_READER
 # The wxWidgets-based components
 if (USE_WXWIDGETS)
 FILE(GLOB SOURCES_CREAIMAGEIO_WX
+         creaImageIOWxAttributeSelectionPanel.cpp
+         creaImageIOWxCustomizeConfigPanel.cpp
+         creaImageIOWxDescriptorPanel.cpp
+         creaImageIOWxEditFieldsPanel.cpp
+         creaImageIOWxExportDlg.cpp
+         creaImageIOWxDumpPanel.cpp
          creaImageIOWxGimmickView.cpp
-         creaImageIOWxTreeView.cpp
-      creaImageIOWxGimmickReaderDialog.cpp
+         creaImageIOWxGimmickReaderDialog.cpp
       creaImageIOWxGimmickFrame.cpp
       creaImageIOWxGimmickPanel.cpp
       creaImageIOWxGimmickTools.cpp
-      creaImageIOWxCustomizeConfigPanel.cpp
       creaImageIOWxListenerPanel.cpp
-      creaImageIOWxEditFieldsPanel.cpp
-         creaImageIOWxAttributeSelectionPanel.cpp
-         creaImageIOWxPACSConnectionPanel.cpp
-         creaImageIOWxDescriptorPanel.cpp
-         creaImageIOWxDumpPanel.cpp
+      creaImageIOWxPACSConnectionPanel.cpp
+         creaImageIOWxTreeView.cpp
          )
 endif()
 
index 0a880875e5280727c533608da706f958c901e203..017d153ce92e0f8f6f1705c6f65ea85843ac7501 100644 (file)
@@ -111,8 +111,11 @@ namespace creaImageIO
     /// Type of map from TreeHandler name to TreeHandler*
        typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
 
+       typedef std::map<std::string, TreeHandler*>::const_iterator ItTreeHandlerMap;
+
     /// Returns the TreeHandlerMap (ref)
     TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
+       
     /// Returns the TreeHandlerMap (const ref)
     const TreeHandlerMapType& GetTreeHandlerMap() const
     { return mTreeHandlerMap; }    
index 47b74ca4b20c9964e92895996d52bc7ab4bbb6c2..0510c1742e1ada032b8b8a21407b3e3b4598a2b9 100644 (file)
@@ -98,6 +98,10 @@ namespace creaImageIO
          virtual void DumpTags(const std::string filename)
          {GimmickError("INTERNAL ERROR : DumpTags not implemented"); }
          
+           ///Edits the fields of a given node
+         virtual void ExportToStorage(const std::vector<std::string> keys)
+         { GimmickError("INTERNAL ERROR : ExportToStorage not implemented"); }
+      
           ///Copies selected files
          virtual void SaveAs(const std::vector<std::string>& filenames)
          { GimmickError("INTERNAL ERROR : SaveAs not implemented"); }
index 626c44d242dadd1f2900c5073c33a357c1382149..203a4091c3750c11c98f965e3df96ecd8b1fb884 100644 (file)
@@ -31,7 +31,7 @@ namespace creaImageIO
   //=====================================================================
  //=====================================================================
  /// Gimmick DB are based on descriptors with a tree structure .
- /// Ecah level contains attributes (DICOM or other) to identify data
+ /// Each level contains attributes (DICOM or other) to identify data
  /// WxDescriptorPanel allows creation, modification and save of descriptors. 
  ///
 
diff --git a/src2/creaImageIOWxExportDlg.cpp b/src2/creaImageIOWxExportDlg.cpp
new file mode 100644 (file)
index 0000000..c2e06e8
--- /dev/null
@@ -0,0 +1,42 @@
+#include <creaImageIOWxExportDlg.h>
+
+namespace creaImageIO
+{
+       // CTor
+       WxExportDlg::WxExportDlg(wxWindow *parent, const std::vector<std::string> storages)
+    : wxDialog(parent, -1,_T("EXPORT FILES TO STORAGE"), wxDefaultPosition, wxSize(260,150))
+   {
+         int size = 16;
+       
+         wxStaticText * ExportText=new wxStaticText(this,-1,_T(" Storage to export: "), wxPoint(5,10));
+         wxArrayString names;
+         std::vector<std::string>::const_iterator it = storages.begin();
+         for(;it != storages.end(); it++)
+         {
+                 names.Add(crea::std2wx(*it));
+         }
+         ExportCombo  = new wxComboBox(this, ID_EXPORTCOMBO_CTRL,_T(""),wxPoint(120,10), wxSize(120,25),names);
+         ExportCombo->SetSelection(0);
+       //  Connect( ExportCombo->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &WxDescriptorPanel::OnDicomAttribute ); 
+
+         // VALIDATION BUTTON
+         wxButton *Ok = new wxButton(this, -1,_T("OK"), wxPoint(5,50) );
+         Connect( Ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxExportDlg::OnOk ); 
+       
+         wxButton *Cancel = new wxButton(this, wxID_CANCEL,_T("CANCEL"), wxPoint(100,50) );
+         Layout(); 
+         
+       }
+
+       WxExportDlg::~WxExportDlg(){}
+
+
+       void WxExportDlg::OnOk(wxCommandEvent &event)
+       {
+               m_name = crea::wx2std(ExportCombo->GetValue());
+               Close();
+               SetReturnCode(ID_EXPORT_OK);
+       }
+
+       
+}
\ No newline at end of file
diff --git a/src2/creaImageIOWxExportDlg.h b/src2/creaImageIOWxExportDlg.h
new file mode 100644 (file)
index 0000000..6c5c9cd
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef __creaImageIOWxExportDlg_h_INCLUDED__
+#define __creaImageIOWxExportDlg_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+
+#define ID_EXPORTCOMBO_CTRL 1801
+#define ID_EXPORT_OK           1802
+
+namespace creaImageIO{
+       /**
+   * \ingroup GUI
+   */
+  //=====================================================================
+ //=====================================================================
+ /// Gimmick can handle multiple database with different organisations.
+ /// WxDescriptorPanel allows to select the storage to export data. 
+ ///
+       class WxExportDlg : public wxDialog
+       {
+       public:
+               ///CTor
+               WxExportDlg(wxWindow *parent, const std::vector<std::string> storages);
+               ///DTor
+               ~WxExportDlg();
+
+       /// Get selected storage
+       const std::string& GetStorage(){ return m_name;}
+
+       private:
+
+               /// Storage ComboBox
+               wxComboBox *ExportCombo;
+
+               ///Validate selected storage
+               void OnOk(wxCommandEvent &event);
+
+               /// Storage name
+               std::string m_name;
+       };
+}
+#endif // USE_WIDGETS
+// EOF
+#endif
index 0d9efc82910746efbc78b7ee971dd90a248fddf8..77f2a5234c010e0f9be2ca1ea64b5100ca64e081 100644 (file)
@@ -9,6 +9,7 @@
 #include <creaImageIOWxAttributeSelectionPanel.h>
 #include <creaImageIOWxDescriptorPanel.h>
 #include <creaImageIOWxDumpPanel.h>
+#include <creaImageIOWxExportDlg.h>
 
 using namespace crea;
 // Icons
@@ -1025,6 +1026,39 @@ namespace creaImageIO
     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)
   {
index fa7d4d76b3899bf3a9030d9a5073b9ff4e763ddd..61fcc7d0367f4d3234974e6cc545836ae67fc2a8 100644 (file)
@@ -203,6 +203,9 @@ namespace creaImageIO
        /// Display all Dicom Tags
        void DumpTags(const std::string i_filename);
  
+       /// Export from Storage to Storage
+       void ExportToStorage(const std::vector<std::string> i_filenames);
     /// Progress dialog
     wxProgressDialog* mProgressDialog;
 
index 9b1f54eb5ae88a7aff505c0774bbba38e7d0331a..86850e4192e795c7691f69567ea2f7dab904860e 100644 (file)
@@ -208,6 +208,10 @@ namespace creaImageIO
        Connect( mFilterID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupFilter) );
 
 
+       ////SubMenuItem EXPORT
+       subExportMenu = new wxMenu;
+       wxMenuItem *subExp1 = subExportMenu->Append(wxID_ANY, _T("&Export to Storage"));
+       Connect( subExp1->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnExportToStorage) );
 
        //ItemMenu
        menuItem =new wxMenu;
@@ -215,16 +219,19 @@ namespace creaImageIO
        wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy"));
        wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T("&Edit Fields"));
        wxMenuItem* m4Item=menuItem->Append(wxID_ANY, _T("&Display Dicom Tags"));
+       menuItem->AppendSubMenu(subExportMenu, wxT("&Export"));
 
        mAnonymizingID=m1Item->GetId();
        mLocalCopyID=m2Item->GetId();
        mEditFieldID=m3Item->GetId();
        mDumpID=m4Item->GetId();
+       
        //Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) );
        Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) );
        Connect( mEditFieldID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnEditField) );
        Connect( mDumpID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnDumpTags) );
        
+
        
 #endif // wxUSE_MENUS
        /// Initialize the first level splitter
@@ -872,27 +879,44 @@ namespace creaImageIO
        }
   }
 
+  //================================================================
+
+  //================================================================
+
+  void WxTreeView::OnExportToStorage(wxCommandEvent &event)
+  {
+       std::vector<std::string> filesname;
+       std::vector<tree::Node*> nodes;
+       nodes.push_back(((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node);
+       GetFilenamesAsString(nodes,filesname);
+       GetGimmickView()->ExportToStorage(filesname);
+  }
+
+  //================================================================
+
+  //================================================================
+
   void WxTreeView::OnDumpTags(wxCommandEvent &event)
   {
          if(mLastRightSelected!=-1)
        {
-    tree::Node* node=((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node;
-       tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
-       std::vector<std::string> names;
-       std::vector<std::string> keys;
-       for (a  = GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).begin();
-            a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).end();
-            ++a)
-       {
-               if(a->GetKey()=="FullFileName")
-           {
-                       GetGimmickView()->DumpTags(node->GetAttribute("FullFileName"));
-                       return;
-               }
-       }
+               tree::Node* node=((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node;
+               tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+               std::vector<std::string> names;
+               std::vector<std::string> keys;
+               for (a  = GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).begin();
+                        a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).end();
+                        ++a)
+                       {
+                               if(a->GetKey()=="FullFileName")
+                               {
+                                       GetGimmickView()->DumpTags(node->GetAttribute("FullFileName"));
+                                       return;
+                               }
+                       }
          }
-         
   }
+  
 
   //================================================================
 
index 49dd62b9c3fc87344db462404c77767e9793fce0..e620a4a7b63ccb31d24e49a97fef8829c16bc0b3 100644 (file)
@@ -78,6 +78,9 @@ namespace creaImageIO
          ///Callback when the user needs to display alll dicom tags for a file
          void OnDumpTags(wxCommandEvent &event);
       
+         ///Callback when the user needs to transfer data from storage to storage
+         void OnExportToStorage(wxCommandEvent &event);
+      
       ///Callback on mouse click
       void OnMouseClick(wxMouseEvent& event);
 
@@ -184,10 +187,13 @@ namespace creaImageIO
       unsigned int mLastLevel;
       
          wxMenu* menuItem;
+         wxMenu *subExportMenu;
          int mAnonymizingID;
          int mLocalCopyID;
          int mEditFieldID;
          int mDumpID;
+         int mExportID;
+         int mExport2StorageID;
          
       // If set to true then OnSelectedChanged returns immediately.
       // Used to do avoid useless process during multiple selections