00001 /* 00002 * 00003 * Copyright (C) 1998-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmpstat 00015 * 00016 * Author: Marco Eichelberg 00017 * 00018 * Purpose: 00019 * classes: DVPresentationState 00020 * 00021 * Last Update: $Author: joergr $ 00022 * Update Date: $Date: 2010-10-14 13:16:37 $ 00023 * CVS/RCS Revision: $Revision: 1.47 $ 00024 * Status: $State: Exp $ 00025 * 00026 * CVS/RCS Log at end of file 00027 * 00028 */ 00029 00030 #ifndef DVPSTAT_H 00031 #define DVPSTAT_H 00032 00033 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00034 #include "dcmtk/dcmpstat/dcmpstat.h" 00035 00036 class DicomImage; 00037 class DiDisplayFunction; 00038 00043 class DVPresentationState: public DcmPresentationState 00044 { 00045 public: 00058 DVPresentationState( 00059 DiDisplayFunction **dispFunction=NULL, 00060 unsigned long minPrintBitmapX=0, 00061 unsigned long minPrintBitmapY=0, 00062 unsigned long maxPrintBitmapX=0, 00063 unsigned long maxPrintBitmapY=0, 00064 unsigned long maxPreviewImageX=0, 00065 unsigned long maxPreviewImageY=0); 00066 00068 virtual ~DVPresentationState(); 00069 00074 void clear(); 00075 00086 OFCondition read(DcmItem &dset); 00087 00114 OFCondition createFromImage(DcmItem &dset, 00115 DVPSoverlayActivation overlayActivation = DVPSO_copyOverlays, 00116 DVPSVOIActivation voiActivation = DVPSV_preferVOILUT, 00117 OFBool curveActivation = OFTrue, 00118 OFBool shutterActivation = OFTrue, 00119 OFBool presentationActivation = OFTrue, 00120 DVPSGraphicLayering layering = DVPSG_twoLayers, 00121 const char * aetitle = NULL, 00122 const char * filesetID = NULL, 00123 const char * filesetUID = NULL); 00124 00134 OFCondition addImageReferenceAttached( 00135 const char *aetitle=NULL, 00136 const char *filesetID=NULL, 00137 const char *filesetUID=NULL); 00138 00142 OFCondition removeImageReferenceAttached(); 00143 00150 OFCondition setCurrentPresentationLUT(DVPSPresentationLUTType newType); 00151 00158 OFCondition setDefaultPresentationLUTShape(); 00159 00172 OFCondition setPresentationLookupTable( 00173 DcmUnsignedShort& lutDescriptor, 00174 DcmUnsignedShort& lutData, 00175 DcmLongString& lutExplanation); 00176 00187 OFCondition setPresentationLookupTable(DcmItem &dset); 00188 00196 OFCondition writePresentationLUTforPrint(DcmItem &dset); 00197 00203 OFBool isMonochrome1Image() { return currentImageMonochrome1; } 00204 00208 OFBool haveActiveVOIWindow(); 00209 00213 OFBool haveActiveVOILUT(); 00214 00219 const char *getCurrentVOIDescription(); 00220 00226 OFCondition getCurrentWindowWidth(double &w); 00227 00233 OFCondition getCurrentWindowCenter(double &c); 00234 00237 size_t getNumberOfVOILUTsInImage(); 00238 00241 size_t getNumberOfVOIWindowsInImage(); 00242 00249 const char *getDescriptionOfVOILUTsInImage(size_t idx); 00250 00257 const char *getDescriptionOfVOIWindowsInImage(size_t idx); 00258 00265 OFCondition setVOILUTFromImage(size_t idx, 00266 DVPSObjectApplicability applicability=DVPSB_currentImage); 00267 00274 OFCondition setVOIWindowFromImage(size_t idx, 00275 DVPSObjectApplicability applicability=DVPSB_currentImage); 00276 00285 OFCondition setVOIWindow(double wCenter, double wWidth, const char *description=NULL, 00286 DVPSObjectApplicability applicability=DVPSB_currentImage); 00287 00300 OFCondition setVOILUT( 00301 DcmUnsignedShort& lutDescriptor, 00302 DcmUnsignedShort& lutData, 00303 DcmLongString& lutExplanation, 00304 DVPSObjectApplicability applicability=DVPSB_currentImage); 00305 00311 void deactivateVOI(DVPSObjectApplicability applicability=DVPSB_currentImage); 00312 00325 OFCondition setGammaVOILUT(double gammaValue, DVPSObjectApplicability applicability=DVPSB_currentImage); 00326 00331 DVPSPresentationSizeMode getDisplayedAreaPresentationSizeMode(); 00332 00339 double getDisplayedAreaPresentationPixelAspectRatio(); 00340 00350 OFCondition getStandardDisplayedArea(Sint32& tlhcX, Sint32& tlhcY, Sint32& brhcX, Sint32& brhcY); 00351 00361 OFCondition getImageRelativeDisplayedArea(Sint32& tlhcX, Sint32& tlhcY, Sint32& brhcX, Sint32& brhcY); 00362 00368 OFCondition getDisplayedAreaPresentationPixelSpacing(double& x, double& y); 00369 00374 OFCondition getDisplayedAreaPresentationPixelMagnificationRatio(double& magnification); 00375 00380 OFBool canUseDisplayedAreaTrueSize(); 00381 00399 OFCondition setStandardDisplayedArea( 00400 DVPSPresentationSizeMode sizeMode, 00401 Sint32 tlhcX, Sint32 tlhcY, 00402 Sint32 brhcX, Sint32 brhcY, 00403 double magnification=1.0, 00404 DVPSObjectApplicability applicability=DVPSB_currentImage); 00405 00424 OFCondition setImageRelativeDisplayedArea( 00425 DVPSPresentationSizeMode sizeMode, 00426 Sint32 tlhcX, Sint32 tlhcY, 00427 Sint32 brhcX, Sint32 brhcY, 00428 double magnification=1.0, 00429 DVPSObjectApplicability applicability=DVPSB_currentImage); 00430 00435 void removeShutter(DVPSShutterType type); 00436 00447 OFCondition setRectShutter(Sint32 lv, Sint32 rv, Sint32 uh, Sint32 lh); 00457 OFCondition setCircularShutter(Sint32 centerX, Sint32 centerY, Sint32 radius); 00458 00470 OFCondition addPolyShutterVertex(Sint32 x, Sint32 y); 00471 00477 OFCondition removeGraphicLayer(size_t idx); 00478 00486 size_t getNumberOfTextObjects(size_t layer); 00487 00497 DVPSTextObject *getTextObject(size_t layer, size_t idx); 00498 00508 DVPSTextObject *addTextObject(size_t layer, 00509 DVPSObjectApplicability applicability=DVPSB_allImages); 00510 00519 OFCondition removeTextObject(size_t layer, size_t idx); 00520 00534 OFCondition moveTextObject(size_t old_layer, size_t idx, size_t new_layer, 00535 DVPSObjectApplicability applicability=DVPSB_allImages); 00536 00544 size_t getNumberOfGraphicObjects(size_t layer); 00545 00555 DVPSGraphicObject *getGraphicObject(size_t layer, size_t idx); 00556 00566 DVPSGraphicObject *addGraphicObject(size_t layer, 00567 DVPSObjectApplicability applicability=DVPSB_allImages); 00568 00577 OFCondition removeGraphicObject(size_t layer, size_t idx); 00578 00592 OFCondition moveGraphicObject(size_t old_layer, size_t idx, size_t new_layer, 00593 DVPSObjectApplicability applicability=DVPSB_allImages); 00594 00602 DVPSCurve *getCurve(size_t layer, size_t idx); 00603 00608 size_t getNumberOfCurvesInImage(); 00609 00616 DVPSCurve *getCurveInImage(size_t idx); 00617 00626 OFCondition addCurve(size_t layer, size_t curveidxinimage); 00627 00633 const char *getActiveOverlayLabel(size_t layer, size_t idx); 00634 00640 const char *getActiveOverlayDescription(size_t layer, size_t idx); 00641 00648 OFBool activeOverlayIsROI(size_t layer, size_t idx); 00649 00671 OFCondition getOverlayData( 00672 size_t layer, 00673 size_t idx, 00674 const void *&overlayData, 00675 unsigned int &width, 00676 unsigned int &height, 00677 unsigned int &left_pos, 00678 unsigned int &top_pos, 00679 OFBool &isROI, 00680 Uint16 &fore, 00681 unsigned int bits = 8); 00682 00689 size_t getNumberOfOverlaysInImage(); 00690 00695 Uint16 getOverlayInImageGroup(size_t idx); 00696 00701 const char *getOverlayInImageLabel(size_t idx); 00702 00707 const char *getOverlayInImageDescription(size_t idx); 00708 00715 size_t getOverlayInImageActivationLayer(size_t idx); 00716 00722 OFBool overlayInImageIsROI(size_t idx); 00723 00731 OFCondition removeOverlayFromPresentationState(size_t idx); 00732 00743 OFCondition changeOverlayGroupInPresentationState(size_t idx, Uint16 newGroup=0); 00744 00760 OFCondition addOverlayToPresentationState(DcmItem& overlayIOD, Uint16 groupInItem, Uint16 newGroup=0); 00761 00770 OFBool overlayIsSuitableAsBitmapShutter(size_t idx); 00771 00780 OFCondition activateOverlayInImage(size_t layer, size_t idx); 00781 00791 OFCondition activateOverlayInPresentationState(size_t layer, size_t idx); 00792 00800 OFCondition activateOverlayAsBitmapShutter(size_t idx); 00801 00810 OFCondition deactivateOverlay(size_t layer, size_t idx); 00811 00824 OFCondition attachImage(DcmDataset *dataset, OFBool transferOwnership); 00825 00838 OFCondition attachImage(DcmFileFormat *fileformat, OFBool transferOwnership); 00839 00842 void detachImage(); 00843 00847 OFBool isInverse(); 00848 00853 OFCondition invertImage(); 00854 00873 OFCondition getPixelData( 00874 const void *&pixelData, 00875 unsigned long &width, 00876 unsigned long &height); 00877 00886 OFCondition getPixelData( 00887 void *pixelData, 00888 unsigned long size); 00889 00893 const char *getAttachedImageSOPClassUID(); 00894 00898 const char *getAttachedImageSOPInstanceUID(); 00899 00908 OFCondition getImageWidth(unsigned long &width); 00909 00918 OFCondition getImageHeight(unsigned long &height); 00919 00924 unsigned long getPrintBitmapSize(); 00925 00933 OFCondition setMinimumPrintBitmapWidthHeight(unsigned long width, 00934 unsigned long height); 00935 00943 OFCondition setMaximumPrintBitmapWidthHeight(unsigned long width, 00944 unsigned long height); 00945 00953 OFCondition getPrintBitmapWidthHeight(unsigned long &width, 00954 unsigned long &height); 00955 00962 OFCondition getPrintBitmapWidth(unsigned long &width); 00963 00970 OFCondition getPrintBitmapHeight(unsigned long &height); 00971 00977 double getPrintBitmapPixelAspectRatio(); 00978 00987 OFCondition getPrintBitmapRequestedImageSize(OFString& requestedImageSize); 00988 00999 OFCondition getPrintBitmap(void *bitmap, 01000 unsigned long size, 01001 OFBool inversePLUT = OFFalse); 01002 01016 OFCondition createPreviewImage(unsigned long maxWidth, 01017 unsigned long maxHeight, 01018 OFBool clipMode = OFFalse); 01019 01022 void deletePreviewImage(); 01023 01028 unsigned long getPreviewImageSize(); 01029 01035 OFCondition getPreviewImageWidthHeight(unsigned long &width, 01036 unsigned long &height); 01037 01042 OFCondition getPreviewImageWidth(unsigned long &width); 01043 01048 OFCondition getPreviewImageHeight(unsigned long &height); 01049 01056 OFCondition getPreviewImageBitmap(void *bitmap, 01057 unsigned long size); 01058 01069 OFCondition getImageMinMaxPixelRange(double &minValue, double& maxValue); 01070 01081 OFCondition getImageMinMaxPixelValue(double &minValue, double& maxValue); 01082 01089 OFCondition getImageNumberOfFrames(unsigned long &frames); 01090 01098 OFCondition selectImageFrameNumber(unsigned long frame); 01099 01103 unsigned long getSelectedImageFrameNumber(); 01104 01111 DVPSDisplayTransform getDisplayTransform() { return displayTransform; } 01112 01118 void setDisplayTransform(DVPSDisplayTransform transform) { displayTransform = transform; } 01119 01129 Uint16 convertPValueToDDL(Uint16 pvalue, unsigned int bits = 8); 01130 01138 OFCondition writeHardcopyImageAttributes(DcmItem &dset); 01139 01143 const char *getCurrentImageModality(); 01144 01153 Uint16 findOverlayGroup(Uint16 currentGroup=0); 01154 01163 void renderPixelData(OFBool display = OFTrue); 01164 01170 DVPSDisplayedArea *getDisplayedAreaSelection(); 01171 01176 DVPSSoftcopyVOI *getCurrentSoftcopyVOI(); 01177 01178 private: 01179 01187 static OFCondition activateOverlayHelper( 01188 DVPSOverlay& ovl, 01189 DicomImage &image, 01190 OFBool asShutter = OFFalse, 01191 Uint16 pvalue = 0); 01192 01193 /* connection with dcmimage */ 01194 01198 DcmDataset *currentImageDataset; 01203 DcmFileFormat *currentImageFileformat; 01207 DicomImage *currentImage; 01211 DicomImage *previewImage; 01214 unsigned long currentImageWidth; 01217 unsigned long currentImageHeight; 01220 unsigned long renderedImageWidth; 01223 unsigned long renderedImageHeight; 01226 signed long renderedImageTop; 01230 signed long renderedImageLeft; 01234 signed long renderedImageBottom; 01237 signed long renderedImageRight; 01240 char *currentImageSOPClassUID; 01243 char *currentImageSOPInstanceUID; 01247 unsigned long currentImageSelectedFrame; 01253 OFBool currentImageOwned; 01257 OFBool currentImageVOIValid; 01261 OFBool currentImagePLUTValid; 01264 OFBool currentImageFlip; 01267 DVPSRotationType currentImageRotation; 01272 int currentImageOverlaysValid; 01273 01276 DVPSCurve_PList currentImageCurveList; 01279 DVPSVOILUT_PList currentImageVOILUTList; 01282 DVPSVOIWindow_PList currentImageVOIWindowList; 01283 01286 DcmCodeString currentImageModality; 01287 01290 OFBool currentImageMonochrome1; 01291 01295 DVPSDisplayTransform displayTransform; 01296 01299 OFBool imageInverse; 01300 01303 DiDisplayFunction **displayFunction; 01304 01307 unsigned long minimumPrintBitmapWidth; 01308 01311 unsigned long minimumPrintBitmapHeight; 01312 01315 unsigned long maximumPrintBitmapWidth; 01316 01319 unsigned long maximumPrintBitmapHeight; 01320 01323 unsigned long maximumPreviewImageWidth; 01324 01327 unsigned long maximumPreviewImageHeight; 01328 01329 }; 01330 01331 #endif 01332 01333 /* 01334 * $Log: dvpstat.h,v $ 01335 * Revision 1.47 2010-10-14 13:16:37 joergr 01336 * Updated copyright header. Added reference to COPYRIGHT file. 01337 * 01338 * Revision 1.46 2009-11-24 14:12:58 uli 01339 * Switched to logging mechanism provided by the "new" oflog module. 01340 * 01341 * Revision 1.45 2009-05-28 10:55:38 joergr 01342 * Fixed various Doxygen API documentation issues. 01343 * 01344 * Revision 1.44 2005/12/08 16:04:07 meichel 01345 * Changed include path schema for all DCMTK header files 01346 * 01347 * Revision 1.43 2003/09/05 14:30:06 meichel 01348 * Introduced new API methods that allow Displayed Areas to be queried 01349 * and set either relative to the image (ignoring rotation and flip) or 01350 * in absolute values as defined in the standard. Rotate and flip methods 01351 * now adjust displayed areas in the presentation state. 01352 * 01353 * Revision 1.42 2003/08/27 14:57:19 meichel 01354 * Splitted class DVPresentationState into a base class DcmPresentationState 01355 * that does not depend on module dcmimgle and current derived class with 01356 * public API identical to the previous version. 01357 * 01358 * Revision 1.41 2002/12/09 13:29:49 joergr 01359 * Renamed parameter/local variable to avoid name clashes with global 01360 * declaration left and/or right (used for as iostream manipulators). 01361 * 01362 * Revision 1.40 2001/09/26 15:36:17 meichel 01363 * Adapted dcmpstat to class OFCondition 01364 * 01365 * Revision 1.39 2001/06/01 15:50:23 meichel 01366 * Updated copyright header 01367 * 01368 * Revision 1.38 2000/11/13 15:50:43 meichel 01369 * Added dcmpstat support methods for creating image references 01370 * in SR documents. 01371 * 01372 * Revision 1.37 2000/07/04 15:58:03 joergr 01373 * Added support for overriding the presentation LUT settings made for the 01374 * image boxes. 01375 * 01376 * Revision 1.36 2000/06/09 10:14:12 joergr 01377 * Added support for rendering inverse presentation LUT into print bitmaps. 01378 * 01379 * Revision 1.35 2000/06/08 17:36:51 joergr 01380 * Corrected bug in addImageReferenceToPState(). 01381 * 01382 * Revision 1.34 2000/06/02 16:00:53 meichel 01383 * Adapted all dcmpstat classes to use OFConsole for log and error output 01384 * 01385 * Revision 1.33 2000/05/30 14:21:24 joergr 01386 * Renamed some variables to avoid compiler warnings (reported by gcc 2.9x with 01387 * additional compiler flags). 01388 * 01389 * Revision 1.32 2000/05/30 13:47:03 joergr 01390 * Added support for multi-frame images and multiple references from a single 01391 * presentation to a number of images. 01392 * Removed methods which were already marked as "retired". 01393 * Added new function allowing to set a VOILUT created from a given gamma 01394 * value. 01395 * 01396 * Revision 1.31 2000/03/08 16:28:57 meichel 01397 * Updated copyright header. 01398 * 01399 * Revision 1.30 2000/02/29 12:16:16 meichel 01400 * Fixed bug in dcmpstat library that caused Monochrome1 images 01401 * to be printed inverse if a Presentation LUT was applied. 01402 * 01403 * Revision 1.29 1999/11/15 19:02:16 joergr 01404 * Changed behaviour of method getOverlayData(): parameter 'transp' replaced by 01405 * 'fore' to specify the foreground color used for the overlay plane. 01406 * 01407 * Revision 1.28 1999/11/03 10:36:32 joergr 01408 * Enhanced comments for methods dealing with arrays of pixel data. 01409 * 01410 * Revision 1.27 1999/10/20 10:49:20 joergr 01411 * Enhanced method getOverlayData to support 12 bit data for print. 01412 * Enhanced method convertPValueToDDL to support 12 bit data for print. 01413 * Added support for a down-scaled preview image of the current DICOM image 01414 * (e.g. useful for online-windowing or print preview). 01415 * 01416 * Revision 1.26 1999/10/19 16:24:50 meichel 01417 * Corrected handling of MONOCHROME1 images when used with P-LUTs 01418 * 01419 * Revision 1.25 1999/10/13 14:11:57 meichel 01420 * Added config file entries and access methods 01421 * for user-defined VOI presets, log directory, verbatim logging 01422 * and an explicit list of image display formats for each printer. 01423 * 01424 * Revision 1.24 1999/10/07 17:21:51 meichel 01425 * Reworked management of Presentation LUTs in order to create tighter 01426 * coupling between Softcopy and Print. 01427 * 01428 * Revision 1.23 1999/09/10 12:46:48 meichel 01429 * Added implementations for a number of print API methods. 01430 * 01431 * Revision 1.22 1999/09/10 09:02:32 joergr 01432 * Added support for CIELAB display function. New methods to handle display 01433 * functions. Old methods are marked as retired and should be removed asap. 01434 * 01435 * Revision 1.21 1999/09/07 09:04:37 joergr 01436 * Completed support for getting a print bitmap out of a pstate object. 01437 * 01438 * Revision 1.20 1999/09/01 16:14:42 meichel 01439 * Added support for requested image size to print routines 01440 * 01441 * Revision 1.19 1999/08/27 15:57:58 meichel 01442 * Added methods for saving hardcopy images and stored print objects 01443 * either in file or in the local database. 01444 * 01445 * Revision 1.18 1999/08/25 16:48:01 joergr 01446 * Added minimal support to get a print bitmap out of a pstate object. 01447 * 01448 * Revision 1.17 1999/07/30 13:34:51 meichel 01449 * Added new classes managing Stored Print objects 01450 * 01451 * Revision 1.16 1999/07/22 16:39:13 meichel 01452 * Adapted dcmpstat data structures and API to supplement 33 letter ballot text. 01453 * 01454 * Revision 1.15 1999/05/04 12:28:11 meichel 01455 * Removed carriage returns 01456 * 01457 * Revision 1.14 1999/04/27 11:23:57 joergr 01458 * Added method to check whether current image is inverse or not. 01459 * 01460 * Revision 1.13 1999/03/22 09:05:35 joergr 01461 * Added parameter to get value of (transparent) background color for method 01462 * getOverlayData. 01463 * 01464 * Revision 1.12 1999/03/03 13:26:06 joergr 01465 * Added method to invert an image by changing the presentation state LUT or 01466 * shape. 01467 * Moved method 'isBartenTransformPossible()' from presentation state class to 01468 * interface class. 01469 * 01470 * Revision 1.11 1999/03/02 13:01:02 joergr 01471 * Added method to presentation state class that checks whether Barten 01472 * transformation is possible or not. 01473 * 01474 * Revision 1.10 1999/02/25 18:40:08 joergr 01475 * Added method to fill pixel data into an externally handled storage area. 01476 * 01477 * Revision 1.9 1999/02/18 11:36:38 meichel 01478 * Added new method convertPValueToDDL() to DVPresentationState 01479 * that maps P-Values to DDLs. 01480 * 01481 * Revision 1.8 1999/02/17 10:05:32 meichel 01482 * Moved creation of Display Function object from DVPresentationState to 01483 * DVInterface to avoid unnecessary re-reads. 01484 * 01485 * Revision 1.7 1999/02/09 15:58:57 meichel 01486 * Implemented bitmap shutter activation amd method for 01487 * exchanging graphic layers. 01488 * 01489 * Revision 1.6 1999/02/05 17:45:36 meichel 01490 * Added config file entry for monitor characteristics file. Monitor charac- 01491 * teristics are passed to dcmimage if present to activate Barten transform. 01492 * 01493 * Revision 1.5 1999/01/15 17:33:05 meichel 01494 * added methods to DVPresentationState allowing to access the image 01495 * references in the presentation state. Also added methods allowing to 01496 * get the width and height of the attached image. 01497 * 01498 * Revision 1.4 1999/01/11 13:35:49 meichel 01499 * added new methods getImageAspectRatio, getImageMinMaxPixelRange and 01500 * getImageMinMaxPixelValue to class DVPresentationState. 01501 * 01502 * Revision 1.3 1998/12/22 17:57:07 meichel 01503 * Implemented Presentation State interface for overlays, 01504 * VOI LUTs, VOI windows, curves. Added test program that 01505 * allows to add curve data to DICOM images. 01506 * 01507 * Revision 1.2 1998/12/14 16:10:35 meichel 01508 * Implemented Presentation State interface for graphic layers, 01509 * text and graphic annotations, presentation LUTs. 01510 * 01511 * Revision 1.1 1998/11/27 14:50:34 meichel 01512 * Initial Release. 01513 * 01514 * 01515 */