------------------------------------------------------------------ -- -- NAME: PIXELS - BODY -- DISCREPANCY REPORTS: ------------------------------------------------------------------ -- file: pixels_b.ada -- level: 0a, 1a, 2a, 0b, 1b, 2b, 0c, 1c, 2c with WSM; with CGI_SUBTYPES_A; with GKS_OPERATING_STATE_LIST; with GKS_ERRORS; with GKS_STATE_LIST; with TRANSFORMATION_MATH; use WSM; use CGI_SUBTYPES_A; use GKS_OPERATING_STATE_LIST; use GKS_ERRORS; package body PIXELS is -- This is the package body providing the procedures to call the -- workstation manager to inquire information about pixels. -- -- Each of the procedures in this package inquires the -- GKS_OPERATING_STATE_LIST to check if GKS is in one -- of the states WSOP, WSAC, or SGOP. If is not, error -- indicator 7 occurs but no exception is raised. In addition, -- each procedure inquires the GKS_STATE_LIST to see if the -- workstation is in the set of open workstations. If it is not, -- error indicator 25 occurs but no exception is raised. procedure INQ_PIXEL_ARRAY_DIMENSIONS (WS : in WS_ID; CORNER_1_1 : in WC.POINT; CORNER_DX_DY : in WC.POINT; ERROR_INDICATOR : out ERROR_NUMBER; DIMENSIONS : out RASTER_UNIT_SIZE) is -- This procedure calls the workstation manager to obtain the -- dimensions of the pixel array. If the inquired information -- is available, the error indicator is returned by the workstation -- manager as 0. If the inquired information is not available, the -- workstation manager returns error 39 to indicate the reason -- for non-availability. -- -- WS - Determines the specified workstation whose device -- coordinate resolution will be used to calculate the -- dimension of the pixel array. -- CORNER_1_1 - Specifies the lower left point of the inquired -- pixel array area. -- CORNER_DX_DY - Specifies the upper right point of the inquired -- pixel array area. -- ERROR_INDICATOR - Returns an error code, if any. -- DIMENSIONS - Returns the dimensions in raster units of the -- inquired pixel area. GKS_INSTR : CGI_INQ_PIXEL_ARRAY_DIMENSIONS; begin -- The following if structure inquires the GKS_OPERATING_ -- STATE_LIST to see if GKS is in the correct state. Then -- it inquires the GKS_STATE_LIST to see if the WS is in the -- set of open workstations. If both conditions are true, -- the call to the WS_MANAGER is made. if (CURRENT_OPERATING_STATE = GKCL) or (CURRENT_OPERATING_STATE = GKOP) then ERROR_INDICATOR := NOT_WSOP_WSAC_SGOP; -- Error 7 DIMENSIONS := (X => RASTER_UNITS'FIRST, Y => RASTER_UNITS'FIRST); elsif not WS_IDS.IS_IN_LIST (WS,GKS_STATE_LIST.LIST_OF_OPEN_WS) then ERROR_INDICATOR := WS_NOT_OPEN; -- Error 25 DIMENSIONS := (X => RASTER_UNITS'FIRST, Y => RASTER_UNITS'FIRST); else GKS_INSTR.WS_TO_INQ_PIXEL_ARRAY_DIMENSIONS := WS; -- Transformation logic to transform the 2 points passed in -- from WC to NDC. GKS_INSTR.PIXEL_ARRAY_CORNER_1_1_INQ := TRANSFORMATION_MATH. WC_TO_NDC(GKS_STATE_LIST.LIST_OF_NORMALIZATION_TRANSFORMATIONS (GKS_STATE_LIST.CURRENT_NORMALIZATION_TRANSFORMATION) .NDC_FACTORS, CORNER_1_1); GKS_INSTR.PIXEL_ARRAY_CORNER_DX_DY_INQ := TRANSFORMATION_MATH. WC_TO_NDC(GKS_STATE_LIST.LIST_OF_NORMALIZATION_TRANSFORMATIONS (GKS_STATE_LIST.CURRENT_NORMALIZATION_TRANSFORMATION) .NDC_FACTORS, CORNER_DX_DY); WS_MANAGER (GKS_INSTR); if GKS_INSTR.ERROR_INDICATOR /= SUCCESSFUL then -- Error 0 if GKS_INSTR.ERROR_INDICATOR = WS_NOT_OUTPUT_OUTIN then -- Error 39 ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; else ERROR_INDICATOR := UNKNOWN; -- Error 2501 end if; else ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; end if; DIMENSIONS := GKS_INSTR.DIMENSIONS_INQ; end if; exception when NUMERIC_ERROR | CONSTRAINT_ERROR => ERROR_INDICATOR := ARITHMETIC; -- Error 308 end INQ_PIXEL_ARRAY_DIMENSIONS; procedure INQ_PIXEL_ARRAY (WS : in WS_ID; CORNER : in WC.POINT; DX : in RASTER_UNITS; DY : in RASTER_UNITS; ERROR_INDICATOR : out ERROR_NUMBER; INVALID_VALUES : out INVALID_VALUES_INDICATOR; PIXEL_ARRAY : out VARIABLE_PIXEL_COLOUR_MATRIX) is -- This procedure calls the workstation manager to obtain the -- presence of invalid values and the colour index array. If -- the inquired information is available, the error indicator -- is returned by the workstation manager as 0. If the inquired -- information is not available, the workstation manager returns -- either error 39, or 40 to indicate the reason for non- -- availability. -- -- WS - Determines the specified workstation whose pixels -- will be inquired for colour values. -- CORNER - The point in WC that will be transformed to NDC and -- sent to CGI as the initial point where the pixels will -- be inquired for colour values. -- DX, DY - These parameters provide the dimensions of the PIXEL_ARRAY -- when PIXEL_ARRAY is unconstrained. If PIXEL_ARRAY is -- constrained, then these parameters are ignored and the -- discriminants of PIXEL_ARRAY are used. -- ERROR_INDICATOR - Returns the error code, if any. -- INVALID_VALUES - A flag to indicate the presence of pixels -- which had been transformed outside the workstation's -- viewport. -- PIXEL_ARRAY - The array of colour values of the pixel area -- inquired on the workstation. It should be unconstrained so that -- any size matrix can be returned. If it is constrained, then the -- actual colour matrix will be truncated or will fill only a -- portion of the returned object. GKS_INSTR : CGI_INQ_PIXEL_ARRAY; INVALID_PIXEL_ARRAY : VARIABLE_PIXEL_COLOUR_MATRIX (PIXEL_ARRAY.DX,PIXEL_ARRAY.DY); begin -- The following if structure inquires the GKS_OPERATING_ -- STATE_LIST to see if GKS is in the correct state. Then -- it inquires the GKS_STATE_LIST to see if the WS is in the -- set of open workstations. If both conditions are true, -- the call to the WS_MANAGER is made. if (CURRENT_OPERATING_STATE = GKCL) or (CURRENT_OPERATING_STATE = GKOP) then ERROR_INDICATOR := NOT_WSOP_WSAC_SGOP; -- Error 7 INVALID_VALUES := INVALID_VALUES_INDICATOR'FIRST; PIXEL_ARRAY := INVALID_PIXEL_ARRAY; elsif not WS_IDS.IS_IN_LIST (WS,GKS_STATE_LIST.LIST_OF_OPEN_WS) then ERROR_INDICATOR := WS_NOT_OPEN; -- Error 25 INVALID_VALUES := INVALID_VALUES_INDICATOR'FIRST; PIXEL_ARRAY := INVALID_PIXEL_ARRAY; else GKS_INSTR.WS_TO_INQ_PIXEL_ARRAY := WS; -- Transformation logic to transform the point passed in -- from WC to NDC. GKS_INSTR.PIXEL_ARRAY_CORNER_INQ:=TRANSFORMATION_MATH.WC_TO_NDC (GKS_STATE_LIST.LIST_OF_NORMALIZATION_TRANSFORMATIONS (GKS_STATE_LIST.CURRENT_NORMALIZATION_TRANSFORMATION) .NDC_FACTORS, CORNER); if PIXEL_ARRAY'constrained then GKS_INSTR.DX_INQ := RASTER_UNITS(PIXEL_ARRAY.DX); GKS_INSTR.DY_INQ := RASTER_UNITS(PIXEL_ARRAY.DY); else GKS_INSTR.DX_INQ := DX; GKS_INSTR.DY_INQ := DY; end if; WS_MANAGER (GKS_INSTR); if GKS_INSTR.ERROR_INDICATOR /= SUCCESSFUL then -- Error 0 if (GKS_INSTR.ERROR_INDICATOR = WS_NOT_OUTPUT_OUTIN) or -- Error 39 (GKS_INSTR.ERROR_INDICATOR = WS_CANNOT_PIXEL_READBACK) then -- Error 40 ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; else ERROR_INDICATOR := UNKNOWN; -- Error 2501 end if; INVALID_VALUES := INVALID_VALUES_INDICATOR'FIRST; PIXEL_ARRAY := INVALID_PIXEL_ARRAY; else ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; -- Error 0 INVALID_VALUES := GKS_INSTR.INVALID_VALUES_INQ; if PIXEL_ARRAY'constrained then PIXEL_ARRAY.MATRIX := GKS_INSTR.PIXEL_ARRAY_INQ.all; else PIXEL_ARRAY := ( DX => GKS_INSTR.PIXEL_ARRAY_INQ'LENGTH(1), DY => GKS_INSTR.PIXEL_ARRAY_INQ'LENGTH(2), MATRIX => GKS_INSTR.PIXEL_ARRAY_INQ.all); end if; FREE_PIXEL_COLOUR_MATRIX (GKS_INSTR.PIXEL_ARRAY_INQ); end if; end if; exception when NUMERIC_ERROR | CONSTRAINT_ERROR => ERROR_INDICATOR := ARITHMETIC; -- Error 308 INVALID_VALUES := INVALID_VALUES_INDICATOR'FIRST; PIXEL_ARRAY := INVALID_PIXEL_ARRAY; end INQ_PIXEL_ARRAY; procedure INQ_PIXEL (WS : in WS_ID; POINT : in WC.POINT; ERROR_INDICATOR : out ERROR_NUMBER; PIXEL_COLOUR : out PIXEL_COLOUR_INDEX) is -- This procedure calls the workstation manager to obtain the -- colour index of the pixel. If the inquired information is -- available, the error indicator is returned by the workstation -- manager as 0. If the inquired information is not available, -- the error indicator is set to 39, or 40 to indicate the -- reason for non-availability. -- -- WS - The specified workstation. -- POINT - The WC point which when transformed to NDC will be -- passed to WS_MANAGER for inquiring the DC pixel colour. -- ERROR_INDICATOR - returns the error code, if any. -- PIXEL_COLOUR - Returns the colour of the pixel of a valid point -- on the workstation viewport. GKS_INSTR : CGI_INQ_PIXEL; begin -- The following if structure inquires the GKS_OPERATING_ -- STATE_LIST to see if GKS is in the correct state. Then -- it inquires the GKS_STATE_LIST to see if the WS is in the -- set of open workstations. If both conditions are true, -- the call to the WS_MANAGER is made. if (CURRENT_OPERATING_STATE = GKCL) or (CURRENT_OPERATING_STATE = GKOP) then ERROR_INDICATOR := NOT_WSOP_WSAC_SGOP; -- Error 7 PIXEL_COLOUR := PIXEL_COLOUR_INDEX'FIRST; elsif not WS_IDS.IS_IN_LIST (WS,GKS_STATE_LIST.LIST_OF_OPEN_WS) then ERROR_INDICATOR := WS_NOT_OPEN; -- Error 25 PIXEL_COLOUR := PIXEL_COLOUR_INDEX'FIRST; else GKS_INSTR.WS_TO_INQ_PIXEL := WS; -- Transformation logic to transform the point passed in -- from WC to NDC. GKS_INSTR.PIXEL_POINT_INQ := TRANSFORMATION_MATH.WC_TO_NDC (GKS_STATE_LIST.LIST_OF_NORMALIZATION_TRANSFORMATIONS (GKS_STATE_LIST.CURRENT_NORMALIZATION_TRANSFORMATION) .NDC_FACTORS, POINT); WS_MANAGER (GKS_INSTR); if GKS_INSTR.ERROR_INDICATOR /= SUCCESSFUL then -- Error 0 if (GKS_INSTR.ERROR_INDICATOR = WS_NOT_OUTPUT_OUTIN) or -- Error 39 (GKS_INSTR.ERROR_INDICATOR = WS_CANNOT_PIXEL_READBACK) then -- Error 40 ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; else ERROR_INDICATOR := UNKNOWN; -- Error 2501 end if; else ERROR_INDICATOR := GKS_INSTR.ERROR_INDICATOR; end if; PIXEL_COLOUR := GKS_INSTR.PIXEL_COLOUR_INQ; end if; exception when NUMERIC_ERROR | CONSTRAINT_ERROR => ERROR_INDICATOR := ARITHMETIC; end INQ_PIXEL; end PIXELS;