]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxGimmickView.cpp
After checking that the event goes up in the hierarchy (in win32 at least)
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.cpp
index 900101ad1a4cdc848fa05489766bb0d3382689ea..7594cbef3bcda45fc83ad4ee44106988c3ff7de1 100644 (file)
@@ -61,7 +61,8 @@ namespace creaImageIO
                               wxWindow *parent, 
                               const wxWindowID id,
                               const wxPoint& pos, const wxSize& size,
-                              int image_type,
+                              int min_dim,
+                                  int max_dim,
                               int number_of_threads)
     : wxPanel(parent,id,pos,size),
       GimmickView(gimmick),
@@ -98,15 +99,19 @@ namespace creaImageIO
        //Gimmick
        mGimmick=gimmick;
 
+       mSelectionMaxDimension=max_dim;
+       mSelectionMinDimension=min_dim;
+
     // Create the views
     CreateTreeViews();
 
     // Bottom panel 
     mBottomPanel = new wxPanel(mSplitter,-1);
-
+       mText = new wxStaticText(mBottomPanel, wxID_ANY, wxT("Status: Welcome to Gimmick!"));
+       
     // Splitting
     int hsize = size.GetHeight();
-    int bottom_minsize = 200;
+    int bottom_minsize = 20;
 
     mSplitter->SetMinimumPaneSize( bottom_minsize );
     mSplitter->SplitHorizontally( mNotebook, mBottomPanel, 
@@ -180,6 +185,9 @@ namespace creaImageIO
                   name<<"'"<<std::endl);
     // Create the WxTreeView
     WxTreeView* view = new WxTreeView(h,mNotebook,-1);
+       
+       view->SetMaxDimension(mSelectionMaxDimension);
+       view->SetMinDimension(mSelectionMinDimension);
 
     // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
     // ALREADY IN THE MAP
@@ -190,8 +198,18 @@ namespace creaImageIO
 
   }
   //======================================================================
+  /// Returns the selected Image so that it complies with the given parameter(<4D)
+  vtkImageData* WxGimmickView::GetSelectedImage(int dim)
+  {
+         return GetTreeViewMap()["Local database"]->GetSelectedImage(dim);
+  }
 
-
+  //======================================================================
+  /// Returns the selected Images so that they comply with the given parameter(4D)
+  void WxGimmickView::GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+  {
+         GetTreeViewMap()["Local database"]->GetSelectedImages(s,dim);
+  }
 
   //=================================================
   void WxGimmickView::CreateIconList()
@@ -263,8 +281,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
@@ -274,30 +292,7 @@ namespace creaImageIO
 
        UpdateTreeViewLevel("Local database",1);
        delete mProgressDialog;
-       
-    /*   
-       TreeItemData *data = 
-         (TreeItemData *)
-         mTreeListCtrl->GetItemData(mItemOfMenu);
-       DicomDatabase* db = data->GetDicomNode()->GetDicomDatabase();
-       DicomDatabase::UpdateSummary summary;
-       wxProgressDialog* progress = 
-         new wxProgressDialog(_T("Adding file(s)"),
-                              _T(""),
-                              1000,
-                              this,
-                              wxPD_ELAPSED_TIME |
-                              wxPD_ESTIMATED_TIME | 
-                              wxPD_REMAINING_TIME |
-                              wxPD_CAN_ABORT );
-       
-       db->AddFiles(filenames,progress,summary);
-       
-       progress->Pulse(_T("Updating view..."));
-       UpdateDicomDatabaseView(db);
-       delete progress;
-       DisplayUpdateSummary(summary,this);
-       */
+       DisplayAddSummary();    
       }
        
   }
@@ -334,8 +329,8 @@ namespace creaImageIO
                               1000,
                               this,
                               wxPD_ELAPSED_TIME |
-                              wxPD_ESTIMATED_TIME | 
-                              wxPD_REMAINING_TIME |
+                              //                              wxPD_ESTIMATED_TIME | 
+                              //                              wxPD_REMAINING_TIME |
                               wxPD_CAN_ABORT );
        std::string dirname = wx2std (FD->GetPath()) ;
        mCurrentDirectory = FD->GetPath();  
@@ -347,11 +342,29 @@ namespace creaImageIO
        
        UpdateTreeViewLevel("Local database",1);
        delete mProgressDialog;
-       
+       DisplayAddSummary();
       }
   }
   //=================================================
 
+  //=================================================
+  void WxGimmickView::SetMessage(const wxString& mess)
+  {      
+    wxBusyCursor busy;
+    
+    mText->SetLabel(_T("Status: ")+mess);
+   }
+  //=================================================
+
+   //=================================================
+  void WxGimmickView::OnRemove(wxCommandEvent& event)
+  {
+       //TODO Select current tree handler       
+    wxBusyCursor busy;
+    GetTreeViewMap()["Local database"]->RemoveSelected(1);
+  }
+  //=================================================
+
   //=================================================
   /// AddProgress Gimmick callback
   void WxGimmickView::OnAddProgress( Gimmick::AddProgress& p)
@@ -363,7 +376,7 @@ namespace creaImageIO
           p.GetNumberScannedFiles(),
           p.GetNumberHandledFiles(),
           p.GetNumberAddedFiles());
-    std::cout << "OnAddProgress "<<mess<<std::endl;
+    //    std::cout << "OnAddProgress "<<mess<<std::endl;
     wxString s(wxString::From8BitData(mess));
     //  std::cout << "Pulse"<<std::endl;
     if (!mProgressDialog->Pulse(s)) 
@@ -374,11 +387,40 @@ 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";
+
+    /*    char times[500];
+    sprintf(times,"Time to parse dir \t\t: %ld ms \t%d°/o\nTime to read files info \t: %ld ms \t%d°/o\nTime to update structs \t: %ld ms \t%d°/o\nTime to update database \t: %ld ms \t%d°/o\nTotal time \t\t\t: %ld ms",
+           summary.parse_time,
+           (int)( summary.parse_time*100./summary.total_time),
+           summary.file_scan_time,
+           (int)(summary.file_scan_time*100./summary.total_time),
+           summary.update_structs_time,
+           (int)(summary.update_structs_time*100./summary.total_time),
+           summary.update_database_time,
+           (int)(summary.update_database_time*100./summary.total_time),
+           summary.total_time );
+    
+    mess << times;
+    */
+    wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this);
+  }
+   //=================================================
+
+   //=================================================
   BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
     EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
     EVT_TOOL(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir)
-    END_EVENT_TABLE()
+       EVT_TOOL(TOOL_REMOVE_ID, WxGimmickView::OnRemove)
+  END_EVENT_TABLE()
   //=================================================
 
 } // EO namespace creaImageIO