1 /* 2 * 3 * Copyright (C) 1998-2012, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmpstat 15 * 16 * Author: Marco Eichelberg 17 * 18 * Purpose: 19 * classes: DVPSGraphicAnnotation 20 * 21 */ 22 23 #ifndef DVPSGA_H 24 #define DVPSGA_H 25 26 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 27 28 #include "dcmtk/dcmdata/dcvrcs.h" /* for DcmCodeString */ 29 #include "dcmtk/dcmpstat/dvpstxl.h" /* for DVPSTextObject_PList */ 30 #include "dcmtk/dcmpstat/dvpsgrl.h" /* for DVPSGraphicObject_PList */ 31 #include "dcmtk/dcmpstat/dvpsril.h" /* for DVPSReferencedImage_PList */ 32 #include "dcmtk/dcmpstat/dvpstyp.h" /* for enum types */ 33 34 /** an item of the graphic annotation sequence in a presentation state (internal use only). 35 * This class manages the data structures comprising one item 36 * of the Graphic Annotation Sequence in a Presentation State object. 37 */ 38 39 class DCMTK_DCMPSTAT_EXPORT DVPSGraphicAnnotation 40 { 41 public: 42 /// default constructor 43 DVPSGraphicAnnotation(); 44 45 /// copy constructor 46 DVPSGraphicAnnotation(const DVPSGraphicAnnotation& copy); 47 48 /** clone method. 49 * @return a pointer to a new DVPSGraphicAnnotation object containing 50 * a deep copy of this object. 51 */ clone()52 DVPSGraphicAnnotation *clone() { return new DVPSGraphicAnnotation(*this); } 53 54 /// destructor 55 virtual ~DVPSGraphicAnnotation(); 56 57 /** reads a graphic annotation from a DICOM dataset. 58 * The DICOM elements of the Graphic Annotation item are copied 59 * from the dataset to this object. 60 * The completeness of the item (presence of all required elements, 61 * value multiplicity) is checked. 62 * If this method returns an error code, the object is in undefined state afterwards. 63 * @param dset the item of the GraphicAnnotationSequence from which the data is to be read 64 * @return EC_Normal if successful, an error code otherwise. 65 */ 66 OFCondition read(DcmItem &dset); 67 68 /** writes the graphic annotation managed by this object to a DICOM dataset. 69 * Copies of the DICOM element managed by this object are inserted into 70 * the DICOM dataset. 71 * @param dset the the item of the GraphicAnnotationSequence to which the data is written 72 * @return EC_Normal if successful, an error code otherwise. 73 */ 74 OFCondition write(DcmItem &dset); 75 76 /** get annotation layer name. 77 * @return a pointer to the annotation layer name 78 */ 79 const char *getAnnotationLayer(); 80 81 /** set annotation layer name of this annotation. 82 * @param aLayer a pointer to the annotation layer name, which is copied into this object. 83 */ 84 void setAnnotationLayer(const char *aLayer); 85 86 /** add a new image reference. 87 * Checks if the referenced SOP instance UID already exists in this sequence. 88 * If it exists, an error code is returned. Otherwise a new image reference 89 * is created and added to the ReferencedImageSequence. 90 * @param sopclassUID the SOP class UID of the image reference to be added. 91 * @param instanceUID the SOP instance UID of the image reference to be added. 92 * @param frame the frame number of the image reference (current image) to be added. 93 * @param applicability the applicability of the image reference (DVPSB_currentFrame or DVPSX_currentImage) 94 * @return EC_Normal if successful, an error code otherwise. 95 */ 96 OFCondition addImageReference( 97 const char *sopclassUID, 98 const char *instanceUID, 99 unsigned long frame, 100 DVPSObjectApplicability applicability); 101 102 /** checks if this annotation layer is empty. 103 * An annotation layer is empty when it contains no text object and no graphic object. 104 * @return OFTrue if empty. 105 */ 106 OFBool isEmpty(); 107 108 /** checks if this annotation layer is applicable to the given image and frame. 109 * @param instanceUID SOP instance UID of the current image 110 * @param frame number of the current frame 111 * @param applicability the required (minimum) applicability of the reference. Default: 112 * annotation layer applies to the current frame of the current image. 113 * @return OFTrue if applicable. 114 */ 115 OFBool isApplicable( 116 const char *instanceUID, 117 unsigned long frame, 118 DVPSObjectApplicability applicability=DVPSB_currentFrame); 119 120 /** returns the number of text objects in this annotation. 121 * @return number of text objects 122 */ 123 size_t getNumberOfTextObjects(); 124 125 /** returns the number of graphic objects in this annotation. 126 * @return number of graphic objects 127 */ 128 size_t getNumberOfGraphicObjects(); 129 130 /** returns a pointer to the text object with the given 131 * index or NULL if it does not exist. 132 * @param idx index, must be < getNumberOfTextObjects() 133 * @return pointer to text object or NULL 134 */ 135 DVPSTextObject *getTextObject(size_t idx); 136 137 /** returns a pointer to the graphic object with the given 138 * index or NULL if it does not exist. 139 * @param idx index, must be < getNumberOfGraphicObjects() 140 * @return pointer to graphic object or NULL 141 */ 142 DVPSGraphicObject *getGraphicObject(size_t idx); 143 144 /** adds the given text object to 145 * the list of text objects managed by this object. 146 * @param text text object to be inserted. 147 */ 148 void addTextObject(DVPSTextObject *text); 149 150 /** adds the given graphic object to 151 * the list of graphic objects managed by this object. 152 * @param text graphic object to be inserted. 153 */ 154 void addGraphicObject(DVPSGraphicObject *graphic); 155 156 /** returns a pointer to the text object with the given 157 * index (or NULL if it does not exist) and removes it from the list. 158 * @param idx index, must be < getNumberOfTextObjects() 159 * @return pointer to text object or NULL 160 */ 161 DVPSTextObject *removeTextObject(size_t idx); 162 163 /** returns a pointer to the graphic object with the given 164 * index (or NULL if it does not exist) and removes it from the list. 165 * @param idx index, must be < getNumberOfGraphicObjects() 166 * @return pointer to graphic object or NULL 167 */ 168 DVPSGraphicObject *removeGraphicObject(size_t idx); 169 170 private: 171 172 /// private undefined assignment operator 173 DVPSGraphicAnnotation& operator=(const DVPSGraphicAnnotation&); 174 175 /// ReferencedImageSequence, Type 1c 176 DVPSReferencedImage_PList referencedImageList; 177 /// VR=CS, VM=1, Type 1 178 DcmCodeString graphicAnnotationLayer; 179 /// TextObjectSequence, Type 1c 180 DVPSTextObject_PList textObjectList; 181 /// GraphicObjectSequence, Type 1c 182 DVPSGraphicObject_PList graphicObjectList; 183 184 }; 185 186 #endif 187