]> Creatis software - creaImageIO.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Tue, 17 Feb 2009 10:37:29 +0000 (10:37 +0000)
committerguigues <guigues>
Tue, 17 Feb 2009 10:37:29 +0000 (10:37 +0000)
src2/creaImageIOGimmickView.cpp
src2/creaImageIOGimmickView.h
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index d7f04de80ca379fd6097674744548d7bef261b66..c391d4a4a6136f96c005234df1908f78b3d2d3ab 100644 (file)
@@ -5,6 +5,7 @@ namespace creaImageIO
 {
   // CTor
   GimmickView::GimmickView(Gimmick* gimmick)
+    : mGimmick(gimmick)
   {
     GimmickDebugMessage(1,"GimmickView::GimmickView"
                        <<std::endl);
@@ -29,6 +30,21 @@ namespace creaImageIO
   void GimmickView::Finalize()
   {
   }
+
+
+  /// Create the tree views 
+  void GimmickView::CreateTreeViews()
+  {
+    GimmickMessage(2,"Creating the tree views"<<std::endl);
+    Gimmick::TreeHandlerMapType::const_iterator i;
+    for (i = mGimmick->GetTreeHandlerMap().begin();
+        i!= mGimmick->GetTreeHandlerMap().end();
+        ++i)
+      {
+       this->CreateTreeView(i->second);
+      }
+  }
+
   
 } // EO namespace creaImageIO
 
index a9298b9def91013991e36e78f282fb7177416ec2..1bef90c0c0758b8eb24f01102e560d1047bf2f04 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <creaImageIOGimmick.h>
 #include <creaImageIOTreeView.h>
+#include <creaImageIOSystem.h>
 //#include <map>
 #include <vtkImageData.h>
 
@@ -51,6 +52,12 @@ namespace creaImageIO
       virtual void GetSelectedImages(std::vector<vtkImageData*>& s) {}
       virtual void GetSelectedFiles(std::vector<std::string>& s) {}
 
+      /// Create the tree views 
+      void CreateTreeViews();
+
+      /// Create the tree view for TreeHandler provided
+      virtual void CreateTreeView( TreeHandler* h) { GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
+
     private:
       /// Controller which manages the interaction with the model
       Gimmick* mGimmick;
index b5ee40fcae6cbe893928cb0395995beeb2984749..c30f96ca9918629c107f1f892a16f13e6abec725 100644 (file)
@@ -1,8 +1,59 @@
 #include <creaImageIOWxGimmickView.h>
+#include <creaImageIOWxTreeView.h>
 #include <creaImageIOSystem.h>
 
+// Icons
+#include "../src/icons/database.xpm"
+#include "../src/icons/folder.xpm"
+#include "../src/icons/dicomdir.xpm"
+#include "../src/icons/patient.xpm"
+#include "../src/icons/study.xpm"
+#include "../src/icons/series.xpm"
+#include "../src/icons/image.xpm"
+#include "../src/icons/root.xpm"
+
+#include <wx/imaglist.h>
+
 namespace creaImageIO
 {
+  //======================================================================
+  // The ids of the different tools
+  enum
+    {
+      TOOL_ADDFILE_ID = 1
+    };
+  //======================================================================
+
+  //================================================================
+  // 
+  const int icon_number = 8;
+  // Icon ids
+  typedef enum
+    {
+      Icon_Root,
+      Icon_Database,
+      Icon_Folder,
+      Icon_DicomDir,
+      Icon_Patient,
+      Icon_Study,
+      Icon_Series,
+      Icon_Image
+    }
+    icon_id;
+  //================================================================
+
+  //================================================================
+  /*
+  const icon_id Icon[5] = { Icon_Database,  
+                           Icon_Patient,
+                           Icon_Study,
+                           Icon_Series,
+                           Icon_Image };
+  */
+  //================================================================
+
+
+  //======================================================================
   // CTor
   WxGimmickView::WxGimmickView(Gimmick* gimmick,
                               wxWindow *parent, 
@@ -15,23 +66,138 @@ namespace creaImageIO
   {
     GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
                        <<std::endl);
+    // Create the list of icons (mIcon)
+    CreateIconList();
 
     // Global sizer
-    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+    // Create the tool bar
+    CreateToolBar(); 
+    sizer->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(this,
+    mNotebook = new wxNotebook(mSplitter,
                               -1,wxDefaultPosition, wxDefaultSize, 0);
-    
+
+    // Create the views
+    CreateTreeViews();
+
+    // Bottom panel 
+    mBottomPanel = new wxPanel(mSplitter,-1);
+
+    // Splitting
+    int hsize = size.GetHeight();
+    int bottom_minsize = 200;
+
+    mSplitter->SetMinimumPaneSize( viewsminsize );
+    mSplitter->SplitHorizontally( mNotebook, mBottomPanel, 
+                                  hsize - bottom_minsize);
+  
+    sizer->Add( mSplitter,1,wxGROW  ,0);
+
+
+    SetSizer( sizer );     
+    SetAutoLayout(true);
+    Layout();
+
   }
+  //======================================================================
 
+  //======================================================================
   /// Destructor
   WxGimmickView::~WxGimmickView()
   {
     GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
                        <<std::endl);
   }
+  //======================================================================
   
-  
+  //======================================================================
+  /// Creates the tool bar
+  void WxGimmickView::CreateToolBar()
+  {
+    long style = wxTB_HORIZONTAL | wxNO_BORDER;
+    mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
+                            style);
+
+    mToolAddFile = mToolBar->AddTool( TOOL_ADDFILE_ID, 
+                                     _T("Add file"),
+                                     mIcon->GetBitmap(Icon_Database),
+                                     _T("Add file")
+                                     );
+    //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
+
+    mToolBar->Realize();
+  }
+  //======================================================================
+
+  //======================================================================
+  /// Create the tree view for TreeHandler provided
+  void WxGimmickView::CreateTreeView( TreeHandler* h)
+  {
+    std::string name(h->GetTree().GetAttribute("Name"));
+    GimmickMessage(2,"Creating the tree view for '"<<
+                  name<<"'"<<std::endl);
+    // Create the WxTreeView
+    WxTreeView* view = new WxTreeView(h,mNotebook,-1);
+
+    // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
+    // ALREADY IN THE MAP
+    GetTreeViewMap()[name] = view;
+
+    // Add Notebook page
+    mNotebook->AddPage( view, crea::std2wx(name) );
+
+  }
+  //======================================================================
+
+
+
+  //=================================================
+  void WxGimmickView::CreateIconList()
+  {
+    // Size of the icons;
+    int size = 32;
+
+    wxIcon icons[20];
+    // should correspond to Icon_xxx enum
+    icons[Icon_Patient] = wxIcon(patient_xpm);
+    icons[Icon_Study] = wxIcon(study_xpm);
+    icons[Icon_Series] = wxIcon(series_xpm);
+    icons[Icon_Image] = wxIcon(image_xpm);
+    icons[Icon_Database] = wxIcon(database_xpm);
+    icons[Icon_Folder] = wxIcon(folder_xpm);
+    icons[Icon_DicomDir] = wxIcon(dicomdir_xpm);
+    icons[Icon_Root] = wxIcon(root_xpm);
+
+    unsigned int NbIcons = 8;
+    // Make an image list containing small icons
+    mIcon = new wxImageList(size,size,true);
+    
+    // Make all icons the same size = size of the first one
+    int sizeOrig = icons[0].GetWidth();
+    for ( size_t i = 0; i < NbIcons; i++ )
+      {
+       if ( size == sizeOrig )
+         {
+           mIcon->Add(icons[i]);
+         }
+        else
+         {
+            mIcon->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
+         }
+      }
+  }
+  //=================================================
+
+
 
 } // EO namespace creaImageIO
 
index 08710e6620c80ac3567d2e33eafe9a7aed02a7ec..b6e41215cea2cb081e81375640ccf53587b05911 100644 (file)
@@ -6,6 +6,10 @@
 #include <creaImageIOGimmickView.h>
 #include <creaWx.h>
 
+#include <wx/splitter.h>
+#include <wx/toolbar.h> 
+#include <wx/tbarbase.h> 
+#include <wx/notebook.h>
 
 namespace creaImageIO
 {
@@ -31,12 +35,28 @@ namespace creaImageIO
       /// Virtual destructor
       virtual ~WxGimmickView();
 
+    protected:
+      /// Creates the tool bar
+      void CreateToolBar(); 
 
-  
+      /// Create the tree view for TreeHandler provided 
+      /// (overloaded from GimmickView)
+      void CreateTreeView( TreeHandler* );
 
     private:
-      
-    };
+      /// The ToolBar and the tools
+      wxToolBar*         mToolBar;
+      wxToolBarToolBase* mToolAddFile;
+
+      wxSplitterWindow* mSplitter;
+      wxPanel*          mBottomPanel;
+      wxNotebook*       mNotebook;
+
+      /// The list of icons 
+      wxImageList *    mIcon;
+      void CreateIconList();
+
+   };
     // EO class WxGimmickView
     //=====================================================================
   
index fb6bcf30eafb8c68d76bd2f3e962c5c050bf709d..f615a6916af72a5743e9c733241710410bf2d04e 100644 (file)
@@ -1,5 +1,6 @@
 #include <creaImageIOWxTreeView.h>
 #include <creaImageIOSystem.h>
+#include <wx/splitter.h>
 
 namespace creaImageIO
 {
@@ -12,6 +13,56 @@ namespace creaImageIO
   {
     GimmickDebugMessage(1,"WxTreeView::WxTreeView"
                        <<std::endl);
+
+    
+    // Split part below toolbar into notebook for views and panel
+    // for preview, messages...
+    // TO DO : Splitter
+    //    mSplitter = new wxSplitterWindow( this , -1);
+
+    // Global sizer
+    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+    
+    int ctrl_style = wxLC_REPORT;
+    int col_style = wxLIST_FORMAT_LEFT;
+
+    // Creating the ListCtrl for the levels > 0 (not for Root level)
+    for (int i = 1;
+        i < handler->GetTree().GetNumberOfLevels();
+        ++i)
+      {
+       GimmickDebugMessage(5,"Creating ListCtrl for level "<<i
+                           <<std::endl);
+
+       wxListCtrl* ctrl = new wxListCtrl(this,
+                                         i,
+                                         wxDefaultPosition, 
+                                         wxDefaultSize,
+                                         ctrl_style);
+       
+       // Create the columns : one for each attribute of the level
+       int col = 0;
+       tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+       for (a  = handler->GetTree().GetAttributeDescriptorList(i).begin();
+            a != handler->GetTree().GetAttributeDescriptorList(i).end();
+            ++a)
+         {
+           GimmickDebugMessage(5,"Creating column "<<col<<" : "
+                               <<a->GetName()
+                               <<std::endl);
+           ctrl->InsertColumn(col, 
+                              crea::std2wx(a->GetName()),
+                              col_style);
+           col++;
+         }
+       mListCtrl.push_back(ctrl);
+       sizer->Add( ctrl ,1, wxGROW  ,0);
+      }
+    
+    SetSizer( sizer );     
+    SetAutoLayout(true);
+    Layout();
+
   }
 
   /// Destructor
index 678c626039ccb04bd83bcb316ce4fff4b63db9a7..65e783d6435c9b571c0d092388222737b60d27aa 100644 (file)
@@ -6,6 +6,8 @@
 #include <creaImageIOTreeView.h>
 #include <creaWx.h>
 
+#include <wx/listctrl.h>
+
 namespace creaImageIO
 {
   /**
@@ -29,7 +31,9 @@ namespace creaImageIO
       
 
     private:
-
+      /// The vector of wxListCtrl : one for each level of the tree
+      std::vector<wxListCtrl*> mListCtrl;
+      
     };
     // EO class WxTreeView
     //=====================================================================