------------------------------------------------------------------ -- -- NAME: TEK_CONTROL_OPERATIONS -- DISCREPANCY REPORTS: ------------------------------------------------------------------ -- FILE: TEK_WS_CONT_1C_B.ADA -- LEVEL: 1C, 2C with TEK_EXTENDED_CONTROL_OPERATIONS; with TEK; with GKS_ERRORS; with GKS_ESCAPE; with SEGMENT_STATE_LIST_TYPES; with WSR_ESCAPE; with WSR_WS_TRANSFORMATION; with TEK_COLOUR_OPERATIONS; with TEK_WS_TABLES; with TEK_TASKS; use GKS_ESCAPE; -- for operator visibility package body TEK_CONTROL_OPERATIONS is -- The following packages are used in this package for the given -- reasons: -- The TEK package contains all procedures that are -- used in the device driver. -- The GKS_ERRORS package contain all the error constants. procedure OPEN_WS (WS : in WS_ID; CONNECTION : in CGI.ACCESS_CONNECTION_ID_TYPE; TYPE_OF_WS : in WS_TYPE; ATTRIBUTES : in out OUTPUT_ATTRIBUTES_TYPE.OUTPUT_ATTRIBUTES; ERROR_INDICATOR : out ERROR_NUMBER) is -- This procedure calls the device driver procedure to open the device -- and establish communication to it. If there is no error in opening -- the device it creates and initializes a WS_STATE_LIST from its -- WS_DESCRIPTION_TABLE. It initializes the OUTPUT_ATTR record in the -- WS_STATE_LIST from the parameter ATTRIBUTES. -- -- The parameters used in this procedure are: -- WS - The workstation id the application programmer assigned to -- associate the workstation with. -- CONNECTION - The physical location the device driver needs to -- decide which device to open. -- TYPE_OF_WS - The type of workstation that is being opened. -- ATTRIBUTES - A copy of the output attributes stored in the GKS_STATE_ -- LIST. -- ERROR_INDICATOR - contains any error that may be returned while -- attempting to open the device. CONNECTION_ID : VARIABLE_CONNECTION_ID(CONNECTION'length); -- Creates an object the length of the string access type passed in. begin -- Call the TEK_WS_TBLS package to initialize the WS_STATE_ -- LIST and add its WS_ID to the LIST_OF_WS_STATE_LISTS. CONNECTION_ID.CONNECT := CONNECTION.all; -- Call the device driver to open the workstation TEK.INIT(CONNECTION_ID.CONNECT, WS); ERROR_INDICATOR := GKS_ERRORS.SUCCESSFUL; TEK_WS_TABLES.ADD_STATE_LIST_TO_LIST (WS, CONNECTION_ID, TYPE_OF_WS, ATTRIBUTES, ERROR_INDICATOR); declare WS_SL : WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR; ERROR : ERROR_NUMBER; -- A dummy error indicator that will always be successful. -- When this error indicator is returned it is expected that -- it will be successful. The device has already been opened -- and the ws state list allocated, therefore no other error -- can happen. Since the colours and indices SET_COLOUR_ -- REPRESENTATION procedure receives are from its own -- description table it is assumed that they are valid, -- therefore this error indicator does not need to be checked. begin WS_SL := TEK_WS_TABLES.GET_STATE_LIST_PTR(WS); -- Initialize the Look up table on the device. for I in TEK_WS_TABLES.TEK_WS_DT .PREDEFINED_COLOUR_REP'range loop TEK_COLOUR_OPERATIONS.SET_COLOUR_REPRESENTATION (WS_SL, COLOUR_INDEX(I), TEK_WS_TABLES.TEK_WS_DT.PREDEFINED_COLOUR_REP(I), ERROR); end loop; end; TEK.UPDATE; TEK_TASKS.START_TASKS; end OPEN_WS; procedure CLOSE_WS (WS_ST_LST : in out WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR) is -- This procedure calls a procedure in the device driver to -- flush the device buffer. It goes through its list of segment state -- list and deallocates them. It then calls the DELETE_WS_STATE- -- LIST procedure in the TEK_WS_TABLES package to deallocate the -- WS_STATE_LIST. -- -- The following parameter is used in theis procedure: -- WS_ST_LST - The workstation state list of the workstation being -- closed. NEW_SEGMENT, SEGMENT : SEGMENT_STATE_LIST_TYPES.SEG_STATE_LIST_PTR; -- The preceding are used to go through the list of stored segments to -- delete them. function "=" (A,B : SEGMENT_STATE_LIST_TYPES.SEG_STATE_LIST_PTR) return BOOLEAN renames SEGMENT_STATE_LIST_TYPES."="; begin TEK_TASKS.STOP_TASKS(WS_ST_LST); TEK.UPDATE; -- Deallocate all the stored segment state list on the workstation. SEGMENT := WS_ST_LST.LIST_OF_SEG_ST_LSTS.LOW_PRIORITY_SEG; while SEGMENT /= NULL loop NEW_SEGMENT := SEGMENT.HIGHER_PRIORITY_SEG; SEGMENT_STATE_LIST_TYPES.FREE_SEGMENT_STATE_LIST (SEGMENT); SEGMENT := NULL; SEGMENT := NEW_SEGMENT; end loop; WS_ST_LST.LIST_OF_SEG_ST_LSTS.LOW_PRIORITY_SEG := NULL; WS_ST_LST.LIST_OF_SEG_ST_LSTS.HIGH_PRIORITY_SEG := NULL; -- Delete the WS_STATE_LIST from the list. TEK_WS_TABLES.DELETE_STATE_LIST_FROM_LIST( WS_ST_LST .WORKSTATION_ID); TEK.FINISH; end CLOSE_WS; procedure CLEAR_WS (WS_ST_LST : in out WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR; FLAG : in CONTROL_FLAG) is -- This procedure calls the UPDATE procedure that empties the device -- buffer. It then updates the WS_ST_LST and calls the device driver -- procedure CLEAR to clear the display. -- -- The following parameters are used in this procedure: -- WS_ST_LST - The workstation state list for the specified device. -- FLAG - A flag used to control if the display surface should be -- cleared needlessly. NEW_SEGMENT, SEGMENT : SEGMENT_STATE_LIST_TYPES.SEG_STATE_LIST_PTR; -- The preceding are used to go through the list of stored segments. function "=" (A,B : SEGMENT_STATE_LIST_TYPES.SEG_STATE_LIST_PTR) return BOOLEAN renames SEGMENT_STATE_LIST_TYPES."="; begin -- Execute all deferred actions. TEK.UPDATE; -- Check the FLAG if it's ALWAYS or if the WS_DISPLAY_SURFACE is -- NOTEMPTY then clear the device. if FLAG = ALWAYS or else WS_ST_LST.WS_DISPLAY_SURFACE = NOTEMPTY then -- Clear the display. TEK.CLEAR; -- Flush the buffer to get the CLEAR out TEK.UPDATE; end if; -- If the WS_XFORM_UPDATE_STATE entry in the WS_OUTPUT_STATE_ -- LIST is PENDING, the CURRENT_WS_WINDOW and CURRENT_WS_ -- VIEWPORT entries in the WS_OUTPUT_STATE LIST are assigned -- the values of the REQUESTED_WS_WINDOW and REQUESTED_WS_ -- VIEWPORT entries; the WS_XFORM_UPDATE_STATE entry is set -- to NOTPENDING. The package WSR_WS_TRANSFORMATION also -- computes the EFFECTIVE_CLIPPING_RECTANGLE. if WS_ST_LST.WS_XFORM_UPDATE_STATE = PENDING then WSR_WS_TRANSFORMATION.UPDATE_WS_TRANSFORMATION( WS_ST_LST ); end if; -- Deallocate the set of segment names in the workstation. WS_ST_LST.SET_OF_STORED_SEGS := GKS_TYPES.SEGMENT_NAMES.NULL_LIST; -- Deallocate all the stored segment state list on the workstation. SEGMENT := WS_ST_LST.LIST_OF_SEG_ST_LSTS.LOW_PRIORITY_SEG; while SEGMENT /= NULL loop NEW_SEGMENT := SEGMENT.HIGHER_PRIORITY_SEG; SEGMENT_STATE_LIST_TYPES.FREE_SEGMENT_STATE_LIST (SEGMENT); SEGMENT := NULL; SEGMENT := NEW_SEGMENT; end loop; WS_ST_LST.LIST_OF_SEG_ST_LSTS.LOW_PRIORITY_SEG := NULL; WS_ST_LST.LIST_OF_SEG_ST_LSTS.HIGH_PRIORITY_SEG := NULL; -- The WS_NEW_FRAME_ACTION entry in the WS_OUTPUT_STATE_LIST -- is set to NO. WS_ST_LST.WS_NEW_FRAME_ACTION := NO; -- The WS_DISPLAY_SURFACE entry in the WS_OUTPUT_STATE_LIST -- is set to EMPTY. WS_ST_LST.WS_DISPLAY_SURFACE := EMPTY; end CLEAR_WS; procedure UPDATE_WS (WS_ST_LST : in out WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR; REGENERATION : in UPDATE_REGENERATION_FLAG) is -- This procedure updates the workstation. Since this is a level ma -- and 0a procedure there is no implicit regeneration of all visible -- segments stored on this workstation done in this procedure. -- -- The following parameters are used in this procedure: -- WS_ST_LST - The workstation state list for the specified device. -- REGENERATION - A flag used to determine if an implicit regeneration -- should be done with this UPDATE_WS call. begin -- Call the device driver to flush all deferred actions. TEK.UPDATE; -- IF the REGENERATION flag is set to PERFORM and the -- WS_NEW_FRAME_ACTION entry in the WS_STATE_LIST is -- YES, then the following actions will be performed: if REGENERATION = PERFORM and WS_ST_LST .WS_NEW_FRAME_ACTION = YES then -- The display surface is cleared only if the WS_DISPLAY_ -- SURFACE entry in the WS_STATE_LIST is NOTEMPTY. -- The entry is set to EMPTY. if WS_ST_LST.WS_DISPLAY_SURFACE = NOTEMPTY then TEK.CLEAR; WS_ST_LST.WS_DISPLAY_SURFACE := EMPTY; end if; -- If the WS_XFORM_UPDATE_STATE entry in the WS_STATE_LIST is -- PENDING, the CURRENT_WS_WINDOW and CURRENT_WS_VIEWPORT -- entries in the WS_OUTPUT_STATE LIST are assigned the values -- of the REQUESTED_WS_WINDOW and REQUESTED_WS_VIEWPORT entries; -- the WS_XFORM_UPDATE_STATE entry is set to NOTPENDING. if WS_ST_LST.WS_XFORM_UPDATE_STATE = PENDING then -- The following procedure updates the transformation state -- and compute the new EFFECTIVE_CLIPPING_RECTANGLE in the -- workstation state list. WSR_WS_TRANSFORMATION.UPDATE_WS_TRANSFORMATION( WS_ST_LST ); end if; -- PERFORM flag requires that all segments be redrawn. TEK_EXTENDED_CONTROL_OPERATIONS.REDRAW_ALL_SEGMENTS_ON_WS (WS_ST_LST); -- The WS_NEW_FRAME_ACTION entry in the WS_STATE_LIST -- is set to NO. WS_ST_LST.WS_NEW_FRAME_ACTION := NO; end if; end UPDATE_WS; procedure ESCAPE ( WS_SL : in out WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR; ESCAPE_NAME : in GKS_ESCAPE.ESCAPE_ID; ESCAPE_DATA_IN : in CGI.ACCESS_ESC_DATA_RECORD; ESCAPE_DATA_OUT : out CGI.ACCESS_ESC_DATA_RECORD) is -- -- This procedure processes the specified workstation specific -- escape function. -- -- WS_SL - a pointer to the workstation state list associated with the WS_ID. -- ESCAPE_NAME - the ESCAPE_ID number. -- ESCAPE_DATA_IN - a pointer to the input ESC_DATA_RECORD. -- ESCAPE_DATA_OUT - a pointer to the output ESC_DATA_RECORD begin case ESCAPE_NAME is when GKS_ESCAPE.VIRTUAL_EXTENDED_PICK_ID => -- ESCAPE_DATA_IN - a pointer to an ESC_DATA_RECORD which -- contains the WS_ID, the maximum number of items to -- be picked, and the NDC pick rectangle. -- ESCAPE_DATA_OUT - a pointer to an ESC_DATA_RECORD which -- contains the list of available segments and pick id's -- and the pick request status. WSR_ESCAPE.VIRTUAL_EXTENDED_PICK ( ESCAPE_DATA_IN_PTR => ESCAPE_DATA_IN, ESCAPE_DATA_OUT_PTR => ESCAPE_DATA_OUT, WS_SL_PTR => WS_SL); when others => null; end case; end ESCAPE; end TEK_CONTROL_OPERATIONS;