]> Creatis software - gdcm.git/blob - src/gdcmSeqEntry.cxx
PLEASE : keep on waiting for the final version !
[gdcm.git] / src / gdcmSeqEntry.cxx
1 // gdcmSeqEntry.cxx
2 //-----------------------------------------------------------------------------
3 //
4 #include "gdcmSeqEntry.h"
5 #include "gdcmSQItem.h"
6 #include "gdcmTS.h"
7 #include "gdcmGlobal.h"
8 #include "gdcmUtil.h"
9
10 #include <iostream>
11 #include <iomanip>
12 //-----------------------------------------------------------------------------
13 // Constructor / Destructor
14 /**
15  * \ingroup gdcmSeqEntry
16  * \brief   Constructor from a given gdcmSeqEntry
17  */
18 gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e) 
19              : gdcmDocEntry(e)
20 {
21    //ListSQItem items est un *champ* de gdcmSeqEntry.
22    
23    delimitor_mode = false;
24    seq_term  = NULL;   
25 }
26
27 /**
28  * \ingroup gdcmSeqEntry
29  * \brief   Canonical destructor.
30  */
31 gdcmSeqEntry::~gdcmSeqEntry() {
32    for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
33    {
34       delete *cc;
35    }
36 }
37
38 //-----------------------------------------------------------------------------
39 // Print
40 /*
41  * \ingroup gdcmSeqEntry
42  * \brief   canonical Printer
43  */
44 void gdcmSeqEntry::Print(std::ostream &os){
45
46    std::ostringstream s;
47    string vr;
48    unsigned short int g, e;
49    long lgth;
50    size_t o;    
51    char greltag[10];  //group element tag
52    char st[20]; 
53
54
55    SetPrintLevel(2);   
56 //   PrintCommonPart(os); // FIXME : why doesn't it work ?
57      
58    // First, Print the Dicom Element itself. 
59    g  = GetGroup();
60    e  = GetElement();   
61    o  = GetOffset();
62    vr = GetVR();
63    sprintf(greltag,"%04x|%04x ",g,e);           
64    s << greltag ;
65    if (GetPrintLevel()>=2) { 
66       s << "lg : ";
67       lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
68       if (lgth == 0xffffffff) {
69          sprintf(st,"x(ffff)");  // I said : "x(ffff)" !
70          s.setf(std::ios::left);
71          s << std::setw(10-strlen(st)) << " ";  
72          s << st << " ";
73          s.setf(std::ios::left);
74          s << std::setw(8) << "-1";      
75       } else {
76          sprintf(st,"x(%x)",lgth);
77          s.setf(std::ios::left);
78          s << std::setw(10-strlen(st)) << " ";  
79          s << st << " ";
80          s.setf(std::ios::left);
81          s << std::setw(8) << lgth; 
82       }
83       s << " Off.: ";
84       sprintf(st,"x(%x)",o); 
85       s << std::setw(10-strlen(st)) << " ";
86       s << st << " ";
87       s << std::setw(8) << o; 
88    }
89
90    s << "[" << vr  << "] ";
91    if (GetPrintLevel()>=1) {      
92       s.setf(std::ios::left);
93       s << std::setw(66-GetName().length()) << " ";
94    }
95     
96    s << "[" << GetName()<< "]";
97
98    s << std::endl;
99    os << s.str();
100
101  
102     // Then, Print each SQ Item   
103      for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
104    {
105       //(*cc)->SetPrintLevel(GetPrintLevel()); aurait-ce un sens ?
106       (*cc)->Print(os);
107    }
108    // at end, print the sequence terminator item, if any
109    /*
110    if (delimitor_mode) {
111       s << "   | " ;   
112       os << s.str();
113       if (seq_term = NULL)
114          seq_term->Print(os);      
115    }        
116   */             
117  }
118
119 //-----------------------------------------------------------------------------
120 // Public
121
122  /// \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.      
123 void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem) {
124    items.push_back(sqItem);
125 }
126 //-----------------------------------------------------------------------------
127 // Protected
128
129 //-----------------------------------------------------------------------------
130 // Private
131
132 // end-user intended : the guy *wants* to create his own SeQuence ?!?
133 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByNumber(guint16 group,
134                                                 guint16 element) {
135 // TODO                           
136    gdcmDocEntry *a;   
137    return a;                              
138 }
139
140 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByName  (std::string Name) {
141 // TODO :                         
142    gdcmDocEntry *a;   
143    return a;
144 }       
145 //-----------------------------------------------------------------------------