]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOWxGimmick.cpp
*** empty log message ***
[creaImageIO.git] / src / creaImageIOWxGimmick.cpp
index 3ad5e81280ede7cdd930ffcaab3ae209e648a723..63470ba141b56f8d126d92715499c4a1fc90b79d 100644 (file)
@@ -63,6 +63,8 @@ namespace creaImageIO
       PopUp_Settings = 501,
       PopUp_About    = 502,
       PopUp_User = WxGimmick::UserMenuFirstId,
+      PopUp_SaveAs = 701,
+      PopUp_AddToFavorites = 702
     };
   //================================================================
 
@@ -716,8 +718,7 @@ namespace creaImageIO
        mTreeListCtrl->SetItemText(item,std2wx(lab));
       }
     else 
-      {
-       
+      {        
        int c = 0;
        Settings::ColumnListType::iterator col;
        // If Study and Series level are merged and node type is Series
@@ -786,7 +787,7 @@ namespace creaImageIO
 
   //================================================================
   void WxGimmick::UpdateColumnsTitles(wxTreeItemId& item,
-                                                   DicomNode::Type t)
+                                      DicomNode::Type t)
   {
     //    std::cout << "Update columns titles "<<t<<std::endl;
     int c = 0;
@@ -931,11 +932,13 @@ namespace creaImageIO
   {
     wxBusyCursor busy;
     //    std::cout << "WxGimmick : Reading config"<<std::endl;
+    LoadOrCreateFavoritesDatabase();
 
     //    std::cout <<     
     creaMessage("Gimmick!",1,"Gimmick! : ==> Loading collections from '"<<mDatabaseListFile<<"'"<<std::endl);
     //       <<"'"<<std::endl;
 
+
     std::ifstream s;
     s.open(mDatabaseListFile.c_str());
     if (s.good())
@@ -1024,6 +1027,13 @@ namespace creaImageIO
   }
   //================================================================
 
+  //================================================================
+  void WxGimmick::LoadOrCreateFavoritesDatabase()
+  {
+    // TODO
+  }
+  //================================================================
+
   /*
   //================================================================
   void  WxGimmick::OnClose(wxCloseEvent& event)
@@ -1103,7 +1113,6 @@ namespace creaImageIO
   //================================================================
   void WxGimmick::OnItemExpanded(wxTreeEvent& event)                   
   {
-
     //    std::cout << "* Expanded *"<<std::endl;
     //  }
 
@@ -1253,7 +1262,6 @@ namespace creaImageIO
   
   void WxGimmick::OnItemRightClick(wxTreeEvent& event)
   {
-
     wxTreeItemId itemId = event.GetItem();
     if (itemId.IsOk())
       {
@@ -1264,8 +1272,6 @@ namespace creaImageIO
     event.Skip();
   }
   //=====================================================================
-  
-
 
   //=====================================================================
   void WxGimmick::ShowMenu(wxTreeItemId id, const wxPoint& pt)
@@ -1366,13 +1372,11 @@ namespace creaImageIO
       }
     GetEventHandler()->ProcessEvent(ev);
     //
-  
+
     if (menu.GetMenuItemCount()>0) menu.AppendSeparator();
     menu.Append(PopUp_Settings, wxT("&Settings..."));
     menu.Append(PopUp_About, wxT("&About..."));
   
-
-  
     /*
       wxMenu* newmenu = new wxMenu;
       wxMenu* openmenu = new wxMenu;
@@ -1432,9 +1436,6 @@ namespace creaImageIO
       }
       }
     */
-
-
  
     PopupMenu(&menu, pt);
 #endif // wxUSE_MENUS
@@ -1471,7 +1472,6 @@ namespace creaImageIO
   }
   //=====================================================================
   
-
  
   //=====================================================================
   void  WxGimmick::OnPopUpOpenCollection(wxCommandEvent& event)
@@ -1501,22 +1501,21 @@ namespace creaImageIO
   void  WxGimmick::OnPopUpDeleteCollection(wxCommandEvent& event)
   {
     if (wxMessageBox(_T("This will physically delete the collection's file on disk and cannot be reverted. Proceed ?"),_T("Confirm"),wxYES_NO,this)==wxNO) return;
-    
+  
     wxBusyCursor busy;
 
-   
     //   std::cout << "OnPopUpClose"<<std::endl;
     //  wxTreeItemId id = event.GetId();
     TreeItemData *data = (TreeItemData *)mTreeListCtrl->GetItemData(mItemOfMenu);
     DicomDatabase* r = data->GetDicomNode()->GetDicomDatabase();
-
     wxRemoveFile(std2wx(r->GetFileName()));
     //   std::cout << "OnPopUpClose '"<<r->GetName()<<"'"<<std::endl;
     DeleteDicomDatabase(mItemOfMenu,r);
-    
   }
   //=====================================================================
-  
+
   void DisplayUpdateSummary( DicomDatabase::UpdateSummary& summary,
                             wxWindow* parent )
   {
@@ -1539,18 +1538,18 @@ namespace creaImageIO
            summary.update_database_time,
            (int)(summary.update_database_time*100./summary.total_time),
            summary.total_time );
-    
+
     mess << times;
-    
     wxMessageBox(std2wx(mess.str()),_T("Update summary"),wxOK,parent);
   }
-  
-  
+
+
   //=====================================================================
   void  WxGimmick::OnPopUpAddFile(wxCommandEvent& event)
   {
     long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
-    std::string wc("*.*");
+    std::string wc("*");
     wxFileDialog* FD = new wxFileDialog( 0, 
                                         _T("Select file"),
                                         mCurrentDirectory,
@@ -1558,7 +1557,7 @@ namespace creaImageIO
                                         std2wx(wc),
                                         style,
                                         wxDefaultPosition);
-    
+
     if (FD->ShowModal()==wxID_OK)
       {
        wxBusyCursor busy;
@@ -1992,7 +1991,7 @@ namespace creaImageIO
              }
            sib = GetTreeListCtrl()->GetNextSibling(sib);
          }
-       prio = maxprio + 1000;
+       prio = maxprio + 999;
        sib = GetTreeListCtrl()->GetPrevSibling(item);
        while (sib.IsOk())
          {
@@ -2035,13 +2034,17 @@ namespace creaImageIO
   void WxGimmick::ShowImage(vtkImageData* im)
   {
     //  wxBusyCursor busy;
+    mViewer->SetInput( im );
+    mViewer->SetSlice( 0 );
     
+
     int x1,x2,y1,y2,z1,z2;
     double spx,spy,spz;
+    im->Update();
     im->GetSpacing(spx,spy,spz);
     im->GetExtent (x1,x2,y1,y2,z1,z2);
-    
     /*
+    std::cout << "-----------------------------"<<std::endl;
       std::cout << x1 << "-"<<x2<<std::endl; 
       std::cout << y1 << "-"<<y2<<std::endl; 
       std::cout << z1 << "-"<<z2<<std::endl; 
@@ -2069,19 +2072,39 @@ namespace creaImageIO
        mspy = spy;
        mspz = spz;
        
+       double *range = im->GetScalarRange();
+        mViewer->SetColorWindow(range[1] - range[0]);
+        mViewer->SetColorLevel(0.5 * (range[1] + range[0]));
+
+        mViewer->GetRenderer()->ResetCamera();
+       double bounds[6];
+
+
+        mViewer->GetRenderer()->ComputeVisiblePropBounds(bounds);
+
+        /*
+       std::cout <<"bounds : "<<bounds[0]<<","
+<<bounds[1]<<","
+<<bounds[2]<<","
+<<bounds[3]<<","
+<<bounds[4]<<","
+                 <<bounds[5]<<std::endl;
+        */
+        mViewer->GetRenderer()->ResetCameraClippingRange(bounds);
+       /*
        vtkCamera *camera = mViewer->GetRenderer()->GetActiveCamera();
        
        camera->SetViewUp ( spx*0, -spy*1, spz*0);
-       camera->SetPosition( spx*(x1+x2)/2, spy*(y1+y2)/2, -spz*10000000); 
+       camera->SetPosition( spx*(x1+x2)/2, spy*(y1+y2)/2, spz*10000000); 
        camera->SetFocalPoint   ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0); 
        
        camera->ComputeViewPlaneNormal();
        camera->SetParallelScale(  spx*(x2-x1)/2.0 );
        
+       camera->Roll ( 180 );
+       */
       }
     
-    mViewer->SetInput( im );
-    mViewer->SetSlice( 0 );
     mInteractor->Render();
   } 
   //================================================================
@@ -2270,6 +2293,10 @@ namespace creaImageIO
            ext[5] = im.size();
            out->SetExtent(ext);
            // LG : TODO : Z Spacing  ?
+           //
+           // ==> to get an accurate ZSpacing from a Dicom set of files
+           // ==> you need a gdcm::SerieHelper
+           //  JPR
            
            out->AllocateScalars();