DEF 3.0 File Specification
==========================

Overview of changes since DEF 2.0:

- Addition of a View Table.
- Addition of a GCP Table.
- Addition of a Image Table.
- Addition of a Color Table.

- Layer tables have been enhanced to include color,
  weight and style information.

- New Header variables:

    Version
    Color_By_Layer
    Style_By_Layer
    Weight_By_Layer

- The addition of a new entity type: 3D_Face

- Bsplines and Bziers no longer add an extraneous point.

DEF import will automatically detect whether the file being imported
is a DEF 2.0 or a DEF 3.0 file.  Full DEF 3.0 import is supported.


DEF 3.0 file format
===================

A complete file consists of the following sections:

Header
Layer Table
Style Table
View Table
GCP Table
Image Table
Color Table
Floating Global Variables
Entity Definitions

Note: The following descriptions will be much clearer if you
print a small DEF file from DynaCADD to follow as an example.


Header
------

Version
The Major version number multiplied by 100 plus the minor
version number.  For example the current DEF version number
written by DynaCADD 2.00.02 is 300.

Note: This is the one header variable that is not optional.
ALL DEF 3.0 files must include the Version number 300.

Scale
A floating point value representing the drawing scale.
For example 0.5 represents one half scale.

Units
An integer index to the selected unit base:
    1 = inches
    2 = feet
    3 = yards
    4 = miles
    5 = millimeters
    6 = centimeters
    7 = meters
    8 = kilometers

Width
The width of the drawing specified in the currently
selected units.

Height
The height of the drawing specified in the currently
selected units.

Line_Scale
The global line style scale.

Origin_X
The 2D drawing origin along the X axis.

Origin_Y
The 2D drawing origin along the Y axis.

Color_By_Layer
A flag determining the state of the Color_By_Layer variable
Off = 0
On  = 1

Style_By_Layer
A flag determining the state of the Style_By_Layer variable
Off = 0
On  = 1

Weight_By_Layer
A flag determining the state of the Weight_By_Layer variable
Off = 0
On  = 1

Comments
Any line preceded by *** is considered to be a
comment and is ignored.

*** Sample DEF 3.0 Header

Version
300
Scale
1.0
Units
1
Width
17.0
Height
11.0
Line_Scale
1.0
Origin_X
0.000000
Origin_Y
0.000000
Color_By_Layer
0
Style_By_Layer
0
Weight_By_Layer
0

*** End of Sample Header


Layer Table
-----------

The Layer Table is optional and is used to define all layer parameters.
A layer definition consists of the following structure:

Layer_Definition
layer index (integer)
layer name (string)
layer lock status (integer)
1 = locked
0 = unlocked
layer visibility (integer)
1 = visible
0 = invisible
layer color (integer [1..15])
layer style (integer [0..63])
layer weight (integer [0..2])
End

*** Sample Layer Definition

Layer_Definition
0
SAMPLE_LAYER
0
1
1
0
1
End

*** End of Sample Layer Definition

The preceding sample definition names layer 0 as SAMPLE_LAYER
and declares it to be unlocked and visible.  The layer color is 1,
using style 0 from the style table.  The layer weight is set to 1.


Style Table
-----------

The Style Table is optional and is used to define all line styles.
A style definition consists of the following structure:

Style_Definition
style index (integer)
style name (string)
style local scale (floating point)
style string (string)
End

*** Sample Style Definition

Style_Definition
0
SAMPLE_STYLE
1.50
++++ ++++ ++++ ++++
End

*** End of Sample Style Definition

The preceding sample definition names style 0 as SAMPLE_STYLE,
with a local scale of 1.50.  The style string is the line pattern,
constructed according to the manner explained in Chapter 5.


GCP Table
---------

The GCP Table is optional and is used to define all Geometric
Coordinate Planes.  A GCP definition consists of the following
structure:

GCP_Definition
GCP index (integer)
GCP name (string)
plane rotation about the Z axis (angle in degrees)
plane rotation about the X axis (angle in degrees)
plane rotation about the Y axis (angle in degrees)
GCP X Translation (floating point)
GCP Y Translation (floating point)
GCP Z Translation (floating point)
End

*** Sample GCP Definition

GCP_Definition
0
Top
0.000000
0.000000
0.000000
1.000000
2.000000
0.000000
End

*** End of Sample GCP Definition

The preceding sample definition names GCP 0 as Top with no rotation
from the absolute 3D plane, and an X-Y-Z translation of 1, 2, 0
from the absolute 3D origin.


View Table
----------

The View Table is optional and is used to define all active 3D views.
A view definition consists of the following structure:

View_Definition
view index (integer)
view GCP index (integer)
X location of lower left corner of view bounds
Y location of lower left corner of view bounds
X location of upper right corner of view bounds
Y location of upper right corner of view bounds
X location of view origin
Y location of view origin
view zoom factor (floating point)
plane rotation about the Z axis (angle in degreess)
plane rotation about the X axis (angle in degreess)
plane rotation about the Y axis (angle in degreess)
view scale factor (floating point)
scroll distance of view origin along the 2D X axis
scroll distance of view origin along the 2D Y axis
End

*** Sample View Definition

View_Definition
0
1
0.000000
0.000000
34.000000
22.000000
17.000000
11.000000
1.000000
0.000000
0.000000
0.000000
0.250000
0.000000
0.000000
End

*** End of Sample View Definition

The preceding sample defines view 0 as having GCP 1 as it's prime
rotation viewing plane.  The bounding area of the view is encompassed
by the coordinates 0, 0 to 34, 22 with the origin in the center at
coordinate 17, 11.  The view zoom factor is 1.0.  The current viewing
plane has not been rotated from the absolute 3D plane.  The scale
factor is set to 0.25 and the view has not been scrolled along the
2D X or Y axes.


Color Table
-----------

The Color Table is optional and is used to define the full drawing
color pallete.  A color definition consists of the following structure:

Color_Definition
color index (integer)
red component of the color (integer [0..1000])
green component of the color (integer [0..1000])
blue component of the color (integer [0..1000])
End

*** Sample Color Definition

Color_Definition
0
800
800
800
End

*** End of Sample Color Definition

The preceding sample defines color 0 as have RGB components of
R:800 G:800 B:800 (light gray).

Note: Color indexes 0 through 3 are used by the Amiga DynaCADD user
interface and should normally be left undefined in a DEF file.  If they
are defined they should be set to the following values:

Color 0 - R:667  G:667  B:667
Color 1 - R:0    G:0    B:0
Color 2 - R:1000 G:1000 B:1000
Color 3 - R:400  G:467  B:600


Image Table
-----------

The Image Table is optional and is used to define all images.
A image definition consists of the following structure:

Image_Definition
image index (integer)
image name (string)
X location of lower left corner of image
Y location of lower left corner of image
X location of upper right corner of image
Y location of upper right corner of image
End

*** Sample Image Definition

Image_Definition
0
TestImg
2.500000
3.000000
5.000000
8.000000
End

*** End of Sample Image Definition

The preceding sample definition names image 0 as TestImg with a
bounding area encompassed by the coordinates 2.5, 3.0 and 5.0, 8.0.


Floating Global Variables
-------------------------

There are nine floating global variables used when defining the
attributes of any entity definitions that follow in the DEF file.
The variables are:

Layer
Color
Weight
Style
Group
Groupend
Mask
Unmask
Viewmask

Note: Floating variables may be placed anywhere in a DEF file
with 2 restrictions.

    1] They must never be placed in a Table.
    2] They must never be placed where a ASCII name is expected.


Layer
Layer defines the current layer index assigned to all following
entities.  The range of valid layer indexes is 0 to 255.

*** Example
Layer
12
*** End of example

The preceding example sets the current layer index as 12.

Color
Color defines the current color index assigned to all following
entities.  The range of valid color indexes is 1 to 15.

*** Example
Color
3
*** End of example

The preceding example sets the current color to 3.

Weight
Weight defines the current weight index assigned to all following
entities.  The range of valid weight indexes is 0 to 2.

*** Example
Weight
1
*** End of example

The preceding example sets the current pen weight to 1.

Style
Style sets the current style index assigned to all following
entities.  The range of valid style indexes is 0 to 63.

*** Example
Style
2
*** End of example

The preceding example set the current style index to 2.

Group and Groupend
All entities that are grouped together as a DynaCADD figure should be
preceded by the global name Group and end with the global name
Groupend.  These globals must not be nested.  That is no Group label
should appear between another set of Group and Groupend labels.

Note: Hatch patterns and section lines are treated as groups.

*** Example of grouping entities
Group

*** Entity definitions go here

Groupend
*** End of example


Mask and Unmask

All entities defined after a Mask command will not be displayed
by DynaCADD.  Unmask is used to reset the state of the mask flag.

*** Example of masking entities
Mask

*** Entity definitions go here

Unmask
***End of example

Viewmask
Viewmask is a bitwise flag that controls the generation of 3D
entities each active 3D View.

1 = View #1
2 = View #2
4 = View #3
8 = View #4

To mask a 3D entity in view #1 and view #3 Viewmask would be
set to 5 (1+4).

*** Example
Viewmask
7
*** End of example

The preceding example set all 3D entities that follow to display
is only in view #4.  To reset the display to all views, set
Viewmask to 0.


Entity Definitions
==================

The following list contains the specification for currently supported
2D and 3D entities.  If entities types are added to DynaCADD, this list
will be updated.  You should therefore read entities in a table driven
manner and ignore all unsupported entities.

All angles are given in degrees with the zero degree mark towards the
east and the positive direction increasing in a counter-clockwise
direction.  Unless otherwise noted, all values are defined as floating
point variables.  All entity definitions must start with the entity
name, as shown here, and finish with End.

2D Entities
-----------

2D_Point
X location
Y location
End

2D_Line
X location of start
Y location of start
X location of end
Y location of end
End

2D_Circle
X location of center
Y location of center radius
End

2D_Arc
X location of center
Y location of center
radius
start angle
end angle
End

2D_Ellipse
X location of center
Y location of center
major axis
minor axis
rotation
End

2D_Ell_Arc
X location of center
Y location of center
major axis
minor axis
rotation
start angle
end angle
End

2D_Text
X location, lower left corner of text string
Y location, lower left corner of text string
character width
character height
character slant (angle in degrees)
text rotation
text spacing type (integer)
    0 = constant (mono spacing)
    1 = proportional
    2 = kerned
additional spacing
name of font (string) (ie: LEROY_R)
text string (string)
End

2D_Bspline
X location of point #1
Y location of point #1
X location of point #2
Y location of point #2 (up to 49 control points)
X location of last point
Y location of last point
End

2D_Bezier
X location of point #1
Y location of point #1
X location of point #2
Y location of point #2 (up to 49 control points)
X location of last point
Y location of last point
End

2D_Solid
X location of point #1
Y location of point #1
X location of point #2
Y location of point #2
X location of point #3
Y location of point #3
X location of point #4
Y location of point #4
End

3D Entities
-----------

All 3D coordinates are given in absolute 3D space and are NOT
considered relative to the current GCP.

3D_Point
X location
Y location
Z location
End

3D_Line
X location of start
Y location of start
Z location of start
X location of end
Y location of end
Z location of end
End

3D_Circle
X location of center
Y location of center
Z location of center radius
plane rotation about the Z axis
plane rotation about the X axis
plane rotation about the Y axis
End

3D_Arc
X location of center
Y location of center
Z location of center radius
start angle
end angle
plane rotation about the Z axis
plane rotation about the X axis
plane rotation about the Y axis
End

3D_Ellipse
X location of center
Y location of center
Z location of center major axis
minor axis
rotation
plane rotation about the Z axis
plane rotation about the X axis
plane rotation about the Y axis
End

3D_Ell_Arc
X location of center
Y location of center
Z location of center major axis
minor axis
rotation
start angle
end angle
plane rotation about the Z axis
plane rotation about the X axis
plane rotation about the Y axis
End

3D_Text
X location, lower left corner of text string
Y location, lower left corner of text string
Z location, lower left corner of text string
character width
character height
character slant
text rotation
plane rotation about the Z axis
plane rotation about the X axis
plane rotation about the Y axis
text spacing type (integer)
    0 = constant (mono spacing)
    1 = proportional
    2 = kerned
additional spacing
name of font (string) (ie: LEROY_R)
text string (string)
End

3D_Bspline
X location of point #1
Y location of point #1
Z location of point #1
X location of point #2
Y location of point #2
Z location of point #2 (up to 49 control points)
X location of last point
Y location of last point
Z location of last point
End

3D_Bezier
X location of point #1
Y location of point #1
Z location of point #1
X location of point #2
Y location of point #2
Z location of point #2 (up to 49 points)
X location of last point
Y location of last point
Z location of last point
End

3D_Face
X location of point #1
Y location of point #1
Z location of point #1
X location of point #2
Y location of point #2
Z location of point #2
X location of point #3
Y location of point #3
Z location of point #3
X location of point #4
Y location of point #4
Z location of point #4
End
