]> Creatis software - creaImageIO.git/commitdiff
Clean-Up with Juan Sebastien
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Thu, 25 Jun 2009 15:20:52 +0000 (15:20 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Thu, 25 Jun 2009 15:20:52 +0000 (15:20 +0000)
22 files changed:
src2/CMakeLists.txt
src2/creaImageIOAbstractImageReader.h
src2/creaImageIODicomImageReader.cpp
src2/creaImageIODicomImageReader.h
src2/creaImageIOGimmick.h
src2/creaImageIOGimmickView.h
src2/creaImageIOImageReader.cpp
src2/creaImageIOImageReader.h
src2/creaImageIOListener.h
src2/creaImageIOMultiThreadImageReader.cpp
src2/creaImageIOSQLiteTreeHandler.cpp
src2/creaImageIOSQLiteTreeHandler.h
src2/creaImageIOTreeAttributeDescriptor.cpp
src2/creaImageIOTreeAttributeDescriptor.h
src2/creaImageIOTreeDescriptor.cpp
src2/creaImageIOTreeHandlerImageAdder.cpp
src2/creaImageIOTreeNode.h
src2/creaImageIOUltrasonixImageReader.cpp
src2/creaImageIOUltrasonixImageReader.h
src2/creaImageIOVtkImageReader.cpp
src2/creaImageIOVtkImageReader.h
src2/creaImageIOWxViewer.cpp

index 6f3924e75c50c9fa0e48b90fa84aa92611e9d419..9aded620bca6570f3ffc86e377dc9091132da3cc 100644 (file)
@@ -14,7 +14,7 @@ SET( SRCS
   creaImageIOTreeDescriptor
   creaImageIOTreeLevelDescriptor
   creaImageIOTreeAttributeDescriptor
-  creaImageIOTreeComparators
+
 
   # Image readers
   creaImageIOAbstractImageReader
index c1c15ef948b8a418e5218fd129fd083f92b85878..e7326204bf906adc293ba216e980b3c6a960483b 100644 (file)
@@ -24,14 +24,25 @@ namespace creaImageIO
     AbstractImageReader() {}
     virtual ~AbstractImageReader() {}
 
+       /// Get the reader's name
     const std::string& GetName() const { return mName; }
+
+       /// Add file extensions read by the reader
     virtual void PushBackExtensions(std::vector<std::string>&) {}
+
+       /// Test if file is read by this reader
     virtual bool CanRead(const std::string& filename) { return false; }
+
+       /// return for a file a 2D VTkImage
     virtual vtkImageData* ReadImage(const std::string& filename) { return 0; } 
+
+       /// Read the attributes for a file
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr) {}
 
   protected:
+
+    /// Set the reader's name
     void SetName(const std::string& s) { mName = s; }
   private:
     std::string mName;
index b51bff21b46f555ce69512d72dee795158d9d9db..35075fb475510623e856e2c4e351dff8a3dd960d 100644 (file)
@@ -28,16 +28,6 @@ namespace creaImageIO
   //=====================================================================  
   bool DicomImageReader::CanRead(const std::string& filename)
   { 
-    //      std::cout << "## Reader "<<GetName()
-    //<<" ::CanRead("<<filename<<")"
-    //         <<std::endl;
-    //      return true;
-    
-    
-    //      GDCM_NAME_SPACE
-    //  std::cout << "GDCM_NAME_SPACE = '" << STRINGIFY_SYMBOL(GDCM_NAME_SPACE)
-    // << "'" 
-    // <<std::endl;
     
        GDCM_NAME_SPACE::Document*doc;
     GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
@@ -58,9 +48,6 @@ namespace creaImageIO
   //=====================================================================
   vtkImageData* DicomImageReader::ReadImage(const std::string& filename)
   {
-    //      std::cout << "## Reader "<<GetName()
-    //<<" ::Read("<<filename<<")"
-    //         <<std::endl;
     
     vtkImageData* im = 0;
     try
@@ -110,7 +97,7 @@ namespace creaImageIO
   void DicomImageReader::ReadAttributes(const std::string& filename, 
                      std::map<std::string,std::string>& attr)
   {
-    //    std::cout << "DicomImageReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
     GimmickMessage(2,"Reading attributes from DICOM file '"
                   <<filename<<"'"<<std::endl);
     
@@ -150,14 +137,10 @@ namespace creaImageIO
                uint16_t gr;
                uint16_t el;
                tree::AttributeDescriptor::GetDicomGroupElementFromKey(i->first,gr,el);
-               //                GimmickMessage(2,"Key '"<<i->first<<"' : "<<gr<<"|"<<el
-               //                               <<std::endl);
                if ( ( gr!=0 ) && ( el!=0 ) )
                  {
                    std::string val = file->GetEntryString(gr,el);
                    i->second = irclean(val);
-                   //                GimmickMessage(2,"Key '"<<i->first<<"' : "<<gr<<"|"<<el
-                   //                               <<"="<<i->second<<std::endl);
                  }
              }
          }
index ee10caa3490906c1800db1b1ec0a6c4ce6c53b40..0ff7c66f30dc2b3f93dd6136ce4f4eebef188a1b 100644 (file)
@@ -23,9 +23,13 @@ namespace creaImageIO
     DicomImageReader();
     virtual ~DicomImageReader();
 
+       /// Add file extensions read by the reader
     virtual void PushBackExtensions(std::vector<std::string>&);
+       /// Test if file is read by this reader
     virtual bool CanRead(const std::string& filename);
-    virtual vtkImageData* ReadImage(const std::string& filename);      
+       /// return for a file a 2D VTkImage
+    virtual vtkImageData* ReadImage(const std::string& filename);
+       /// Read the attributes for a file
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
index 458720b39a93633811eb71464f948d4734625a05..4b307eeacc7314ed509d1c15254e65b6c6c48091 100644 (file)
@@ -116,7 +116,7 @@ namespace creaImageIO
                                const std::string &i_locDesc, 
                                const std::string &i_locDB);
 
-       // add an existent DB 
+       /// add an existent DB 
        void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
 
     /// Returns the TreeHandler with a given name
index 3287c4d3209e3fd676e9ba9b1c68164314fa9402..9230ba38f10fece6a08cb9b70207fc00c46ce5bd 100644 (file)
@@ -203,149 +203,7 @@ namespace creaImageIO
     //=====================================================================
   
 
-  /*
-
-
-
-
-
-
-
-
-       //====================================================================
-       // General
-       //====================================================================
-
-    /// Returns the size of the current selection
-    virtual int GetSelectionSize() { return 0; } 
-    /// Returns true if there is a valid selection
-    virtual bool IsSelectionValid(){ return false; }
-    /// Returns the vector of full filenames of selected images
-    virtual void GetSelectedFiles(std::vector<std::string>&){ return; }
-    /// Returns the vector of images corresponding to selection
-    virtual void GetSelectedImages(std::vector<vtkImageData*>&){ return; }
-    /// Returns the vector of DicomNode corresponding to selection
-    virtual void GetSelectedDicomNodes(std::vector<DicomNode*>&){ return; }
-   /// Returns the DicomNode corresponding to the tree item
-    virtual DicomNode* GetDicomNodeOfItem(const TreeItemId& i);
-
-       
-       /// Type of list of DicomDatabase
-    typedef std::vector<DicomDatabase*> DicomDatabaseListType;
-    /// Returns the list of DicomDatabase open
-    virtual DicomDatabaseListType& GetDicomDatabaseList() 
-    { return null; }
-    /// Returns the list of DicomDatabase open (const)
-    virtual const DicomDatabaseListType& GetDicomDatabaseList() const 
-    { return null; }
-
-       protected:
-       ///Opens an existing database, or else, creates a local database.
-    virtual void OpenOrNewDatabase(bool open){ return; }
-       ///Shows the help
-       virtual void ShowHelp();
-
-       private:
-       ///Gets the extension of the database
-       const std::string& GetDatabaseExtension() { return null; }
-       ///Sets the extension of the database
-    virtual void SetDatabaseExtension(const std::string& ext){ return; }
-
-
-       //====================================================================
-    // Preview Display Related
-       //====================================================================
-
-
-    ///Shows the image sent as a parameter
-       private:
-        virtual void ShowImage(vtkImageData* image){ return; }
-
-       //====================================================================
-    // Favorites Related
-       //====================================================================
-
-
-       public:
-       ///Loads or creates a favorites database
-    virtual void LoadOrCreateFavoritesDatabase(){ return; }
-       private:
-       ///Creates the user settings directory
-    void CreateUserSettingsDirectory(){ return; }
-       ///Obtains the user settings directory
-       const std::string& GetUserSettingsDirectory(){ return null; }
-
-       //====================================================================  
-       // Attribute Display Related
-       //====================================================================
-
-
-       ///Shows the Information regarding the node sent as a parameter
-       private:
-     virtual void ShowInformation(DicomNode*){ return; }
-   
-       //====================================================================
-    // Tree Display Related
-    //====================================================================
-
-       protected:
-    /// Completely rebuilds the view with 
-    /// current DicomDatabaseList
-    virtual void RebuildView(){ return; }
-       /// Recursively updates the part of the view corresponding 
-    /// to the DicomDatabase passed
-    /// i.e. creates items for the DicomNode which do not have
-    ///      deletes obsolete items (whose DicomNode has been deleted)
-    virtual void UpdateDicomDatabaseView(DicomDatabase*){ return; }
-    /// Recursively updates the part of the view corresponding 
-    /// to the DicomNode provided.
-    /// parent is its parent in the tree (where to insert / remove it)
-       virtual void UpdateDicomNodeView(DicomNode* n, const TreeItemId& parent){ return; }
-    
-       private:
-       ///Type definition of the data regarding the tree
-    typedef WxGimmickTreeItemData TreeItemData;
-       ///Gets the item data of the tree item passed as a parameter
-    TreeItemData* GetItemData(const TreeItemId& id){ return null; }
-    ///Type definition of the data insid a node of the tree
-    typedef WxGimmickDicomNodeData NodeData;
-
-
-       //====================================================================
-    // Class Attributes
-    //====================================================================
-
-       
-       int mSelectionType;
-    int mSelectionMaxImageDimension;
-    int mCurrentSelectionImageSize[4];
-
-       ///Existent Database List
-    DicomDatabaseListType mDicomDatabaseList;
-       ///Favorites database
-    DicomDatabase* mFavoriteDatabase;
-
-       ///Path to the database list file
-    std::string mDatabaseListFile;
-       ///Extension of the database
-    std::string mDatabaseExtension;
-
-    bool mJustStarted;
-
-    int  mFirstDicomDatabaseIconIndex;
-
-   // Previewer
-    vtkImageViewer2* mViewer;
-    
-    int mx1,mx2,my1,my2,mz1,mz2;
-    double mspx,mspy,mspz;
-  
-    // Image preview :
-    // Multi-thread image reader
-    MultiThreadImageReader mReader;
-    // map of images name to node
-    std::map<std::string,DicomNode*> mImageFileNameToNode;
-  */
  
 } // EO namespace creaImageIO
 
index 3e02d4005fb8ec8f2ae4e647aed556ff775af81c..b1f9279e47a7412c525c21ba847a8abc6698ba3e 100644 (file)
@@ -46,17 +46,7 @@ namespace creaImageIO
     Register(new DicomImageReader);
     Register(new UltrasonixImageReader);
 
-    /*
-    std::cout << "## Registered file extensions : "<<std::endl;
-    std::vector<std::string>::const_iterator i;
-    for (i=GetKnownExtensions().begin();
-        i!=GetKnownExtensions().end();
-        i++)
-      {
-       std::cout << "'"<<(*i)<<"'"<<std::endl;
-      }
-    */
-    // 
     mUnreadableImage = vtkImageData::New();
     int dim[3];
     dim[0] = dim[1] = 128; 
@@ -81,12 +71,9 @@ namespace creaImageIO
   //=====================================================================
   ImageReader::~ImageReader()
   {
-    //    std::cout << "#### ImageReader::~ImageReader()"<<std::endl;
-    std::vector<AbstractImageReader*>::iterator i;
+      std::vector<AbstractImageReader*>::iterator i;
     for (i=mReader.begin(); i!=mReader.end(); i++)
       {
-       //      std::cout << "#### ImageReader::UnRegister("
-       //                << (*i)->GetName()<<")"<<std::endl;
        delete (*i);
       }
     mReader.clear();
@@ -101,23 +88,19 @@ namespace creaImageIO
   //=====================================================================
   void ImageReader::Register(AbstractImageReader* r)
   {
-    //    std::cout << "#### ImageReader::Register("<<r->GetName()<<")"<<std::endl;
     mReader.push_back(r);
-    //    r->PushBackExtensions(mKnownExtensions);
+
   }
   //=====================================================================
 
   //=====================================================================
   // Returns true iff the file is readable
   bool ImageReader::CanRead( const std::string& filename ) 
-  //                        const std::string& exclude )
   {
-    //    std::cout << "## ImageReader::CanRead("<<filename<<")"<<std::endl;
     bool ok = false;
     std::vector<AbstractImageReader*>::iterator i;
     for (i=mReader.begin(); i!=mReader.end(); i++)
       {
-       //      if ((*i)->GetName()==exclude) continue;
        ok = (*i)->CanRead(filename);
        if (ok) 
          {
@@ -133,29 +116,22 @@ namespace creaImageIO
   //=====================================================================
   // Reads the file (CanRead must be called before : no test here)
   vtkImageData*  ImageReader::ReadImage( const std::string& filename)
-  //                                    const std::string& exclude )
   {
-    //    std::cout << "## ImageReader::Read("<<filename<<")"<<std::endl;
     if (mLastFilename!=filename)
       {
-       if (!CanRead(filename)) //,exclude)) 
+       if (!CanRead(filename))  
          { 
-           //      std::cout << "  -- Cannot read image "<<std::endl;
            vtkImageData* im = vtkImageData::New();
            im->ShallowCopy(mUnreadableImage);
            return im;
          }
       }
     vtkImageData* i = mLastReader->ReadImage(mLastFilename);
-    //    std::cout << "i="<<i<<std::endl;
     if (i==0) 
       {
-       //      std::cout << "i=UNREAD"<<i<<std::endl;
        i = vtkImageData::New();
        i->ShallowCopy(mUnreadableImage);
       }
-    //    std::cout << "i="<<i<<std::endl;
-    //std::cout<<"return: "<<i->GetScalarTypeAsString()<<", pointer="<<i<<std::endl;
     return i;
   }
   //=====================================================================
@@ -165,8 +141,6 @@ namespace creaImageIO
    void ImageReader::ReadAttributes(const std::string& filename, 
                                    std::map<std::string,std::string>& attr)
    {
-     // std::cout << "ImageReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
-    //    std::cout << "## ImageReader::Read("<<filename<<")"<<std::endl;
     if (mLastFilename!=filename)
       {
        if (!CanRead(filename)) 
index d80da229d10a142b1d7156940cd054417264cd4e..f0823f47f6f8d37bd122191b1a4e2cab066f622a 100644 (file)
@@ -41,6 +41,7 @@ namespace creaImageIO
 
   protected:
     
+    /// Register a reader
     void Register(AbstractImageReader*);
 
     std::vector<AbstractImageReader*> mReader;
index 0405351b85f40eb512dee64e2ec19abd7cef32f3..fe65ed80075ae65797548e158390c959a16f366c 100644 (file)
@@ -4,7 +4,7 @@
 #include <creaImageIOSystem.h>
 #include <stdio.h>
 #include <time.h>
-
+#include <wx/thread.h>
 // Signal/slot mechanism
 #include <boost/signal.hpp>
 #include <boost/bind.hpp>
index 9e4db3ced7ebd1bce3a3c987630dca2ae13adfa9..3f4ba3ab6413f38c722ab51e41fe848cad3141e3 100644 (file)
@@ -13,6 +13,7 @@ namespace creaImageIO
     vtkImageData* image)
   {
     wxMutexLocker lock(mMultiThreadImageReaderUserMutex);
+
     this->OnMultiThreadImageReaderEvent(filename,type,image);
   }
   //=====================================================================
@@ -54,6 +55,8 @@ namespace creaImageIO
       {
        ThreadedImageReader* t = new ThreadedImageReader(this);
        mThreadedImageReaderList.push_back(t);
+        std::cout << "  ===> Thread "<<i
+                             <<" successfully added"<< std::endl;
       }
     mNumberOfThreadedReadersRunning = 0;
     // Init the queue
@@ -90,8 +93,8 @@ namespace creaImageIO
          }
        else 
          {
-           //      std::cout << "  ===> Thread "<<(*i)->GetCurrentId()
-           //                <<" successfully created"<< std::endl;
+                   std::cout << "  ===> Thread "<<(*i)->GetCurrentId()
+                             <<" successfully created"<< std::endl;
            
          }
       }
@@ -114,7 +117,8 @@ namespace creaImageIO
     for (i =mThreadedImageReaderList.begin();
         i!=mThreadedImageReaderList.end();
         i++)
-      {
+      { std::cout << "  ===> Thread "<<(*i)->GetCurrentId()
+                             <<" successfully stopped"<< std::endl;
                  if((*i)->IsAlive())
                  {
                        (*i)->Delete();
@@ -130,7 +134,7 @@ namespace creaImageIO
     do 
       {
        // Sleep a little
-       wxMilliSleep(10);
+               wxMilliSleep(10);
        // Lock
        {
          wxMutexLocker locker(GetMultiThreadImageReaderUserMutex());
@@ -279,7 +283,8 @@ namespace creaImageIO
       }
     else if (e==MultiThreadImageReaderUser::ThreadedReaderStopped)
       {
-       mNumberOfThreadedReadersRunning--;
+       
+                mNumberOfThreadedReadersRunning--;
        //      std::cout << "#TR=" << mNumberOfThreadedReadersRunning << std::endl;
       }
   }
@@ -545,8 +550,7 @@ namespace creaImageIO
     // While was not deleted 
     while (!TestDestroy())
       {
-       //      std::cout << "### Thread "<<GetCurrentId()<<" waiting for image"
-       //        << std::endl;
+               //std::cout << "### Thread "<<GetCurrentId()<<" still alive"  << std::endl;
          
        // Lock the mutex
        mMultiThreadImageReader->MultiThreadImageReaderEventLock();
index 3d3fe70c1639ad2357a75f628ff63462020a2e9f..f29a8ce7ef4b7ced02410167684d1b1405cfef16 100644 (file)
@@ -45,29 +45,6 @@ namespace creaImageIO
   //=============================================================
   
 
-  //=============================================================
-  //  void SQLiteTreeHandler::Print() const 
-  //  {
-    /*
-    std::cout << "-> '"<<GetName()<< "' - '"
-             << GetFileName()<<"'"<<std::endl;
-    ChildrenListType::const_iterator i;
-    for (i=GetChildrenList().begin(); i!=GetChildrenList().end(); i++)
-      {
-       (*i)->Print();
-      }
-    */
-  //  }
-  //=============================================================
-  
-  //=====================================================================
-  /*
-  bool SQLiteTreeHandler::LocationIsValid()
-  {
-    // TO DO 
-    return true;
-  }
-  */
   //=====================================================================
 
 
@@ -222,11 +199,7 @@ namespace creaImageIO
   }
   //=====================================================================
 
-  //  sqlite3_exec(db, zSQL, 0, 0, 0);
-  //  sqlite3_free(zSQL);
-  //   char* CHAIN = format_sql(QUER);         \
-//  sqlite3_free(CHAIN);                               \
-
+  
   //=====================================================================
 #define QUERYDB(QUER,RES)                                              \
     try                                                                        \
@@ -447,7 +420,7 @@ namespace creaImageIO
   //=====================================================================
   bool SQLiteTreeHandler::DBImportTreeDescription()
   {
-    GimmickMessage(1,"Importing tree description from database ..."
+    GimmickMessage(1,"Importing tree description for database ..."
                   <<std::endl);
 
     // Test table 'LEVELS' existence
@@ -544,14 +517,7 @@ namespace creaImageIO
         a!= GetTree().GetAttributeDescriptorList(0).end();
         ++a)
       {
-       /*
-       std::string v;
-       AttributeMapType::const_iterator i = attr.find(a->GetKey());
-       if ( i != attr.end() )  
-         {
-           v = i->second;
-         }
-       */
+
        GetTree().UnsafeSetAttribute( a->GetKey(), "" );
       }
 
@@ -573,22 +539,6 @@ namespace creaImageIO
   }
   //=====================================================================
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
   //========================================================================
   /// 
   std::string& SQLformat(std::string& str)
@@ -626,7 +576,7 @@ namespace creaImageIO
          {
            continue;
          }
-       //      std::cout << "("<<i->first<<","<<i->second<<")"<<std::endl;
+
        atts += "'" + i->first + "'";
        values += "'" + SQLformat(i->second) + "'"; 
        atts += ",";
@@ -670,7 +620,6 @@ namespace creaImageIO
   }
   //=====================================================================
 
-
   //=====================================================================
   int SQLiteTreeHandler::DBLoadChildren(tree::Node* node, 
                                        int numberoflevels)
@@ -710,7 +659,7 @@ namespace creaImageIO
     query += GetTree().GetLevelDescriptor(level+1).GetName();
     if (level>0)
       {
-       query += " WHERE PARENT_ID='" + node->UnsafeGetAttribute("ID") 
+       query += " WHERE PARENT_ID='" + node->GetAttribute("ID") 
          + "'";
       }
     CppSQLite3Query q;
@@ -728,13 +677,7 @@ namespace creaImageIO
          {
            n->UnsafeSetAttribute(q.fieldName(fld),q.getStringField(fld));          
          }
-       /*
-       // Index 
-       TypeId ti;
-       ti.type = type;
-       ti.id = n->GetFieldValue("ID");    
-       mTypeIdToNodeMap[ti] = n;
-       */
+
        // recurse 
        if ( numberoflevels != 1 ) 
          {
@@ -807,39 +750,10 @@ namespace creaImageIO
        
        // Insert in DB
        DBInsert(child);
-       /*
-       std::string val;
-       SQLAppendAttributesValues(child,val);
-       std::string insert("INSERT INTO ");
-       insert += GetTree().GetLevelDescriptor(child->GetLevel()).GetName();
-       insert += " " + val + ";";
-       UPDATEDB(insert);
        
-       // Store DB id of newly created node;
-       long lastrow = mDB->lastRowId();
-       std::stringstream ri;
-       ri << mDB->lastRowId();
-       child->SetAttribute("ID",ri.str());
-       */
        // Down one level
        parent = child;
-       
-       /*
-       // Insert in TypeId map
-       TypeId ti;
-       ti.type = node->GetType();
-       ti.id = node_id;
-       mTypeIdToNodeMap[ti] = node;
-       //    std::cout << "== Insert TypeId ("<<ti.type<<","<<ti.id<<")"<<std::endl; 
-       // 
-       msw[2].Pause();
-       
-       if (node->GetType()==Node::Patient) summary.added_patients++;
-       if (node->GetType()==Node::Study) summary.added_studies++;
-       if (node->GetType()==Node::Series) summary.added_series++;
-       if (node->GetType()==Node::Image) summary.added_images++;
-       */
-      }
+         }
   }
   //======================================================================
 
@@ -1019,7 +933,7 @@ namespace creaImageIO
        query += GetTree().GetLevelDescriptor(level).GetName();
        if (level>0)
          {
-           query += " WHERE ID='" + n->UnsafeGetAttribute("ID") 
+           query += " WHERE ID='" + n->GetAttribute("ID") 
              + "'";
          }
        CppSQLite3Query q;
@@ -1104,363 +1018,4 @@ namespace creaImageIO
         UPDATEDB(out.str());
        }
 
-  /*
-  //=====================================================================
-  bool SQLiteTreeHandler::DBInsert(Node* alien_node,
-                                  UpdateSummary& summary)
-  {
-    //    std::cout << "SQLiteTreeHandler::Insert('"<<alien_node->GetLabel()
-    //       <<"')"<<std::endl;
-    
-    //    if (!ChildrenLoaded()) DBLoadChildren(this,Node::Database);
-    
-    // Find parent
-    Node* parent;
-    std::string parent_id; 
-    parent = DBGetOrCreateParent(alien_node,parent_id,summary);
-    
-    // Insert 
-    DBRecursiveGetOrCreateNode(alien_node,parent,parent_id,summary);
-   return true;
-  }
-  //=====================================================================
-
-
-  //=====================================================================
-  Node* SQLiteTreeHandler::DBGetOrCreateParent(Node* alien_node,
-                                               std::string& parent_id,
-                                               UpdateSummary& summary)
-  {
-    //    std::cout << "DBGetOrCreateParent '" << alien_node->GetLabel()<<"'"
-    //       << std::endl;
-    // Load the patients if not already done
-    DBLoadChildren(this,Node::Patient);
-
-    parent_id = "";
-    Node* parent = this;
-
-    // The chain of ancestors
-    std::deque<Node*> chain;
-    Node* cur = alien_node->GetParent();
-    for (int type=Node::Patient; 
-        type<alien_node->GetType();++type)
-      {
-       chain.push_front(cur);
-       cur = cur->GetParent();
-      }
-
-    // create the nodes if do not exist
-    std::deque<Node*>::iterator i;
-    for (i=chain.begin();i!=chain.end();++i)
-      {
-       //      std::cout << " cur = '"<<(*i)->GetLabel()<<"'"<<std::endl;
-       //      std::string cur_id = DBGetNodeId(*i,parent_id);
-       //      if (cur_id.size()==0)
-       //        {
-       // Node does not exist : create it
-       std::string cur_id;
-       parent = DBGetOrCreateNode(*i, 
-                                       parent,
-                                       parent_id,
-                                       cur_id,
-                                       summary
-                                       );
-       DBLoadChildren(parent,parent->GetType()+1);
-
-       parent_id = cur_id;
-      }
-    return parent;
-  }
-  //=====================================================================
-
-
-
-  //=====================================================================
-  void SQLiteTreeHandler::DBRecursiveGetOrCreateNode(Node* alien_node, 
-                                                     Node* parent, 
-                                                     const std::string& parent_id,
-                                                     UpdateSummary& summary)
-  {
-    //    std::cout << "SQLiteTreeHandler::RecursiveGetOrCreateNode('"
-    //       <<alien_node->GetLabel()
-    //       <<"','"<<parent<<"','"<<parent_id<<"')"<<std::endl;
-    if (parent != 0) 
-      {
-       //      std::cout << " -- Parent = '"<<parent->GetLabel()<<"'"<<std::endl;
-      }   
-    std::string new_id;
-    Node* new_node = DBGetOrCreateNode(alien_node, 
-                                                parent,
-                                                parent_id,
-                                                new_id,
-                                                summary);
-    Node::ChildrenListType::iterator i;
-    for (i  = alien_node->GetChildrenList().begin();
-        i != alien_node->GetChildrenList().end();
-        i++)
-      {
-       DBRecursiveGetOrCreateNode((*i),new_node,new_id,summary);
-      }
-  }
-  //=====================================================================
-
-
-  //=====================================================================
-  Node* SQLiteTreeHandler::DBGetOrCreateNode(Node* alien_node, 
-                                                  Node* internal_parent,
-                                                  std::string parent_id,
-                                                  std::string& node_id,
-                                                  UpdateSummary& summary)
-  {
-    //   std::cout << "DBGetOrCreateNode('"<<alien_node->GetLabel()<<"','"
-    //       << internal_parent << "','"<< parent_id<<"')"<<std::endl;
-    if (internal_parent != 0) 
-      {
-       //      std::cout << " -- Parent = '"<<internal_parent->GetLabel()<<"'"<<std::endl;
-      }
-    // Node Exists ? return it 
-    // First try among children of internal parent 
-    Node* node = GetChildrenLike(internal_parent,alien_node);
-    if (node>0)
-      {
-       node_id = node->UnsafeGetFieldValue("ID");
-       return node;
-      }
-    // Second : try in DB 
-   
-    // Does not exist : Create new one
-    node = new Node(alien_node->GetType(),this,internal_parent);
-    node->SetChildrenLoaded(true);
-    // Copy fields values from alien
-    Node::FieldValueMapType::iterator i,j;
-    for (i =  node->GetFieldValueMap().begin();
-        i != node->GetFieldValueMap().end();
-        i++)
-      {
-       j = alien_node->GetFieldValueMap().find(i->first);
-       if (j != alien_node->GetFieldValueMap().end() )
-         {
-           i->second = j->second;
-         }
-      }
-
-    msw[2].Resume();
-    if (node->GetType()!=Node::Patient) 
-      node->SetFieldValue("PARENT_ID",parent_id);
-
-    // Insert in DB
-    std::string val;
-    BuildSQLFieldsValues(node,val);
-    std::string insert("INSERT INTO ");
-    insert += std::string(SQLiteTreeHandlerStructure::Table(node->GetType())) 
-      + " " + val + ";";
-    //    std::cout << "** SQL = '"<<insert<<"'"<<std::endl;
-    UPDATEDB(insert);
-    //    std::cout << "** SQL OK"<<std::endl;
-
-    // Store DB id of newly created node;
-    long lastrow = mDB->lastRowId();
-    std::stringstream ri;
-    ri << mDB->lastRowId();
-    node_id = ri.str();
-    //    std::cout << "LastRowId='"<<mDB->lastRowId()<<"' vs '"<<created_id<<"'"<<std::endl;
-
-    node->SetFieldValue("ID",node_id);
-    // Insert in TypeId map
-    TypeId ti;
-    ti.type = node->GetType();
-    ti.id = node_id;
-    mTypeIdToNodeMap[ti] = node;
-    //    std::cout << "== Insert TypeId ("<<ti.type<<","<<ti.id<<")"<<std::endl; 
-    // 
-    msw[2].Pause();
-
-    if (node->GetType()==Node::Patient) summary.added_patients++;
-    if (node->GetType()==Node::Study) summary.added_studies++;
-    if (node->GetType()==Node::Series) summary.added_series++;
-    if (node->GetType()==Node::Image) summary.added_images++;
-
-    return node;
-  }
-  //=====================================================================
-
-  //=====================================================================
-  Node* SQLiteTreeHandler::GetChildrenLike(Node* parent,
-                                           Node* alien_node)
-  {
-    Node::ChildrenListType::iterator i;
-    for (i  = parent->GetChildrenList().begin();
-        i != parent->GetChildrenList().end();
-        i++)
-      {
-       Node::Type type = alien_node->GetType();
-       bool ok = true;
-       for (int j=0;
-            j<SQLiteTreeHandlerStructure::NbQueryFields(type);
-            j++) 
-         {
-           if ( 
-               alien_node->GetFieldValue(SQLiteTreeHandlerStructure::
-                                   QueryField(type,j).key )   !=
-               (*i)->GetFieldValue(SQLiteTreeHandlerStructure::
-                                   QueryField(type,j).key ) )
-             {
-               ok = false;
-               break;
-             }
-         }
-       if (ok) 
-         {
-           return (*i);
-         }
-      }
-    return 0;    
-  }
-  //=====================================================================
-
-  //=====================================================================
-  std::string SQLiteTreeHandler::DBGetNodeId(Node* node, 
-                                             const std::string& parent_id)
-  {
-    //    std::cout << "SQLiteTreeHandler::DBGetNodeId('"<<node->GetLabel()
-    //       <<"','"<<parent_id<<"')"
-    //       <<std::endl;
-    msw[2].Resume();
-    int type = node->GetType();
-
-    std::string table = SQLiteTreeHandlerStructure::Table(type);
-    std::string where = "WHERE ";
-    
-    if (type!=Node::Patient)
-      {
-       where += "PARENT_ID='" + parent_id 
-         //node->GetFieldValue("PARENT_ID") 
-         + "' AND ";
-      }
-
-    for (int i=0;i<SQLiteTreeHandlerStructure::NbQueryFields(type);i++) 
-      {
-       where += SQLiteTreeHandlerStructure::QueryField(type,i).key + "='"
-         + node->GetFieldValue(SQLiteTreeHandlerStructure::QueryField(type,i).key) + "' ";
-       if (i<SQLiteTreeHandlerStructure::NbQueryFields(type)-1)
-         where += "AND ";
-    }
-
-    std::string query = "SELECT ID FROM " + table + " " + where + ";";                                                   
-    //    std::cout << "** SQL = '"<<query<<"'"<<std::endl;
-    CppSQLite3Query q;
-    QUERYDB(query,q);
-
-    if (!q.eof())
-      {
-       
-       //      std::cout << " - Node exists " << std::endl;
-       std::string id = q.getStringField(0);
-       //      std::cout << " id = '"<<id<<"'"<<std::endl;
-       msw[2].Pause();
-       return id;
-      }
-    msw[2].Pause();
-    return "";
-  }
-  //=====================================================================
-
-
-
-  //=====================================================================
-  Node* SQLiteTreeHandler::GetNodeFromTypeId(Node::Type type,
-                                      const std::string& id)
-  {
-    //    std::cout << "GetNodeFromTypeId("<<type<<","<<id<<")"<<std::endl;
-
-    TypeId ti;
-    ti.type = type;
-    ti.id = id;
-    
-    TypeIdToNodeMapType::iterator i = mTypeIdToNodeMap.find(ti);
-    if (i == mTypeIdToNodeMap.end())
-      {
-
-           std::cout << "Internal error : mTypeIdToNodeMap does not contain key"
-                     << std::endl;
-           creaError("Internal error : mTypeIdToNodeMap does not contain key");
-           // }
-      }
-
-    //    std::cout << " ** Node = "<<i->second<<std::endl;
-    return i->second;
-  }
-  //=====================================================================
-
-  //=====================================================================
-  bool SQLiteTreeHandler::Remove(Node* node)
-  {
-
-    //DBRecursiveRemoveNode(node);
-    //    std::cout << "DELETE"<<std::endl;
-    if (node->GetParent())
-      {
-       node->GetParent()->RemoveChildrenFromList(node);
-      }
-    delete node;
-    //    std::cout << "DELETE OK"<<std::endl;
-    return true;
-  }
-  
-  
-  //========================================================================
-
-  //=====================================================================
-  void SQLiteTreeHandler::DBRecursiveRemoveNode(Node* node)
-  {
-    //    std::cout << "SQLiteTreeHandler::DBRecursiveRemoveNode('"
-    //       <<node->GetLabel()<<"')"<<std::endl;
-
-    std::string query = "DELETE FROM ";
-    query += SQLiteTreeHandlerStructure::Table(node->GetType());
-    query += " WHERE ID='"+ node->GetFieldValue("ID") + "';";
-    UPDATEDB(query);
-
-    Node::ChildrenListType::iterator i;
-    for (i  = node->GetChildrenList().begin();
-        i != node->GetChildrenList().end();
-        i++)
-      {
-       DBRecursiveRemoveNode((*i));
-      }
-  }
-  
-  //=====================================================================
-  
-  //=====================================================================
-  int SQLiteTreeHandler::DBQueryNumberOfChildren(Node* node)
-  {
-    std::string query = "SELECT COUNT (ID) FROM ";
-    query += SQLiteTreeHandlerStructure::Table(node->GetType()+1);
-    if (node->GetType() != Node::Database) 
-      {
-       query += " WHERE PARENT_ID='"+ node->GetFieldValue("ID")+"'";
-      }
-    query  += ";";
-    
-    //   std::cout << "**SQL = "<< query << std::endl;
-    
-    CppSQLite3Query q;
-    QUERYDB(query,q);
-   
-     //    std::cout << "**RES = "<< q.getIntField(0) <<std::endl;
-
-    return q.getIntField(0);
-  }
-  //=====================================================================
-
-*/
-
-
-
 } // namespace creaImageIO
index 0b102b584f4f66a71fc66d93e41375c450dd28ab..1172298500f114096ee6195b71b0687251853084 100644 (file)
@@ -217,47 +217,7 @@ namespace creaImageIO
  
        //======================================================================
 
-    /*
-    /// 
-    int DBQueryNumberOfChildren(tree::Node* n);
-    
-    // Insertion
-    bool DBInsert(tree::Node* alien_node) ; //, UpdateSummary& summary);
-    
-    //
-    std::string DBGetNodeId(tree::Node* node, const std::string& parent_id);
-
-    tree::Node* GetNodeFromTypeId(int level, 
-                                 const std::string& id);
-
-    // 
-    tree::Node* DBGetOrCreateNode(tree::Node* alien_node, 
-                                     tree::Node* internal_parent,
-                                     std::string parentid,
-                                 std::string& created_id);
-    //                               UpdateSummary& summary);
-    
-    tree::Node* DBGetOrCreateParent(tree::Node* alien_node,
-                                   std::string& parent_id);
-                                   //                             UpdateSummary& summary);
-    
-    void DBRecursiveGetOrCreateNode(tree::Node* alien_node, 
-                                        tree::Node* parent, 
-                                   const std::string& parent_id);
-    //                                  UpdateSummary& summary);
-    
-
-       */
-
-       /*
-
-    void BuildSQLFieldsValues(tree::Node* n,
-                             std::string& str);
-
-
-    tree::Node* GetChildrenLike(tree::Node* internal_parent,
-                              tree::Node* alien_node);
-    */
+  
   private:
     /// The DB
     CppSQLite3DB* mDB;
@@ -269,21 +229,7 @@ namespace creaImageIO
     bool GetWritable() const { return mWritable; }
        bool mIsAdding;
 
-    /*
-    struct TypeId
-    {
-      int type;
-      std::string id;
-      bool operator< (const TypeId& o) const 
-      {
-       return ((type<o.type) ||
-               ((type==o.type)&&id<o.id));
-      }
-    };
-    
-    typedef std::map<TypeId,tree::Node*> TypeIdToNodeMapType;
-    TypeIdToNodeMapType mTypeIdToNodeMap;
-    */
+   
   };
   // EO class SQLiteTreeHandler
   //=======================================================================
index 08fd784d9e26960199d35fc69585051121022305..c6a694f8cff678e267d621f9da6a8d7585e4c902 100644 (file)
@@ -183,15 +183,11 @@ namespace creaImageIO
                {
                        // Numerical 
                        typ = 1;
-//                     type="1";
-//                      sscanf(type.c_str(),"%u",&typ);
                }
                else
                {
                        // String
                        typ = 2;
-                       //                      type="2";
-//                      sscanf(type.c_str(),"%u",&typ);
                }
                
          }
index 68f0da965af186c68791c86404a7b812ae6fcf65..1ae86ddeb89c94381cc240dbf589a31c6d33abf6 100644 (file)
@@ -83,7 +83,10 @@ namespace creaImageIO
          ///Decodes the type of attribute into the existing ones
          void DecodeType(unsigned int& type) const;
 
+         /// Determines if Attribute is a date
          bool isDateEntry() const;
+
+         /// Determines if Attribute is a time
          bool isTimeEntry() const;
 
     private:
index c1dca8e78b1d5ee575aee2bc12d6d00614a9d866..80244d0f41c9616a49bf880f9094c34f8d3408cc 100644 (file)
@@ -21,6 +21,7 @@ namespace creaImageIO
     const unsigned int AttributeDescriptor::IDENTIFIER = 2;
        /// The attribute can be edited
        const unsigned int AttributeDescriptor::EDITABLE = 3;
+       /// the attribute describes the node
     const unsigned int AttributeDescriptor::LABEL = 4;
     //==================================================================
 
index f0f5bf39dbda6e8c3a3fa79645057df8fefe01bd..ad88ef77abb5d800743a1a64097ac54126cd0a10 100644 (file)
@@ -412,7 +412,7 @@ namespace creaImageIO
           std::string databaseVal;
           mTreeHandler->GetAttribute("Image","FullFileName",file,a->GetKey(),databaseVal);
           std::string fileVal=attr.find(a->GetKey())->second;
-          if ( a->GetFlags()==0 && databaseVal.compare(fileVal)!=0 
+          if ( a->GetFlags()==0 && databaseVal == fileVal
            {
                        if(repair)
                        {
index fca904ca53a216609933bf7459d121fed0cce84a..55d6ab570b36a46c7adad26c00419fb0e5ccf284 100644 (file)
@@ -83,22 +83,31 @@ namespace creaImageIO
       /// Remove the given children from the children list
       int RemoveChildrenFromList(Node*);
 
-
+       
+         /// Get the Attributes Map
       AttributeMapType& GetAttributeMap() { return mAttributeMap; }
+
+         /// Get the Attributes Map
       const AttributeMapType& GetAttributeMap() const { return mAttributeMap; }
+
+         /// Get the Attribute for a specific key
       const std::string& GetAttribute(const std::string& k) const;
-      const std::string& GetCleanAttribute(const std::string& k) const;
-      const std::string& UnsafeGetAttribute(const std::string& k) const
-      { return mAttributeMap.find(k)->second; }
+      
+         /// Get the Attribute for a specific key without OS dependance (not implemented)
+         // TODO : backslash OS uniformity
+         const std::string& GetCleanAttribute(const std::string& k) const;
+
+         /// Set an Attribute for a specific key
       void SetAttribute(const std::string& k, const std::string& v);
+
+         /// Set an Attribute for a specific key(unsafe mode)
       void UnsafeSetAttribute(const std::string& k, const std::string& v)
       { mAttributeMap[k] = v; }
     
+         /// Get Descriptor for an Attribute
       const AttributeDescriptor& GetAttributeDescriptor(const std::string& k)const;
-      //      { return GetTypeDescription().GetFieldDescription(k); }
-
-
-      /// Returns true iff the KEY attributes of the node match those of the map provided
+      
+      /// Returns true if the KEY attributes of the node match those of the map provided
       bool Matches( const AttributeMapType& ) const;
 
       /// Returns the node data casted into the type T
@@ -111,14 +120,12 @@ namespace creaImageIO
       /// Sorts the children of the node 
       void SortChildren(const LexicographicalComparator&);
 
+         /// Print the node
       virtual void Print() const;
+
+         /// Get the Label of the node
       std::string GetLabel() const;
-      /*
-       int ImageGetRows() const;
-       int ImageGetColumns() const;
-       int ImageGetFrames() const;
-       const std::string& ImageGetFullFileName() const { return UnsafeGetAttribute("FullFileName"); }
-      */
 
     private:
       /// The parent of the node
index 8b07ad1319a1cad85e895880014016c57d036f9a..014e0953c7a6be97215f1ff10844922d61fd61d4 100644 (file)
@@ -172,9 +172,7 @@ namespace creaImageIO
   void UltrasonixImageReader::ReadAttributes(const std::string& filename, 
                                      std::map<std::string,std::string>& attr)
   {
-    //      std::cout << "UltrasonixImageReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
     GimmickMessage(2,"Reading attributes from '"<<filename<<std::endl);
 
     FILE *Ultrasonix_file=fopen(filename.c_str(),"rb");
     if (!Ultrasonix_file) return;
@@ -207,8 +205,6 @@ namespace creaImageIO
     std::map<std::string,std::string>::iterator i;
     if ( (i = attr.find("FullFileName")) != attr.end())
     {
-       //      boost::filesystem::path full_path(filename);
-       // std::string f = full_path.leaf();
                i->second = filename;
     }
     if ( (i = attr.find("D0004_1500")) != attr.end())
index 29a58a2f74852c9c66a6bfc09f86daa167976624..6ba7b42d3dc92b3b2de3b52aa676f07b351be57b 100644 (file)
@@ -21,13 +21,17 @@ namespace creaImageIO
     UltrasonixImageReader();
 
     virtual ~UltrasonixImageReader();
-
+       /// Add file extensions read by the reader
     virtual void PushBackExtensions(std::vector<std::string>&);
+       /// Test if file is read by this reader
     virtual bool CanRead(const std::string& filename);
+       /// return for a file a 2D VTkImage
     virtual vtkImageData* ReadImage(const std::string& filename);
+       /// Read the attributes for a file
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
+
   };
   //=====================================================================
 
index 69dd65f03a8b8be541a48a811f51714529d9052c..cd93e86f9a7c6ffa68042bb35d1f698d9c7b6ad0 100644 (file)
@@ -38,9 +38,6 @@ namespace creaImageIO
   //=====================================================================
   bool VtkImageReader::CanRead(const std::string& filename)
   { 
-    //      std::cout << "## Reader "<<GetName()
-    //<<" ::CanRead("<<filename<<")"
-    //         <<std::endl;
     return (mReader->CanReadFile(filename.c_str())!=0);
   }
   //=====================================================================
@@ -48,9 +45,6 @@ namespace creaImageIO
   //=====================================================================
   vtkImageData* VtkImageReader::ReadImage(const std::string& filename)
   {
-    //      std::cout << "## Reader "<<GetName()
-    //<<" ::Read("<<filename<<")"
-    //         <<std::endl;
     vtkImageData* im = 0;
     try
       {
@@ -108,7 +102,6 @@ namespace creaImageIO
   void VtkImageReader::ReadAttributes(const std::string& filename, 
                                      std::map<std::string,std::string>& attr)
   {
-    //      std::cout << "VtkImageReader::ReadDicomInfo '"<<filename<<"'"<<std::endl;
     GimmickMessage(2,"Reading attributes from '"<<filename<<std::endl);
     // Get image dimensions
     // How to get the image info without loading it in vtk ?
@@ -125,14 +118,10 @@ namespace creaImageIO
     // Planes 
     char planes[128];
     sprintf(planes,"%i",ext[5]-ext[4]);
-    
-    
-    // 
-    std::map<std::string,std::string>::iterator i;
+   
+       std::map<std::string,std::string>::iterator i;
     if ( (i = attr.find("FullFileName")) != attr.end())
       {
-       //        boost::filesystem::path full_path(filename);
-       // std::string f = full_path.leaf();
        i->second = filename;
       }
     if ( (i = attr.find("D0004_1500")) != attr.end())
@@ -152,7 +141,7 @@ namespace creaImageIO
     
     if ( (i = attr.find("D0028_0012")) != attr.end())
       {
-       i->second = planes;
+               i->second = planes;
       }
          if ( (i = attr.find("FullFileDirectory")) != attr.end())
       {
index 3ae6a436fc69b38b1c3f4f394de4d10d01e674fb..b9712103ec03fc566aa691dc5d66a16f31c2def1 100644 (file)
@@ -26,9 +26,13 @@ namespace creaImageIO
 
     virtual ~VtkImageReader();
 
+       /// Add file extensions read by the reader
     virtual void PushBackExtensions(std::vector<std::string>&);
+       /// Test if file is read by this reader
     virtual bool CanRead(const std::string& filename);
+       /// return for a file a 2D VTkImage
     virtual vtkImageData* ReadImage(const std::string& filename);
+       /// Read the attributes for a file
     virtual void ReadAttributes(const std::string& filename, 
                                tree::AttributeMapType& attr);
 
index 420096352729b592f721385bd77f6e69d3d137b5..193fedb7881179c91504be980052c55f178f2e13 100644 (file)
@@ -26,21 +26,11 @@ namespace creaImageIO
     {}
     
     void* Entry();
-    //    void SetImagesToPlay(std::vector<vtkImageData*> im);
-    //    void ShowImage(vtkImageData* v);
-    //   void StartIterator();
     void  OnExit();
        
   private:
-    //std::vector<vtkImageData*> mImagesToPlay;
-    //vtkImageViewer2* mViewer;
-    /// Associated wxvtk interactor
-    //crea::creawxVTKRenderWindowInteractor  *mInteractor;
-    //std::vector<vtkImageData*>::iterator i;
+
     WxViewer* mWxViewer;
-    
-    //    int mx1,mx2,my1,my2,mz1,mz2;
-    //    double mspx,mspy,mspz;
   };
   
   //=====================================================================