home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-14 | 56.9 KB | 1,891 lines |
-
-
- X-CAD Database format
- =====================
-
- The following document describes the X-CAD database format as used in the.
- xdr files created by X-CAD versions 1.3 and 1.4 and X-SKETCH. The file
- consists of a header followed by two or more blocks describing each entity
- or object held in the database.
-
- The block descriptions that follow use the C language structure type to
- define each element belonging to a block. The space considerations for each
- element type are:
-
- byte One 8 bit byte.
- short Two byte integer.
- long Four byte integer.
- float Four byte floating point number.
- double Eight byte floating point number.
-
-
- File Header
- ===========
-
- The file header consists of 5 data elements describing the type, revision
- and size of the. xdr file.
-
- struct HEADER
- {
- long ID;
- short REV;
- long ENTS;
- long MEMREQ;
- short FLAGS;
- }
-
- ID This is the file identifier - a 4 byte code that must be equal to
- the string "ACDR".
-
- REV The drawing file revision number.
-
- ENTS The number of entity blocks that follow this header block.
-
- MEMREQ The total amount of data ( as a number of bytes ) in this file
- excluding the header block.
-
- FLAGS Bit encoded flags:
- Bit 0 on = This drawing file contains no graphics information
- ( there are no GIBLOCKs or GBBLOCKS in this file ).
- Bit 1 on = This drawing file contains a password. If this bit is
- set, then the header block is followed by 8 bytes
- containing a coded password. ( Currently unused ).
-
-
- Entity Blocks
- =============
-
- Following the file header are two or more entity blocks. Each block contains
- the total description for an entity.
-
- Entity blocks are formatted as follows:
-
-
- INDEX [] denotes optional
- HIBLOCK (s) denotes block may be repeated
- EHBLOCK
- EDBLOCK(s)
- [ GIBLOCK(s) ]
- [ GBBLOCK(s) ]
-
-
- Entity Index
- ============
-
- The entity index is a 2 byte unsigned integer containg the unique index
- number of this entity. The index number is used as a reference throughout an
- X-CAD drawing file and database. Entity index numbers are allocated
- according to the following criteria:
-
- Index 1 The drawing entity.
-
- Index 2 The SHEET viewport.
-
- Index 3-33 Auxiliary viewports.
-
- Index 34-512 Attribute entities.
-
- Index 513-1024 Reserved.
-
- Index 1025-65535 Drawing entities.
-
-
- Entity HIBLOCK
- ==============
-
- The entity HIBLOCK is a data structure containing the basic information
- about this entity. An HIBLOCK always follows the entity index.
-
- struct HIBLOCK
- {
- struct EHBLOCK *EHBLOCK;
- short FLAGS1;
- short FLAGS2;
- struct GIBLOCK *GRAPHICS;
- }
-
- EHBLOCK Used as a pointer to an EHBLOCK structure when the .xdr file is
- loaded, but has no meaning within the .xdr file.
-
- FLAGS1 Bit encoded word:
- 0-4 Entity type
- 5 Transient bit used by redraw routines
- 6 On if entity is visible
- 7 On if entity identified by IDENTS
- 8-15 Entity layer
-
- FLAGS2 Bit encoded word:
- 0-4 Viewport number ( +2 = index number of viewport entity )
- 5-8 Entity depth
- 9 Non-delete flag
- 10 On if entity is tagged by IDENTS
- 11 On if entity is highlighted
- 12 On if entity is currently displayed
- 13-14 Transient bits used by symbols
- 15 Transient bit used for family tracing
-
- GRAPHICS Used internally as a pointer to the first GIBLOCK for this
- entity. If GRAPHICS is non-zero, then a GIBLOCK will follow
- on after the last EDBLOCK. If GRAPHICS is zero then there are
- no GIBLOCKs present.
-
- This element should be ignore if bit 0 is set in the FLAGS
- element of the file header.
-
-
- Entity EHBLOCK
- ==============
-
- The entity EHBLOCK is a data structure containing additional information
- about each entity. An EHBLOCK always follows the HIBLOCK.
-
- struct EHBLOCK
- {
- struct EDBLOCK *FIRST;
- short FLAGS;
- short AWORD1;
- short AWORD2;
- short AWORD3;
- }
-
- FIRST Used internally as a pointer to the first EDBLOCK that follows
- this EHBLOCK. If FIRST is non-zero, then one or more EDBLOCKs
- follow. If FIRST is zero, there are no EDBLOCKs present.
-
- FLAGS Unused.
-
- AWORD1/2/3 Three 2 byte words available internally to any application.
-
-
- Entity EDBLOCK
- ==============
-
- An entity EDBLOCK is a structure containing a block of data or a set of
- parameters relevent to the entity. Each entity can contain one or more
- EDBLOCKs that make up the database description of the entity.
-
- struct EDBLOCK
- {
- struct EDBLOCK *NEXT;
- unsigned char *BLOCKID;
- unsigned char *SUBID;
- long LENGTH;
- }
- DATA
-
- NEXT Used internally as a pointer to the next EDBLOCK. If NEXT is
- non-zero then another EDBLOCK follows on from this one. If
- NEXT is zero then there are no more EDBLOCKs present.
-
- BLOCKID The data block identifier used to determine the type of data
- found after the EDBLOCK.
-
- SUBID The data block sub-identifier.
-
- LENGTH The length of the data block in bytes ( always an even number ).
-
- DATA The actual data. The format of this is dependent on the
- BLOCKID and SUBID.
-
-
- Entity GIBLOCK
- ==============
-
- The entity GIBLOCK data structure contains information about the display
- list data associated with this entity. GIBLOCKs are only present if the
- GRAPHICS element is non-zero in the entity HIBLOCK, and only then if bit 0
- in the FLAGS element of the file header is not set.
-
- struct GIBLOCK
- {
- struct GIBLOCK *NEXT;
- unsigned char *LAYOFF;
- unsigned char *DEPOFF;
- struct GBBLOCK *FIRST;
- }
-
- NEXT Used internally as a pointer to the next GIBLOCK. If NEXT is
- non-zero, then another GIBLOCK follows on after any GBBLOCKs
- associated with this GIBLOCK. If NEXT is zero there are no more
- GIBLOCKs present.
-
- LAYOFF Contains a layer offset to apply to all display list data
- associated with this GIBLOCK. ie the actual layer is
- ( entity layer + LAYOFF ) mod 256 .
-
- DEPOFF Contains a depth offset to apply to all display list data
- associated with this GIBLOCK. ie the actual depth is
- ( entity depth + DEPOFF ) mod 8 .
-
- FIRST Used internally as a pointer to the first GBBLOCK associated
- with this GIBLOCK. Any GBBLOCKs associated with a GIBLOCK
- follow before the next GIBLOCK in the list. If FIRST is non-
- zero a GBBLOCK follows. If FIRST is zero, there are no
- GBBLOCKs associated with this GIBLOCK.
-
-
- Entity GBBLOCK
- ==============
-
- The entity GBBLOCK contains display list data associated with the last
- GIBLOCK. Display list data is in the form of a vector list describing what
- is actually shown on the screen.
-
- struct GBBLOCK
- {
- struct GBBLOCK *NEXT;
- unsigned char TYPE;
- unsigned char FLAGS;
- long SIZE;
- }
- DATA
-
- NEXT Used internally as a pointer to the next GBBLOCK in this
- list. If NEXT is non-zero another GBBLOCK follows this one.
- If GBBLOCK is zero there are no more GBBLOCKs in this list.
-
- TYPE The display list data block type.
-
- =1 Stroke vector list
- =2 Filled polygon vector list
- =3 Filled line vector list
- =4 Non-scaled symbol coordinate list
-
- FLAGS Unused.
-
- SIZE The size of the display list data block in bytes.
-
- DATA The display list data block. The contents of this data block are
- dependent on the TYPE element. ( See section on GBBLOCK data ).
-
-
- Entity Types
- ============
-
- Entity types are represented by a number between 0 and 31 encoded in the
- FLAGS1 element of the HIBLOCK. The entity types current used by X-CAD are as
- follows:
-
- 0 Drawing parameters entity
- 1 Viewport entity
- 2 Attribute entity
- 3 String entity
- 4 Arc entity
- 5 Ellipse entity
- 6 Construction point entity
- 7 Polygon entity
- 8 Line entity
- 9 Spline entity
- 10 Cross-hatch polygon entity
- 11 Text entity
- 12 Text-node entity
- 13 Dimension entity
- 14 Symbol entity
- 15 Terminal entity
- 16 Netline entity
- 17-31 Not allocated
-
-
- EDBLOCKS Associated with entity types
- =====================================
-
- Each entity type must have one or more EDBLOCKs associated with it. The
- following list shows which EDBLOCK types must be present to correctly define
- the entity in the X-CAD drawing database.
-
- Entity type: 0 Drawing parameters entity
-
- BLOCKID 2 Drawing parameters data.
-
- Entity type: 1 Viewport entity
-
- BLOCKID 1 Viewport parameters.
-
- Entity type: 2 Attribute entity
-
- BLOCKID 12 Text string - contains attribute name.
- BLOCKID 13 Child member list - lists all entities with this
- attribute.
-
- Entity type: 3 String entity
-
- BLOCKID 3 Coordinate list.
-
- Entity type: 4 Arc entity
-
- BLOCKID 3 Coordinate list - describes arc origin.
- BLOCKID 5 Arc parameters.
-
- Entity type: 5 Ellipse entity
-
- BLOCKID 3 Coordinate list - describes ellipse origin.
- BLOCKID 6 Ellipse parameters.
-
- Entity type: 6 Construction point entity
-
- BLOCKID 3 Coordinate list.
-
- Entity type: 7 Polygon entity
-
- BLOCKID 3 Coordinate list - each boundary within the polygon entity
- is described with a separate type 3
- EDBLOCK.
-
- Entity type: 8 Line entity
-
- BLOCKID 3 Coordinate list.
-
- Entity type: 9 Spline entity
-
- BLOCKID 3 Coordinate list - describes spline control points.
-
- Entity type: 10 Cross-hatch polygon entity
-
- BLOCKID 3 Coordinate list - each boundary within the polygon entity
- is described with a separate type 3
- EDBLOCK.
- BLOCKID 8 Xhatch parameters.
-
- Entity type: 11 Text entity
-
- BLOCKID 3 Coordinate list - represents origin of text.
- BLOCKID 11 Text parameters.
- BLOCKID 12 Text string.
-
- Entity type: 12 Text-node entity
-
- BLOCKID 3 Coordinate list - represents origin of text-node.
- BLOCKID 11 Text parameters.
- BLOCKID 13 Child member list - lists index of related text entity.
-
- Entity type: 13 Dimension entity
-
- BLOCKID 11 Text parameters.
- BLOCKID 17 Dimension parameters.
- BLOCKID 19 Dimension details.
-
- Entity type: 14 Symbol entity
-
- BLOCKID 3 Coordinate list - represents symbol origin.
- BLOCKID 12 Text string - symbol name.
- BLOCKID 16 Symbol parameters.
-
- Entity type: 15 Terminal entity.
-
- BLOCKID 3 Coordinate list - represents origin of terminal.
- BLOCKID 21 Terminal type.
-
- Entity type: 16 Netline entity.
-
- BLOCKID 3 Coordinate list.
-
-
- BLOCKID 1 Viewport Parameters
- =============================
-
- Each viewport entity in a drawing must have associated with it a Viewport
- parameters data structure.
-
- struct ACViewPort
- {
- char NAME[22];
- double WIDTH;
- double HEIGHT;
- short UNITS;
- double XORG;
- double YORG;
- double SCL;
- short XOFF;
- short YOFF;
- short XMAX;
- short YMAX;
- short CXMIN;
- short CYMIN;
- short CXMAX;
- short CYMAX;
- short VISIBLE;
- double SHXOFF;
- double SHYOFF;
- };
-
- NAME The viewport name as a null terminated character string. The name
- can have a maximum of 20 characters.
-
- WIDTH The width of the viewport in viewport units.
-
- HEIGHT The height of the viewport in viewport units.
-
- UNITS The viewport units: 0 = Millimetres
- 1 = Centimetres
- 2 = Metres
- 3 = Kilometres
- 4 = Inches
- 5 = Feet
- 6 = Miles
-
- XORG X origin of the viewport in viewport units relative to the bottom
- left corner of the viewport.
-
- YORG Y origin of the viewport in viewport units relative to the bottom
- left corner of the viewport.
-
- SCL Scale to apply to viewport coordinates to transform to display
- coordinate system. ( See section on coordinate systems ).
-
- XOFF X offset of viewport in display coordinate system.
-
- YOFF Y offset of viewport in display coordinate system.
-
- XMAX Width of viewport in display coordinate system.
-
- YMAX Height of viewport in display coordinate system.
-
- CXMIN Current minimum x clip for viewport in viewport coordinate system.
- This value is relative to the viewport origin (0,0) at the top left
- corner of the viewport.
-
- CYMIN Current minimum y clip for this viewport.
-
- CXMAX Current maximum x clip for this viewport.
-
- CYMAX Current maximum y clip for this viewport.
-
- VISIBLE Viewport open/close flag. 1 = open, 0 = closed.
-
- SHXOFF X coordinate of the viewport origin ( bottom left corner ) in the
- sheet viewport ( viewport 0 ) coordinates.
-
- SHYOFF Y coordinate of the viewport origin in sheet viewport coordinates.
-
-
- BLOCKID 2 Drawing Parameter Data
- ================================
-
- Each X-CAD drawing has a drawing parameters entity. Associated with the
- drawing parameters entity is a number of drawing parameters data blocks. The
- SUBID of each type 2 BLOCKID defines the type of data found.
-
- A SUBID of 1 defines a layer name data structure:
-
- struct LayerName
- {
- char NAME[16];
- short LAYER;
- };
-
- NAME The layer name. A maximum 14 character null terminated text string.
-
- LAYER The actual layer number associated with the layer name.
-
- A SUBID of 2 defines a layer list data structure:
-
- struct LayerList
- {
- char NAME[16];
- short LAYLIST[16];
- };
-
- NAME The layer name. A maximum 14 character null terminated text string.
-
- LAYLIST A visibility mask for all 255 layers associated with this named
- layer list. Word 1 defines visibility for layers 0-15, word 2 for
- layers 16-32 etc. Each bit on within the word specifies that layer
- is visible.
-
- A SUBID of 4 defines the current layer colour assignments for the drawing.
- The data that follows is 256 bytes each of which use the first 7 bits to
- define the assigned layer colour. The first byte corresponds to layer 0, the
- second byte to layer 1 etc.
-
- A SUBID of 5 defines an image data structure associated with this drawing:
-
- struct ZoomImage
- {
- char NAME[10];
- short XMIN;
- short YMIN;
- short XMAX;
- short YMAX;
- };
-
- NAME The image name. A maximum 8 character null terminated text string.
-
- XMIN Minimum x clip of window in display coordinate system for sheet
- viewport.
-
- YMIN Minimum y clip of window.
-
- XMAX Maximum x clip of window.
-
- YMAX Maximum y clip of window.
-
- A SUBID of 6 defines the colours currectly selected for this drawing. 9 two
- byte integers follow this EDBLOCK. The first 8 words define each of the 8
- visible colours, the last word defines the colour of the cursor. Each word
- defines a colour as a combination of 3 nibbles describing the RGB components
- of the colour:
-
- Bits 0-3 blue
- Bits 4-7 green
- Bits 8-11 red
-
- A SUBID of 7 defines the currently selected symbol directory for this
- drawing. The data that follows is a null terminated character string
- containing the directory name.
-
- A SUBID of 8 defines the currently selected patternfill datafile for this
- drawing. The data that follows is a null terminated character string
- containing the patternfill datafile name.
-
- A SUBID of 9 defines the currently selected softfont datafile for this
- drawing. The data that follows is a null terminated character string
- containing the softfont datafile name.
-
-
- BLOCKID 3 Coordinate List
- =========================
-
- Most entity types within an X-CAD drawing have a type 3 BLOCKID. The data
- following this type of EDBLOCK is aways one or sets of xy coordinates. Each
- set of xy coordinate points is represented by 2 doubles. The coordinate
- points are always relative to the entities viewport.
-
- Most type 3 BLOCKIDs have a SUBID of 0 denoting no special meaning. The
- meaning of other SUBIDs are as follows.
-
- A SUBID of 2 occurs on polygon and cross-hatch polygon entities. This type
- of entity can have one or more type 3 BLOCKIDs, one for each boundary of the
- polygon. A SUBID of 2 defines the outer or first boundary. A SUBID of 3
- defines any inner or subsequent boundaries.
-
- A SUBID of 4 occurs only on spline entities. This means that the spline is
- closed, ie it runs smoothly through the first and last control points.
-
-
- BLOCKID 4 Font Parameters
- =========================
-
- A type 4 BLOCKID can occur on most entities as it defines the appearance or
- font of the entity. The type of data structure used to define the font is
- dependent on the SUBID of the EDBLOCK.
-
- A SUBID of 1 defines a hardfont data structure:
-
- struct HardFont
- {
- char THICK;
- char STYLE;
- };
-
- THICK Line thickness as a value between 1-5.
-
- STYLE Line style as a value between 0-15.
-
- If this SUBID is found on a type 4 BLOCKID associated with a viewport
- entity, it defines the default hardfont for the text parameters associated
- with this viewport.
-
- A SUBID of 2 defines a named softfont data structure:
-
- struct NamedSoftFont
- {
- char NAME[16];
- float SCALE;
- };
-
- NAME The softfont name. A maximum 15 character null terminated character
- string containing the softfont name.
-
- SCALE Scale to apply to the font width etc.
-
- A SUBID of 3 defines a local softfont data structure:
-
- struct SoftFont
- {
- char TYPE;
- char UNITS;
- char NAME[16];
- char FLAGS;
- char COLOUR;
- char PATNAME[12];
- short HARDSTYLE;
- float WIDTH;
- short DASH_DOT;
- float SP[16];
- };
-
- TYPE Bit flag containing information about font type:
-
- Bit 0 On indicates local font ( used internally ).
- 1 On indicates named font ( used internally ).
- 2 On indicates fixed scale font, units stored in UNITS.
- 3 On indicates patterfilled font.
-
- UNITS The units type of the viewport used to define the font. Units values
- are as in the Viewport Parameters data structure.
-
- NAME The name of the font if TYPE bit 1 is set. ( Used internally ).
-
- FLAGS Bit flag containing additional information about font.
-
- Bit 0 On indicates font has a width.
- 1 On indicates font width is left justified.
- 2 On indicates font width is right justified.
- 3 On indicates width font is open-ended.
- 4 On indicates width font has extended ends.
- 5 On indicates width font is filled.
- 6 On indicates width font is filled with an absolute colour.
- 7 On indicates width font has an outline in the layer
- assigned colour.
-
- COLOUR Fill colour if FLAGS bit 6 is set.
-
- PATNAME Patternfill name if TYPE bit 3 is set.
-
- WIDTH Width of the font in UNITS if TYPE bit 1 is set else viewport
- units.
-
- DASH_DOT The number of dash/space values in SP.
-
- SP A list of dash/space pairs for the font in UNITS if TYPE bit 1 is
- set else viewport units.
-
- A SUBID of 4 indicates a polygon fill data structure. This SUBID only occurs
- on polygon entities.
-
- struct PolyFont
- {
- char TYPE;
- char DUM;
- char FLAGS;
- char COLOUR;
- char PATNAME;
- };
-
- TYPE Bit flag containing information about font type:
-
- Bit 3 On indicates patterfilled font.
- 4 On indicates background of single colour patternfilled
- polygon is rendered in layer assigned colour.
- 5 On indicates shadow polygon.
-
- DUM Not used.
-
- FLAGS Bit flag containing additional information about font.
-
- Bit 1 On indicates patternfilled polygon has transparent
- background.
- 2 On indicates single colour patternfilled polygon is used
- as a mask.
- 3 On indicates colour filled polygon is halftoned.
- 5 On indicates polygon is filled.
- 6 On indicates polygon is filled with an absolute colour.
- 7 On indicates polygon has an outline in the layer assigned
- colour.
-
- COLOUR Fill colour if FLAGS bit 6 is set.
-
- PATNAME Patternfill name if TYPE bit 3 is set.
-
- A SUBID of 11 defines hardfont data in the same way as SUBID 1. This SUBID
- only occurs on viewport entities. It defines the hardfont used for the
- default dimension parameters for this viewport.
-
-
- BLOCKID 5 Arc Parameters
- ========================
-
- A type 5 EDBLOCK is followed by an arc parameters data structure:
-
- struct ArcParameters
- {
- double RADIUS;
- double AGO;
- double AEND;
- };
-
- RADIUS The arc radius in viewport units.
-
- AGO The arc start angle in radians.
-
- AEND The arc end angle in radians.
-
-
- BLOCKID 6 Ellipse Parameters
- ============================
-
- A type 6 EDBLOCK is followed by an ellipse parameters data structure:
-
- struct ElpParameters
- {
- double MAJOR;
- double MINOR;
- double INCL;
- double AGO;
- double AEND;
- };
-
- MAJOR The ellipse major radius in viewport units.
-
- MINOR The ellipse minor radius in viewport units.
-
- INCL The ellipse inclination angle in radians.
-
- AGO The arc start angle in radians.
-
- AEND The arc end angle in radians.
-
-
- BLOCKID 8 Xhatch Parameters
- ===========================
-
- A type 8 EDBLOCK is followed by an xhatch parameters data structure:
-
- struct XhParameters
- {
- double SPACING;
- double ANGLE;
- };
-
- SPACING Parallel distance of lines used for cross-hatch.
-
- ANGLE Angle of cross-hatch in radians.
-
-
- BLOCKID 11 Text Parameters
- ==========================
-
- A type 11 EDBLOCK is followed by a text parameters data structure:
-
- struct TextParams
- {
- char FONT[10];
- float HEIGHT;
- float WIDTH;
- float ANGLE;
- float CSPACE;
- float SLANT;
- char JUST;
- char FLAGS;
- float LNSP;
- };
-
- FONT The text font name. A maximum 8 charater null terminated text
- string.
-
- HEIGHT The height of the text in viewport units.
-
- WIDTH The width of the text in viewport units. The height and width used
- are for the tile size of the letter. The width does not include the
- space between letters, this is defined by the CSPACE variable.
-
- ANGLE The angle of the text in radians.
-
- CSPACE The text character spacing as a proportion of the width. ie, if
- CSPACE is 1.3, the space between each letter is .3 times the
- letter width.
-
- SLANT The slant of the text in radians.
-
- JUST Text justification flag: -1 = left justified
- 0 = centre justified
- 1 = right justified
-
- FLAGS Bit encoded flag: Bit 0 On indicates uniform spacing
- 0 Off indicates proportional spacing
- 1 On indicates filled text
-
- LNSP Text line spacing as a proportion of the text height.
-
- If this EDBLOCK is associated with a viewport entity, it defines the default
- text parameters associated with the viewport.
-
-
- EDBLOCK 12 Text String
- ======================
-
- A type 12 EDBLOCK is always followed by a null terminated character string.
- This is generally used as some sort of label, ie. a symbol name or string
- associated with a text entity.
-
-
- EDBLOCK 13 Child Member List
- ============================
-
- A type 13 EDBLOCK is followed by one or more 2 byte integers each of which
- are the index number of an entity. The entities in this list are all child
- members in the relationship for which this entity is the parent. Each of the
- child members should have a parent member list containing the index of this
- entity.
-
- The SUBIDs used with a type 13 EDBLOCK define the kind of relationship
- involved. The child member entities in a type 13 EDBLOCK with a specific
- SUBID must also contain a parent member list ( type 15 EDBLOCK ) with the
- same SUBID.
-
- A SUBID of 0 is found on an attribute entity. The child member list contains
- the indexes of all entities sharing this attribute. This SUBID is the
- exception to the rule in that the child entities do not have a type 15
- BLOCKID with a SUBID of 0 containing the index of the parent attribute
- entity. Instead a type 22 BLOCKID is used to relate the child member back to
- its parent.
-
- A SUBID of 1 is found on a text-node or netline entity. This block should
- only contain a single member which is the text entity related to the text-
- node or netline.
-
- A SUBID of 2 is found on an exploded symbol entity. The child member list
- contains the indexes of all entities related to the symbol origin except for
- any text-node, symbol or terminal entities.
-
- A SUBID of 3 is found on a symbol entity. The child member list contains the
- indexes for any text-node, symbol or terminal entities related to the
- symbol.
-
- A SUBID of 6 is found on a symbol entity. The child member list contains the
- indexes for any construction point entities related to the symbol.
-
- A SUBID of 10 is found on a viewport entity. The child member list contains
- the indexes for any entities ( usually dimensions ) the are related to the
- viewport.
-
- A SUBID of 11 is found on a terminal entity. The child member list contains
- the indexes of all netline entities whose origin point is this terminal.
-
- A SUBID of 12 is found on a terminal entity. The child member list contains
- the indexes of all netline entities whose end point is this terminal.
-
- A SUBID of 100 is a general relationship with no specific meaning. This is
- usually set up using the RELATE ENTITY command.
-
-
- BLOCKID 14 Equal Member List
- ============================
-
- A type 14 EDBLOCK is followed by one or more 2 byte integers each of which
- are the index number of an entity. The entities in this list are all equal
- members in the relationship for which this entity is a member. Each of the
- equal members should also have an equal member list containing the index of
- this entity.
-
- The only SUBID used on a type 14 EDBLOCK is 100 meaning general relationship.
-
-
- BLOCKID 15 Parent Member List
- =============================
-
- A type 15 EDBLOCK is the exact inverse of a type 13 EDBLOCK. The block is
- followed by one or more 2 byte integers each of which are the index number
- of an entity. The entities in this list are all parent members in the
- relationship for which this entity is a child.
-
- The SUBIDs found are the same as described under the type 13 EDBLOCK.
-
-
- BLOCKID 16 Symbol Parameters
- ============================
-
- A type 16 EDBLOCK is followed by a symbol parameters data structure:
-
- struct SymParams
- {
- double XSCL;
- double YSCL;
- double ANGLE;
- short FLAGS;
- };
-
- XSCL The x scale to apply to the symbol.
-
- YSCL The y scale to apply to the symbol.
-
- ANGLE The symbol angle in radians.
-
- FLAGS Bit encoded word containing additional information about the symbol.
-
- Bit 0 On indicates the symbol is mirrored about its x axis.
- Bit 2 On indicates no units conversion should take place.
- Bit 3 On indicates symbol text should not be rotated.
- Bit 4 On indicates symbol text should not be scaled.
- Bit 5 On indicates symbol text should not be mirrored.
- Bit 6 On indicates use relative layer.
- Bit 7 On indicates use relative depth.
- Bit 15 On indicates an exploded symbol.
-
-
- BLOCKID 17 Dimension Parameters
- ===============================
-
- A type 17 EDBLOCK is followed by a dimension parameters data structure:
-
- struct DimParams
- {
- long FLAGS;
- float GAP;
- float EXT;
- float ALENGTH;
- float ARATIO;
- double SCALE;
- short FRAC;
- char PREC;
- char UNITS;
- float TOL[2];
- };
-
- FLAGS Bit encoded word containing additional information about dimension.
-
- Bit 0 On indicates suppress first dimension leader line.
- Bit 1 On indicates suppress second dimension leader line.
- Bit 2 On indicates use filled arrowhead.
- Bit 3 On indicates use open arrowhead ( > ).
- Bit 4 On indicates use dash arrowhead ( / ).
- Bit 5 On indicates that dimension text should be aligned to the
- witness line.
- Bit 6 On indicates that dimension text should be horizontally
- aligned.
- Bit 7 On indicates that the witness line should be broken to
- accomodate the dimension text.
- Bit 8 On indicates that the dimension is associative.
- Bit 9 On indicates that the dimension has prefix text.
- Bit 10 On indicates that the dimension has suffix text.
- Bit 11 On indicates that leading zeros should be suppressed when
- formatting dimension value text.
- Bit 12 On indicates that the dimension value should be in the
- units type under UNITS.
- Bit 13 On indicates no arrowhead should be used.
- Bit 14 On indicates that decimal notation should be used for
- imperial units.
- Bit 15 On indicates that trailing zeros should be suppressed when
- formatting the dimension value text.
- Bit 16 On indicates that fractions should be used for imperial
- units.
- Bit 17 On indicates that the fraction denominator should be fixed
- for imperial units.
- Bit 18 On indicates that the dimension value text should include
- a tolerance for +/-.
- Bit 19 On indicates that the dimension value text should include a
- separate tolerance for + and -.
- Bit 20 On indicates that the dimension value text should include a
- tolerance for + only.
- Bit 21 On indicates that the dimension value text should include a
- tolerance for - only.
- Bit 22 On indicates that the dimension text should consist of 2
- values, one for the absolute + value, one for the absolute -
- value.
- Bit 23 On indicates use dot arrowhead.
-
- GAP The size of the gap between the dimensioned object and the start
- of the leader line in viewport units.
-
- EXT The length of the extension of the leader line beyond the dimension
- witness line in viewport units.
-
- ALENGTH The length of the arrowhead in viewport units.
-
- ARATIO The width of the arrowhead as a proportion of its length.
-
- SCALE Scale factor to apply to dimension values.
-
- FRAC Fractional denominator for imperial units.
-
- PREC Number of places of precision for dimension value text.
-
- UNITS Alternative units type to use if FLAGS bit 12 is set. The units
- type value is the same as used in the viewport parameters data
- structure.
-
- TOL Two tolerance values to use if FLAGS bits 18 to 22 are set.
-
- If this EDBLOCK is associated with a viewport entity, it defines the default
- dimension parameters associated with the viewport.
-
- Note, dimension parameter data structures that occur on X-CAD V1.3 drawings
- do not have the TOL element. The LENGTH value in the EDBLOCK should be
- checked to verify this.
-
-
- BLOCKID 18 Viewport Scale
- =========================
-
- A type 18 EDBLOCK only appears in viewport entities. It is followed by a
- single double value specifing the viewport scale. ie, if the viewport was
- defined with a scale of 1 to 100, the value following the EDBLOCK would be
- 100.0.
-
-
- BLOCKID 19 Dimension Details
- ============================
-
- A type 19 EDBLOCK is followed by a dimension details data structure
- containing additional information about the dimension.
-
- struct DimDetails
- {
- char TYPE;
- char FLAGS;
- double LOCS[10];
- double RADIUS;
- char VPNUM;
- char NUM;
- };
-
- TYPE The dimension type: 0 = horizontal
- 1 = vertical
- 2 = linear
- 3 = point
- 4 = angular
- 5 = diametric
- 6 = radial
-
- FLAGS Bit encoded word containing additional information about the
- dimension.
-
- Bit 0 On indicates that a fixed text string ( found in a type 11
- EDBLOCK on the same entity ) is to be used in place of the
- dimension value.
- 1 On indicates that the dimension value should be calculated
- for the viewport VPNUM.
- 2 On indicates that the position of the text is specific and
- contained in LOCS. If this bit is not set, the position of
- the text is calculated automatically.
-
- LOCS A set of up to 5 coordinates used to define the position of the
- dimension. The coordinates correspond to those used the enter the
- dimension using DRAW DIMENSION.
-
- RADIUS The radius of the selected arc if the dimension type is radial or
- diametric.
-
- VPNUM Viewport number of viewport used to calculate dimension values if
- FLAGS bit 1 is on.
-
- NUM Number of coordinate pairs in LOCS.
-
-
- BLOCKID 20 Hide List
- ====================
-
- A type 20 EDBLOCK is followed by one or more pairs of xy coordinate points.
- Each pair of xy points represent 2 points on a line, string or netline
- entity. These pairs of points on the entity represent off and on drawing
- positions when the entity is displayed thus generating hidden segments.
-
- The coordinate points in the type 20 EDBLOCK are always sorted with respect
- to the type 3 coordinate list associated with the same entity.
-
-
- BLOCKID 21 Terminal Type
- ========================
-
- A type 20 EDBLOCK only occurs on a terminal entity. It is followed by a
- single 2 byte integer whose value specifies the number of connections that
- can be made to this terminal. The value should be -1 or 1-4. If it is -1
- then this terminal allows any number of connections.
-
-
- BLOCKID 22 Attribute Value
- ==========================
-
- A type 22 BLOCKID can occur on any entity. It contains the parent index of
- the attribute entity plus any attribute value used by this entity. The
- EDBLOCK is followed by a 2 byte integer containing the index number of the
- parent attribute entity, followed by an optional set of data items. The type
- of data item is dependent on the SUBID of this EDBLOCK.
-
- A SUBID of 1 indicates that this is a NULL value attribute. Therefore there
- are no data items following the parent index.
-
- A SUBID of 2 indicates that this is an INTEGER value attribute. The parent
- index will be followed by one or more 4 byte integer values associated with
- the attribute. The number of values can be calculated from the LENGTH
- element in the EDBLOCK.
-
- A SUBID of 3 indicates that this is a REAL value attribute. The parent index
- will be followed by one or more 8 byte real values associated with the
- attribute. The number of values can be calculated from the LENGTH element in
- the EDBLOCK.
-
- A SUBID of 4 indicates that this is a TEXT value attribute. The parent index
- will be followed by a null terminated character string.
-
-
- Coordinate Systems
- ==================
-
- X-CAD drawings use a number of coordinate systems internally to represent
- the drawing database and the graphics display list. All coordinate systems
- used are based on the original definition of the sheet viewport ( viewport 0
- ).
-
- The initial starting point is a sheet viewport of a given height and width.
- No other viewports can be defined outside of this area and no graphics can
- be created or moved outside of this area. The sheet viewport defines the
- maximum usable drawing area.
-
- The viewport coordinate system is based on the units and origin of a
- viewport. For the sheet viewport, the origin is always in the bottom left
- corner of the screen. The positive x axis runs to the right of the origin
- while the positive y axis runs above the origin. Other viewports defined
- within the sheet viewport have the own local origin and units. Any
- coordinate values found in an EDBLOCK associated with an entity are always
- relative to the viewport in which the entity resides.
-
- To map a coordinate from a secondary viewport to the sheet viewport, the
- following transformation must be made.
-
- coor_2 = ( ( coor_1 + viewport_origin ) * units_sf ) + vp_sheet_origin
-
- Where:
-
- viewport_origin This is the local origin of the secondary viewport.
- The local origin can be found in the XORG and YORG
- elements of its viewport parameters data structure.
-
- units_sf This is the scale factor to apply to the coordinate
- point to map the point from its local units type and
- scale to the sheet viewport units type.
-
- vp_sheet_origin This is the point in the sheet viewport of the bottom
- left corner of the secondary viewport. This point can
- be found in the SHXOFF and SHYOFF elements of the
- secondary viewports viewport parameters data structure.
-
- The size and height/width proportions are used to define the display
- coordinate system. The display coordinate system is used internally by X-CAD
- for drawing purposes and for the construction of the graphics display list.
- The longer of the height or width of the sheet viewport is used to set the
- height or width of the display coordinate system to 32767 arbitary units.
- The second dimension is then calculated as the proportion of the longest
- length. ie, a sheet viewport with a width of 22 inches and a height of 17
- inches will set a maximum display coordinate area of 32767 units wide by
- 25319 units high. These values can be found in the XMAX and YMAX elements of
- the sheet viewport parameters structure.
-
- The orientation of the display coordinate system has the y axis reversed, ie
- the 0,0 origin point of the display coordinate system is always at the top
- left corner of the viewport.
-
- Secondary viewports also use a display coordinate system local to their own
- viewports. The scale of the display coordinate system is always set by the
- sheet viewport, but the origin is always the top left corner of the
- secondary viewport. ie, it is offset from the display coordinate system of
- the sheet viewport by the values XOFF and YOFF found in the secondary
- viewport parameters data structure.
-
- To map a coordinate from its viewport coordinate system to its display
- coordinate system, the following transformation must be made.
-
- dx = ( viewport_x + viewport_origin ) * viewport_scale
-
- dy = viewport_ymax - ( viewport_y + viewport_origin ) * viewport_scale
-
- Where:
-
- viewport_origin This is the local origin of the secondary viewport.
- The local origin can be found in the XORG and YORG
- elements of its viewport parameters data structure.
-
- viewport_scale This is the scale factor to apply to the coordinate
- point to map it from its viewport to its display
- coordinate system. This value can be found in the
- SCL element of the viewport parameters data structure.
-
- viewport_ymax This is the height of the viewport in the display
- coordinate system used to reverse the y axis of the
- viewport coordinate. This value can be found in the
- YMAX element of the viewport parameters data structure.
-
- To map a coordinate from its viewport coordinate system to the sheet
- viewports display coordinate system, the viewport display origin ( XOFF and
- YOFF ) must be added.
-
-
- X-CAD Display List
- ==================
-
- The display list associated with an X-CAD drawing file contains the data
- used when a redraw or zoom is performed on the screen. These functions do
- not access the entity coordinate data via EDBLOCKS as this would require a
- large amount of calculation and slow the redraw times. Instead, the GBBLOCKs
- associated with an entity contain lists of vectors in a third coordinate
- system - the display list coordinate system.
-
- This is exactly the same as the display coordinate system except that the
- origin is offset in the x and y by -16384 units. ie, the point 0,0 in the
- display coordinate system is the point 16384,16384 in the display list
- coordinate system.
-
- Although the X-CAD database contains objects such as arcs, ellipses and
- splines, the graphics display list holds these objects as a series of short
- straight vectors simplifing the clipping and transformation process. The
- most efficient way to access any graphics data from an X-CAD drawing file is
- to use the display list data held in GBBLOCKS. To map a coordinate from the
- display list coordinate system to real world or sheet viewport coordinates,
- the following transformation is used.
-
- real_x = ( dx - 16384 + view_doff ) / view_scl
-
- real_y = ( view_ymax - ( dy - 16384 + view_doff ) ) / view_scl
-
- Where:
-
- view_doff This is the display offset of the viewport. The offset
- can be found in the XOFF and YOFF elements of the
- viewport parameters data structure.
-
- view_scl This is the scale factor to apply to the coordinate
- point to map it from the display coordinate system to
- the sheet viewport coordinate system. This value can be
- found in the SCL element of the viewport parameters data
- structure for the sheet viewport.
-
- view_ymax This is the height of the sheet viewport in the display
- coordinate system used to reverse the y axis of the
- viewport coordinate. This value can be found in the
- YMAX element of the viewport parameters data structure
- for the sheet viewport.
-
-
- GBBLOCK Data
- ============
-
- The display list data found after a GBBLOCK consists of a series of 2 byte
- integers formatted as follows:
-
- [ style data ]
- [ extents data ]
- [ vector block count ]
- [ vector blocks ]
-
- The contents of each of these blocks are dependent on the display list type
- found in the TYPE element of the GBBLOCK data structure.
-
- Style Data
- ----------
-
- TYPE 1 2 3 4
-
- word 1 [line style] [fill style ] [fill style ] [symbol type]
- word 2 [ ] [ ]
- word 3 [ ] [ ]
- word 4 [patternfill] [patternfill]
- word 5 [name ] [name ]
- word 6 [ ] [ ]
- word 7 [ ] [ ]
-
- [line style] This word contains a copy of the hardfont line style used to
- render the vector list:
-
- Bit 0-7 Hardware line style.
- Bit 8-15 Line draw thickness.
-
- [fill style] A bit encoded word defining the fill type for a polygon.
-
- Bit 0-3 Fill colour if bit 4 is set.
-
- Bit 1 Only applicable for pattern fills of a single
- colour and if bit 4 is not set. This bit on
- indicates the patternfill will be used as a
- mask.
-
- Bit 4 If this bit is set, then the colour used to
- fill the polygon is set in bits 0-3. If this
- bit is not set, the colour assigned to the layer
- of the entity is used.
-
- Bit 5 If this bit is set on, the polygon will be
- rendered with an outline in the colour assigned
- to the layer of the entity.
-
- Bit 6 If this bit is on, the polygon if filled with
- a pattern as opposed to a solid colour. If the
- bit is set off, then words 2-7 are not present.
-
- Bit 7 Only applicable for pattern fills of a single
- colour. This bit on indicates the background
- colour of the patternfill will be the colour
- assigned to the layer of the entity.
-
- Bit 8 Use a half-tone mask for solid colour fills.
-
- Bit 9 Use a mask to create a shadow fill polygon.
-
- [patternfill] These 6 words are only present if bit 6 is set in the fill-
- [name ] style word. The 6 words contain the null terminated pattern
- fill name.
-
- [symbol type] Contains the id of the bit pattern used to display a non-
- scalable symbol such as a text-node, construction-point or
- terminal.
-
- Extents Data
- ------------
-
- TYPE 1 2 3 4
-
- word 1 [xmin] [xmin] [xmin] no data
- word 2 [ymin] [ymin] [ymin]
- word 3 [xmax] [xmax] [xmax]
- word 4 [ymax] [ymax] [ymax]
- word 5 [width scale]
-
- [xmin] etc. These 4 words represent the bounding extents of all of the
- vector data described for this display list block. The
- extents values are in dsplay list coordinates. If word 1 is
- equal to hex ffff, words 2-4 are not present.
-
- [width scale] Contains the width of the filled vector sequence in display
- values. This word is used to determine if only a vector
- sequnce and not a polygon is worth drawing.
-
- Vector Block Count
- ------------------
-
- TYPE 1 2 3 4
-
- word 1 [block count] [block count] [block count] no data
-
- [block count] This word contains the number of vector blocks that follow.
- In the case of a TYPE 4 ( Non-scaled sysmbols ), only one
- vector block follows.
-
- Vector Blocks
- -------------
-
- TYPE 1 2 3 4
-
- word 1 [block extent] [block extent] [block extent] [coor count]
- word 2 [num vectors] [num vectors] [num vectors] [first x]
- word 3 [first x] [first x] [first x] [first y]
- word 4 [first y] [first y] [first y]
-
- [block extent] The is the diagonal length of the bounding box containing
- the following vector list. This value is used to determine
- if only a single pixel is required to render this vector
- list at the current zoom scale.
-
- [coor count] The number of xy coordinate pairs in display list coordinates
- that follows.
-
- [num vectors] The number of vectors represented by xy coordinate pairs in
- display list coordinates that follows. ie, there will be
- [num vectors]+1 coordinate pairs.
-
- [first x] First coordinate x value in display list coordinates.
-
- [first y] First coordinate y value in display list coordinates.
-
-
- APPENDIX A Example C routine
- =============================
-
- The example program shown below is a simple display routine used to draw an
- X-CAD .xdr file in a window set up on the Workbench screen. The program
- examines the display list data within GBBLOCKs and maps these coordinates to
- a standard non-interlaced high res window.
-
- The program will run on an NTSC or PAL machine.
-
-
- ----------------------------------------------------------------------------
- main.c
- ----------------------------------------------------------------------------
-
- /*
-
- G.Osis 6-October-88
-
- Example routine to read an X-CAD .xdr file and display the graphics to a
- workbench window.
-
- */
-
- #include "include.h"
- #include "include/libraries/dos.h"
- #include "include/intuition/intuition.h"
-
- #define NOGRAPHICS 0x0001
- #define PASSWORD 0x0002
- #define ACDR 0x41434452
- #define SWIDTH 640 /* change these to suit other formats */
- #define SHEIGHT 400
-
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
-
- struct ACViewPort views[32];
- struct Header head;
- struct HeaderIndex hi;
- struct EntityHeader eh;
- struct EntityData ed;
- struct GraphicsInfo gi;
- struct GraphicsBlock gb;
-
- /* structures for area draws */
-
- short tmem2[1280];
- struct TmpRas t;
- struct AreaInfo a;
-
- /* display window definition */
-
- struct NewWindow nw = {
-
- 0,0,0,0,0xff,0xff,VANILLAKEY,SMART_REFRESH|ACTIVATE,0,0,0,0,0,0,0,0,0,
- WBENCHSCREEN };
-
-
-
- main( argc , argv )
-
- long argc;
- char *argv[];
-
- {
-
- long fh,ents_read,graphics,tmem1,rassize;
- short index,vpnum,close,code,*display_list;
- double ratio,scale_fac,rtemp;
- struct Window *w;
- struct IntuiMessage *mess;
- struct RastPort *r;
-
-
- /* open the libraries */
-
- if ( (IntuitionBase=(struct IntuitionBase *)OpenLibrary(
- "intuition.library",0)) == 0 )
- {
- printf(" Failed to open intuition.library\n");
- Exit(0);
- }
-
- if ( (GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0)) == 0 )
- {
- printf(" Failed to open graphics.library\n");
- Exit(0);
- }
-
- /* check a drawing name was entered on the command line */
-
- if ( argc != 2 )
- {
- printf("\n Command format is: XDR my_drawing.xdr\n");
- Exit(0);
- }
-
- /* open the file */
-
- if ( !(fh=Open(argv[1],MODE_OLDFILE)) )
- {
- printf("\n Cannot open %s due to error %d\n",argv[1],IoErr());
- Exit(0);
- }
-
- /* read in and check the header */
-
- Read(fh,&head,sizeof(struct Header));
-
- if ( head.ID != ACDR )
- {
- Close(fh);
- printf("\n %s is not an X-CAD drawing file\n",argv[1]);
- Exit(0);
- }
-
- if ( head.flags & NOGRAPHICS )
- {
- Close(fh);
- printf("\n Drawing was saved with the NOGRAPHICS option\n");
- Exit(0);
- }
-
- /* skip password if needs be */
-
- if ( head.flags & PASSWORD )
- Seek(fh,8,0);
-
- /* load all of the viewport data */
-
- for(ents_read=0;ents_read<head.ents;ents_read++)
- {
-
- Read(fh,&index,2);
-
- if ( index > 33 )
- break;
-
- Seek(fh,HIBLOCK+EHBLOCK,0);
-
- do {
- Read(fh,&ed,EDBLOCK);
-
- if ( ed.blockID == 1 )
- Read(fh,&views[index-2],ed.length);
- else
- Seek(fh,ed.length,0);
-
- } while( ed.next );
- }
-
- /* any more entities ? */
-
- if ( ents_read == head.ents )
- {
- Close(fh);
- printf("\n Drawing contains no graphics entities\n");
- Exit(0);
- }
-
- Seek(fh,-2,0);
-
- /* set up display window based on sheet viewport proportions */
-
- ratio=(double)SHEIGHT/(double)SWIDTH;
-
- if ( (rtemp=views[0].height/views[0].width) < ratio )
- {
- scale_fac=(double)SWIDTH/(double)views[0].xmax;
- nw.Width=SWIDTH;
- nw.Height=(short)((double)SWIDTH*rtemp)>>1;
- }
- else
- {
- scale_fac=(double)SHEIGHT/(double)views[0].ymax;
- nw.Height=SHEIGHT>>1;
- nw.Width=(short)((double)SHEIGHT/rtemp);
- }
-
- rassize=RASSIZE(nw.Width,nw.Height);
- if ( !(tmem1=AllocMem(rassize,MEMF_CHIP|MEMF_CLEAR)) )
- {
- Close(fh);
- printf("\n Cannot allocate enough TmpRas memory %d\n",rassize);
- Exit(0);
- }
-
- /* open the window */
-
- if ( !(w=(struct Window *)OpenWindow(&nw)) )
- {
- Close(fh);
- FreeMem(tmem1,rassize);
- printf("\n Cannot open display window %d %d\n",
- nw.Width,nw.Height);
- Exit(0);
- }
-
- r=w->RPort;
- SetAPen(r,3);
-
- /* add area for polygon draws */
-
- w->RPort->TmpRas=(struct TmpRas *)InitTmpRas(&t,tmem1,rassize);
-
- InitArea(&a,tmem2,512);
- w->RPort->AreaInfo=&a;
-
- /* start loop to read all entities */
-
- for( ;ents_read<head.ents;ents_read++)
- {
-
- /* save graphics and viewport data from HIBLOCK and skip past all the
- database stuff */
-
- Read(fh,&index,2);
- Read(fh,&hi,HIBLOCK);
-
- graphics=hi.graphics;
- vpnum=hi.flags2&0x001f;
-
- Read(fh,&eh,EHBLOCK);
-
- if ( eh.first )
- do {
- Read(fh,&ed,EDBLOCK);
- Seek(fh,ed.length,0);
- } while( ed.next );
-
- /* any graphics display data to retrieve ? */
-
- if ( graphics )
- {
- do {
- Read(fh,&gi,GIBLOCK);
- do {
- Read(fh,&gb,GBBLOCK);
-
- if ( !(display_list=(short *)AllocMem(gb.size,0)) )
- Seek(fh,gb.size,0);
- else
- {
- Read(fh,display_list,gb.size);
-
- render(display_list,gb.type,&views[vpnum],r,scale_fac);
-
- FreeMem(display_list,gb.size);
- }
- } while( gb.next );
- } while( gi.next );
- }
- }
-
- FreeMem(tmem1,rassize);
-
- /* display complete, close file */
-
- Close(fh);
-
- /* wait for return to be pressed then close down */
-
- SetAPen(r,2);
- SetBPen(r,1);
- Move(r,10,12);
- Text(r," Press return to end ",21);
-
- close=1;
-
- do {
- Wait(1<<w->UserPort->mp_SigBit);
-
- while( mess=(struct IntuiMessage *)GetMsg(w->UserPort) )
- {
- code=mess->Code;
- ReplyMsg(mess);
-
- if ( code == 0x000d )
- {
- close=0;
- break;
- }
- }
- } while( close );
-
- CloseWindow(w);
-
- Exit(0);
-
- }
-
- /*
-
- Render the display list.
-
- */
-
- #define HARD_VEC_LIST 1
- #define COLOUR_FILL_POLY 2
- #define COLOUR_FILL_VEC 3
-
-
- render( display_list , type , view , r , scale_fac )
-
- short *display_list;
- short type;
- struct ACViewPort *view;
- struct RastPort *r;
- double scale_fac;
-
- {
-
- register short vblocks,i,j,*vl;
- register unsigned short *p=display_list;
- short vec[2],num_vecs,pd;
-
-
- /* switch on type */
-
- switch( type )
- {
-
- /* vector list */
-
- case HARD_VEC_LIST:
-
- p++;
-
- if ( *p == 0xffff )
- p++;
- else
- p+=4;
-
- vblocks=*p++;
- for(i=0;i<vblocks;i++)
- {
- p++;
-
- for(num_vecs=(*p)+1,vl=p+1,j=0;j<num_vecs;j++,vl+=2)
- {
- map_display_to_screen(vl,vec,view,scale_fac);
-
- if ( !j )
- Move(r,vec[0],vec[1]);
- else
- Draw(r,vec[0],vec[1]);
- }
-
- p+=(*p<<1)+3;
- }
-
- break;
-
- /* polygon data */
-
- case COLOUR_FILL_POLY:
- case COLOUR_FILL_VEC:
-
- if ( *p & 0x0040 )
- p+=11;
- else
- p+=5;
-
- if ( gb.type == COLOUR_FILL_VEC )
- p++;
-
- vblocks=*p++;
-
- for(i=0,pd=0;i<vblocks;i++)
- {
- p++;
-
- for(num_vecs=(*p)+1,vl=p+1,j=0;j<num_vecs;j++,vl+=2)
- {
- map_display_to_screen(vl,vec,view,scale_fac);
-
- if ( !j )
- AreaMove(r,vec[0],vec[1]);
- else
- AreaDraw(r,vec[0],vec[1]);
- }
-
- if ( ++pd == 32 )
- {
- AreaEnd(r);
- pd=0;
- }
-
- p+=(*p<<1)+3;
-
- }
- if ( pd )
- AreaEnd(r);
-
- break;
-
- }
-
- }
-
- /*
-
- Map display list coordinates to screen coordinates.
-
- */
-
- map_display_to_screen( vl , vec , view , scale_fac )
-
- unsigned short *vl;
- short *vec;
- struct ACViewPort *view;
- double scale_fac;
-
- {
-
- register short rx,ry;
-
- rx=*vl-16384+view->xoff;
- ry=*(vl+1)-16384+view->yoff;
-
- *vec=(short)((double)rx*scale_fac);
- *(vec+1)=(short)((double)ry*scale_fac)>>1;
-
- }
-
-
- ---------------------------------------------------------------------------
- include.h
- ---------------------------------------------------------------------------
-
-
- #include "INCLUDE:exec/types.h"
- #include "INCLUDE:exec/memory.h"
-
- struct Header
- {
- long ID;
- short rev;
- long ents;
- long memreq;
- short flags;
- };
-
- struct HeaderIndex
- {
- long head;
- short flags1;
- short flags2;
- long graphics;
- };
-
- struct EntityHeader
- {
- long first;
- short flags;
- short aword1;
- short aword2;
- short aword3;
- };
-
- struct EntityData
- {
- long next;
- unsigned char blockID;
- unsigned char subID;
- long length;
- };
-
- struct GraphicsInfo
- {
- long next;
- unsigned char layoff;
- unsigned char depoff;
- long gblock;
- };
-
- struct GraphicsBlock
- {
- long next;
- char type;
- char flags;
- long size;
- };
-
- #define HIBLOCK sizeof(struct HeaderIndex)
- #define EHBLOCK sizeof(struct EntityHeader)
- #define EDBLOCK sizeof(struct EntityData)
- #define GIBLOCK sizeof(struct GraphicsInfo)
- #define GBBLOCK sizeof(struct GraphicsBlock)
-
- struct ACViewPort
- {
- char name[22];
- double width;
- double height;
- short units;
- double xorg;
- double yorg;
- double scl;
- short xoff;
- short yoff;
- short xmax;
- short ymax;
- short cxmin;
- short cymin;
- short cxmax;
- short cymax;
- short visible;
- double shxoff;
- double shyoff;
- };
-