]> Creatis software - creaImageIO.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Wed, 1 Oct 2008 14:23:56 +0000 (14:23 +0000)
committerguigues <guigues>
Wed, 1 Oct 2008 14:23:56 +0000 (14:23 +0000)
appli/TestWxGimmickDialog/main.cxx
src/creaImageIODicomNode.cpp
src/creaImageIODicomNode.h
src/creaImageIOWxGimmick.cpp
src/creaImageIOWxGimmick.h
src/creaImageIOWxGimmickDialog.cpp
src/creaImageIOWxGimmickDialog.h
src/treelistctrl.cpp
src/treelistctrl.h

index 63b001ccc2345b5f17d3e91d6b3d17af19bf3cb2..b0ad1da522ff609659b88967b8d3afc0680b2356 100644 (file)
@@ -2,6 +2,8 @@
 #include <creaWx.h>
 #include <creaImageIOWxGimmickDialog.h>
 
+#include <creaVtkBasicSlicer.h>
+
 class myApp : public wxApp
 {
 public:
@@ -11,20 +13,7 @@ public:
 
 IMPLEMENT_APP(myApp);
 
-#if defined(_WIN32) 
-
-//  How to have a Console and wxWidgets
-//  http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
-//   In Visual C++ 6 (7 should be similar), to create an application that is both a console application 
-//  (cout's to the console are visible) and has a wxWidgets GUI, 
-//  you need to use the linker option "/subsystem:console" and the following code:
-int main(int argc, char* argv[])
-{
-       return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
-}
-
-#endif // defined(_WIN32) 
-
+CREA_WXMAIN_WITH_CONSOLE
 
 bool myApp::OnInit( )
 {       
@@ -35,14 +24,16 @@ bool myApp::OnInit( )
 #endif
    wxInitAllImageHandlers();
 
+   int image_type = GIMMICK_3D_IMAGE_SELECTION;
    int threads = 1;
 
    creaImageIO::WxGimmickDialog w(0,
-                          -1,
-                          _T("WxGimmickDialog test"),
-                          wxDefaultPosition,
-                          wxSize(1200,800),
-                          threads);
+                                 -1,
+                                 _T("WxGimmickDialog test"),
+                                 wxDefaultPosition,
+                                 wxSize(1200,800),
+                                 image_type,
+                                 threads);
    w.ShowModal();
    
    if (w.GetReturnCode() == wxID_OK)
@@ -50,13 +41,19 @@ bool myApp::OnInit( )
        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
        std::cout << "$$$$ selected files : "<<std::endl;
        std::vector<std::string> s;
-       w.GetSelectedImages(s);
+       w.GetSelectedFiles(s);
        std::vector<std::string>::iterator i;
        for (i=s.begin();i!=s.end();++i) 
         {
           std::cout << *i << std::endl;
         }
        std::cout << "$$$$ "<<std::endl;
+
+       std::vector<vtkImageData*> images;
+       w.GetSelectedImages(images);
+       crea::VtkBasicSlicer(images.front());
+       images.front()->Delete();
+
      }
    else if (w.GetReturnCode() == wxID_CANCEL)
      {
index 011c434d073b27844b335112585c73761c5a7183..1ddbd6f4809bf736ae5ac8dfa50c1389f14f9c6c 100644 (file)
@@ -165,6 +165,27 @@ namespace creaImageIO
   }
   //=============================================================
 
+  //=============================================================
+  int DicomNode::ImageGetRows() const
+  {
+    return atoi(UnsafeGetFieldValue("A0028_0010").c_str());
+  }
+  //=============================================================
+
+  //=============================================================
+  int DicomNode::ImageGetColumns() const
+  {
+    return atoi(UnsafeGetFieldValue("A0028_0011").c_str());
+  }
+  //=============================================================
+
+  //=============================================================
+  int DicomNode::ImageGetFrames() const
+  {
+    return atoi(UnsafeGetFieldValue("A0028_0008").c_str());
+  }
+  //=============================================================
+
   //=============================================================
   void DicomNode::Print() const 
   {
index ae45ed963d06496315264bb7fa278a2e252b794c..42949c6684085d48c68a5abc91823809836943b4 100644 (file)
@@ -97,6 +97,12 @@ namespace creaImageIO
 
     void SortChildren(const LexicographicalDicomNodeComparator&);
 
+
+    int ImageGetRows() const;
+    int ImageGetColumns() const;
+    int ImageGetFrames() const;
+    const std::string& ImageGetFullFileName() const { return UnsafeGetFieldValue("FullFileName"); }
+
   protected:
     DicomDatabase* mDicomDatabase;
 
index 7bfed5b624ed7a85adf498ebb648410652db836e..2bcc3ab50c53bc08f25fcdfd1ebbae703b725365 100644 (file)
@@ -255,14 +255,26 @@ namespace creaImageIO
   //================================================================
   //================================================================
   WxGimmick::WxGimmick(wxWindow *parent, 
-                                                  wxWindowID id,
-                                                  const wxPoint& pos,
-                                                  const wxSize& size,
-                                                  int threads)
+                      wxWindowID id,
+                      const wxPoint& pos,
+                      const wxSize& size,
+                      int image_type,
+                      int threads)
     : wxPanel(parent,id,pos,size),
+      mSelectionType(image_type),
       mSaveConfigurationOnClose(true),
       mReader(threads)
   {
+    // Initialize image size corresponding to current selection
+    switch (mSelectionType) 
+      {
+      case GIMMICK_2D_IMAGE_SELECTION : mSelectionMaxImageDimension = 2; break;
+      case GIMMICK_3D_IMAGE_SELECTION : mSelectionMaxImageDimension = 3; break;
+      case GIMMICK_4D_IMAGE_SELECTION : mSelectionMaxImageDimension = 4; break;
+      default : mSelectionMaxImageDimension = 0;
+      }
+
+
     // Start the threads ...
     mReader.Start();
 
@@ -1023,6 +1035,54 @@ namespace creaImageIO
   }
   //================================================================
 
+  //================================================================
+  void WxGimmick::LoadChildren(wxTreeItemId& id)
+  {
+    TreeItemData *item = (TreeItemData *)mTreeListCtrl->GetItemData(id);
+    if (item)
+      {
+       if ( ( item->IsDicomNode() || item->IsDatabase() ) &&
+            ( ! item->GetDicomNode()->ChildrenLoaded() ) )
+         {
+           
+           // If children not already loaded : do it 
+           if (
+               item->GetDicomNode()->GetDicomDatabase()->DBLoadChildren
+               (item->GetDicomNode(),item->GetDicomNode()->GetType()+1)
+               > 0 )
+             {
+               // Some new children loaded
+               // Sort them
+               if (mSettings.HasActiveComparator
+                   (item->GetDicomNode()->GetType()+1))
+                 {
+                   /*                  std::cout << "Sorting using '"
+                     << mSettings.GetActiveComparator
+                     (item->GetDicomNode()->GetType()+1).GetName() 
+                     << "' ... ";
+                   */
+                   item->GetDicomNode()->SortChildren
+                     ( mSettings.GetActiveComparator
+                       (item->GetDicomNode()->GetType()+1)
+                       );
+                   //                  std::cout << "ok"<<std::endl;
+                 }
+               // Update tree
+               DicomNode::ChildrenListType::iterator i;
+               for (i=item->GetDicomNode()->GetChildrenList().begin();
+                    i!=item->GetDicomNode()->GetChildrenList().end();
+                    i++)
+                 {
+                   UpdateDicomNodeView(*i,id);
+                 }
+             }
+           // EO If children not already loaded 
+         }
+      } 
+  }
+  //================================================================
+
+
   //================================================================
   void WxGimmick::OnItemExpanded(wxTreeEvent& event)                   
   {
@@ -1033,7 +1093,10 @@ namespace creaImageIO
     wxBusyCursor busy;
     
     wxTreeItemId itemId = event.GetItem();
+    LoadChildren(itemId);
+    
+    return;
+
     // expand if collapsed and collapse if expanded ...
     TreeItemData *item = 
       (TreeItemData *)mTreeListCtrl->GetItemData(itemId);
@@ -1725,25 +1788,111 @@ namespace creaImageIO
   }
   //=================================================
 
+
+
+
+
+
+
+
+  //================================================================
+  bool WxGimmick::IsImageSelectable(DicomNode* node)                   
+  {
+    int rows = node->ImageGetRows();
+    int cols = node->ImageGetColumns();
+    int frms = node->ImageGetFrames();
+    
+    //    std::cout << "R/C/F = " << rows << "/"<< cols <<"/"<<frms<<std::endl;
+
+    int dim = 0;
+    if (frms>0) dim=3;
+    else if (cols>0) dim=2;
+    else if (rows>0) dim=1;
+    
+    if (dim == 0) 
+      {
+       std::cout << "Unknown image dimension : cannot select !" 
+                 << std::endl;
+       return false;
+      }
+    else if (dim>mSelectionMaxImageDimension)
+      {
+       std::cout << "Selecting "<<dim<<"D images is not allowed !" 
+                 << std::endl;
+       return false;
+      }
+    
+    if ( mTreeListCtrl->GetSelectionSize() == 0 ) 
+      {
+       mCurrentSelectionImageSize[0] = cols;
+       mCurrentSelectionImageSize[1] = rows;
+       mCurrentSelectionImageSize[2] = frms;
+       return true;
+      }
+    else 
+      {
+       if ( dim == mSelectionMaxImageDimension )
+         {
+           std::cout << "Cannot add this image to selection : would result in a "<<dim+1<<"D image !" << std::endl;
+           return false;
+         }
+       if ( ( cols != mCurrentSelectionImageSize[0] ) ||
+            ( rows != mCurrentSelectionImageSize[1] ) ||
+            ( frms != mCurrentSelectionImageSize[2] ) )
+         {
+           std::cout << "Cannot add this image to selection : image size is incomptatible with currently selected images" << std::endl; 
+           return false;
+         }
+      }
+    std::cout << "Selecting : "<<node->ImageGetFullFileName() << std::endl;
+    return true;
+  }
+  //================================================================
+
   //================================================================
   void WxGimmick::OnSelChanging(wxTreeEvent& event)                   
   {
+    event.Veto();
     wxTreeItemId id = event.GetItem();
     if (!id.IsOk()) 
       {
-       std::cout << "ERROR : ID NOT OK"<<std::endl;
+       std::cout << "INTERNAL ERROR : ID NOT OK"<<std::endl;
        return;
       }
 
-    TreeItemData *data = (TreeItemData *)mTreeListCtrl->GetItemData(id);
 
-    event.Veto();
+    TreeItemData *data = (TreeItemData *)mTreeListCtrl->GetItemData(id);
     if (data->IsDicomNode())
       {
-       if ((data->GetDicomNode()>0)&&
-           ( data->GetDicomNode()->GetType()==DicomNode::Image))
+       if (data->GetDicomNode()>0)
          {
-           event.Allow();
+           // An image was selected 
+           if (data->GetDicomNode()->GetType()==DicomNode::Image)
+             {
+               if (IsImageSelectable(data->GetDicomNode())) event.Allow();
+             }
+           // A series was selected 
+           else if (data->GetDicomNode()->GetType()==DicomNode::Series)
+             {
+               // If images not loaded do it 
+               LoadChildren(id);
+               // can be selected if all its images can
+               wxTreeItemId child;
+               wxTreeItemIdValue cookie;
+               for (child = mTreeListCtrl->GetFirstChild(id,cookie);
+                    child.IsOk();
+                    child = mTreeListCtrl->GetNextChild(id,cookie))
+                 {    
+                   TreeItemData *cdata = 
+                     (TreeItemData *)mTreeListCtrl->GetItemData(child);
+                   if ((cdata->IsDicomNode())&&
+                       (cdata->GetDicomNode()>0)&&
+                       (cdata->GetDicomNode()->GetType()==DicomNode::Image)&&
+                       (!IsImageSelectable(cdata->GetDicomNode())))
+                     return;
+                 }
+               event.Allow();
+             }
          }
       }
   }
@@ -1817,9 +1966,9 @@ namespace creaImageIO
                //                                << nsib->GetFieldValue("FullFileName")
                //                                << "' prio="<<prio<<std::endl;
                mReader.Request(this,
-                               nsib->GetFieldValue("FullFileName"), 
+                               nsib->ImageGetFullFileName(), 
                                prio);
-               mImageFileNameToNode[nsib->GetFieldValue("FullFileName")] =
+               mImageFileNameToNode[nsib->ImageGetFullFileName()] =
                  nsib;
                prio--;
              }
@@ -1836,9 +1985,9 @@ namespace creaImageIO
                //                                << nsib->GetFieldValue("FullFileName")
                //                                << "' prio="<<prio<<std::endl;
                mReader.Request(this,
-                               nsib->GetFieldValue("FullFileName"), 
+                               nsib->ImageGetFullFileName(), 
                                prio);
-               mImageFileNameToNode[nsib->GetFieldValue("FullFileName")] =
+               mImageFileNameToNode[nsib->ImageGetFullFileName()] =
                  nsib;
                prio--;
              }
@@ -1999,9 +2148,17 @@ namespace creaImageIO
   //================================================================
  
 
+  //================================================================
+  // LG : For the moment any selection is valid but in the future 
+  // incomplete selections can be invalid...
+  bool WxGimmick::IsSelectionValid() 
+  { 
+    return (mTreeListCtrl->GetSelectionSize()>0); 
+  } 
+  //================================================================
 
   //================================================================
-  void WxGimmick::GetSelectedImages(std::vector<std::string>& f)
+  void WxGimmick::GetSelectedFiles(std::vector<std::string>& f)
   {
     wxArrayTreeItemIds id;
     // TO DO : TEST THAT STYLE IS MULTIPLE 
@@ -2015,7 +2172,7 @@ namespace creaImageIO
          {
            if (data->GetDicomNode()->GetType()==DicomNode::Image)
              {
-               f.push_back ( data->GetDicomNode()->GetFieldValue("FullFileName") );
+               f.push_back ( data->GetDicomNode()->ImageGetFullFileName() );
              }
            else if (data->GetDicomNode()->GetType()==DicomNode::Series)
              {
@@ -2024,7 +2181,7 @@ namespace creaImageIO
                     j!=data->GetDicomNode()->GetChildrenList().end();
                     j++) 
                  {
-                   f.push_back((*j)->GetFieldValue("FullFileName"));
+                   f.push_back((*j)->ImageGetFullFileName());
                  }
              }
          }
@@ -2032,6 +2189,99 @@ namespace creaImageIO
   }
   //================================================================
 
+  //================================================================
+  void WxGimmick::GetSelectedImages(std::vector<vtkImageData*>& f)
+  {
+    wxArrayTreeItemIds id;
+    // TO DO : TEST THAT STYLE IS MULTIPLE 
+    unsigned int nb = mTreeListCtrl->GetSelections(id);
+    f.clear();
+
+    // Collect the brute vector of Image nodes
+    std::vector<DicomNode*> im;
+    for (unsigned int i=0; i<nb; ++i)
+      {
+       TreeItemData *data = 
+         (TreeItemData *)mTreeListCtrl->GetItemData(id[i]);
+       if ((data) && (data->IsDicomNode()))
+         {
+           if (data->GetDicomNode()->GetType()==DicomNode::Image)
+             {
+               im.push_back ( data->GetDicomNode() );
+
+             }
+           else if (data->GetDicomNode()->GetType()==DicomNode::Series)
+             {
+               DicomNode::ChildrenListType::iterator j;
+               for (j =data->GetDicomNode()->GetChildrenList().begin();
+                    j!=data->GetDicomNode()->GetChildrenList().end();
+                    j++) 
+                 {
+                   im.push_back ( *j );
+                 }
+             }
+         }
+      }
+    // Create the output data
+    if (im.size()==1) 
+      {
+       // Only one image : give it
+       vtkImageData* out = vtkImageData::New();
+       out->ShallowCopy(mReader.GetImage(im.front()->ImageGetFullFileName()));
+       f.push_back( out );
+      }
+    else if (im.size()>1)
+      {
+       vtkImageData* first = mReader.GetImage( im.front()->ImageGetFullFileName() );
+       if (first->GetDataDimension()==2) 
+         {     
+           // n2D to 3D
+           vtkImageData* out = vtkImageData::New();
+           out->CopyStructure(first);
+           int ext[6];
+           first->GetExtent(ext);
+           ext[5] = im.size();
+           out->SetExtent(ext);
+           
+           out->AllocateScalars();
+           out->Print(std::cout);
+           
+           int dim[3];
+           first->GetDimensions(dim);
+           unsigned long imsize = 
+             ( (unsigned long)first->GetScalarPointer(0,1,0)
+               - (unsigned long)first->GetScalarPointer(0,0,0))
+             *dim[1];
+           std::cout << "imsize="<<imsize<<std::endl;
+
+           int slice = 0;
+           std::vector<DicomNode*>::iterator it;
+           for (it=im.begin(); it!=im.end(); ++it) 
+             {
+               vtkImageData* cur = mReader.GetImage( (*it)->ImageGetFullFileName() );
+               
+               void* src = cur->GetScalarPointer(0,0,0);
+               void* dst = out->GetScalarPointer(0,0,slice);
+               memcpy(dst,src,imsize);
+               slice++;
+             }
+           f.push_back(out);
+         }
+       else 
+         {
+           // n3D
+           std::vector<DicomNode*>::iterator it;
+           for (it=im.begin(); it!=im.end(); ++it) 
+             {
+               vtkImageData* out = vtkImageData::New();
+               out->ShallowCopy(mReader.GetImage((*it)->ImageGetFullFileName()));
+               f.push_back(out);
+             }
+         }
+      }
+  }
+  //================================================================
+
 
   //================================================================
   void WxGimmick::GetSelectedDicomNodes(std::vector<DicomNode*>& f)
@@ -2052,7 +2302,7 @@ namespace creaImageIO
 
        if (data->GetDicomNode()->GetType()==DicomNode::Image)
        {
-       f.push_back ( data->GetDicomNode() ); //->GetFieldValue("FullFileName") );
+       f.push_back ( data->GetDicomNode() ); //->ImageGetFullFileName() );
        }  
        else if (data->GetDicomNode()->GetType()==DicomNode::Series)
        {
@@ -2061,8 +2311,7 @@ namespace creaImageIO
        j!=data->GetDicomNode()->GetChildrenList().end();
        j++) 
        {
-       f.push_back((*j)); //->GetFieldValue("FullFileName"));
-       }
+       f.push_back((*j)); //->ImageGetFullFileName() );        }
        }
        }
        */
@@ -2596,17 +2845,14 @@ namespace creaImageIO
          //================================================================
          //================================================================
          WxGimmickFrame::WxGimmickFrame( wxWindow *parent, 
-                                                                     wxString title, 
-                                                                     wxSize size)
+                                         wxString title, 
+                                         wxSize size)
            : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
            {   
              wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-             long style = wxTR_DEFAULT_STYLE |
-#ifndef NO_VARIABLE_HEIGHT
-               wxTR_HAS_VARIABLE_ROW_HEIGHT |
-#endif
-               wxTR_EDIT_LABELS | wxSUNKEN_BORDER;
-             mWxGimmick = new WxGimmick(this,-1,wxDefaultPosition,wxDefaultSize,style);
+             mWxGimmick = new WxGimmick(this,-1,
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
              sizer->Add(mWxGimmick,1,wxGROW);
              SetSizer(sizer);
              SetAutoLayout(true);
index 062d8de3116d0de65f1a68653a4a76089dc518c2..13cdaf8e3109fc01749d4877339eaf98f5b0ef7f 100644 (file)
@@ -35,48 +35,58 @@ namespace creaImageIO
   class WxGimmickDicomNodeData;
   //====================================================================
 
+#define GIMMICK_NO_IMAGE_SELECTION 0
+#define GIMMICK_2D_IMAGE_SELECTION 2
+#define GIMMICK_3D_IMAGE_SELECTION 3
+#define GIMMICK_4D_IMAGE_SELECTION 4
+
   //====================================================================
   class CREAIMAGEIO_EXPORT WxGimmick : public wxPanel,
-                                 public MultiThreadImageReaderUser
+                                      public MultiThreadImageReaderUser
   {
   public:
+
     WxGimmick(wxWindow *parent, const wxWindowID id,
-                           const wxPoint& pos, const wxSize& size,
-                           int number_of_threads = 0);
+             const wxPoint& pos, const wxSize& size,
+             int image_type = GIMMICK_3D_IMAGE_SELECTION,
+             int number_of_threads = 0);
 
     virtual ~WxGimmick();
 
+    int GetSelectionSize() { return mTreeListCtrl->GetSelectionSize(); } 
+    bool IsSelectionValid();
+    void GetSelectedFiles(std::vector<std::string>&);
+    void GetSelectedImages(std::vector<vtkImageData*>&);
+    void GetSelectedDicomNodes(std::vector<DicomNode*>&);
+    void GetSelectedItems(std::vector<wxTreeItemId>&);
+    DicomNode* GetDicomNodeOfItem(const wxTreeItemId& i);
+
+    static const int UserMenuFirstId;
+
+    typedef WxGimmickSettings Settings;
+    const Settings& GetSettings() const { return mSettings; }
+    Settings& GetSettings() { return mSettings; }
+
+    typedef WxGimmickEvent EventType;
+
     typedef std::vector<DicomDatabase*> DicomDatabaseListType;
 
-    DicomDatabaseListType& GetDicomDatabaseList() { return mDicomDatabaseList; }
-    const DicomDatabaseListType& GetDicomDatabaseList() const { return mDicomDatabaseList; }
+    DicomDatabaseListType& GetDicomDatabaseList() 
+    { return mDicomDatabaseList; }
+    const DicomDatabaseListType& GetDicomDatabaseList() const 
+    { return mDicomDatabaseList; }
     
     wxTreeListCtrl* GetTreeListCtrl() { return mTreeListCtrl; }
     const wxTreeListCtrl* GetTreeListCtrl() const { return mTreeListCtrl; }
 
     void SetConfigurationFile(const std::string& filename) 
-    {
-      mConfigurationFile = filename;
-    }
+    { mConfigurationFile = filename;}
     void LoadConfiguration();
     void SaveConfiguration();
     void SetSaveConfigurationOnClose(bool v) 
     { mSaveConfigurationOnClose = v; }
 
 
-    void GetSelectedImages(std::vector<std::string>&);
-    void GetSelectedDicomNodes(std::vector<DicomNode*>&);
-    void GetSelectedItems(std::vector<wxTreeItemId>&);
-    DicomNode* GetDicomNodeOfItem(const wxTreeItemId& i);
-
-
-    static const int UserMenuFirstId;
-
-    typedef WxGimmickSettings Settings;
-    const Settings& GetSettings() const { return mSettings; }
-    Settings& GetSettings() { return mSettings; }
-
-    typedef WxGimmickEvent EventType;
 
   protected:
     void RebuildView();
@@ -92,6 +102,7 @@ namespace creaImageIO
     void InsertDicomDatabase(wxTreeItemId& id, DicomDatabase* r);
     void DeleteDicomDatabase(wxTreeItemId& id, DicomDatabase* r);
 
+    void LoadChildren( wxTreeItemId& id );
     friend class WxGimmickEvent;
 
   private:
@@ -99,6 +110,10 @@ namespace creaImageIO
     WxGimmick() { }
     WxGimmick(const WxGimmick& ) { }
 
+    int mSelectionType;
+    int mSelectionMaxImageDimension;
+    int mCurrentSelectionImageSize[4];
+
     DicomDatabaseListType mDicomDatabaseList;
 
     wxTreeListCtrl* mTreeListCtrl;
@@ -197,6 +212,7 @@ namespace creaImageIO
     void OnItemCollapsing(wxTreeEvent& event);
     void OnSelChanged(wxTreeEvent& event);
     void OnSelChanging(wxTreeEvent& event);
+    bool IsImageSelectable(DicomNode* node);
     void OnTreeKeyDown(wxTreeEvent& event);
     void OnItemActivated(wxTreeEvent& event);
     void OnItemRightClick(wxTreeEvent& event);
index 0a736d34480821327142550434562e2e00ff3734..87c44a46aec693c5f6c86ff886da1e828eb79158 100644 (file)
@@ -12,30 +12,32 @@ namespace creaImageIO
   
   //================================================================
   WxGimmickDialog::WxGimmickDialog(wxWindow *parent, 
-                                              wxWindowID id,
-                                              wxString title,
-                                              const wxPoint& pos,
-                                              const wxSize& size,
-                                              int threads)
+                                  wxWindowID id,
+                                  wxString title,
+                                  const wxPoint& pos,
+                                  const wxSize& size,
+                                  int image_type,
+                                  int threads)
     :   wxDialog( parent, 
-               id, 
-               title,
-               pos,
-               size,
-               wxRESIZE_BORDER | 
-               wxSYSTEM_MENU  |
-               wxCLOSE_BOX |
-               wxMAXIMIZE_BOX | 
-               wxMINIMIZE_BOX | 
-               wxCAPTION  
-               )
+                 id, 
+                 title,
+                 pos,
+                 size,
+                 wxRESIZE_BORDER | 
+                 wxSYSTEM_MENU  |
+                 wxCLOSE_BOX |
+                 wxMAXIMIZE_BOX | 
+                 wxMINIMIZE_BOX | 
+                 wxCAPTION  
+                 )
   {
     wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
+    
     mView = new ViewType(this,
                         TVID,
                         wxDefaultPosition,
                         size,
+                        image_type,
                         threads);
  
     topsizer->Add( mView,1,wxGROW,0);
@@ -65,25 +67,8 @@ namespace creaImageIO
   void WxGimmickDialog::OnSelChanged(EventType& event)
   {
     //    std::cout << "++++++++++ WxGimmickDialog::OnSelChanged ++++++++++"
-    //       <<std::endl;
-    std::vector<DicomNode*> nodes;
-    mView->GetSelectedDicomNodes(nodes);
-    
-    bool ok = false;
-    std::vector<DicomNode*>::iterator i;
-    for (i=nodes.begin();i!=nodes.end();++i)
-      {
-       if ((*i)->GetType() == DicomNode::Image)
-         {
-           ok = true;
-           break;
-         }
-       //      std::cout << "'" << (*i)->GetFieldValue("FullFileName") 
-       //                << "'" << std::endl;
-      }
-    //    std::cout << "++++++++++++++++++++" << std::endl;
-    
-    if (ok)
+  
+    if (mView->IsSelectionValid())
       {
        mOkButton->Enable(true);
       }
index caa7edd7972dcf34adaa8b05932d406c0de24d5d..aafdc5d712c948c8b34ce40f2387deb1f5bcb62a 100644 (file)
@@ -14,22 +14,23 @@ namespace creaImageIO
   public:
     WxGimmickDialog();    
     WxGimmickDialog(wxWindow *parent, 
-                              const wxWindowID id,
-                              wxString title,
-                              const wxPoint& pos, 
-                              const wxSize& size,
-                              int threads = 0);
+                   const wxWindowID id,
+                   wxString title,
+                   const wxPoint& pos, 
+                   const wxSize& size,
+                   int image_type = GIMMICK_3D_IMAGE_SELECTION,
+                   int threads = 0);
     
     typedef WxGimmick ViewType;
     typedef WxGimmick::EventType EventType;
 
     ~WxGimmickDialog();
 
-    vtkImageData* GetImage();
-
-    void GetSelectedImages(std::vector<std::string>& s)
-    { return mView->GetSelectedImages(s); }
-
+    void GetSelectedImages(std::vector<vtkImageData*>& s)
+    { mView->GetSelectedImages(s); }
+    void GetSelectedFiles(std::vector<std::string>& s) 
+    { mView->GetSelectedFiles(s); }
+    
     void OnSelChanged(EventType& event);
     void OnContextualMenu(EventType& event);
     void OnMenuTest(wxCommandEvent& event);
index 205a5cae963c61654acf4207495889f0ca6993e9..2df0ab96a5a6f63ed9460ab19a26a5b5b67b77b9 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Robert Roebling
 // Maintainer:  Otto Wyss
 // Created:     01/02/97
-// RCS-ID:      $Id: treelistctrl.cpp,v 1.2 2008/09/30 08:41:54 guigues Exp $
+// RCS-ID:      $Id: treelistctrl.cpp,v 1.3 2008/10/01 14:23:59 guigues Exp $
 // Copyright:   (c) 2004 Robert Roebling, Julian Smart, Alberto Griggio,
 //              Vadim Zeitlin, Otto Wyss
 // Licence:     wxWindows
@@ -405,6 +405,9 @@ public:
     // get all the items currently selected, return count of items
     size_t GetSelections(wxArrayTreeItemIds&) const;
 
+  // returns the number of currently selected items
+  size_t GetSelectionSize() const;
+   
     // get the parent of this item (may return NULL if root)
     wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
 
@@ -2685,6 +2688,13 @@ void wxTreeListMainWindow::FillArray (wxTreeListItem *item,
     }
 }
 
+
+// returns the number of currently selected items
+ size_t wxTreeListMainWindow::GetSelectionSize() const
+ {
+   return m_selected.GetCount();
+ }
+
 size_t wxTreeListMainWindow::GetSelections (wxArrayTreeItemIds &array) const {
   /* 
      LG : NOT OK AS IS NOT IN TREE ORDER
@@ -4451,6 +4461,10 @@ wxTreeItemId wxTreeListCtrl::GetRootItem() const
 //{ return m_main_win->GetSelection(); }
  wxTreeItemId wxTreeListCtrl::GetCurrent() const
  { return m_main_win->GetCurrent(); }
+ // returns the number of currently selected items
+ size_t wxTreeListCtrl::GetSelectionSize() const
+ { return m_main_win->GetSelectionSize(); }
 
 size_t wxTreeListCtrl::GetSelections(wxArrayTreeItemIds& arr) const
 { return m_main_win->GetSelections(arr); }
index a5c31b8e491b7dee8d11517e99330f41e30409b3..5c23dfce37bdf3a982dbd44b07bc83f2248ca3bb 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Robert Roebling
 // Maintainer:  Otto Wyss
 // Created:     01/02/97
-// RCS-ID:      $Id: treelistctrl.h,v 1.2 2008/09/30 08:41:54 guigues Exp $
+// RCS-ID:      $Id: treelistctrl.h,v 1.3 2008/10/01 14:23:59 guigues Exp $
 // Copyright:   (c) 2004 Robert Roebling, Julian Smart, Alberto Griggio,
 //              Vadim Zeitlin, Otto Wyss
 // Licence:     wxWindows
@@ -371,6 +371,9 @@ public:
   //    wxTreeItemId GetSelection() const;
   wxTreeItemId GetCurrent() const;
 
+    // returns the number of currently selected items
+    size_t GetSelectionSize() const;
+
     // get the items currently selected, return the number of such item
     size_t GetSelections (wxArrayTreeItemIds&) const;