43#include "dl_attributes.h"
64 this->version = version;
67 paperSpace0Handle = 0;
83 dxfString(0,
"SECTION");
180 dxfString(0,
"ENDSEC");
195 void table(
const char* name,
int num,
int h=0)
const {
196 dxfString(0,
"TABLE");
198 if (version>=DL_VERSION_2000) {
205 dxfString(100,
"AcDbSymbolTable");
224 table(
"LAYER", num, 2);
242 table(
"LTYPE", num, 5);
259 table(
"APPID", num, 9);
276 table(
"STYLE", num, 3);
288 dxfString(0,
"ENDTAB");
312 dxfString(999, text);
325 void entity(
const char* entTypeName)
const {
326 dxfString(0, entTypeName);
327 if (version>=DL_VERSION_2000) {
353 if (version>=DL_VERSION_2000 || attrib.
getColor()!=256) {
356 if (version>=DL_VERSION_2000 && attrib.
getColor24()!=-1) {
359 if (version>=DL_VERSION_2000) {
362 if (version>=DL_VERSION_2000) {
363 dxfReal(48, attrib.getLinetypeScale());
366 std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);
367 if (version>=DL_VERSION_2000 || linetype==
"BYLAYER") {
388 dxfString(0,
"LAYER");
389 if (version>=DL_VERSION_2000) {
395 dxfString(100,
"AcDbSymbolTableRecord");
396 dxfString(100,
"AcDbLayerTableRecord");
409 dxfString(0,
"LTYPE");
410 if (version>=DL_VERSION_2000) {
417 dxfString(100,
"AcDbSymbolTableRecord");
418 dxfString(100,
"AcDbLinetypeTableRecord");
431 dxfString(0,
"APPID");
432 if (version>=DL_VERSION_2000) {
439 dxfString(100,
"AcDbSymbolTableRecord");
440 dxfString(100,
"AcDbRegAppTableRecord");
453 dxfString(0,
"BLOCK");
454 if (version>=DL_VERSION_2000) {
461 dxfString(100,
"AcDbEntity");
466 dxfString(100,
"AcDbBlockBegin");
479 dxfString(0,
"ENDBLK");
480 if (version>=DL_VERSION_2000) {
487 dxfString(100,
"AcDbEntity");
492 dxfString(100,
"AcDbBlockEnd");
496 void color(
int col=256)
const {
499 void linetype(
const char *lt)
const {
502 void linetypeScale(
double scale)
const {
505 void lineWeight(
int lw)
const {
509 void coord(
int gc,
double x,
double y,
double z=0)
const {
515 void coordTriplet(
int gc,
const double* value)
const {
517 dxfReal(gc, *value++);
518 dxfReal(gc+10, *value++);
519 dxfReal(gc+20, *value++);
523 void resetHandle()
const {
532 dxfHex(gc, m_handle);
550 virtual void dxfReal(
int gc,
double value)
const = 0;
559 virtual void dxfInt(
int gc,
int value)
const = 0;
568 virtual void dxfBool(
int gc,
bool value)
const {
569 dxfInt(gc, (
int)value);
579 virtual void dxfHex(
int gc,
int value)
const = 0;
588 virtual void dxfString(
int gc,
const char* value)
const = 0;
597 virtual void dxfString(
int gc,
const std::string& value)
const = 0;
600 mutable unsigned long m_handle;
601 mutable unsigned long modelSpaceHandle;
602 mutable unsigned long paperSpaceHandle;
603 mutable unsigned long paperSpace0Handle;
Storing and passing around attributes.
Definition: dl_attributes.h:41
std::string getLinetype() const
Definition: dl_attributes.h:198
int getColor() const
Definition: dl_attributes.h:149
int getWidth() const
Definition: dl_attributes.h:172
std::string getLayer() const
Definition: dl_attributes.h:122
int getColor24() const
Definition: dl_attributes.h:158
version
Version numbers for the DXF Format.
Definition: dl_codes.h:96
Defines interface for writing low level DXF constructs to a file.
Definition: dl_writer.h:58
virtual void dxfInt(int gc, int value) const =0
Must be overwritten by the implementing class to write an int value to the file.
virtual void dxfString(int gc, const char *value) const =0
Must be overwritten by the implementing class to write a string to the file.
void dxfEOF() const
End of the DXF file.
Definition: dl_writer.h:299
void sectionTables() const
Section TABLES.
Definition: dl_writer.h:111
void tableEnd() const
End of a table.
Definition: dl_writer.h:287
void sectionClasses() const
Section CLASSES.
Definition: dl_writer.h:153
virtual void dxfReal(int gc, double value) const =0
Must be overwritten by the implementing class to write a real value to the file.
void tableLinetypeEntry(unsigned long int h=0) const
Line type (must be in the TABLES section LTYPE).
Definition: dl_writer.h:408
void sectionObjects() const
Section OBJECTS.
Definition: dl_writer.h:167
unsigned long getNextHandle() const
Definition: dl_writer.h:539
void section(const char *name) const
Generic section for section 'name'.
Definition: dl_writer.h:82
virtual void dxfString(int gc, const std::string &value) const =0
Must be overwritten by the implementing class to write a string to the file.
void comment(const char *text) const
Comment.
Definition: dl_writer.h:311
void tableLinetypes(int num) const
Table for line types.
Definition: dl_writer.h:240
void tableStyle(int num) const
Table for text style.
Definition: dl_writer.h:275
void entity(const char *entTypeName) const
Entity.
Definition: dl_writer.h:325
void tableLayers(int num) const
Table for layers.
Definition: dl_writer.h:223
void sectionBlockEntry(unsigned long int h=0) const
Block (must be in the section BLOCKS).
Definition: dl_writer.h:452
void sectionEnd() const
End of a section.
Definition: dl_writer.h:179
void sectionBlockEntryEnd(unsigned long int h=0) const
End of Block (must be in the section BLOCKS).
Definition: dl_writer.h:478
void tableLayerEntry(unsigned long int h=0) const
Layer (must be in the TABLES section LAYER).
Definition: dl_writer.h:387
void subClass(const char *sub) const
Subclass.
Definition: dl_writer.h:375
unsigned long handle(int gc=5) const
Writes a unique handle and returns it.
Definition: dl_writer.h:530
virtual void dxfHex(int gc, int value) const =0
Must be overwritten by the implementing class to write an int value (hex) to the file.
virtual void dxfBool(int gc, bool value) const
Can be overwritten by the implementing class to write a bool value to the file.
Definition: dl_writer.h:568
void sectionBlocks() const
Section BLOCKS.
Definition: dl_writer.h:125
void table(const char *name, int num, int h=0) const
Generic table for table 'name' with 'num' entries:
Definition: dl_writer.h:195
DL_Writer(DL_Codes::version version)
Definition: dl_writer.h:63
void tableAppid(int num) const
Table for application id.
Definition: dl_writer.h:258
void tableAppidEntry(unsigned long int h=0) const
Appid (must be in the TABLES section APPID).
Definition: dl_writer.h:430
void sectionHeader() const
Section HEADER.
Definition: dl_writer.h:97
void sectionEntities() const
Section ENTITIES.
Definition: dl_writer.h:139
void entityAttributes(const DL_Attributes &attrib) const
Attributes of an entity.
Definition: dl_writer.h:346
DL_Codes::version version
DXF version to be created.
Definition: dl_writer.h:608