# gdcmPrinter.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2010 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015 #ifndef GDCMPRINTER_H
    00016 #define GDCMPRINTER_H
    00017
    00018 // TODO Class to implement printing
    00019 // Since DICOM does printing ?
    00020 // Also I would like to encapsulate the IsCharacterPrintable thing
    00021 // (to avoid printing \0 and other weird characters)
    00022 // \todo I still need to implement skiping of group (shadow)
    00023 // need to implement longer field to read
    00024
    00025 /*
    00026  * Output:
    00027  * For ASCII:
    00028  * Typically will look like:
    00029  * [ORIGINAL\PRIMARY\OTHER]
    00030  * If a non printable character is found: RED and INVERSE is used:
    00031  * [                .]
    00032  *
    00033  * when the VR is not found (file or dict), we check if we can print the output:
    00034  * on success ASCII mode is used, on failure the output is printed a series of bytes
    00035  *
    00036  * Special case when the data element is empty:
    00037  * INVERSE << (no value)
    00038  *
    00039  * retired public element are printed in red and underline
    00040  * unknown private element are printed in RED followed by 'UNKNOWN'
    00041  *
    00042  * Correct VR is printed in green just after the found VR
    00043  *
    00044  * length of data element is printed in bytes, followed by the VM, a green VM is appended
    00045  * if this is not compatible
    00046  */
    00047 #include "gdcmFile.h"
    00048 #include "gdcmDataElement.h"
    00049
    00050 namespace gdcm
    00051 {
    00052
    00053 class DataSet;
    00054 class DictEntry;
    00055 class Dicts;
    00059 // It's a sink there is no output
    00060 class GDCM_EXPORT Printer
    00061 {
    00062 public:
    00063   Printer();
    00064   ~Printer();
    00065
    00066   void SetFile(File const &f) { F = &f; }
    00067
    00068   void SetColor(bool c);
    00069
    00070   typedef enum {
    00071     VERBOSE_STYLE = 0, // GDCM Legacy VERBOSE one
    00072     CONDENSED_STYLE, //
    00073     // Ok I am missing voc here ...better naming would be nice
    00074     XML // sure why not
    00075   } PrintStyles;
    00076
    00077   void SetStyle(PrintStyles ps) {
    00078     PrintStyle = ps;
    00079   }
    00080   PrintStyles GetPrintStyle() const {
    00081     return PrintStyle;
    00082     }
    00083
    00084   void Print(std::ostream& os);
    00085
    00086   //now no longer protected so that individual datasets can be printed directly
    00087   //as per bug #131 in trac.
    00088   //12 jan 2011 mmr
    00089   void PrintDataSet(const DataSet &ds, std::ostream& os, const std::string &s = "");
    00090
    00091 protected:
    00092   void PrintDataSetOld(std::ostream &os, const DataSet &ds);
    00093   void PrintElement(std::ostream& os, const DataElement &xde, const DictEntry &entry);
    00094   VR PrintDataElement(std::ostringstream & os, const Dicts &dicts, const DataSet & ds, const DataElement &de, std::ostream &out, std::string const & indent );
    00095 void PrintSQ(const SequenceOfItems *sqi, std::ostream & os, std::string const & indent);
    00096
    00097   PrintStyles PrintStyle;
    00098   const File *F;
    00099   VL MaxPrintLength;
    00100 };
    00101
    00102 } // end namespace gdcm
    00103
    00104 #endif //GDCMPRINTER_H