------------------------------------------------------------------ -- -- NAME: CGM_GEN_WS_TABLES - BODY -- DISCREPANCY REPORTS: -- ------------------------------------------------------------------ -- file : CGM_GEN_TBLS_0B_B.ADA -- level: 0b with AVAILABLE_WS_TYPES; with WS_TABLE_TYPES; with CONVERT_NDC_DC; with GKS_ERRORS; with UNCHECKED_DEALLOCATION; with CGM_ELEMENT_STATE; with CGM_STANDARD_TYPES; with GKS_TYPES; with WSR_SET_INDIVIDUAL_ATTRIBUTES_0A; use GKS_TYPES; package body CGM_GEN_WS_TABLES is -- This package provides the interface between the workstation (WS) -- state list(s) and the rest of the CGM generator workstation driver -- (WSD). It contains procedures to create an initialized WS state -- list (ADD_STATE_LIST_TO_LIST), delete a previously created WS -- state list (DELETE_STATE_LIST_FROM_LIST), and a function to gain -- access to a WS state list (GET_STATE_LIST_PTR). -- NOTE: -- Because a (physical) WSD must work with many (logical) WS's, a -- WS state list must be maintained by the WSD for each (logical) WS. -- Normally, pointers to these WS state lists are kept in a list -- maintained solely within this package. However, this CGM -- generator WSD only supports one open WS at a time. Thus, it is -- not necessary to maintain a list of WS state lists. The procedure -- names still refer to a list of WS state lists but they do not -- actually maintain one. Rather, a single pointer to a WS state -- list structure is maintained. The WS state list structure is -- still a dynamic object, however, which means it gets allocated -- and deallocated but the pointer to that structure is never kept -- on a list. ------------------------------------------------------------------ subtype PRE_PLINE_BUNDLES is WS_TABLE_TYPES.POLYLINE_BUNDLE; subtype PRE_PMARK_BUNDLES is WS_TABLE_TYPES.POLYMARKER_BUNDLE; subtype PRE_TEXT_BUNDLES is WS_TABLE_TYPES.TEXT_BUNDLE; subtype PRE_FILL_AREA_BUNDLES is WS_TABLE_TYPES.FILL_AREA_BUNDLE; subtype PRE_COLOUR_REP is GKS_TYPES.COLOUR_REPRESENTATION; -------------------------------------------------------------------- LINE_TYPE_LIST : constant LINETYPES. LIST_VALUES := (1,2,3,4,5); -- Creates an array of the available line types -- that are supported. -------------------------------------------------------------------- MARKER_TYPE_LIST : constant MARKER_TYPES. LIST_VALUES := (1,2,3,4,5); -- Creates an array of the available marker types -- that are supported. -------------------------------------------------------------------- INTERIOR_STYLE_LIST : constant INTERIOR_STYLES. LIST_VALUES := (HOLLOW, SOLID, PATTERN, HATCH); -- Creates an array of the available interior styles -- that the metafile supports. -------------------------------------------------------------------- TEXT_FONT_AND_PRECISION_LIST : constant TEXT_FONT_PRECISIONS. LIST_VALUES := (1 => TEXT_FONT_PRECISION' (FONT => 1, PRECISION => STRING_PRECISION), 2 => TEXT_FONT_PRECISION' (FONT => 1, PRECISION => CHAR_PRECISION), 3 => TEXT_FONT_PRECISION' (FONT => 1, PRECISION => STROKE_PRECISION)); -- Creates an array of text fonts and precisions -- that are supported. -------------------------------------------------------------------- HATCH_STYLE_LIST : constant HATCH_STYLES. LIST_VALUES := (1,2,3,4,5,6); -- Creates an array of supported hatch styles. -------------------------------------------------------------------- CGM_ST_LST : WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR; -- A pointer to a WORKSTATION_STATE_LIST. -- The initial value is null. -- NOTE: -- Normally a (physical) workstation driver must support -- more than one (logical) workstation and thus would -- keep a list of pointers to workstation state lists so -- that each open (logical) WS would have its own WS state -- list. However, this CGM generator only supports a -- single WS open at a time so there is only one pointer -- to a WS state list required. -------------------------------------------------------------------- DEFAULT_COLOUR : CGM_STANDARD_TYPES.COLOUR_DIRECT; -- This variable is used to help initialize the predefined -- colour representations in the workstation description table. -------------------------------------------------------------------- function "/" (A, B : CGM_STANDARD_TYPES.INTENSITY) return CGM_STANDARD_TYPES.INTENSITY renames CGM_STANDARD_TYPES."/"; -- This function allows visibility to the operator -- so it can be used in infix notation. -------------------------------------------------------------------- function GET_STATE_LIST_PTR (WS_ID : in GKS_TYPES.WS_ID) return WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR is -- Returns the pointer to the specified state list from -- the list of all workstation state lists. -- Function parameters: -- WS_ID A workstation identification used to access the -- list of WS state lists. -- NOTE: -- In this inplementation, there is only one -- WS state list so no list of pointers exists. begin return CGM_ST_LST; end GET_STATE_LIST_PTR; -------------------------------------------------------------------- procedure ADD_STATE_LIST_TO_LIST (WS_ID : in GKS_TYPES.WS_ID; CONNECT_ID : in GKS_TYPES.VARIABLE_CONNECTION_ID; WS_TYPE : in GKS_TYPES.WS_TYPE; ATTRIBUTES : in OUTPUT_ATTRIBUTES_TYPE.OUTPUT_ATTRIBUTES; ERROR_INDICATOR : out GKS_TYPES.ERROR_NUMBER) is -- Adds a workstation state list to the list of all workstation -- state lists. -- NOTE: -- In this inplementation, there is only one -- WS state list so no list of pointers exists. -- Procedure parameters: -- WS_ID GKS workstation identifier. -- CONNECT_ID A variable length string for -- INQ_WS_CONNECTION_AND_TYPE. -- WS_TYPE Values corresponding to valid workstation -- types. -- ATTRIBUTES The initial output attributes reflecting the -- current state of GKS. -- The following constants are used when initializing the -- workstation state list with valid bundle indicies. PLINE_IDC_LIST : constant POLYLINE_INDICES.LIST_VALUES := (1,2,3,4,5); PMRK_IDC_LIST : constant POLYMARKER_INDICES.LIST_VALUES := (1,2,3,4,5); TEXT_IDC_LIST : constant TEXT_INDICES.LIST_VALUES := (1,2); FILL_AREA_IDC_LIST : constant FILL_AREA_INDICES.LIST_VALUES := (1,2,3,4,5); begin -- Get a new workstation state list. CGM_ST_LST := new WS_STATE_LIST_TYPES.WS_STATE_LST (NUM_POLYLINE_BUNDLES => WS_STATE_LIST_TYPES.PLIN_INDEX (CGM_GEN_WS_DT.MAX_NUM_PLIN_BUNDLE_TBL_ENTRIES), NUM_POLYMARKER_BUNDLES => WS_STATE_LIST_TYPES.PMRK_INDEX (CGM_GEN_WS_DT.MAX_NUM_PMRK_BUNDLE_TBL_ENTRIES), NUM_TEXT_BUNDLES => WS_STATE_LIST_TYPES.TXT_INDEX (CGM_GEN_WS_DT.MAX_NUM_TEXT_BUNDLE_TBL_ENTRIES), NUM_FILL_AREA_BUNDLES => WS_STATE_LIST_TYPES.FA_INDEX (CGM_GEN_WS_DT.MAX_NUM_FA_BUNDLE_TBL_ENTRIES), NUM_PATTERN_TABLES => WS_STATE_LIST_TYPES.PAT_INDEX (CGM_GEN_WS_DT.MAX_NUM_PATTERN_INDICES), NUM_COLOUR_REPRESENTATION => WS_STATE_LIST_TYPES.CLR_INDEX (CGM_GEN_WS_DT.MAX_NUM_COLOUR_INDICES - 1), NUM_OF_LOCATOR_DEVICES => 0, NUM_OF_STROKE_DEVICES => 0, NUM_OF_VALUATOR_DEVICES => 0, NUM_OF_CHOICE_DEVICES => 0, NUM_OF_PICK_DEVICES => 0, NUM_OF_STRING_DEVICES => 0); -- Initialize the new work station state list... -- Initialize with the parameters passed to this procedure. CGM_ST_LST.OUTPUT_ATTR := ATTRIBUTES; CGM_ST_LST.WORKSTATION_ID := WS_ID; CGM_ST_LST.CONNECT_ID := CONNECT_ID; CGM_ST_LST.WORKSTATION_TYPE := WS_TYPE; -- Initialize from the WS description table. CGM_ST_LST.WORKSTATION_CATEGORY := CGM_GEN_WS_DT.WORKSTATION_CATEGORY; CGM_ST_LST.WS_DEFERRAL_MODE := CGM_GEN_WS_DT.DEFER_MODE; CGM_ST_LST.WS_IMPLICIT_REGEN_MODE := CGM_GEN_WS_DT.IMPLICIT_REGEN_MODE; -- The list of polyline bundles. CGM_ST_LST.SET_OF_PLIN_IDC := POLYLINE_INDICES.LIST(PLINE_IDC_LIST); CGM_ST_LST.POLYLINE_BUNDLES := CGM_GEN_WS_DT.PREDEFINED_PLIN_BUNDLES; -- Initialize the bundles... -- The list of polymarker bundles. CGM_ST_LST.SET_OF_PMRK_IDC := POLYMARKER_INDICES.LIST(PMRK_IDC_LIST); CGM_ST_LST.POLYMARKER_BUNDLES := CGM_GEN_WS_DT.PREDEFINED_PMRK_BUNDLES; -- The list of text bundles. CGM_ST_LST.SET_OF_TEXT_IDC := TEXT_INDICES.LIST(TEXT_IDC_LIST); CGM_ST_LST.TEXT_BUNDLES := CGM_GEN_WS_DT.PREDEFINED_TEXT_BUNDLES; -- The list of fill area bundles. CGM_ST_LST.SET_OF_FILL_AREA_IDC := FILL_AREA_INDICES.LIST(FILL_AREA_IDC_LIST); CGM_ST_LST.FILL_AREA_BUNDLES := CGM_GEN_WS_DT.PREDEFINED_FA_BUNDLES; -- The colour table. -- Note: -- This generator supports TOP ver 1.0 which calls for a colour -- table of 256 elements with indicies 0..255. for I in 0 .. 255 loop COLOUR_INDICES.ADD_TO_LIST (GKS_TYPES.PIXEL_COLOUR_INDEX(I), CGM_ST_LST.SET_OF_COLOUR_IDC); end loop; CGM_ST_LST.COLOUR_TABLE := CGM_GEN_WS_DT.PREDEFINED_COLOUR_REP; -- Initialize the aspect source flag values for each attribute. WSR_SET_INDIVIDUAL_ATTRIBUTES_0A.SET_ASF (CGM_ST_LST, CGM_ST_LST.OUTPUT_ATTR.ASPECT_SOURCE_FLAGS); -- Initialize the WS_TRANSFORM in the workstation state list -- for a workstation window of (0.0,1.0,0.0,1.0) and a -- workstation viewport of (0.0,1.0,0.0,1.0). CONVERT_NDC_DC.SET_UNIFORM_SCALES ((0.0,1.0,0.0,1.0), (0.0,1.0,0.0,1.0), CGM_ST_LST.WS_TRANSFORM); -- If the procedure gets to this point without raising an -- exception, the workstation was opened successfully. ERROR_INDICATOR := GKS_ERRORS.SUCCESSFUL; exception when OTHERS => ERROR_INDICATOR := GKS_ERRORS.WS_CANNOT_OPEN; end ADD_STATE_LIST_TO_LIST; -------------------------------------------------------------------- procedure DELETE_STATE_LIST_FROM_LIST (WS_ID : in GKS_TYPES.WS_ID) is -- Deletes a workstation state list from the list of all -- workatation state lists. -- NOTE: In this inplementation, there is only one -- WS state list so no list of pointers exists. -- Procedure parameters: -- WS_ID GKS workstation identifier. procedure FREE_WS_ST_LST is new UNCHECKED_DEALLOCATION (WS_STATE_LIST_TYPES.WS_STATE_LST, WS_STATE_LIST_TYPES.WS_STATE_LIST_PTR); -- This procedure will release the memory used by the -- deleted object back to the system. begin FREE_WS_ST_LST(CGM_ST_LST); end DELETE_STATE_LIST_FROM_LIST; --------------------------------------------------------------------- begin -- This code gets executed at program elaboration (i.e. after -- the program is started by the user but before the main -- procedure is run) to initialize the workstation description -- table. The WS_DT contains parameters used to initialize -- a workstation state list. Those parameters, are in turn -- initialized here, with information specific to this WS. -- This is a Metafile Output (MO) workstation. CGM_GEN_WS_DT.WORKSTATION_TYPE := AVAILABLE_WS_TYPES.CGM_MO; -- The workstation category (output, outin, input etc). CGM_GEN_WS_DT.WORKSTATION_CATEGORY := MO; -- The coordinate units are not in meters. CGM_GEN_WS_DT.DEVICE_COOR_UNITS := OTHER; -- The size of the display in DC units. -- This is an X,Y pair. CGM_GEN_WS_DT.MAX_DISPLAY_SURFACE_DC_UNITS := (4095.0,4095.0); -- The size of the display surface in raster units. -- This is an X,Y pair. CGM_GEN_WS_DT.MAX_DISPLAY_SURFACE_RASTER_UNITS := (4096,4096); -- The display type (raster, vector, other). CGM_GEN_WS_DT.DISPLAY_TYPE := OTHER_DISPLAY; -- The dynamic capabilities of the workstation. -- Indicates whether an update to the state list is per- -- formed immediately (IMM) or is implicitly regenerated -- (IRG). CGM_GEN_WS_DT.WS_DYNAMICS := WS_DESCRIPTION_TABLE_TYPES .DYN_MOD_ACCEPTED_FOR_WS_ATTRIBUTES' (POLYLINE_BUNDLE_REP => IRG, POLYMARKER_BUNDLE_REP => IRG, TEXT_BUNDLE_REP => IRG, FILL_AREA_BUNDLE_REP => IRG, PATTERN_REP => IRG, COLOUR_REP => IMM, WS_TRANSFORMATION => IRG); -- The workstation deferral mode. Set to AS SOON AS POSSIBLE. CGM_GEN_WS_DT.DEFER_MODE := ASAP; -- The implicit regeneration mode. Set to SUPPRESS regeneration. -- Indicates whether implicit regeneration of the display is -- suppressed or allowed. CGM_GEN_WS_DT.IMPLICIT_REGEN_MODE := SUPPRESSED; -- Initializes the LIST_OF_AVAILABLE_LTYPE entry. CGM_GEN_WS_DT. LIST_AVAILABLE_LTYPE := LINETYPES.LIST (LINE_TYPE_LIST); -- The maximum number of line widths that the device supports -- at level ma. CGM_GEN_WS_DT.NUM_AVAILABLE_LWIDTH := 0; CGM_GEN_WS_DT.NOMINAL_LWIDTH := 1.0; -- The maximum range of line widths that the device supports is used. CGM_GEN_WS_DT.RANGE_OF_LWIDTH := (1.0,4095.0); -- The predefined polyline bundle table CGM_GEN_WS_DT.PREDEFINED_PLIN_BUNDLES := WS_TABLE_TYPES.POLYLINE_BUNDLE_LIST' (1=> PRE_PLINE_BUNDLES'(L_TYPE=>1, L_WIDTH=>1.0, COLOUR=>1), 2=> PRE_PLINE_BUNDLES'(L_TYPE=>2, L_WIDTH=>1.0, COLOUR=>1), 3=> PRE_PLINE_BUNDLES'(L_TYPE=>3, L_WIDTH=>1.0, COLOUR=>1), 4=> PRE_PLINE_BUNDLES'(L_TYPE=>4, L_WIDTH=>1.0, COLOUR=>1), 5=> PRE_PLINE_BUNDLES'(L_TYPE=>5, L_WIDTH=>1.0, COLOUR=>1)); -- Initializes the LIST_OF_AVAILABLE_MARKER_TYPES. CGM_GEN_WS_DT. LIST_AVAILABLE_MARKER_TYPES := MARKER_TYPES. LIST (MARKER_TYPE_LIST); -- The number of available marker sizes. CGM_GEN_WS_DT.NUM_AVAILABLE_MARKER_SIZES := 0; -- The normal marker size drawn. CGM_GEN_WS_DT.NOMINAL_MARKER_SIZE := 1.0; -- The range of available marker sizes. CGM_GEN_WS_DT.RANGE_OF_MARKER_SIZES := (1.0,4095.0); -- The predefined polymarker bundle table CGM_GEN_WS_DT.PREDEFINED_PMRK_BUNDLES := WS_TABLE_TYPES.POLYMARKER_BUNDLE_LIST' (1=> PRE_PMARK_BUNDLES'(M_TYPE=>1, M_SIZE=>1.0, COLOUR=>1), 2=> PRE_PMARK_BUNDLES'(M_TYPE=>2, M_SIZE=>1.0, COLOUR=>1), 3=> PRE_PMARK_BUNDLES'(M_TYPE=>3, M_SIZE=>1.0, COLOUR=>1), 4=> PRE_PMARK_BUNDLES'(M_TYPE=>4, M_SIZE=>1.0, COLOUR=>1), 5=> PRE_PMARK_BUNDLES'(M_TYPE=>5, M_SIZE=>1.0, COLOUR=>1)); -- The list of text font and precisions. CGM_GEN_WS_DT. LIST_TEXT_FONT_AND_PRECISION := TEXT_FONT_PRECISIONS. LIST (TEXT_FONT_AND_PRECISION_LIST); -- The number of available character expansions. CGM_GEN_WS_DT.NUM_AVAILABLE_CHAR_EXPANSIONS := 0; -- Only one char expansion supported. CGM_GEN_WS_DT.RANGE_OF_CHAR_EXPANSIONS := (1.0,4095.0); -- The number of available character heights. CGM_GEN_WS_DT.NUM_AVAILABLE_CHAR_HEIGHTS := 0; -- The range of character heights available. -- The minimum character height to the maximum character height. CGM_GEN_WS_DT.RANGE_OF_CHAR_HEIGHTS := (1.0,4095.0); -- The predefined TEXT bundle table CGM_GEN_WS_DT.PREDEFINED_TEXT_BUNDLES := WS_TABLE_TYPES.TEXT_BUNDLE_LIST' (1=>PRE_TEXT_BUNDLES' (TEXT_FONT => TEXT_FONT_PRECISION' (FONT => 1, PRECISION => STROKE_PRECISION), CH_EXPANSION => 1.0, CH_SPACE => 0.0, COLOUR => 1), 2=>PRE_TEXT_BUNDLES' (TEXT_FONT=> TEXT_FONT_PRECISION' (FONT => 1, PRECISION => STROKE_PRECISION), CH_EXPANSION => 0.5, CH_SPACE => 0.0, COLOUR => 1)); -- Initializes the list of available interior styles. CGM_GEN_WS_DT. LIST_OF_AVAL_INTERIOR_STYLE := INTERIOR_STYLES. LIST(INTERIOR_STYLE_LIST); -- Initializes the list of available hatch styles. CGM_GEN_WS_DT. LIST_OF_AVAL_HATCH_STYLE := HATCH_STYLES. LIST (HATCH_STYLE_LIST); -- The predefined fill area bundle table CGM_GEN_WS_DT.PREDEFINED_FA_BUNDLES := WS_TABLE_TYPES.FILL_AREA_BUNDLE_LIST' (1=>PRE_FILL_AREA_BUNDLES'(INT_STYLE=>HATCH,STYLE=>1,COLOUR=>1), 2=>PRE_FILL_AREA_BUNDLES'(INT_STYLE=>HATCH,STYLE=>2,COLOUR=>1), 3=>PRE_FILL_AREA_BUNDLES'(INT_STYLE=>HATCH,STYLE=>3,COLOUR=>1), 4=>PRE_FILL_AREA_BUNDLES'(INT_STYLE=>HATCH,STYLE=>4,COLOUR=>1), 5=>PRE_FILL_AREA_BUNDLES'(INT_STYLE=>HATCH,STYLE=>5,COLOUR=>1)); -- The following is the number of available colours. -- CGM supports 255 intensities for each colour (red, green, blue). -- This means an application programmer can access approximately -- sixteen million colours. We feel that this constitutes a -- continuous range of colours available, therefore we have put a -- zero for the following entry. CGM_GEN_WS_DT.NUM_OF_AVAL_COLOUR_INTENSITY := 0; -- Tells that there is colour available on the device. CGM_GEN_WS_DT.COLOUR_AVAL := COLOUR; -- The colour table's default values are assigned from the TOP ver 1.0 -- specification. for I in CGM_GEN_WS_DT.PREDEFINED_COLOUR_REP'RANGE loop DEFAULT_COLOUR := CGM_ELEMENT_STATE. DEFAULT_DIRECT_COLOUR_VALUE (CGM_STANDARD_TYPES.COLOUR_INDEX(I)); CGM_GEN_WS_DT.PREDEFINED_COLOUR_REP(I) := PRE_COLOUR_REP'(RED => GKS_TYPES. INTENSITY(DEFAULT_COLOUR.RED / 255), GREEN => GKS_TYPES. INTENSITY(DEFAULT_COLOUR.GREEN / 255), BLUE => GKS_TYPES. INTENSITY(DEFAULT_COLOUR.BLUE / 255)); end loop; -- Defines the maximum numbers of bundles available at this level. CGM_GEN_WS_DT.MAX_NUM_PLIN_BUNDLE_TBL_ENTRIES := 5; CGM_GEN_WS_DT.MAX_NUM_PMRK_BUNDLE_TBL_ENTRIES := 5; CGM_GEN_WS_DT.MAX_NUM_TEXT_BUNDLE_TBL_ENTRIES := 2; CGM_GEN_WS_DT.MAX_NUM_FA_BUNDLE_TBL_ENTRIES := 5; CGM_GEN_WS_DT.MAX_NUM_PATTERN_INDICES := 0; CGM_GEN_WS_DT.MAX_NUM_COLOUR_INDICES := 256; end CGM_GEN_WS_TABLES;