]> Creatis software - creaImageIO.git/commitdiff
Correction sur l'affichage des dates et des temps.
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 14 Apr 2009 13:51:35 +0000 (13:51 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Tue, 14 Apr 2009 13:51:35 +0000 (13:51 +0000)
Correction du crash sur le wxViewer thread ens ortie d'application.
Ajout de l'événement clavier sur les listes.

src2/creaImageIOTreeAttributeDescriptor.cpp
src2/creaImageIOTreeAttributeDescriptor.h
src2/creaImageIOWxGimmickReaderDialog.cpp
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxTreeView.cpp
src2/creaImageIOWxTreeView.h

index 54c56b87e2308f22d5d77c15ea97bcd170a72a0c..08fd784d9e26960199d35fc69585051121022305 100644 (file)
@@ -115,6 +115,43 @@ namespace creaImageIO
       return;
     }
 
+       //=====================================================================
+       /// test if the type is a date
+       bool AttributeDescriptor::isDateEntry() const
+       {
+                
+               bool btest = false;
+               // Retrieve the name from gdcm dict
+               GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
+               if(     entry != 0)
+               {
+                       if( entry->GetVR().str() == "DA" )
+                       {
+                               btest = true;
+                       }
+               }
+               return btest;
+       }
+
+       //=====================================================================
+       /// test if the type is a time
+       bool AttributeDescriptor::isTimeEntry() const
+       {
+                
+               bool btest = false;
+               // Retrieve the name from gdcm dict
+               GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
+               if(     entry != 0)
+               {
+                       if( entry->GetVR().str() == "TM" )
+                       {
+                               btest = true;
+                       }
+               }
+               return btest;
+       }
+
+
     //=====================================================================
        /// Decodes the type of the attribute
      void AttributeDescriptor::DecodeType(unsigned int& typ) const
index d2afc8515bacfca18f75fe37e2cb5b65c0cb72e6..ad4d7bfe601fe38922f3fb3b10fae6e97b482cb4 100644 (file)
@@ -81,6 +81,9 @@ namespace creaImageIO
          ///Decodes the type of attribute into the existing ones
          void DecodeType(unsigned int& type) const;
 
+         bool isDateEntry() const;
+         bool isTimeEntry() const;
+
     private:
       std::string mKey;
       std::string mName;
index 6c311fbb95bea391f79f1740db0c01707305c579..e7cd5b8a94691fc5fbc9388afa7ff387b23d7d63 100644 (file)
@@ -78,13 +78,14 @@ namespace creaImageIO
                        <<std::endl);
     if (mView) 
       {
-       delete mView;
+               delete mView;
       }
     if (mGimmick) 
       {
        mGimmick->Finalize();
        delete mGimmick;
       }
+
   }
 
   ///Callback method on a selection
index 21c9a98b8b8cb618136e7a37086a6c7614f28145..f60480e8365f0762b610b088c582cd52d15eadba 100644 (file)
@@ -156,6 +156,8 @@ namespace creaImageIO
   /// Destructor
   WxGimmickView::~WxGimmickView()
   {
+       // stop the viewer before application exit.
+       mViewer->StopPlayer();
     GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
                        <<std::endl);
   }
@@ -347,6 +349,7 @@ namespace creaImageIO
       {
        
        bool recurse = false;
+
        if (wxMessageBox(_T("Recurse into sub-directories ?"),
                         _T("Scan directory"),
                         wxYES_NO,this ) == wxYES)
@@ -571,7 +574,8 @@ namespace creaImageIO
   {
 
     char mess[200];
-    sprintf(mess,"%i dirs - %i files - %i handled - %i added",
+   
+       sprintf(mess,"%i dirs : %i files :\n            %i handled - %i added",
           p.GetNumberScannedDirs(),
           p.GetNumberScannedFiles(),
           p.GetNumberHandledFiles(),
index d81877f38ea60104dd1ff99cc669bf40db004325..49c72ef98bd8d61bcc1c0be867ab7dade7677570 100644 (file)
@@ -3,6 +3,13 @@
 #include <creaImageIOSystem.h>
 #include <wx/splitter.h>
 #include <wx/gdicmn.h>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/local_time_adjustor.hpp>
+#include <boost/date_time/c_local_time_adjustor.hpp>
+
+
+
 
 const std::string empty_string("");
 
@@ -127,8 +134,8 @@ namespace creaImageIO
     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();
+    for (int i = 0;
+        i < handler->GetTree().GetNumberOfLevels() -1;
         ++i)
       {
 
@@ -141,10 +148,11 @@ namespace creaImageIO
        // If the first level : parent = this
        wxWindow* sparent = this;
        // else parent = last splitter
-       if (i>1) sparent = mLevelList[i-2].wxSplitter;
+       if (i>0) 
+               sparent = mLevelList[i-1].wxSplitter;
 
        level.wxSplitter = new wxSplitterWindow( sparent , -1);
-       if(i!=1)
+       if(i!=0)
        {
        level.wxSplitter->Show(false);
        }
@@ -163,10 +171,11 @@ namespace creaImageIO
        int col = 0;
        std::string title;
        tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
-       for (a  = handler->GetTree().GetAttributeDescriptorList(i).begin();
-            a != handler->GetTree().GetAttributeDescriptorList(i).end();
+       for (a  = handler->GetTree().GetAttributeDescriptorList(i+1).begin();
+            a != handler->GetTree().GetAttributeDescriptorList(i+1).end();
             ++a)
-         {
+
+{
        
            GimmickDebugMessage(5,"Creating column "<<col<<" : "
                                <<a->GetName()
@@ -187,15 +196,19 @@ namespace creaImageIO
                  {
                    title=a->GetName();
                  }
-               
+                 std::string temp = a->GetKey();
+                 if (temp.compare("ID") != 0)
+                 {
                ctrl->InsertColumn(col, 
                                   crea::std2wx(title),
                                   col_style);
+               col++;
+                 }
                level.key.push_back(a->GetKey());
 
                //          ctrl->SetColumnWidth(col, wxLIST_AUTOSIZE );
 
-               col++;
+               
              }
                
          }
@@ -466,11 +479,25 @@ namespace creaImageIO
                            
                                for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
                                {
-                               std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
-                               if (val.size()==0) val = "?";
-                               item.SetText( crea::std2wx(val));
-                               item.SetColumn(k);
-                               GetCtrl(l)->SetItem(item);
+                                       std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
+                                       if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry())
+                                       {
+                                               boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
+                                               val = to_iso_extended_string(d1);
+                                       }
+                                       else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry())
+                                       {
+                                               if (val != "" || val != " ")
+                                                       val = val.substr(0,2) + " : " + val.substr(2,2) + " : " + val.substr(4,2);
+                                       }
+                                       else
+                                       {
+
+                                       }
+                                       if (val.size()==0) val = "?";
+                                       item.SetText( crea::std2wx(val));
+                                       item.SetColumn(k);
+                                       GetCtrl(l)->SetItem(item);
                                }       
                            
                        }
@@ -861,6 +888,17 @@ namespace creaImageIO
                }
     }
 
+  }
+  //================================================================
+   //=================================================
+  void WxTreeView::OnKeyDown(wxListEvent &event)
+  {
+         if(event.GetKeyCode() == WXK_DELETE)
+         {
+                   RemoveSelected();
+               //      ClearSelection();
+         }
+                 
   }
   //================================================================
 
@@ -1041,6 +1079,7 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
     EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
 #endif
   */
+    EVT_LIST_KEY_DOWN(-1, WxTreeView::OnKeyDown)
     EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnItemSelected)
   
     EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnItemDeSelected)
index fff55314492581c7a04567fc54c210f7c69f0e0d..4b97590f6cf33284eb6e17fb6a94f0b900defaec 100644 (file)
@@ -112,6 +112,7 @@ namespace creaImageIO
       ///UnSelects all the elements of a level 
       void UnSelectAll(int level);
 
+         void OnKeyDown(wxListEvent &event);
       /// Sorts the level
       void SortLevel(int level);