00001 /* 00002 * 00003 * Copyright (C) 1998-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmpstat 00019 * 00020 * Author: Marco Eichelberg 00021 * 00022 * Purpose: 00023 * classes: DVPresentationState 00024 * 00025 * Last Update: $Author: meichel $ 00026 * Update Date: $Date: 2005/12/08 16:04:07 $ 00027 * CVS/RCS Revision: $Revision: 1.44 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 #ifndef __DVPSTAT_H__ 00035 #define __DVPSTAT_H__ 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 #include "dcmtk/dcmpstat/dcmpstat.h" 00039 00040 class DicomImage; 00041 class DiDisplayFunction; 00042 00047 class DVPresentationState: public DcmPresentationState 00048 { 00049 public: 00062 DVPresentationState( 00063 DiDisplayFunction **dispFunction=NULL, 00064 unsigned long minPrintBitmapX=0, 00065 unsigned long minPrintBitmapY=0, 00066 unsigned long maxPrintBitmapX=0, 00067 unsigned long maxPrintBitmapY=0, 00068 unsigned long maxPreviewImageX=0, 00069 unsigned long maxPreviewImageY=0); 00070 00072 virtual ~DVPresentationState(); 00073 00078 void clear(); 00079 00090 OFCondition read(DcmItem &dset); 00091 00118 OFCondition createFromImage(DcmItem &dset, 00119 DVPSoverlayActivation overlayActivation = DVPSO_copyOverlays, 00120 DVPSVOIActivation voiActivation = DVPSV_preferVOILUT, 00121 OFBool curveActivation = OFTrue, 00122 OFBool shutterActivation = OFTrue, 00123 OFBool presentationActivation = OFTrue, 00124 DVPSGraphicLayering layering = DVPSG_twoLayers, 00125 const char * aetitle = NULL, 00126 const char * filesetID = NULL, 00127 const char * filesetUID = NULL); 00128 00138 OFCondition addImageReferenceAttached( 00139 const char *aetitle=NULL, 00140 const char *filesetID=NULL, 00141 const char *filesetUID=NULL); 00142 00146 OFCondition removeImageReferenceAttached(); 00147 00154 OFCondition setCurrentPresentationLUT(DVPSPresentationLUTType newType); 00155 00162 OFCondition setDefaultPresentationLUTShape(); 00163 00176 OFCondition setPresentationLookupTable( 00177 DcmUnsignedShort& lutDescriptor, 00178 DcmUnsignedShort& lutData, 00179 DcmLongString& lutExplanation); 00180 00191 OFCondition setPresentationLookupTable(DcmItem &dset); 00192 00200 OFCondition writePresentationLUTforPrint(DcmItem &dset); 00201 00207 OFBool isMonochrome1Image() { return currentImageMonochrome1; } 00208 00212 OFBool haveActiveVOIWindow(); 00213 00217 OFBool haveActiveVOILUT(); 00218 00223 const char *getCurrentVOIDescription(); 00224 00230 OFCondition getCurrentWindowWidth(double &w); 00231 00237 OFCondition getCurrentWindowCenter(double &c); 00238 00241 size_t getNumberOfVOILUTsInImage(); 00242 00245 size_t getNumberOfVOIWindowsInImage(); 00246 00253 const char *getDescriptionOfVOILUTsInImage(size_t idx); 00254 00261 const char *getDescriptionOfVOIWindowsInImage(size_t idx); 00262 00269 OFCondition setVOILUTFromImage(size_t idx, 00270 DVPSObjectApplicability applicability=DVPSB_currentImage); 00271 00278 OFCondition setVOIWindowFromImage(size_t idx, 00279 DVPSObjectApplicability applicability=DVPSB_currentImage); 00280 00289 OFCondition setVOIWindow(double wCenter, double wWidth, const char *description=NULL, 00290 DVPSObjectApplicability applicability=DVPSB_currentImage); 00291 00304 OFCondition setVOILUT( 00305 DcmUnsignedShort& lutDescriptor, 00306 DcmUnsignedShort& lutData, 00307 DcmLongString& lutExplanation, 00308 DVPSObjectApplicability applicability=DVPSB_currentImage); 00309 00315 void deactivateVOI(DVPSObjectApplicability applicability=DVPSB_currentImage); 00316 00329 OFCondition setGammaVOILUT(double gammaValue, DVPSObjectApplicability applicability=DVPSB_currentImage); 00330 00335 DVPSPresentationSizeMode getDisplayedAreaPresentationSizeMode(); 00336 00343 double getDisplayedAreaPresentationPixelAspectRatio(); 00344 00354 OFCondition getStandardDisplayedArea(Sint32& tlhcX, Sint32& tlhcY, Sint32& brhcX, Sint32& brhcY); 00355 00365 OFCondition getImageRelativeDisplayedArea(Sint32& tlhcX, Sint32& tlhcY, Sint32& brhcX, Sint32& brhcY); 00366 00372 OFCondition getDisplayedAreaPresentationPixelSpacing(double& x, double& y); 00373 00378 OFCondition getDisplayedAreaPresentationPixelMagnificationRatio(double& magnification); 00379 00384 OFBool canUseDisplayedAreaTrueSize(); 00385 00403 OFCondition setStandardDisplayedArea( 00404 DVPSPresentationSizeMode sizeMode, 00405 Sint32 tlhcX, Sint32 tlhcY, 00406 Sint32 brhcX, Sint32 brhcY, 00407 double magnification=1.0, 00408 DVPSObjectApplicability applicability=DVPSB_currentImage); 00409 00428 OFCondition setImageRelativeDisplayedArea( 00429 DVPSPresentationSizeMode sizeMode, 00430 Sint32 tlhcX, Sint32 tlhcY, 00431 Sint32 brhcX, Sint32 brhcY, 00432 double magnification=1.0, 00433 DVPSObjectApplicability applicability=DVPSB_currentImage); 00434 00439 void removeShutter(DVPSShutterType type); 00440 00451 OFCondition setRectShutter(Sint32 lv, Sint32 rv, Sint32 uh, Sint32 lh); 00461 OFCondition setCircularShutter(Sint32 centerX, Sint32 centerY, Sint32 radius); 00462 00474 OFCondition addPolyShutterVertex(Sint32 x, Sint32 y); 00475 00481 OFCondition removeGraphicLayer(size_t idx); 00482 00490 size_t getNumberOfTextObjects(size_t layer); 00491 00501 DVPSTextObject *getTextObject(size_t layer, size_t idx); 00502 00512 DVPSTextObject *addTextObject(size_t layer, 00513 DVPSObjectApplicability applicability=DVPSB_allImages); 00514 00523 OFCondition removeTextObject(size_t layer, size_t idx); 00524 00538 OFCondition moveTextObject(size_t old_layer, size_t idx, size_t new_layer, 00539 DVPSObjectApplicability applicability=DVPSB_allImages); 00540 00548 size_t getNumberOfGraphicObjects(size_t layer); 00549 00559 DVPSGraphicObject *getGraphicObject(size_t layer, size_t idx); 00560 00570 DVPSGraphicObject *addGraphicObject(size_t layer, 00571 DVPSObjectApplicability applicability=DVPSB_allImages); 00572 00581 OFCondition removeGraphicObject(size_t layer, size_t idx); 00582 00596 OFCondition moveGraphicObject(size_t old_layer, size_t idx, size_t new_layer, 00597 DVPSObjectApplicability applicability=DVPSB_allImages); 00598 00606 DVPSCurve *getCurve(size_t layer, size_t idx); 00607 00612 size_t getNumberOfCurvesInImage(); 00613 00620 DVPSCurve *getCurveInImage(size_t idx); 00621 00630 OFCondition addCurve(size_t layer, size_t curveidxinimage); 00631 00637 const char *getActiveOverlayLabel(size_t layer, size_t idx); 00638 00644 const char *getActiveOverlayDescription(size_t layer, size_t idx); 00645 00652 OFBool activeOverlayIsROI(size_t layer, size_t idx); 00653 00675 OFCondition getOverlayData( 00676 size_t layer, 00677 size_t idx, 00678 const void *&overlayData, 00679 unsigned int &width, 00680 unsigned int &height, 00681 unsigned int &left_pos, 00682 unsigned int &top_pos, 00683 OFBool &isROI, 00684 Uint16 &fore, 00685 unsigned int bits = 8); 00686 00693 size_t getNumberOfOverlaysInImage(); 00694 00699 Uint16 getOverlayInImageGroup(size_t idx); 00700 00705 const char *getOverlayInImageLabel(size_t idx); 00706 00711 const char *getOverlayInImageDescription(size_t idx); 00712 00719 size_t getOverlayInImageActivationLayer(size_t idx); 00720 00726 OFBool overlayInImageIsROI(size_t idx); 00727 00735 OFCondition removeOverlayFromPresentationState(size_t idx); 00736 00747 OFCondition changeOverlayGroupInPresentationState(size_t idx, Uint16 newGroup=0); 00748 00764 OFCondition addOverlayToPresentationState(DcmItem& overlayIOD, Uint16 groupInItem, Uint16 newGroup=0); 00765 00774 OFBool overlayIsSuitableAsBitmapShutter(size_t idx); 00775 00784 OFCondition activateOverlayInImage(size_t layer, size_t idx); 00785 00795 OFCondition activateOverlayInPresentationState(size_t layer, size_t idx); 00796 00804 OFCondition activateOverlayAsBitmapShutter(size_t idx); 00805 00814 OFCondition deactivateOverlay(size_t layer, size_t idx); 00815 00828 OFCondition attachImage(DcmDataset *dataset, OFBool transferOwnership); 00829 00842 OFCondition attachImage(DcmFileFormat *fileformat, OFBool transferOwnership); 00843 00846 void detachImage(); 00847 00851 OFBool isInverse(); 00852 00857 OFCondition invertImage(); 00858 00877 OFCondition getPixelData( 00878 const void *&pixelData, 00879 unsigned long &width, 00880 unsigned long &height); 00881 00890 OFCondition getPixelData( 00891 void *pixelData, 00892 unsigned long size); 00893 00897 const char *getAttachedImageSOPClassUID(); 00898 00902 const char *getAttachedImageSOPInstanceUID(); 00903 00912 OFCondition getImageWidth(unsigned long &width); 00913 00922 OFCondition getImageHeight(unsigned long &height); 00923 00928 unsigned long getPrintBitmapSize(); 00929 00937 OFCondition setMinimumPrintBitmapWidthHeight(unsigned long width, 00938 unsigned long height); 00939 00947 OFCondition setMaximumPrintBitmapWidthHeight(unsigned long width, 00948 unsigned long height); 00949 00957 OFCondition getPrintBitmapWidthHeight(unsigned long &width, 00958 unsigned long &height); 00959 00966 OFCondition getPrintBitmapWidth(unsigned long &width); 00967 00974 OFCondition getPrintBitmapHeight(unsigned long &height); 00975 00981 double getPrintBitmapPixelAspectRatio(); 00982 00991 OFCondition getPrintBitmapRequestedImageSize(OFString& requestedImageSize); 00992 01003 OFCondition getPrintBitmap(void *bitmap, 01004 unsigned long size, 01005 OFBool inversePLUT = OFFalse); 01006 01020 OFCondition createPreviewImage(unsigned long maxWidth, 01021 unsigned long maxHeight, 01022 OFBool clipMode = OFFalse); 01023 01026 void deletePreviewImage(); 01027 01032 unsigned long getPreviewImageSize(); 01033 01039 OFCondition getPreviewImageWidthHeight(unsigned long &width, 01040 unsigned long &height); 01041 01046 OFCondition getPreviewImageWidth(unsigned long &width); 01047 01052 OFCondition getPreviewImageHeight(unsigned long &height); 01053 01060 OFCondition getPreviewImageBitmap(void *bitmap, 01061 unsigned long size); 01062 01073 OFCondition getImageMinMaxPixelRange(double &minValue, double& maxValue); 01074 01085 OFCondition getImageMinMaxPixelValue(double &minValue, double& maxValue); 01086 01093 OFCondition getImageNumberOfFrames(unsigned long &frames); 01094 01102 OFCondition selectImageFrameNumber(unsigned long frame); 01103 01107 unsigned long getSelectedImageFrameNumber(); 01108 01115 DVPSDisplayTransform getDisplayTransform() { return displayTransform; } 01116 01122 void setDisplayTransform(DVPSDisplayTransform transform) { displayTransform = transform; } 01123 01133 Uint16 convertPValueToDDL(Uint16 pvalue, unsigned int bits = 8); 01134 01142 OFCondition writeHardcopyImageAttributes(DcmItem &dset); 01143 01147 const char *getCurrentImageModality(); 01148 01157 Uint16 findOverlayGroup(Uint16 currentGroup=0); 01158 01167 void renderPixelData(OFBool display = OFTrue); 01168 01174 DVPSDisplayedArea *getDisplayedAreaSelection(); 01175 01180 DVPSSoftcopyVOI *getCurrentSoftcopyVOI(); 01181 01187 void setLog(OFConsole *stream, OFBool verbMode, OFBool dbgMode); 01188 01189 private: 01190 01198 static OFCondition activateOverlayHelper( 01199 DVPSOverlay& ovl, 01200 DicomImage &image, 01201 OFBool asShutter = OFFalse, 01202 Uint16 pvalue = 0); 01203 01204 /* connection with dcmimage */ 01205 01209 DcmDataset *currentImageDataset; 01214 DcmFileFormat *currentImageFileformat; 01218 DicomImage *currentImage; 01222 DicomImage *previewImage; 01225 unsigned long currentImageWidth; 01228 unsigned long currentImageHeight; 01231 unsigned long renderedImageWidth; 01234 unsigned long renderedImageHeight; 01237 signed long renderedImageTop; 01241 signed long renderedImageLeft; 01245 signed long renderedImageBottom; 01248 signed long renderedImageRight; 01251 char *currentImageSOPClassUID; 01254 char *currentImageSOPInstanceUID; 01258 unsigned long currentImageSelectedFrame; 01264 OFBool currentImageOwned; 01268 OFBool currentImageVOIValid; 01272 OFBool currentImagePLUTValid; 01275 OFBool currentImageFlip; 01278 DVPSRotationType currentImageRotation; 01283 int currentImageOverlaysValid; 01284 01287 DVPSCurve_PList currentImageCurveList; 01290 DVPSVOILUT_PList currentImageVOILUTList; 01293 DVPSVOIWindow_PList currentImageVOIWindowList; 01294 01297 DcmCodeString currentImageModality; 01298 01301 OFBool currentImageMonochrome1; 01302 01306 DVPSDisplayTransform displayTransform; 01307 01310 OFBool imageInverse; 01311 01314 DiDisplayFunction **displayFunction; 01315 01318 unsigned long minimumPrintBitmapWidth; 01319 01322 unsigned long minimumPrintBitmapHeight; 01323 01326 unsigned long maximumPrintBitmapWidth; 01327 01330 unsigned long maximumPrintBitmapHeight; 01331 01334 unsigned long maximumPreviewImageWidth; 01335 01338 unsigned long maximumPreviewImageHeight; 01339 01340 }; 01341 01342 #endif 01343 01344 /* 01345 * $Log: dvpstat.h,v $ 01346 * Revision 1.44 2005/12/08 16:04:07 meichel 01347 * Changed include path schema for all DCMTK header files 01348 * 01349 * Revision 1.43 2003/09/05 14:30:06 meichel 01350 * Introduced new API methods that allow Displayed Areas to be queried 01351 * and set either relative to the image (ignoring rotation and flip) or 01352 * in absolute values as defined in the standard. Rotate and flip methods 01353 * now adjust displayed areas in the presentation state. 01354 * 01355 * Revision 1.42 2003/08/27 14:57:19 meichel 01356 * Splitted class DVPresentationState into a base class DcmPresentationState 01357 * that does not depend on module dcmimgle and current derived class with 01358 * public API identical to the previous version. 01359 * 01360 * Revision 1.41 2002/12/09 13:29:49 joergr 01361 * Renamed parameter/local variable to avoid name clashes with global 01362 * declaration left and/or right (used for as iostream manipulators). 01363 * 01364 * Revision 1.40 2001/09/26 15:36:17 meichel 01365 * Adapted dcmpstat to class OFCondition 01366 * 01367 * Revision 1.39 2001/06/01 15:50:23 meichel 01368 * Updated copyright header 01369 * 01370 * Revision 1.38 2000/11/13 15:50:43 meichel 01371 * Added dcmpstat support methods for creating image references 01372 * in SR documents. 01373 * 01374 * Revision 1.37 2000/07/04 15:58:03 joergr 01375 * Added support for overriding the presentation LUT settings made for the 01376 * image boxes. 01377 * 01378 * Revision 1.36 2000/06/09 10:14:12 joergr 01379 * Added support for rendering inverse presentation LUT into print bitmaps. 01380 * 01381 * Revision 1.35 2000/06/08 17:36:51 joergr 01382 * Corrected bug in addImageReferenceToPState(). 01383 * 01384 * Revision 1.34 2000/06/02 16:00:53 meichel 01385 * Adapted all dcmpstat classes to use OFConsole for log and error output 01386 * 01387 * Revision 1.33 2000/05/30 14:21:24 joergr 01388 * Renamed some variables to avoid compiler warnings (reported by gcc 2.9x with 01389 * additional compiler flags). 01390 * 01391 * Revision 1.32 2000/05/30 13:47:03 joergr 01392 * Added support for multi-frame images and multiple references from a single 01393 * presentation to a number of images. 01394 * Removed methods which were already marked as "retired". 01395 * Added new function allowing to set a VOILUT created from a given gamma 01396 * value. 01397 * 01398 * Revision 1.31 2000/03/08 16:28:57 meichel 01399 * Updated copyright header. 01400 * 01401 * Revision 1.30 2000/02/29 12:16:16 meichel 01402 * Fixed bug in dcmpstat library that caused Monochrome1 images 01403 * to be printed inverse if a Presentation LUT was applied. 01404 * 01405 * Revision 1.29 1999/11/15 19:02:16 joergr 01406 * Changed behaviour of method getOverlayData(): parameter 'transp' replaced by 01407 * 'fore' to specify the foreground color used for the overlay plane. 01408 * 01409 * Revision 1.28 1999/11/03 10:36:32 joergr 01410 * Enhanced comments for methods dealing with arrays of pixel data. 01411 * 01412 * Revision 1.27 1999/10/20 10:49:20 joergr 01413 * Enhanced method getOverlayData to support 12 bit data for print. 01414 * Enhanced method convertPValueToDDL to support 12 bit data for print. 01415 * Added support for a down-scaled preview image of the current DICOM image 01416 * (e.g. useful for online-windowing or print preview). 01417 * 01418 * Revision 1.26 1999/10/19 16:24:50 meichel 01419 * Corrected handling of MONOCHROME1 images when used with P-LUTs 01420 * 01421 * Revision 1.25 1999/10/13 14:11:57 meichel 01422 * Added config file entries and access methods 01423 * for user-defined VOI presets, log directory, verbatim logging 01424 * and an explicit list of image display formats for each printer. 01425 * 01426 * Revision 1.24 1999/10/07 17:21:51 meichel 01427 * Reworked management of Presentation LUTs in order to create tighter 01428 * coupling between Softcopy and Print. 01429 * 01430 * Revision 1.23 1999/09/10 12:46:48 meichel 01431 * Added implementations for a number of print API methods. 01432 * 01433 * Revision 1.22 1999/09/10 09:02:32 joergr 01434 * Added support for CIELAB display function. New methods to handle display 01435 * functions. Old methods are marked as retired and should be removed asap. 01436 * 01437 * Revision 1.21 1999/09/07 09:04:37 joergr 01438 * Completed support for getting a print bitmap out of a pstate object. 01439 * 01440 * Revision 1.20 1999/09/01 16:14:42 meichel 01441 * Added support for requested image size to print routines 01442 * 01443 * Revision 1.19 1999/08/27 15:57:58 meichel 01444 * Added methods for saving hardcopy images and stored print objects 01445 * either in file or in the local database. 01446 * 01447 * Revision 1.18 1999/08/25 16:48:01 joergr 01448 * Added minimal support to get a print bitmap out of a pstate object. 01449 * 01450 * Revision 1.17 1999/07/30 13:34:51 meichel 01451 * Added new classes managing Stored Print objects 01452 * 01453 * Revision 1.16 1999/07/22 16:39:13 meichel 01454 * Adapted dcmpstat data structures and API to supplement 33 letter ballot text. 01455 * 01456 * Revision 1.15 1999/05/04 12:28:11 meichel 01457 * Removed carriage returns 01458 * 01459 * Revision 1.14 1999/04/27 11:23:57 joergr 01460 * Added method to check whether current image is inverse or not. 01461 * 01462 * Revision 1.13 1999/03/22 09:05:35 joergr 01463 * Added parameter to get value of (transparent) background color for method 01464 * getOverlayData. 01465 * 01466 * Revision 1.12 1999/03/03 13:26:06 joergr 01467 * Added method to invert an image by changing the presentation state LUT or 01468 * shape. 01469 * Moved method 'isBartenTransformPossible()' from presentation state class to 01470 * interface class. 01471 * 01472 * Revision 1.11 1999/03/02 13:01:02 joergr 01473 * Added method to presentation state class that checks whether Barten 01474 * transformation is possible or not. 01475 * 01476 * Revision 1.10 1999/02/25 18:40:08 joergr 01477 * Added method to fill pixel data into an externally handled storage area. 01478 * 01479 * Revision 1.9 1999/02/18 11:36:38 meichel 01480 * Added new method convertPValueToDDL() to DVPresentationState 01481 * that maps P-Values to DDLs. 01482 * 01483 * Revision 1.8 1999/02/17 10:05:32 meichel 01484 * Moved creation of Display Function object from DVPresentationState to 01485 * DVInterface to avoid unnecessary re-reads. 01486 * 01487 * Revision 1.7 1999/02/09 15:58:57 meichel 01488 * Implemented bitmap shutter activation amd method for 01489 * exchanging graphic layers. 01490 * 01491 * Revision 1.6 1999/02/05 17:45:36 meichel 01492 * Added config file entry for monitor characteristics file. Monitor charac- 01493 * teristics are passed to dcmimage if present to activate Barten transform. 01494 * 01495 * Revision 1.5 1999/01/15 17:33:05 meichel 01496 * added methods to DVPresentationState allowing to access the image 01497 * references in the presentation state. Also added methods allowing to 01498 * get the width and height of the attached image. 01499 * 01500 * Revision 1.4 1999/01/11 13:35:49 meichel 01501 * added new methods getImageAspectRatio, getImageMinMaxPixelRange and 01502 * getImageMinMaxPixelValue to class DVPresentationState. 01503 * 01504 * Revision 1.3 1998/12/22 17:57:07 meichel 01505 * Implemented Presentation State interface for overlays, 01506 * VOI LUTs, VOI windows, curves. Added test program that 01507 * allows to add curve data to DICOM images. 01508 * 01509 * Revision 1.2 1998/12/14 16:10:35 meichel 01510 * Implemented Presentation State interface for graphic layers, 01511 * text and graphic annotations, presentation LUTs. 01512 * 01513 * Revision 1.1 1998/11/27 14:50:34 meichel 01514 * Initial Release. 01515 * 01516 * 01517 */ 01518