CD - Canvas Draw

CD_DXF - AutoCAD Image Exchange File Driver (cddxf.h)

This driver allows generating an AutoCAD image exchange file. The file name usually has an extension .DXF. This driver supports only AutoCAD version 10.0 or later. The format's copyrights are property of Autodesk.


Use

The file is created and opened by calling function cdCreateCanvas(CD_DXF, Data), in which Data contains the file name and canvas dimensions. This function opens the file and writes its header. Then, other functions in the CD library can be called as usual. The Data parameter string has the following format:

"filename [widthxheight] [resolution]" or in C "%s %gx%g %g"

Only the parameter filename is required. The filename must be inside double quotes (") if it has spaces. Width and height are provided in millimeters (note the lowercase "x" between them), and their default value in pixels is INT_MAX for both dimensions. Resolution is the number of pixels per millimeter; its default value is "3.8". Width, height and resolution are given in real values and can be used only by cdGetCanvasSize and in pixel-millimeter conversion. 

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to close the DXF file properly.

Images - The DXF format does not support client or server images and works with an indexed-color format (color quality is limited to 256 fixed colors).

Precision of Coordinates - The primitives use coordinates in real numbers.

Layers - The format can work with several layers. It is necessary to draw the primitives of layer '0' first, then layer '1' and so on. Use functions cdFlush to change the current layer.


Behavior of Functions

Control

  • cdFlush: changes the current layer (the initial layer is '0', followed by '1' and so on).
  • cdClear: does nothing.
  • cdPlay: does nothing, returns CD_ERROR.

Coordinate System and Clipping

  • cdClip: does nothing (no clipping function is supported), returns CD_CLIPOFF.
  • cdClipArea: does nothing.
  • cdGetClipArea: does nothing, returns CD_CLIPOFF.
  • cdUpdateYAxis: does nothing. Axis orientation is the same as in the CD library.
  • Complex Regions: not supported.

Primitives

  • cdBox: draws only the box's borders (no filling function is supported). Behaves like cdRect.
  • cdSector: draws a "hollow" sector, that is, only its borders.
  • cdMark: besides employing simulation, filled marks are drawn in the same way as their corresponding empty marks, that is, only the borders.
  • cdBegin: CD_FILL is mapped to CD_CLOSED_LINES. if parameter CD_CLIP or CD_BEZIER are specified, does nothing.
  • cdChord: does nothing.

Attributes

  • cdBackOpacity: does nothing, returns CD_TRANSPARENT.
  • cdWriteMode: does nothing, returns CD_REPLACE.
  • cdMarkType: since no filling function is supported, configuring mark type to solid type is the same as configuring it to its corresponding empty type (that is, CD_BOX corresponds to CD_HOLLOW_BOX, and so on).
  • cdInteriorStyle: does nothing (filling is not supported), returns 0.
  • cdHatch: does nothing.
  • cdFillMode: does nothing.
  • cdLineCap: does nothing.
  • cdLineJoin: does nothing.
  • cdStipple: does nothing.
  • cdPattern: does nothing.
  • cdTextSize: returns a bounding box usually larger than the text (the computation is based on the widest character).
  • cdNativeFont: does nothing.
  • cdTextOrientation: does nothing.
  • cdFont: italic styles correspond to the basic styles with an inclination of 15o. See the font mapping table for the equivalence used to map fonts of the CD library into AutoCAD  fonts.
Font Mapping
CD Fonts AutoCAD Fonts
CD_SYSTEM STANDARD (sem arquivo)
CD_COURIER / CD_PLAIN ROMAN (romanc.shx)
CD_COURIER / CD_PLAIN ROMAN_BOLD (romant.shx)
CD_TIMES_ROMAN / CD_PLAIN ROMANTIC (rom_____.pfb)
CD_TIMES_ROMAN / CD_BOLD ROMANTIC_BOLD (romb_____.pfb)
CD_HELVETICA / CD_PLAIN SANSSERIF (sas_____.pfb)
CD_HELVETICA / CD_BOLD SANSSERIF_BOLD (sasb____.pfb)

Colors

  • cdForeground: indexes long int *color  in the fixed palette (AutoCAD uses a 256-color palette -  for further detail, see AutoCAD's Reference Manual).
  • cdBackground: does nothing, returns CD_WHITE.
  • cdGetColorPlanes: returns 8.
  • cdPalette: does nothing (the palette is fixed).

Client Images

  • All functions do nothing.

Server Images

  • All functions do nothing.