]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
FileHelper has CallProgressMethod and others
[gdcm.git] / src / gdcmDicomDir.cxx
index ef45a81e8388d2f040828f95ee971b67f0c6c5fb..a5902b911e288bf7fe00107cedc9ca560fc56645 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:31:23 $
-  Version:   $Revision: 1.175 $
+  Date:      $Date: 2005/11/30 11:41:35 $
+  Version:   $Revision: 1.179 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -118,7 +118,6 @@ namespace gdcm
  * \brief   Constructor : creates an empty DicomDir
  */
 DicomDir::DicomDir()
-         :Document( )
 {
    Initialize();  // sets all private fields to NULL
    ParseDir = false;
@@ -203,13 +202,13 @@ bool DicomDir::DoTheLoadingJob( )
          char buf[2048];
          const char *cwd = getcwd(buf, 2048);
          if( cwd )
-           {
+         {
            SetFileName( buf ); // will be converted into a string
-           }
+         }
          else
-           {
+         {
            gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
-           }
+         }
       }
       NewMeta();
       gdcmDebugMacro( "Parse directory and create the DicomDir : " 
@@ -436,6 +435,33 @@ bool DicomDir::Anonymize()
    return true;
 }
 
+/**
+ * \brief Copies all the attributes from an other DocEntrySet 
+ * @param set entry to copy from
+ * @remarks The contained DocEntries are not copied, only referenced
+ */
+void DicomDir::Copy(DocEntrySet *set)
+{
+   // Remove all previous childs
+   ClearPatient();
+
+   Document::Copy(set);
+
+   DicomDir *dd = dynamic_cast<DicomDir *>(set);
+   if( dd )
+   {
+      if(MetaElems)
+         MetaElems->Unregister();
+      MetaElems = dd->MetaElems;
+      if(MetaElems)
+         MetaElems->Register();
+
+      Patients = dd->Patients;
+      for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient)
+         (*ItPatient)->Register();
+   }
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 /**
@@ -451,12 +477,12 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
    File *f;
 
    DirListType fileList = dirList.GetFilenames();
-
+   unsigned int nbFile = fileList.size();
    for( DirListType::iterator it  = fileList.begin();
                               it != fileList.end();
                               ++it )
    {
-      Progress = (float)(count+1)/(float)fileList.size();
+      Progress = (float)(count+1)/(float)nbFile;
       CallProgressMethod();
       if ( Abort )
       {
@@ -497,32 +523,6 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
    }
 }
 
-/**
- * \brief   CallStartMethod
- */
-void DicomDir::CallStartMethod()
-{
-   Progress = 0.0f;
-   Abort    = false;
-   CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
-}
-
-/**
- * \brief   CallProgressMethod
- */
-void DicomDir::CallProgressMethod()
-{
-   CommandManager::ExecuteCommand(this,CMD_PROGRESS);
-}
-
-/**
- * \brief   CallEndMethod
- */
-void DicomDir::CallEndMethod()
-{
-   Progress = 1.0f;
-   CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
-}
 
 //-----------------------------------------------------------------------------
 // Private
@@ -653,7 +653,7 @@ void DicomDir::CreateDicomDir()
         continue;
       }
       if ( si )
-         si->MoveObject(tmpSI);  // New code : Copies the List
+         si->Copy(tmpSI);
 
       tmpSI=s->GetNextSQItem();
    }
@@ -1003,15 +1003,16 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
  * @param dst destination SQItem
  * @param src source SQItem
  */
-void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
+void DicomDir::MoveSQItem(DocEntrySet *dst, DocEntrySet *src)
 { 
    DocEntry *entry;
-
+// todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
+//        to save time
    entry = src->GetFirstEntry();
    while(entry)
    {
+      dst->AddEntry(entry);  // use it, *before* removing it!
       src->RemoveEntry(entry);
-      dst->AddEntry(entry);
       // we destroyed -> the current iterator is not longer valid
       entry = src->GetFirstEntry();
    }