ALTERNATIVE TEXT AND SYMBOL DRAWING ROUTINES

There are facilities in LITES2 to allow sites to have their own text and symbol drawing routines. This is a specialised facility and it is not envisaged that users would write their own routines without help from Laser-Scan.

The interface described below is liable to be altered at the discretion of Laser-Scan. The main purpose of the fragments of Fortran source code below is to document the arguments passed to the routines. The actual code merely draws and blanks the features in exactly the same way that LITES2 would have done if the routine had not been supplied.

The examples below, together with command files to build them, are in LSL$PUBLIC_ROOT:_[LITES2.ROUTINES.DRAWING_]. The routines are passed several routines from the FRT library as arguments. Since LITES2 uses the shareable image version of the FRT library, the routines may also be linked with this and will then share the library and associated data in common blocks. If for any reason variables in the FRT common blocks are changed, then they should be restored to their previous values afterwards, otherwise LITES2 could behave unpredictably. Similar caution should be exercised in calling any FRT routines other than those passed as arguments.

TEXT DRAWING

If the logical name LSL$TEXT_ROUTINE points to a shared image which has a UNIVERSAL entry point called DRAW_TEXT, the routine supplied will be called rather than the LITES2 internal routine. The specification of DRAW_TEXT is

	SUBROUTINE DRAW_TEXT(
     &		TEXT,FC,SC,XPOS,YPOS,AUX,TRITXT,SRIPLT,TRISCN,FS,HW)
C
C Copyright Laser Scan Laboratories Ltd., Cambridge, England.
C
C The routine is expected to be used as a shareable image by LITES2
C and FPP, on logical name LSL$TEXT_ROUTINE.
C
	IMPLICIT NONE
C
C define layout of AUX array
C
	PARAMETER AUXLEN = 8	! length of auxiliary array
	PARAMETER ANGI = 1	! angle
	PARAMETER COSI = 2	! cosine
	PARAMETER SINI = 3	! sine
	PARAMETER SIZI = 4	! size
	PARAMETER MINXI= 5	! minimum x
	PARAMETER MAXXI= 6	! maximum x
	PARAMETER MINYI= 7	! minimum y
	PARAMETER MAXYI= 8	! maximum y
C
C arguments
	CHARACTER*(*) TEXT		! text to draw
	INTEGER	FC			! feature code
	INTEGER	SC			! secondary code (font) from FRT
	REAL	XPOS,YPOS		! coordinate
	REAL	AUX(AUXLEN)		! array of extra information
	LOGICAL	TRITXT			! FRTLIB routine to draw text
	LOGICAL	SRIPLT			! FRTLIB routine to draw symbol
	LOGICAL	TRISCN			! FRTLIB routine to size text
	INTEGER*2 FS(4)			! Feature status for feature.
	LOGICAL	HW			! use h/w text?
C
C local variables
	REAL	X,Y
C
C This example code draws the text in exactly the same way
C as LITES2 or FPP themselves would have done.
C
C calculate position of bottom left of text (allow justification)
	X = XPOS+AUX(MINXI)*AUX(COSI)-AUX(MINYI)*AUX(SINI)
	Y = YPOS+AUX(MINXI)*AUX(SINI)+AUX(MINYI)*AUX(COSI)
	CALL TRITXT(TEXT,SC,X,Y,AUX(SIZI),AUX(ANGI),HW)
C
	RETURN
	END

SYMBOL DRAWING

If the logical name LSL$SYMBOL_ROUTINE points to a shared image which has a UNIVERSAL entry point called DRAW_SYMBOL, the routine supplied will be called rather than the LITES2 internal routine. The specification of DRAW_SYMBOL is

	SUBROUTINE DRAW_SYMBOL(
     &		FC,SC,NATT,ATTC,ATTV,XPOS,YPOS,AUX,TRITXT,SRIPLT,
     &          TRISCN,DRAW_TEXT,FS)
C
C Copyright Laser Scan Laboratories Ltd., Cambridge, England.
C
C The routine is expected to be used as a shareable image by LITES2
C and FPP, on logical name LSL$SYMBOL_ROUTINE.
C
C
	IMPLICIT NONE
	
C define layout of AUX array (copy of LITES2 CMN:AUXDEF.PAR)
C
	PARAMETER AUXLEN = 8	! length of auxiliary array
	PARAMETER ANGI = 1	! angle
	PARAMETER COSI = 2	! cosine
	PARAMETER SINI = 3	! sine
	PARAMETER SIZI = 4	! size
	PARAMETER MINXI= 5	! minimum x
	PARAMETER MAXXI= 6	! maximum x
	PARAMETER MINYI= 7	! minimum y
	PARAMETER MAXYI= 8	! maximum y
C
C arguments
	INTEGER	FC			! feature code
C
	INTEGER		SC		! secondary code from FRT
	INTEGER		NATT		! number of attributes
	INTEGER		ATTC(*)		! the column headers
	INTEGER		ATTV(*)		! the attributes
	REAL		XPOS,YPOS	! coordinate
	REAL		AUX(AUXLEN)	! array of extra information
	LOGICAL		TRITXT		! FRTLIB routine to draw text
	LOGICAL		SRIPLT		! FRTLIB routine to draw symbol
	LOGICAL		TRISCN		! FRTLIB routine to size text
C
	EXTERNAL	DRAW_TEXT	! user's text drawing routine
	INTEGER*2	FS(4)		! feature status for feature
C
C This example code draws the symbol in exactly the same way
C as LITES2 or FPP themselves would have done.
C
	CALL SRIPLT(SC,XPOS,YPOS,AUX(SIZI),AUX(ANGI))
C
	RETURN
	END

TEXT BLANKING

The same shared image on logical name LSL$TEXT_ROUTINE may have a second UNIVERSAL entry point called BLANK_TEXT. The routine supplied will be called to supply a blanking polygon for a text rather than the LITES2 internal routine. The specification of BLANK_TEXT is

	SUBROUTINE BLANK_TEXT(
     &		TEXT,FC,SC,N,XY,OFF,CMPLX,
     &		XPOS,YPOS,AUX,
     &		TRI_BOUND,SRI_BOUND,TRISCN,SRI_OFFSET_POLYGON,
     &		FS,HW)
C
	IMPLICIT NONE
C
C Copyright Laser Scan Laboratories Ltd., Cambridge, England.
C
C The routine is expected to be used as a shareable image by LITES2
C and FPP, on logical name LSL$TEXT_ROUTINE.
C It is called to return an outline polygon for a text feature when
C a line or area code is used as part of the prioritised representation
C of a text.
C If N is returned zero or negative, then the programs will supply the
C default blanking.
C
C define layout of AUX array (copy of LITES2 CMN:AUXDEF.PAR)
C
	PARAMETER AUXLEN = 8	! length of auxiliary array
	PARAMETER ANGI = 1	! angle
	PARAMETER COSI = 2	! cosine
	PARAMETER SINI = 3	! sine
	PARAMETER SIZI = 4	! size
	PARAMETER MINXI= 5	! minimum x
	PARAMETER MAXXI= 6	! maximum x
	PARAMETER MINYI= 7	! minimum y
	PARAMETER MAXYI= 8	! maximum y
C
C arguments
	CHARACTER*(*) TEXT		! text to draw
	INTEGER	FC			! feature code
	INTEGER	SC			! secondary code (font) from FRT
	INTEGER	N			! number of points in/out
	REAL	XY(2,*)			! the blanking points
	REAL	OFF			! offset from FRTSIZ
	LOGICAL	CMPLX			! complex blanking?
	REAL	XPOS,YPOS		! coordinate
	REAL	AUX(AUXLEN)		! array of extra information
	LOGICAL	TRI_BOUND		! FRTLIB routine to get text bounds
	LOGICAL	SRI_BOUND		! FRTLIB routine to get symbol bounds
	LOGICAL	TRISCN			! FRTLIB routine to size text
	EXTERNAL SRI_OFFSET_POLYGON	! FRTLIB routine to offset polygon
	INTEGER*2 FS(4)			! feature status
	LOGICAL	HW			! use h/w text?
C
C local variables
	INTEGER	I
	REAL	TXY(2)
	REAL SIZE,SINANG,COSANG,OFFXY(2)
	INTEGER	NIN
C
	NIN = N		! save input size of array
C
	SIZE = AUX(SIZI)
	IF (CMPLX) THEN
C
C Use TRI_BOUND to get a region around the text.
C Just for example, use an offset of 0.0, then offset the
C region ourselves. We are passed OFF as a fraction of the size.
	   IF (TRI_BOUND(TEXT,SC,N,XY,0.0,HW)) N = 0
C
C Offset the region
	   CALL SRI_OFFSET_POLYGON(NIN,XY,N,OFF)
C
C Save bottom left position (e.g. for text which is not bottom-
C left justified)
	   OFFXY(1) = AUX(MINXI)
	   OFFXY(2) = AUX(MINYI)
	ELSE
C
C Simple blanking - just generate a box
	   N = 4
	   XY(1,1) = AUX(MINXI)-OFF*SIZE
	   XY(2,1) = AUX(MINYI)-OFF*SIZE
	   XY(1,2) = AUX(MAXXI)+OFF*SIZE
	   XY(2,2) = XY(2,1)
	   XY(1,3) = XY(1,2)
	   XY(2,3) = AUX(MAXYI)+OFF*SIZE
	   XY(1,4) = XY(1,1)
	   XY(2,4) = XY(2,3)
	   SIZE = 1.0		! already scaled to size
	   OFFXY(1) = 0.0
	   OFFXY(2) = 0.0
	ENDIF
C
C Scale, offset, and rotate the region to its final position
	COSANG = AUX(COSI)
	SINANG = AUX(SINI)
	DO 40 I=1,N
	   TXY(1) = XY(1,I)*SIZE + OFFXY(1)
	   TXY(2) = XY(2,I)*SIZE + OFFXY(2)
	   XY(1,I) = XPOS + TXY(1)*COSANG - TXY(2)*SINANG
	   XY(2,I) = YPOS + TXY(1)*SINANG + TXY(2)*COSANG
40	CONTINUE
C
	RETURN
	END

SYMBOL BLANKING

The same shared image on logical name LSL$SYMBOL_ROUTINE may have a second UNIVERSAL entry point called BLANK_SYMBOL. The routine supplied will be called to supply a blanking polygon for a symbol rather than the LITES2 internal routine. The specification of BLANK_SYMBOL is

	SUBROUTINE BLANK_SYMBOL(
     &		FC,SC,N,XY,OFF,CMPLX,
     &		NATT,ATTC,ATTV,XPOS,YPOS,AUX,
     &		TRI_BOUND,SRI_BOUND,TRISCN,SRI_OFFSET_POLYGON,
     &		BLANK_TEXT,FS)
C
	IMPLICIT NONE
C
C Copyright Laser Scan Laboratories Ltd., Cambridge, England.
C
C The routine is expected to be used as a shareable image by LITES2
C and FPP, on logical name LSL$SYMBOL_ROUTINE.
C It is called to return an outline polygon for a symbol feature when
C a line or area code is used as part of the prioritised representation
C of a symbol.
C If N is returned zero or negative, then the programs will supply the
C default blanking.
C
C define layout of AUX array (copy of LITES2 CMN:AUXDEF.PAR)
C
	PARAMETER AUXLEN = 8	! length of auxiliary array
	PARAMETER ANGI = 1	! angle
	PARAMETER COSI = 2	! cosine
	PARAMETER SINI = 3	! sine
	PARAMETER SIZI = 4	! size
	PARAMETER MINXI= 5	! minimum x
	PARAMETER MAXXI= 6	! maximum x
	PARAMETER MINYI= 7	! minimum y
	PARAMETER MAXYI= 8	! maximum y
C
C arguments
	INTEGER	FC			! feature code
	INTEGER	SC			! secondary code (font) from FRT
	INTEGER	N			! number of points in/out
	REAL	XY(2,*)			! the blanking points
	REAL	OFF			! offset from FRTSIZ
	LOGICAL	CMPLX			! complex blanking?
	INTEGER	NATT			! number of attributes
	INTEGER	ATTC(*)			! the columns headers
	INTEGER	ATTV(*)			! the attributes
	REAL	XPOS,YPOS		! coordinate
	REAL	AUX(AUXLEN)		! array of extra information
	LOGICAL	TRI_BOUND		! FRTLIB routine to get text bounds
	LOGICAL	SRI_BOUND		! FRTLIB routine to get symbol bounds
	LOGICAL	TRISCN			! FRTLIB routine to size text
	EXTERNAL SRI_OFFSET_POLYGON	! FRTLIB routine to offset polygon
	EXTERNAL BLANK_TEXT		! user's text blanking routine
	INTEGER*2 FS(4)			! feature status
C
C local variables
	INTEGER	I
	REAL	TXY(2)
	INTEGER	BOUND_TYPE
	REAL SIZE,SINANG,COSANG
	INTEGER	NIN
C
	NIN = N		! save input size of array
C
	SIZE = AUX(SIZI)
C
C Set BOUND_TYPE for SRI_BOUND
	IF (CMPLX) THEN
	   BOUND_TYPE = 3		! convex hull
	ELSE
	   BOUND_TYPE = 2		! bounding box
	ENDIF
C
C Just for example, use an offset of 0.0, then offset the
C region ourselves. We are passed OFF as a fraction of the size.
	IF (SRI_BOUND(SC,N,XY,0.0,BOUND_TYPE)) N = 0
C
C Offset the region
	CALL SRI_OFFSET_POLYGON(NIN,XY,N,OFF)
C
C Scale, offset, and rotate the region to its final position
	COSANG = AUX(COSI)
	SINANG = AUX(SINI)
	DO 40 I=1,N
	   TXY(1) = XY(1,I)*SIZE
	   TXY(2) = XY(2,I)*SIZE
	   XY(1,I) = XPOS + TXY(1)*COSANG - TXY(2)*SINANG
	   XY(2,I) = YPOS + TXY(1)*SINANG + TXY(2)*COSANG
40	CONTINUE
C
	RETURN
	END