LDicomPrintSCU::UpdateImageBox

#include "ltdic.h"

L_INT LDicomPrintSCU::UpdateImageBox(pszImageBoxInstanceUID, pImage, pParameters, pszRefImageOverlayBoxInstanceUID = NULL, pszRefPresLUTInstanceUID = NULL)

L_CHAR L_FAR * pszImageBoxInstanceUID;

/* SOP Instance UID of the Image Box */

LDicomDS* pImage;

/* image to be printed in the Image Box */

const pIMAGEBOXPARAMETERS pParameters;

/* image Box parameters to be updated */

L_CHAR L_FAR * pszRefImageOverlayBoxInstanceUID;

/* Referenced Image Overlay Box */

L_CHAR L_FAR * pszRefPresLUTInstanceUID;

/* Referenced Presentation LUT */

Requests the Print SCP to update the specified Basic Grayscale/Color Image Box SOP Instance.

Parameter

Description

pszImageBoxInstanceUID

Character string that contains the SOP Instance UID of the Image Box to be updated. The function will return an error if this is NULL or if an empty string is specified. The function LDicomPrintSCU::GetImageBoxInstanceUID returns the SOP Instance UID of a particular Image Box.

pImage

Pointer to an LDicomDS object that contains the image to be printed in the specified Image Box. If this is set to NULL, the Print SCP will be instructed to erase the image (if there is one) in the specified Image Box.

pParameters

Pointer to an IMAGEBOXPARAMETERS structure that specifies the Image Box parameters to be updated. The function will return an error if this parameter is set to NULL or if the Image Position specified is less than 1.

pszRefImageOverlayBoxInstanceUID

Character string that contains the SOP Instance UID of a previously created Basic Print Image Overlay Box SOP Instance to be referenced by the Image Box. This can be set to NULL if the reference is not to be updated; in this case, the corresponding Attribute will not be included in the request to the Print SCP. If an empty string is specified and the Image Box already references an Image Overlay Box, then the update will remove that reference. Refer to the function LDicomPrintSCU::CreateOverlayBox for creating Image Overlay Boxes.

pszRefPresLUTInstanceUID

Character string that contains the SOP Instance UID of a previously created Presentation LUT SOP Instance to be referenced by the Image Box. This can be set to NULL if the reference is not to be updated; in this case, the corresponding Attribute will not be included in the request to the Print SCP. If an empty string is specified and the Image Box already references a Presentation LUT, then the update will remove that reference. Since only a Grayscale Image Box may reference a Presentation LUT, the function ignores this parameter for Color Image Boxes. Refer to the function LDicomPrintSCU::CreatePresentationLUT for creating Presentation LUTs.

Returns

0

The specified Basic Grayscale/Color Image Box SOP Instance was updated successfully.

DICOM_ERROR_PRINTSCU_FAILURE_STATUS

The response of the Print SCP specifies a Failure status code.

DICOM_ERROR_PRINTSCU_CLASS_NOT_SUPPORTED

Neither the Basic Grayscale Print Management Meta SOP Class nor the Basic Color Print Management Meta SOP Class is supported on the Association.

> 0

An error occurred. Refer to Return Codes.

Comments

When the Print SCP is requested to create a Film Box, it will also create one or more Image Boxes, based on the Image Display Format. This function updates a particular Image Box. The Image Box specified (by the SOP Instance UID) must belong to the current (last created) Film Box.

The type of the Image Boxes created by the Print SCP (Grayscale or Color) depends on the Meta SOP Class of the Film Session created at first. Refer to the function LDicomPrintSCU::CreateFilmSession for more information.

The function will not return until it receives the response of the Print SCP, or an error occurs. The function LDicomPrintSCU::GetLastOperationStatus can be used to obtain the status code specified in the response of the Print SCP. When the return value of the function UpdateImageBox is 0, then the Image Box was updated successfully, with either a Success or Warning status code in the response of the Print SCP.

The parameter pParameters points to an IMAGEBOXPARAMETERS structure that specifies the Image Box parameters to be updated. In this structure, if a string member is NULL, then the corresponding Attribute will not be included in the request to the Print SCP and hence will not be updated. Similarly, if a numeric member (that specifies an Attribute) is negative, the corresponding Attribute will not be included in the request and hence will not be updated. Notice that since the Attributes Min Density, Max Density, and Configuration Information are defined only for Grayscale Image Boxes, the function will ignore the following structure members for Color Image Boxes:

nMinDensity

nMaxDensity

pszConfigurationInformation

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

Class Members, LDicomPrintSCU::CreateFilmSession, LDicomPrintSCU::CreateFilmBox, LDicomPrintSCU::GetImageBoxesCount, LDicomPrintSCU::GetImageBoxInstanceUID, LDicomPrintSCU::GetDefaultImageBoxParameters, LDicomPrintSCU::FreeImageBoxesInstanceUIDs, LDicomPrintSCU::GetLastOperationStatus, LDicomPrintSCU::CreateOverlayBox, LDicomPrintSCU::CreatePresentationLUT

Topics:

Print Management SCU

 

DICOM Print Management Service Class User: Functions

Example

L_VOID PerformBasicPM()
{
   LDicomPrintSCU PrintSCU; 
   //CPrintSCU PrintSCU; 

   PrintSCU.SetTimeout (60); // 60 seconds

   L_CHAR szMsg[32]; 

   // Establish the Association
   L_INT iRet = PrintSCU.Associate ("10.0.2.20", 7104, "PrintSCP", "PrintSCU",
                            PRINTSCU_BASIC_GRAYSCALE_PM_META_SOP_CLASS |
                            PRINTSCU_BASIC_COLOR_PM_META_SOP_CLASS |
                            PRINTSCU_BASIC_ANNOTATION_BOX_SOP_CLASS |
                            PRINTSCU_BASIC_PRINT_IMAGE_OVERLAY_BOX_SOP_CLASS |
                            PRINTSCU_PRESENTATION_LUT_SOP_CLASS |
                            PRINTSCU_PRINT_JOB_SOP_CLASS |
                            PRINTSCU_PRINTER_CONFIGURATION_RETRIEVAL_SOP_CLASS); 
   if (iRet == DICOM_ERROR_PRINTSCU_ASSOCIATE_RQ_REJECTED) 
   {
      L_UCHAR nSource, nReason; 
      PrintSCU.GetAssociateRejectInfo (NULL, &nSource, &nReason); 
      
      wsprintf(szMsg, "Source = %i, Reason = %i", nSource, nReason); 
      MessageBox(NULL, szMsg, "Association Request was Rejected", MB_OK); 
      return; 
   }
   else if (iRet != DICOM_SUCCESS) 
   {
      wsprintf(szMsg, "Error code: %i", iRet); 
      MessageBox(NULL, szMsg, "Failed to Establish the Association", MB_OK); 
      return; 
   }

   // Display some printer info
   //GetPrinterInfo(PrintSCU); 

   // Display some printer configuration info
   //GetPrinterConfigInfo(PrintSCU); 

   FILMSESSIONPARAMETERS FilmSessionParams; 

   // Create a Film Session
   PrintSCU.GetDefaultFilmSessionParameters (&FilmSessionParams, 
                                            sizeof(FILMSESSIONPARAMETERS)); 
   FilmSessionParams.nNumberOfCopies = 1; 
   PrintSCU.CreateFilmSession (&FilmSessionParams); 
   MessageBox(NULL, PrintSCU.GetFilmSessionInstanceUID (),
              "Film Session SOP Instance UID", MB_OK); 

   // Update the Film Session to specify a "MED" Print Priority
   PrintSCU.GetDefaultFilmSessionParameters (&FilmSessionParams, 
                                            sizeof(FILMSESSIONPARAMETERS)); 
   FilmSessionParams.pszPrintPriority = "MED";
   PrintSCU.UpdateFilmSession (&FilmSessionParams); 

   FILMBOXPARAMETERS FilmBoxParams; 
   PrintSCU.GetDefaultFilmBoxParameters (&FilmBoxParams, 
                                        sizeof(FILMBOXPARAMETERS)); 

   if (PrintSCU.IsClassSupported (PRINTSCU_BASIC_ANNOTATION_BOX_SOP_CLASS)) 
   {
      FilmBoxParams.pszAnnotationDisplayFormatID = "SomeID";
   }

   // Create a Film Box
   PrintSCU.CreateFilmBox (&FilmBoxParams); 
   MessageBox(NULL, PrintSCU.GetFilmBoxInstanceUID (),
              "Film Box SOP Instance UID", MB_OK); 

   L_PCSTR pszPresLUTInstanceUID = NULL; 

   // Create a Presentation LUT
   if (PrintSCU.IsClassSupported (PRINTSCU_PRESENTATION_LUT_SOP_CLASS)) 
   {
      LDicomDS PresLUT; 
      if (PresLUT.LoadDS("C:\\PresLUT.dic", DS_LOAD_CLOSE) == 0) 
      {
         PrintSCU.CreatePresentationLUT (&PresLUT); 
         
         pszPresLUTInstanceUID = PrintSCU.GetPresentationLUTInstanceUID ();
         MessageBox(NULL, pszPresLUTInstanceUID, 
                    "Pres LUT SOP Instance UID", MB_OK); 
      }
   }
   if (pszPresLUTInstanceUID) 
   {
      // Update the Film Box to reference the Presentation LUT we just created
      PrintSCU.UpdateFilmBox (NULL, pszPresLUTInstanceUID); 
   }

   L_PCSTR pszOverlayBoxInstanceUID = NULL; 

   // Create an Image Overlay Box
   if (PrintSCU.IsClassSupported (
                   PRINTSCU_BASIC_PRINT_IMAGE_OVERLAY_BOX_SOP_CLASS)) 
   {
      LDicomDS Overlay; 
      if (Overlay.LoadDS("C:\\Overlay.dic", DS_LOAD_CLOSE) == 0) 
      {
         OVERLAYBOXPARAMETERS OverlayParams; 
         PrintSCU.GetDefaultOverlayBoxParameters (&OverlayParams, 
                                                 sizeof(OVERLAYBOXPARAMETERS)); 

         PrintSCU.CreateOverlayBox (&Overlay, &OverlayParams); 
         
         pszOverlayBoxInstanceUID = PrintSCU.GetOverlayBoxInstanceUID ();
         MessageBox(NULL, pszOverlayBoxInstanceUID, 
                    "Image Overlay Box SOP Instance UID", MB_OK); 
      }
   }

   // The image to be printed in the Image Box
   LDicomDS Image; 
   Image.LoadDS ("C:\\Image.dic", DS_LOAD_CLOSE); 

   // Update the Image Box. Since the Image Display Format of the Film Box was
   // set to "STANDARD\1,1", then we are supposed to have one Image Box created
   // by the Print SCP. 
   if (PrintSCU.GetImageBoxesCount ())
   {
      L_PCSTR pszImageBoxInstanceUID = PrintSCU.GetImageBoxInstanceUID (0); 
      MessageBox(NULL, pszImageBoxInstanceUID, 
                 "Image Box SOP Instance UID", MB_OK); 

      IMAGEBOXPARAMETERS ImageBoxParams; 
      PrintSCU.GetDefaultImageBoxParameters(&ImageBoxParams, 
                                            sizeof(IMAGEBOXPARAMETERS)); 
      ImageBoxParams.nImagePosition = 1; 

      PrintSCU.UpdateImageBox (pszImageBoxInstanceUID, 
                              &Image, 
                              &ImageBoxParams, 
                              pszOverlayBoxInstanceUID); 

      // We don't need them any more
      PrintSCU.FreeImageBoxesInstanceUIDs();
   }

   // Update the Annotation Boxes (if there are any) 
   L_UINT32 uAnnBoxesCount = PrintSCU.GetAnnotationBoxesCount ();
   for (L_UINT32 i = 0; i < uAnnBoxesCount; i++)
   {
      PrintSCU.UpdateAnnotationBox (PrintSCU.GetAnnotationBoxInstanceUID (i), 
                                   L_UINT16(i + 1), "Some Text");
   }
   PrintSCU.FreeAnnotationBoxesInstanceUIDs (); // We don't need them any more

   // Change the Overlay Origin of the Image Overlay Box referenced by the
   // Image Box
   if (pszOverlayBoxInstanceUID) 
   {
      OVERLAYBOXPARAMETERS OverlayParams; 
      PrintSCU.GetDefaultOverlayBoxParameters (&OverlayParams, 
                                              sizeof(OVERLAYBOXPARAMETERS)); 
      
      OverlayParams.nOverlayOriginRow = 10; 
      OverlayParams.nOverlayOriginColumn = 10; 

      PrintSCU.UpdateOverlayBox (pszOverlayBoxInstanceUID, 
                                NULL, &OverlayParams, TRUE); 
   }

   // Print the Film Session (or the Film Box; there is no difference since we
   // have a single Film Box in the Film Session) 
   if (TRUE) 
   {
      PrintSCU.PrintFilmSession ();
   }
   else
   {
      PrintSCU.PrintFilmBox ();
   }

   // Display some info about the Print Job
   if (PrintSCU.IsClassSupported (PRINTSCU_PRINT_JOB_SOP_CLASS)) 
   {
      //GetPrintJobInfo(PrintSCU, PrintSCU.GetPrintJobInstanceUID ());
   }

   // Delete the Film Box (anyway, it would be deleted when the Film Session
   // is deleted) 
   PrintSCU.DeleteFilmBox ();

   // Delete the Film Session
   PrintSCU.DeleteFilmSession ();

   // Delete the Presentation LUT
   if (pszPresLUTInstanceUID) 
   {
      PrintSCU.DeletePresentationLUT (pszPresLUTInstanceUID); 
   }

   // Delete the Image Overlay Box
   if (pszOverlayBoxInstanceUID) 
   {
      PrintSCU.DeleteOverlayBox (pszOverlayBoxInstanceUID); 
   }

   // Release the Association and close the connection
   PrintSCU.Release();
}