-------------------------------------------------------------------------------- -- -- NAME: CGM_GEN_STATE - BODY -- DISCREPANCY REPORTS: -- -------------------------------------------------------------------------------- -- file: CGM_GEN_STATE_B.ADA -- level: 0a with CGM_BYTE_TYPES; with TEXT_IO; package body CGM_GEN_STATE is -- This package body contains the procedure that reads -- and stores the initial CGM generator state values -- from an external, clear text configuration file if -- one exists. -------------------------------------------------------------------------------- function "="(A, B : CGM_BYTE_TYPES.BYTE_ARRAY_RANGE) return BOOLEAN renames CGM_BYTE_TYPES."="; -- This function makes the operator visible so it can be -- used in infix notation. -------------------------------------------------------------------------------- procedure READ_CONFIGURATION_FILE is -- This procedure reads the clear text configuration file -- if one exists and stores the value strings associated -- with the keywords in the file. package CONFIG_IO is new TEXT_IO.ENUMERATION_IO(CONFIG_KEYWORDS); -- Allow enumerated keywords to be read from a text string. TEXT_FILE : TEXT_IO.FILE_TYPE; -- Allow access to the text configuration file. INPUT_STRING : STRING(1..80); -- The file is read a line of text at a time. LAST_OF_STRING : NATURAL; -- This is the number of the last character in the line -- read from the file. KEYWORD : CONFIG_KEYWORDS; -- This is the enumerated keyword read from the input string. LAST_OF_ENUM : POSITIVE; -- This is the number of the last character in the string -- that defines the enumerated keyword. begin -- Initialize all configuration value strings to be blank -- which is their "null" state. This must be done to allow -- multiple opens and closes of this workstation. for I in CONFIG_KEYWORDS loop CONFIG_VALUE_STRING(I) := BLANK_STRING; end loop; -- Attempt to open the configuration file. Any error must -- be trapped and treated as a no-op since it is not an error -- for the configuration file to be missing. TEXT_IO.OPEN (FILE => TEXT_FILE, MODE => TEXT_IO.IN_FILE, NAME => "CGM_GENERATOR_CONFIGURATION.DAT"); declare begin -- Read and process each line of the configuration file. -- Expect only one keyword-value pair per text line. while not TEXT_IO.END_OF_FILE (TEXT_FILE) loop -- Read the text string from the file. TEXT_IO.GET_LINE (FILE => TEXT_FILE, ITEM => INPUT_STRING, LAST => LAST_OF_STRING); -- Attempt to read the enumerated keyword from the string -- and trap any error. Errors cause the remainder of the -- string to be ignored. declare begin -- Read the keyword from the string. CONFIG_IO.GET (FROM => INPUT_STRING, -- Read the keyword ITEM => KEYWORD, -- from the string. LAST => LAST_OF_ENUM); -- Point to the 1st space character past the keyword. LAST_OF_ENUM := LAST_OF_ENUM + 1; -- Skip all spaces. while LAST_OF_ENUM < INPUT_STRING'LENGTH and then INPUT_STRING(LAST_OF_ENUM) = ' ' loop LAST_OF_ENUM := LAST_OF_ENUM + 1; end loop; -- Insure that we enter data to a blank string. CONFIG_VALUE_STRING(KEYWORD) := BLANK_STRING; -- Store the remainder of the string as the value that is -- associated with the keyword. CONFIG_VALUE_STRING(KEYWORD) (1..(LAST_OF_STRING - LAST_OF_ENUM + 1)) := INPUT_STRING(LAST_OF_ENUM..LAST_OF_STRING); -- Any error reading the keyword causes just the current text -- string (line in the file) to be ignored. exception when OTHERS => null; end; end loop; -- Finished processing the file so close it. TEXT_IO.CLOSE (FILE => TEXT_FILE); -- Any error reading the file causes the remainder of the file -- to be ignored. exception when OTHERS => -- Close the file. TEXT_IO.CLOSE (FILE => TEXT_FILE); end; -- Any error opening the file is treated as a no-op since -- this file does not have to exist. exception when OTHERS => null; end READ_CONFIGURATION_FILE; -------------------------------------------------------------------------------- procedure INITIALIZE_INTEGER_PRECISION is -- Integer precision specifies how may bits will be used -- to encode non-VDC integers. begin -- Convert the configuration string into the desired precision. INTEGER_PRECISION := CGM_STANDARD_TYPES. BINARY_INTEGER_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_INTEGER_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => INTEGER_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_INTEGER_PRECISION; end INITIALIZE_INTEGER_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_TYPE is -- VDC type specifies if VDC values will be encoded in real or -- integer format. begin -- Convert the configuration string into the desired type and -- store in the generator state variable. VDC_TYPE := CGM_STANDARD_TYPES. VDC_TYPES'VALUE (CONFIG_VALUE_STRING (CONFIG_VDC_TYPE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => VDC_TYPE := CGM_STANDARD_DEFAULTS. DEFAULT_VDC_TYPE; end INITIALIZE_VDC_TYPE; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_INTEGER_PRECISION is -- VDC integer precision specifies the number of bits that will -- be used to encode VDC values in integer format. begin -- Convert the configuration string into the desired precision -- and store in the generator state variable. VDC_INTEGER_PRECISION := CGM_STANDARD_TYPES. BINARY_VDC_INTEGER_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_VDC_INTEGER_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => VDC_INTEGER_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_VDC_INTEGER_PRECISION; end INITIALIZE_VDC_INTEGER_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_REAL_VALUE_FORMAT is -- VDC real value format specifies if real VDC values will -- be encoded in floating or fixed point format. -- This procedure loads the variable in the generator state -- but does not write an element. begin -- Convert the configuration string into the desired format and -- store in the generator state variable. VDC_REAL_VALUE_FORMAT := CGM_STANDARD_TYPES. BINARY_VDC_REAL_VALUE_FORMAT'VALUE (CONFIG_VALUE_STRING (CONFIG_VDC_REAL_VALUE_FORMAT)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => VDC_REAL_VALUE_FORMAT := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_VDC_REAL_VALUE_FORMAT; end INITIALIZE_VDC_REAL_VALUE_FORMAT; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_REAL_PRECISION is -- VDC real precision specifies the number of bits that will -- be used to encode VDC values in real format. begin -- Initialize the VDC real value format since that value must -- be used as a parameter to generate the element. INITIALIZE_VDC_REAL_VALUE_FORMAT; -- Convert the configuration string into the desired precision -- and store in the generator state variable. VDC_REAL_PRECISION := CGM_STANDARD_TYPES. BINARY_VDC_REAL_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_VDC_REAL_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => VDC_REAL_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_VDC_REAL_PRECISION; end INITIALIZE_VDC_REAL_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_REAL_VALUE_FORMAT is -- Real value format specifies if real values will -- be encoded in floating or fixed point format. -- This procedure loads the variable in the generator state -- but does not write an element. begin -- Convert the configuration string into the desired format and -- store in the generator state variable. REAL_VALUE_FORMAT := CGM_STANDARD_TYPES. BINARY_REAL_VALUE_FORMAT'VALUE (CONFIG_VALUE_STRING (CONFIG_REAL_VALUE_FORMAT)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => REAL_VALUE_FORMAT := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_REAL_VALUE_FORMAT; end INITIALIZE_REAL_VALUE_FORMAT; -------------------------------------------------------------------------------- procedure INITIALIZE_REAL_PRECISION is -- Real precision specifies the number of bits that will -- be used to encode values in real format. begin -- Initialize the real value format since that value must -- be used as a parameter to generate the element. INITIALIZE_REAL_VALUE_FORMAT; -- Convert the configuration string into the desired precision -- and store in the generator state variable. REAL_PRECISION := CGM_STANDARD_TYPES. BINARY_REAL_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_REAL_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => REAL_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_REAL_PRECISION; end INITIALIZE_REAL_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_INDEX_PRECISION is -- Index precision specifies the number of bits that will -- be used to encode index values. begin -- Convert the configuration string into the desired precision -- and store in the generator state variable. INDEX_PRECISION := CGM_STANDARD_TYPES. BINARY_INDEX_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_INDEX_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => INDEX_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_INDEX_PRECISION; end INITIALIZE_INDEX_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_COLOUR_PRECISION is -- Colour precision specifies the number of bits that will -- be used to encode direct colour values. begin -- Convert the configuration string into the desired precision -- and store in the generator state variable. COLOUR_PRECISION := CGM_STANDARD_TYPES. BINARY_COLOUR_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_COLOUR_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => COLOUR_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_COLOUR_PRECISION; end INITIALIZE_COLOUR_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_COLOUR_INDEX_PRECISION is -- Colour index precision specifies the number of bits that will -- be used to encode colour indicies. begin -- Convert the configuration string into the desired precision -- and store in the generator state variable. COLOUR_INDEX_PRECISION := CGM_STANDARD_TYPES. BINARY_COLOUR_INDEX_PRECISION'VALUE (CONFIG_VALUE_STRING (CONFIG_COLOUR_INDEX_PRECISION)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => COLOUR_INDEX_PRECISION := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_COLOUR_INDEX_PRECISION; end INITIALIZE_COLOUR_INDEX_PRECISION; -------------------------------------------------------------------------------- procedure INITIALIZE_MAXIMUM_COLOUR_INDEX is -- Maximum colour index specifies the greatest index -- that can be used to reference colours. begin -- Convert the configuration string into the desired index -- and store in the generator state variable. MAXIMUM_COLOUR_INDEX := CGM_STANDARD_TYPES. COLOUR_INDEX'VALUE (CONFIG_VALUE_STRING (CONFIG_MAXIMUM_COLOUR_INDEX)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. -- NOTE: -- This is not the CGM X3.122-1986 clause 6 default but -- rather, the one recommended in TOP ver. 1.0. when CONSTRAINT_ERROR => MAXIMUM_COLOUR_INDEX := 255; end INITIALIZE_MAXIMUM_COLOUR_INDEX; -------------------------------------------------------------------------------- procedure INITIALIZE_COLOUR_VALUE_EXTENT is -- Colour value extent specifies the minimum and maximum values -- that can be used to reference colour intensities. A min and -- max value is provided for each primary additive colour: Red, -- Green, and Blue. package INTENSITY_IO is new TEXT_IO. INTEGER_IO(CGM_STANDARD_TYPES. INTENSITY); -- The configuration string contains six intensities that -- must be read one at a time. LAST_NUM : INTEGER := 0; -- Keep track of where we are reading in the string. -- The read will begin at this value plus one! INTENSITIES : array(1..6) of CGM_STANDARD_TYPES.INTENSITY; -- Local storage to read the intensities into from the -- configuration string. begin -- Convert the configuration string into the desired intensities -- and store them in the local variable. for I in INTENSITIES'RANGE loop -- The FROM value is a substring which begins past the last -- number read from the string. INTENSITY_IO.GET (FROM => CGM_GEN_STATE. CONFIG_VALUE_STRING (CONFIG_COLOUR_VALUE_EXTENT) (LAST_NUM+1..CGM_GEN_STATE. CONFIG_STRING'LAST), ITEM => INTENSITIES(I), LAST => LAST_NUM); end loop; -- Assign each of the intensities read in to their proper -- location in the colour value extent record structure. COLOUR_VALUE_EXTENT.MINIMUM.RED := INTENSITIES(1); COLOUR_VALUE_EXTENT.MINIMUM.GREEN := INTENSITIES(2); COLOUR_VALUE_EXTENT.MINIMUM.BLUE := INTENSITIES(3); COLOUR_VALUE_EXTENT.MAXIMUM.RED := INTENSITIES(4); COLOUR_VALUE_EXTENT.MAXIMUM.GREEN := INTENSITIES(5); COLOUR_VALUE_EXTENT.MAXIMUM.BLUE := INTENSITIES(6); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when OTHERS => COLOUR_VALUE_EXTENT := CGM_STANDARD_DEFAULTS. DEFAULT_BINARY_COLOUR_VALUE_EXTENT; end INITIALIZE_COLOUR_VALUE_EXTENT; -------------------------------------------------------------------------------- procedure INITIALIZE_SCALE_FACTOR is -- Scale factor specifies the specific metric scale to be -- related to VDC space if the scaling mode is metric. -- This procedure loads the variable in the generator state -- but does not write an element. package SCALE_IO is new TEXT_IO. FLOAT_IO(CGM_STANDARD_TYPES. METRIC_SCALE_FACTOR); -- This package will be used to read the "real" value -- from the configuration string. DUMMY : POSITIVE; -- Not used but required as a return value from a procedure. begin -- Convert the configuration string for the scale factor -- and store in the generator state variable. SCALE_IO.GET (FROM => CONFIG_VALUE_STRING (CONFIG_SCALE_FACTOR), ITEM => SCALE_FACTOR, LAST => DUMMY); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when OTHERS => SCALE_FACTOR := CGM_STANDARD_DEFAULTS. DEFAULT_SCALING_FACTOR; end INITIALIZE_SCALE_FACTOR; -------------------------------------------------------------------------------- procedure INITIALIZE_SCALING_MODE is -- Scaling mode specifies if VDC space is abstract or related -- to a specific metric scale. This procedure sets two generator -- state variables: the scaling mode and the scale factor, both -- of which must be properly set before the scaling mode element -- is written. begin -- Set the generator state variable for the scale factor. INITIALIZE_SCALE_FACTOR; -- Convert the configuration string for the scaling mode -- into the desired mode and store in the generator state -- variable. SCALING_MODE := CGM_STANDARD_TYPES. SCALING_MODE'VALUE (CONFIG_VALUE_STRING (CONFIG_SCALING_MODE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => SCALING_MODE := CGM_STANDARD_DEFAULTS. DEFAULT_SCALING_MODE; end INITIALIZE_SCALING_MODE; -------------------------------------------------------------------------------- procedure INITIALIZE_COLOUR_SELECTION_MODE is -- Colour selection mode specifies if colours will be referenced -- by indicies or direct colour values (RGB tuples). begin -- Convert the configuration string into the desired mode -- and store in the generator state variable. COLOUR_SELECTION_MODE := CGM_STANDARD_TYPES. COLOUR_SELECTION_MODE'VALUE (CONFIG_VALUE_STRING (CONFIG_COLOUR_SELECTION_MODE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => COLOUR_SELECTION_MODE := CGM_STANDARD_DEFAULTS. DEFAULT_COLOUR_SELECTION_MODE; end INITIALIZE_COLOUR_SELECTION_MODE; -------------------------------------------------------------------------------- procedure INITIALIZE_LINE_WIDTH_SPEC_MODE is -- Line width specification mode specifies if line widths -- will be absolute or scaled. begin -- Convert the configuration string into the desired mode -- and store in the generator state variable. LINE_WIDTH_SPEC_MODE := CGM_STANDARD_TYPES. LINE_WIDTH_SPEC_MODE'VALUE (CONFIG_VALUE_STRING (CONFIG_LINE_WIDTH_SPEC_MODE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => LINE_WIDTH_SPEC_MODE := CGM_STANDARD_DEFAULTS. DEFAULT_LINE_WIDTH_SPEC_MODE; end INITIALIZE_LINE_WIDTH_SPEC_MODE; -------------------------------------------------------------------------------- procedure INITIALIZE_MARKER_SIZE_SPEC_MODE is -- Marker size specification mode specifies if marker size -- will be absolute or scaled. begin -- Convert the configuration string into the desired mode -- and store in the generator state variable. MARKER_SIZE_SPEC_MODE := CGM_STANDARD_TYPES. MARKER_SIZE_SPEC_MODE'VALUE (CONFIG_VALUE_STRING (CONFIG_MARKER_SIZE_SPEC_MODE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => MARKER_SIZE_SPEC_MODE := CGM_STANDARD_DEFAULTS. DEFAULT_MARKER_SIZE_SPEC_MODE; end INITIALIZE_MARKER_SIZE_SPEC_MODE; -------------------------------------------------------------------------------- procedure INITIALIZE_EDGE_WIDTH_SPEC_MODE is -- Edge width specification mode specifies if edge widths -- will be absolute or scaled. begin -- Convert the configuration string into the desired mode -- and store in the generator state variable. EDGE_WIDTH_SPEC_MODE := CGM_STANDARD_TYPES. EDGE_WIDTH_SPEC_MODE'VALUE (CONFIG_VALUE_STRING (CONFIG_EDGE_WIDTH_SPEC_MODE)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => EDGE_WIDTH_SPEC_MODE := CGM_STANDARD_DEFAULTS. DEFAULT_EDGE_WIDTH_SPEC_MODE; end INITIALIZE_EDGE_WIDTH_SPEC_MODE; -------------------------------------------------------------------------------- procedure INITIALIZE_MDR_FLAG is -- The MDR flag defines if the METAFILE DEFAULTS REPLACEMENT -- element should be generated in the metafile descriptor -- or not. True => generate it; False => don't generate it. -- NOTE: -- The MDR element must be generated if the VDC_TYPE is -- integer and the VDC_INTEGER_PRECISION is not SIXTEEN. -- The value of this configuration variable will be ignored -- in the above case and the MDR element will be generated -- by procedure: "CGM_GEN_CONTROL_OPERATIONS.OPEN_WS". begin -- Convert the configuration string into the desired value -- and store in the generator state variable. MDR_FLAG := BOOLEAN'VALUE (CONFIG_VALUE_STRING (CONFIG_MDR_FLAG)); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when CONSTRAINT_ERROR => MDR_FLAG := TRUE; end INITIALIZE_MDR_FLAG; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_MAPPING_MINIMUM is -- This configuration variable is used when the VDC_TYPE is -- integer to map the VDC value, represented as a real, to an -- integer using the equation: -- A := FLOAT (VDC_MAPPING_MINIMUM); -- B := FLOAT (VDC_MAPPING_MAXIMUM); -- X := GKS_VDC_VALUE; -- VALUE := INTEGER (((B - A) * X) + B); -- Mapping occurs in proc: "BINARY_ENCODER.ENCODE_VDC_COORDINATE". -- The value of the configuration variable: VDC_INTEGER_PRECISION -- in this package must be considered when modifing this -- variable since its value normally must map the entire GKS -- NDC range of -7.0 .. 7.0 into the integer range defined by -- VDC_INTEGER_PRECISION. -- NOTE: -- The default for this value is setup by this initialization -- routine to match the VDC_INTEGER_PRECISION value if no value -- was encountered in the configuration file. Thus, the -- initialization routine for VDC_INTEGER_PRECISION must -- be called prior to this routine. package MAPPING_IO is new TEXT_IO. FLOAT_IO(FLOAT); -- This package will be used to read the "real" value -- from the configuration string. DUMMY : POSITIVE; -- Not used but required as a return value from a procedure. begin -- Convert the configuration string for the mapping factor -- and store in the generator state variable. MAPPING_IO.GET (FROM => CONFIG_VALUE_STRING (CONFIG_VDC_MAPPING_MINIMUM), ITEM => VDC_MAPPING_MINIMUM, LAST => DUMMY); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when OTHERS => VDC_MAPPING_MINIMUM := 0.0; end INITIALIZE_VDC_MAPPING_MINIMUM; -------------------------------------------------------------------------------- procedure INITIALIZE_VDC_MAPPING_MAXIMUM is -- This configuration variable is used when the VDC_TYPE is -- integer to map the VDC value, represented as a real, to an -- integer using the equation: -- A := FLOAT (VDC_MAPPING_MINIMUM); -- B := FLOAT (VDC_MAPPING_MAXIMUM); -- X := GKS_VDC_VALUE; -- VALUE := INTEGER (((B - A) * X) + B); -- Mapping occurs in proc: "BINARY_ENCODER.ENCODE_VDC_COORDINATE". -- The value of the configuration variable: VDC_INTEGER_PRECISION -- in this package must be considered when modifing this -- variable since its value normally must map the entire GKS -- NDC range of -7.0 .. 7.0 into the integer range defined by -- VDC_INTEGER_PRECISION. -- NOTE: -- The default for this value is setup by this initialization -- routine to match the VDC_INTEGER_PRECISION value if no value -- was encountered in the configuration file. Thus, the -- initialization routine for VDC_INTEGER_PRECISION must -- be called prior to this routine. package MAPPING_IO is new TEXT_IO. FLOAT_IO(FLOAT); -- This package will be used to read the "real" value -- from the configuration string. DUMMY : POSITIVE; -- Not used but required as a return value from a procedure. begin -- Convert the configuration string for the mapping factor -- and store in the generator state variable. MAPPING_IO.GET (FROM => CONFIG_VALUE_STRING (CONFIG_VDC_MAPPING_MAXIMUM), ITEM => VDC_MAPPING_MAXIMUM, LAST => DUMMY); exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when OTHERS => case VDC_INTEGER_PRECISION is when CGM_STANDARD_TYPES.SIXTEEN => VDC_MAPPING_MAXIMUM := 4095.0; when CGM_STANDARD_TYPES.TWENTY_FOUR => VDC_MAPPING_MAXIMUM := 1048575.0; when CGM_STANDARD_TYPES.THIRTY_TWO => VDC_MAPPING_MAXIMUM := 268435455.0; end case; -- vdc integer precision end INITIALIZE_VDC_MAPPING_MAXIMUM; -------------------------------------------------------------------------------- procedure INITIALIZE_IO_RECORD_SIZE is package SIZE_IO is new TEXT_IO. INTEGER_IO (CGM_BYTE_TYPES. BYTE_ARRAY_RANGE); -- This package will be used to read the integer value -- from the configuration string. DUMMY : POSITIVE; -- Not used but required as a return value from a procedure. begin -- Convert the configuration string for the record size -- and store in the generator state variable. SIZE_IO.GET (FROM => CONFIG_VALUE_STRING (CONFIG_IO_RECORD_SIZE), ITEM => IO_RECORD_SIZE, LAST => DUMMY); -- Do not allow zero length records. if IO_RECORD_SIZE = 0 then IO_RECORD_SIZE := 80; end if; exception -- If the configuration string is incorrect then leave the -- default value in the generator state variable. when OTHERS => IO_RECORD_SIZE := 80; end INITIALIZE_IO_RECORD_SIZE; -------------------------------------------------------------------------------- procedure INITIALIZE_GENERATOR_STATE is -- This procedure will initialize all of the CGM generator state -- variables in this package from either the configuration string -- or the standard default. begin -- The current picture in the metafile is number one (1); CURRENT_PICTURE_NUMBER := 1; -- Initialize the configuration strings from the configuration -- file or with a blank string. READ_CONFIGURATION_FILE; -- Integer precision specifies how may bits will be used -- to encode non-VDC integers. INITIALIZE_INTEGER_PRECISION; -- VDC type specifies if VDC values will be encoded in real or -- integer format. INITIALIZE_VDC_TYPE; -- VDC integer precision specifies the number of bits that will -- be used to encode VDC values in integer format. INITIALIZE_VDC_INTEGER_PRECISION; -- VDC real precision specifies the number of bits that will -- be used to encode VDC values in real format. INITIALIZE_VDC_REAL_PRECISION; -- Real precision specifies the number of bits that will -- be used to encode values in real format. INITIALIZE_REAL_PRECISION; -- Index precision specifies the number of bits that will -- be used to encode index values. INITIALIZE_INDEX_PRECISION; -- Colour precision specifies the number of bits that will -- be used to encode direct colour values. INITIALIZE_COLOUR_PRECISION; -- Colour index precision specifies the number of bits that will -- be used to encode colour indicies. INITIALIZE_COLOUR_INDEX_PRECISION; -- Maximum colour index specifies the greatest index -- that can be used to reference colours. INITIALIZE_MAXIMUM_COLOUR_INDEX; -- Colour value extent specifies the minimum and maximum values -- that can be used to reference colour intensities. A min and -- max value is provided for each primary additive colour: Red, -- Green, and Blue. INITIALIZE_COLOUR_VALUE_EXTENT; -- Scaling mode specifies if VDC space is abstract or related -- to a specific metric scale. This procedure sets two generator -- state variables: the scaling mode and the scale factor, both -- of which must be properly set before the scaling mode element -- is written. -- INITIALIZE_SCALING_MODE; -- Colour selection mode specifies if colours will be referenced -- by indicies or direct colour values (RGB tuples). -- INITIALIZE_COLOUR_SELECTION_MODE; -- Line width specification mode specifies if line widths -- will be absolute or scaled. -- INITIALIZE_LINE_WIDTH_SPEC_MODE; -- Marker size specification mode specifies if marker size -- will be absolute or scaled. -- INITIALIZE_MARKER_SIZE_SPEC_MODE; -- Edge width specification mode specifies if edge widths -- will be absolute or scaled. -- INITIALIZE_EDGE_WIDTH_SPEC_MODE; -- The MDR flag defines if the METAFILE DEFAULTS REPLACEMENT -- element should be generated in the metafile descriptor -- or not. True => generate it; False => don't generate it. -- NOTE: -- The MDR element must be generated if the VDC_TYPE is -- integer and the VDC_INTEGER_PRECISION is not SIXTEEN. -- The value of this configuration variable will be ignored -- in the above case and the MDR element will be generated -- by procedure: "CGM_GEN_CONTROL_OPERATIONS.OPEN_WS". INITIALIZE_MDR_FLAG; -- These configuration variables are used when the VDC_TYPE is -- integer to map the VDC value, represented as a real, to an -- integer using the equation: -- A := FLOAT (VDC_MAPPING_MINIMUM); -- B := FLOAT (VDC_MAPPING_MAXIMUM); -- X := GKS_VDC_VALUE; -- VALUE := INTEGER (((B - A) * X) + B); -- Mapping occurs in proc: "BINARY_ENCODER.ENCODE_VDC_COORDINATE". -- The value of the configuration variable: VDC_INTEGER_PRECISION -- in this package must be considered when modifing these -- variables since their values normally must map the entire GKS -- NDC range of -7.0 .. 7.0 into the integer range defined by -- VDC_INTEGER_PRECISION. -- NOTE: -- Defaults for these values are setup by the initialization -- routine for these variables to match the VDC_INTEGER_PRECISION -- value if no value was encountered in the configuration file. -- Thus, the intialization routine for VDC_INTEGER_PRECISION must -- be called prior to the call to the routine that initializes -- these values. INITIALIZE_VDC_MAPPING_MINIMUM; INITIALIZE_VDC_MAPPING_MAXIMUM; -- The record size generated is variable. INITIALIZE_IO_RECORD_SIZE; end INITIALIZE_GENERATOR_STATE; -------------------------------------------------------------------------------- end CGM_GEN_STATE;