We don't need anymore library dxflib.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-06-21 16:59:58 +03:00
parent 88288f2fba
commit beff9d1322
18 changed files with 0 additions and 11067 deletions

View File

@ -1,260 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_ATTRIBUTES_H
#define DL_ATTRIBUTES_H
#include "dl_global.h"
#include <string>
#include <vector>
#include "dl_codes.h"
/**
* Storing and passing around attributes. Attributes
* are the layer name, color, width and line type.
*
* @author Andrew Mustun
*/
class DXFLIB_EXPORT DL_Attributes
{
public:
/**
* Default constructor.
*/
DL_Attributes() :
layer(""),
color(0),
color24(-1),
width(0),
linetype("BYLAYER"),
linetypeScale(1.0),
handle(-1),
inPaperSpace(false)
{
}
/**
* Constructor for DXF attributes.
*
* @param layer Layer name for this entity or NULL for no layer
* (every entity should be on a named layer!).
* @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
* @param width Line thickness. Defaults to zero. -1 = BYLAYER,
* -2 = BYBLOCK, -3 = default width
* @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults
* to "BYLAYER"
*/
DL_Attributes(const std::string& layer,
int color, int width,
const std::string& linetype,
double linetypeScale) :
layer(layer),
color(color),
color24(-1),
width(width),
linetype(linetype),
linetypeScale(linetypeScale),
handle(-1),
inPaperSpace(false)
{
}
/**
* Constructor for DXF attributes.
*
* @param layer Layer name for this entity or NULL for no layer
* (every entity should be on a named layer!).
* @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
* @param color24 24 bit color (0x00RRGGBB, see DXF reference).
* @param width Line thickness. Defaults to zero. -1 = BYLAYER,
* -2 = BYBLOCK, -3 = default width
* @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults
* to "BYLAYER"
*/
DL_Attributes(const std::string& layer,
int color, int color24, int width,
const std::string& linetype,
int handle=-1) :
layer(layer),
color(color),
color24(color24),
width(width),
linetype(linetype),
linetypeScale(1.0),
handle(handle),
inPaperSpace(false)
{
}
/**
* Sets the layer. If the given pointer points to NULL, the
* new layer name will be an empty but valid string.
*/
void setLayer(const std::string& layer)
{
this->layer = layer;
}
/**
* @return Layer name.
*/
std::string getLayer() const
{
return layer;
}
/**
* Sets the color.
*
* @see DL_Codes, dxfColors
*/
void setColor(int color)
{
this->color = color;
}
/**
* Sets the 24bit color.
*
* @see DL_Codes, dxfColors
*/
void setColor24(int color)
{
this->color24 = color;
}
/**
* @return Color.
*
* @see DL_Codes, dxfColors
*/
int getColor() const
{
return color;
}
/**
* @return 24 bit color or -1 if no 24bit color is defined.
*
* @see DL_Codes, dxfColors
*/
int getColor24() const
{
return color24;
}
/**
* Sets the width.
*/
void setWidth(int width)
{
this->width = width;
}
/**
* @return Width.
*/
int getWidth() const
{
return width;
}
/**
* Sets the line type. This can be any string and is not
* checked to be a valid line type.
*/
void setLinetype(const std::string& linetype)
{
this->linetype = linetype;
}
/**
* Sets the entity specific line type scale.
*/
void setLinetypeScale(double linetypeScale)
{
this->linetypeScale = linetypeScale;
}
double getLinetypeScale() const
{
return linetypeScale;
}
/**
* @return Line type.
*/
std::string getLinetype() const
{
if (linetype.length()==0)
{
return "BYLAYER";
}
else
{
return linetype;
}
}
void setHandle(int h)
{
handle = h;
}
int getHandle() const
{
return handle;
}
void setInPaperSpace(bool on)
{
inPaperSpace = on;
}
bool isInPaperSpace() const
{
return inPaperSpace;
}
private:
std::string layer;
int color;
int color24;
int width;
std::string linetype;
double linetypeScale;
int handle;
// DXF code 67 (true: entity in paper space, false: entity in model space (default):
bool inPaperSpace;
};
#endif
// EOF

View File

@ -1,556 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/**
* Defines common DXF codes and constants.
*/
#ifndef DXF_CODES_H
#define DXF_CODES_H
#include "dl_global.h"
#include "../vmisc/diagnostic.h"
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#define DL_DXF_MAXLINE 1024
#define DL_DXF_MAXGROUPCODE 1100
// used to mark invalid vectors:
//#define DL_DXF_MAXDOUBLE 1.0E+10
/**
* Codes for colors and DXF versions.
*/
class DXFLIB_EXPORT DL_Codes
{
public:
/**
* Standard DXF colors.
*/
enum color
{
black = 250,
green = 3,
red = 1,
brown = 15,
yellow = 2,
cyan = 4,
magenta = 6,
gray = 8,
blue = 5,
l_blue = 163,
l_green = 121,
l_cyan = 131,
l_red = 23,
l_magenta = 221,
l_gray = 252,
white = 7,
bylayer = 256,
byblock = 0
};
/**
* Version numbers for the DXF Format.
*/
enum version
{
AC1009_MIN, // R12, minimalistic
AC1009, // R12
AC1012,
AC1014,
AC1015 // R2000
};
};
// Extended color palette:
// The first entry is only for direct indexing starting with [1]
// Color 1 is red (1,0,0)
const double dxfColors[][3] =
{
{0,0,0}, // unused
{1,0,0}, // 1
{1,1,0},
{0,1,0},
{0,1,1},
{0,0,1},
{1,0,1},
{1,1,1}, // black or white
{0.5,0.5,0.5},
{0.75,0.75,0.75},
{1,0,0}, // 10
{1,0.5,0.5},
{0.65,0,0},
{0.65,0.325,0.325},
{0.5,0,0},
{0.5,0.25,0.25},
{0.3,0,0},
{0.3,0.15,0.15},
{0.15,0,0},
{0.15,0.075,0.075},
{1,0.25,0}, // 20
{1,0.625,0.5},
{0.65,0.1625,0},
{0.65,0.4063,0.325},
{0.5,0.125,0},
{0.5,0.3125,0.25},
{0.3,0.075,0},
{0.3,0.1875,0.15},
{0.15,0.0375,0},
{0.15,0.0938,0.075},
{1,0.5,0}, // 30
{1,0.75,0.5},
{0.65,0.325,0},
{0.65,0.4875,0.325},
{0.5,0.25,0},
{0.5,0.375,0.25},
{0.3,0.15,0},
{0.3,0.225,0.15},
{0.15,0.075,0},
{0.15,0.1125,0.075},
{1,0.75,0}, // 40
{1,0.875,0.5},
{0.65,0.4875,0},
{0.65,0.5688,0.325},
{0.5,0.375,0},
{0.5,0.4375,0.25},
{0.3,0.225,0},
{0.3,0.2625,0.15},
{0.15,0.1125,0},
{0.15,0.1313,0.075},
{1,1,0}, // 50
{1,1,0.5},
{0.65,0.65,0},
{0.65,0.65,0.325},
{0.5,0.5,0},
{0.5,0.5,0.25},
{0.3,0.3,0},
{0.3,0.3,0.15},
{0.15,0.15,0},
{0.15,0.15,0.075},
{0.75,1,0}, // 60
{0.875,1,0.5},
{0.4875,0.65,0},
{0.5688,0.65,0.325},
{0.375,0.5,0},
{0.4375,0.5,0.25},
{0.225,0.3,0},
{0.2625,0.3,0.15},
{0.1125,0.15,0},
{0.1313,0.15,0.075},
{0.5,1,0}, // 70
{0.75,1,0.5},
{0.325,0.65,0},
{0.4875,0.65,0.325},
{0.25,0.5,0},
{0.375,0.5,0.25},
{0.15,0.3,0},
{0.225,0.3,0.15},
{0.075,0.15,0},
{0.1125,0.15,0.075},
{0.25,1,0}, // 80
{0.625,1,0.5},
{0.1625,0.65,0},
{0.4063,0.65,0.325},
{0.125,0.5,0},
{0.3125,0.5,0.25},
{0.075,0.3,0},
{0.1875,0.3,0.15},
{0.0375,0.15,0},
{0.0938,0.15,0.075},
{0,1,0}, // 90
{0.5,1,0.5},
{0,0.65,0},
{0.325,0.65,0.325},
{0,0.5,0},
{0.25,0.5,0.25},
{0,0.3,0},
{0.15,0.3,0.15},
{0,0.15,0},
{0.075,0.15,0.075},
{0,1,0.25}, // 100
{0.5,1,0.625},
{0,0.65,0.1625},
{0.325,0.65,0.4063},
{0,0.5,0.125},
{0.25,0.5,0.3125},
{0,0.3,0.075},
{0.15,0.3,0.1875},
{0,0.15,0.0375},
{0.075,0.15,0.0938},
{0,1,0.5}, // 110
{0.5,1,0.75},
{0,0.65,0.325},
{0.325,0.65,0.4875},
{0,0.5,0.25},
{0.25,0.5,0.375},
{0,0.3,0.15},
{0.15,0.3,0.225},
{0,0.15,0.075},
{0.075,0.15,0.1125},
{0,1,0.75}, // 120
{0.5,1,0.875},
{0,0.65,0.4875},
{0.325,0.65,0.5688},
{0,0.5,0.375},
{0.25,0.5,0.4375},
{0,0.3,0.225},
{0.15,0.3,0.2625},
{0,0.15,0.1125},
{0.075,0.15,0.1313},
{0,1,1}, // 130
{0.5,1,1},
{0,0.65,0.65},
{0.325,0.65,0.65},
{0,0.5,0.5},
{0.25,0.5,0.5},
{0,0.3,0.3},
{0.15,0.3,0.3},
{0,0.15,0.15},
{0.075,0.15,0.15},
{0,0.75,1}, // 140
{0.5,0.875,1},
{0,0.4875,0.65},
{0.325,0.5688,0.65},
{0,0.375,0.5},
{0.25,0.4375,0.5},
{0,0.225,0.3},
{0.15,0.2625,0.3},
{0,0.1125,0.15},
{0.075,0.1313,0.15},
{0,0.5,1}, // 150
{0.5,0.75,1},
{0,0.325,0.65},
{0.325,0.4875,0.65},
{0,0.25,0.5},
{0.25,0.375,0.5},
{0,0.15,0.3},
{0.15,0.225,0.3},
{0,0.075,0.15},
{0.075,0.1125,0.15},
{0,0.25,1}, // 160
{0.5,0.625,1},
{0,0.1625,0.65},
{0.325,0.4063,0.65},
{0,0.125,0.5},
{0.25,0.3125,0.5},
{0,0.075,0.3},
{0.15,0.1875,0.3},
{0,0.0375,0.15},
{0.075,0.0938,0.15},
{0,0,1}, // 170
{0.5,0.5,1},
{0,0,0.65},
{0.325,0.325,0.65},
{0,0,0.5},
{0.25,0.25,0.5},
{0,0,0.3},
{0.15,0.15,0.3},
{0,0,0.15},
{0.075,0.075,0.15},
{0.25,0,1}, // 180
{0.625,0.5,1},
{0.1625,0,0.65},
{0.4063,0.325,0.65},
{0.125,0,0.5},
{0.3125,0.25,0.5},
{0.075,0,0.3},
{0.1875,0.15,0.3},
{0.0375,0,0.15},
{0.0938,0.075,0.15},
{0.5,0,1}, // 190
{0.75,0.5,1},
{0.325,0,0.65},
{0.4875,0.325,0.65},
{0.25,0,0.5},
{0.375,0.25,0.5},
{0.15,0,0.3},
{0.225,0.15,0.3},
{0.075,0,0.15},
{0.1125,0.075,0.15},
{0.75,0,1}, // 200
{0.875,0.5,1},
{0.4875,0,0.65},
{0.5688,0.325,0.65},
{0.375,0,0.5},
{0.4375,0.25,0.5},
{0.225,0,0.3},
{0.2625,0.15,0.3},
{0.1125,0,0.15},
{0.1313,0.075,0.15},
{1,0,1}, // 210
{1,0.5,1},
{0.65,0,0.65},
{0.65,0.325,0.65},
{0.5,0,0.5},
{0.5,0.25,0.5},
{0.3,0,0.3},
{0.3,0.15,0.3},
{0.15,0,0.15},
{0.15,0.075,0.15},
{1,0,0.75}, // 220
{1,0.5,0.875},
{0.65,0,0.4875},
{0.65,0.325,0.5688},
{0.5,0,0.375},
{0.5,0.25,0.4375},
{0.3,0,0.225},
{0.3,0.15,0.2625},
{0.15,0,0.1125},
{0.15,0.075,0.1313},
{1,0,0.5}, // 230
{1,0.5,0.75},
{0.65,0,0.325},
{0.65,0.325,0.4875},
{0.5,0,0.25},
{0.5,0.25,0.375},
{0.3,0,0.15},
{0.3,0.15,0.225},
{0.15,0,0.075},
{0.15,0.075,0.1125},
{1,0,0.25}, // 240
{1,0.5,0.625},
{0.65,0,0.1625},
{0.65,0.325,0.4063},
{0.5,0,0.125},
{0.5,0.25,0.3125},
{0.3,0,0.075},
{0.3,0.15,0.1875},
{0.15,0,0.0375},
{0.15,0.075,0.0938},
{0.33,0.33,0.33}, // 250
{0.464,0.464,0.464},
{0.598,0.598,0.598},
{0.732,0.732,0.732},
{0.866,0.866,0.866},
{1,1,1} // 255
}
;
// AutoCAD VERSION aliases
#define DL_VERSION_R12 DL_Codes::AC1009
#define DL_VERSION_LT2 DL_Codes::AC1009
#define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet
#define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet
#define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet
#define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet
#define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet
#define DL_VERSION_2000 DL_Codes::AC1015
#define DL_VERSION_2002 DL_Codes::AC1015
// DXF Group Codes:
// Strings
#define DL_STRGRP_START 0
#define DL_STRGRP_END 9
// Coordinates
#define DL_CRDGRP_START 10
#define DL_CRDGRP_END 19
// Real values
#define DL_RLGRP_START 38
#define DL_RLGRP_END 59
// Short integer values
#define DL_SHOGRP_START 60
#define DL_SHOGRP_END 79
// New in Release 13,
#define DL_SUBCLASS 100
// More coordinates
#define DL_CRD2GRP_START 210
#define DL_CRD2GRP_END 239
// Extended data strings
#define DL_ESTRGRP_START 1000
#define DL_ESTRGRP_END 1009
// Extended data reals
#define DL_ERLGRP_START 1010
#define DL_ERLGRP_END 1059
#define DL_Y8_COORD_CODE 28
#define DL_Z0_COORD_CODE 30
#define DL_Z8_COORD_CODE 38
#define DL_POINT_COORD_CODE 10
#define DL_INSERT_COORD_CODE 10
#define DL_CRD2GRP_START 210
#define DL_CRD2GRP_END 239
#define DL_THICKNESS 39
#define DL_FIRST_REAL_CODE THICKNESS
#define DL_LAST_REAL_CODE 59
#define DL_FIRST_INT_CODE 60
#define DL_ATTFLAGS_CODE 70
#define DL_PLINE_FLAGS_CODE 70
#define DL_LAYER_FLAGS_CODE 70
#define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf
#define DL_LAST_INT_CODE 79
#define DL_X_EXTRU_CODE 210
#define DL_Y_EXTRU_CODE 220
#define DL_Z_EXTRU_CODE 230
#define DL_COMMENT_CODE 999
// Start and endpoints of a line
#define DL_LINE_START_CODE 10 // Followed by x coord
#define DL_LINE_END_CODE 11 // Followed by x coord
// Some codes used by blocks
#define DL_BLOCK_FLAGS_CODE 70 // An int containing flags
#define DL_BLOCK_BASE_CODE 10 // Origin of block definition
#define DL_XREF_DEPENDENT 16 // If a block contains an XREF
#define DL_XREF_RESOLVED 32 // If a XREF resolved ok
#define DL_REFERENCED 64 // If a block is ref'd in DWG
#define DL_XSCALE_CODE 41
#define DL_YSCALE_CODE 42
#define DL_ANGLE_CODE 50
#define DL_INS_POINT_CODE 10 // Followed by x of ins pnt
#define DL_NAME2_CODE 3 // Second appearance of name
// Some codes used by circle entities
#define DL_CENTER_CODE 10 // Followed by x of center
#define DL_RADIUS_CODE 40 // Followd by radius of circle
#define DL_COND_OP_CODE -4 // Conditional op,ads_ssget
// When using ads_buildlist you MUST use RTDXF0 instead of these
#define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE..
#define DL_SES_CODE 0 // Start End String Code
#define DL_FILE_SEP_CODE 0 // File separator
#define DL_SOT_CODE 0 // Start Of Table
#define DL_TEXTVAL_CODE 1
#define DL_NAME_CODE 2
#define DL_BLOCK_NAME_CODE 2
#define DL_SECTION_NAME_CODE 2
#define DL_ENT_HAND_CODE 5 // What follows is hexa string
#define DL_TXT_STYLE_CODE 7 // Inside attributes
#define DL_LAYER_NAME_CODE 8 // What follows is layer name
#define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord
#define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord
#define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord
#define DL_L_START_CODE 10
#define DL_L_END_CODE 11
#define DL_TXTHI_CODE 40
#define DL_SCALE_X_CODE 41
#define DL_SCALE_Y_CODE 42
#define DL_SCALE_Z_CODE 43
#define DL_BULGE_CODE 42 // Used in PLINE verts for arcs
#define DL_ROTATION_CODE 50
#define DL_COLOUR_CODE 62 // What follows is a color int
#define DL_LTYPE_CODE 6 // What follows is a linetype
// Attribute flags
#define DL_ATTS_FOLLOW_CODE 66
#define DL_ATT_TAG_CODE 2
#define DL_ATT_VAL_CODE 1
#define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows...
#define DL_ATT_INVIS_FLAG 1
#define DL_ATT_CONST_FLAG 2
#define DL_ATT_VERIFY_FLAG 4 // Prompt and verify
#define DL_ATT_PRESET_FLAG 8 // No prompt and no verify
// PLINE defines
// Flags
#define DL_OPEN_PLINE 0x00
#define DL_CLOSED_PLINE 0x01
#define DL_POLYLINE3D 0x80
#define DL_PFACE_MESH 0x40
#define DL_PGON_MESH 0x10
// Vertices follow entity, required in POLYLINES
#define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1
#define DL_VERTEX_COORD_CODE 10
// LAYER flags
#define DL_FROZEN 1
#define DL_FROZEN_BY_DEF 2
#define DL_LOCKED 4
#define DL_OBJECT_USED 64 // Object is ref'd in the dwg
#define DL_BLOCK_EN_CODE -2 // Block entity definition
#define DL_E_NAME -1 // Entity name
// Extended data codes
#define DL_EXTD_SENTINEL (-3)
#define DL_EXTD_STR 1000
#define DL_EXTD_APP_NAME 1001
#define DL_EXTD_CTL_STR 1002
#define DL_EXTD_LYR_STR 1003
#define DL_EXTD_CHUNK 1004
#define DL_EXTD_HANDLE 1005
#define DL_EXTD_POINT 1010
#define DL_EXTD_POS 1011
#define DL_EXTD_DISP 1012
#define DL_EXTD_DIR 1013
#define DL_EXTD_FLOAT 1040
#define DL_EXTD_DIST 1041
#define DL_EXTD_SCALE 1042
#define DL_EXTD_INT16 1070
#define DL_EXTD_INT32 1071
// UCS codes for use in ads_trans
#define DL_WCS_TRANS_CODE 0
#define DL_UCS_TRANS_CODE 1
#define DL_DCS_TRANS_CODE 2
#define DL_PCS_TRANS_CODE 3
#ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0
#endif
#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
# define DL_FALLTHROUGH [[fallthrough]];
#elif defined(Q_CC_CLANG) && __cplusplus >= 201103L
/* clang's fallthrough annotations are only available starting in C++11. */
# define DL_FALLTHROUGH [[clang::fallthrough]];
#elif defined(Q_CC_MSVC)
/*
* MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
* https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx
*/
# include <sal.h>
# define DL_FALLTHROUGH __fallthrough;
#elif defined(Q_CC_GNU) && (__GNUC__ >= 7)
# define DL_FALLTHROUGH [[gnu::fallthrough]];
#else
# define DL_FALLTHROUGH
#endif
#endif

View File

@ -1,141 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_CREATIONADAPTER_H
#define DL_CREATIONADAPTER_H
#include "dl_global.h"
#include "dl_creationinterface.h"
/**
* An abstract adapter class for receiving DXF events when a DXF file is being read.
* The methods in this class are empty. This class exists as convenience for creating
* listener objects.
*
* @author Andrew Mustun
*/
class DXFLIB_EXPORT DL_CreationAdapter : public DL_CreationInterface
{
public:
DL_CreationAdapter() {}
virtual ~DL_CreationAdapter();
virtual void processCodeValuePair(quint32, const std::string&) {}
virtual void endSection() {}
virtual void addLayer(const DL_LayerData&) {}
virtual void addLinetype(const DL_LinetypeData&) {}
virtual void addLinetypeDash(double) {}
virtual void addBlock(const DL_BlockData&) {}
virtual void endBlock() {}
virtual void addTextStyle(const DL_StyleData&) {}
virtual void addPoint(const DL_PointData&) {}
virtual void addLine(const DL_LineData&) {}
virtual void addXLine(const DL_XLineData&) {}
virtual void addRay(const DL_RayData&) {}
virtual void addArc(const DL_ArcData&) {}
virtual void addCircle(const DL_CircleData&) {}
virtual void addEllipse(const DL_EllipseData&) {}
virtual void addPolyline(const DL_PolylineData&) {}
virtual void addVertex(const DL_VertexData&) {}
virtual void addSpline(const DL_SplineData&) {}
virtual void addControlPoint(const DL_ControlPointData&) {}
virtual void addFitPoint(const DL_FitPointData&) {}
virtual void addKnot(const DL_KnotData&) {}
virtual void addInsert(const DL_InsertData&) {}
virtual void addMText(const DL_MTextData&) {}
virtual void addMTextChunk(const std::string&) {}
virtual void addText(const DL_TextData&) {}
virtual void addAttribute(const DL_AttributeData&) {}
virtual void addDimAlign(const DL_DimensionData&,
const DL_DimAlignedData&) {}
virtual void addDimLinear(const DL_DimensionData&,
const DL_DimLinearData&) {}
virtual void addDimRadial(const DL_DimensionData&,
const DL_DimRadialData&) {}
virtual void addDimDiametric(const DL_DimensionData&,
const DL_DimDiametricData&) {}
virtual void addDimAngular(const DL_DimensionData&,
const DL_DimAngularData&) {}
virtual void addDimAngular3P(const DL_DimensionData&,
const DL_DimAngular3PData&) {}
virtual void addDimOrdinate(const DL_DimensionData&,
const DL_DimOrdinateData&) {}
virtual void addLeader(const DL_LeaderData&) {}
virtual void addLeaderVertex(const DL_LeaderVertexData&) {}
virtual void addHatch(const DL_HatchData&) {}
virtual void addTrace(const DL_TraceData&) {}
virtual void add3dFace(const DL_3dFaceData&) {}
virtual void addSolid(const DL_SolidData&) {}
virtual void addImage(const DL_ImageData&) {}
virtual void linkImage(const DL_ImageDefData&) {}
virtual void addHatchLoop(const DL_HatchLoopData&) {}
virtual void addHatchEdge(const DL_HatchEdgeData&) {}
virtual void addXRecord(const std::string&) {}
virtual void addXRecordString(int, const std::string&) {}
virtual void addXRecordReal(int, double) {}
virtual void addXRecordInt(int, int) {}
virtual void addXRecordBool(int, bool) {}
virtual void addXDataApp(const std::string&) {}
virtual void addXDataString(int, const std::string&) {}
virtual void addXDataReal(int, double) {}
virtual void addXDataInt(int, int) {}
virtual void addDictionary(const DL_DictionaryData&) {}
virtual void addDictionaryEntry(const DL_DictionaryEntryData&) {}
virtual void endEntity() {}
virtual void addComment(const std::string&) {}
virtual void setVariableVector(const std::string&, double, double, double, int) {}
virtual void setVariableString(const std::string&, const std::string&, int) {}
virtual void setVariableInt(const std::string&, int, int) {}
virtual void setVariableDouble(const std::string&, double, int) {}
#ifdef DL_COMPAT
virtual void setVariableVector(const char*, double, double, double, int) {}
virtual void setVariableString(const char*, const char*, int) {}
virtual void setVariableInt(const char*, int, int) {}
virtual void setVariableDouble(const char*, double, int) {}
virtual void processCodeValuePair(quint32, char*) {}
virtual void addComment(const char*) {}
virtual void addMTextChunk(const char*) {}
#endif
virtual void endSequence() {}
};
DL_CreationAdapter::~DL_CreationAdapter()
{}
#endif

View File

@ -1,378 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_CREATIONINTERFACE_H
#define DL_CREATIONINTERFACE_H
#include "dl_global.h"
#include <string.h>
#include "dl_attributes.h"
#include "dl_codes.h"
#include "dl_entities.h"
#include "dl_extrusion.h"
/**
* Abstract class (interface) for the creation of new entities.
* Inherit your class which takes care of the entities in the
* processed DXF file from this interface.
*
* Double arrays passed to your implementation contain 3 double
* values for x, y, z coordinates unless stated differently.
*
* @author Andrew Mustun
*/
class DXFLIB_EXPORT DL_CreationInterface
{
public:
DL_CreationInterface() : extrusion(new DL_Extrusion), attributes()
{
}
virtual ~DL_CreationInterface();
/**
* Called for every code / value tuple of the DXF file. The complete DXF file
* contents can be handled by the implemetation of this function.
*/
virtual void processCodeValuePair(quint32 groupCode, const std::string& groupValue) = 0;
/**
* Called when a section (entity, table entry, etc.) is finished.
*/
virtual void endSection() = 0;
/**
* Called for every layer.
*/
virtual void addLayer(const DL_LayerData& data) = 0;
/**
* Called for every linetype.
*/
virtual void addLinetype(const DL_LinetypeData& data) = 0;
/**
* Called for every dash in linetype pattern
*/
virtual void addLinetypeDash(double length) = 0;
/**
* Called for every block. Note: all entities added after this
* command go into this block until endBlock() is called.
*
* @see endBlock()
*/
virtual void addBlock(const DL_BlockData& data) = 0;
/** Called to end the current block */
virtual void endBlock() = 0;
/** Called for every text style */
virtual void addTextStyle(const DL_StyleData& data) = 0;
/** Called for every point */
virtual void addPoint(const DL_PointData& data) = 0;
/** Called for every line */
virtual void addLine(const DL_LineData& data) = 0;
/** Called for every xline */
virtual void addXLine(const DL_XLineData& data) = 0;
/** Called for every ray */
virtual void addRay(const DL_RayData& data) = 0;
/** Called for every arc */
virtual void addArc(const DL_ArcData& data) = 0;
/** Called for every circle */
virtual void addCircle(const DL_CircleData& data) = 0;
/** Called for every ellipse */
virtual void addEllipse(const DL_EllipseData& data) = 0;
/** Called for every polyline start */
virtual void addPolyline(const DL_PolylineData& data) = 0;
/** Called for every polyline vertex */
virtual void addVertex(const DL_VertexData& data) = 0;
/** Called for every spline */
virtual void addSpline(const DL_SplineData& data) = 0;
/** Called for every spline control point */
virtual void addControlPoint(const DL_ControlPointData& data) = 0;
/** Called for every spline fit point */
virtual void addFitPoint(const DL_FitPointData& data) = 0;
/** Called for every spline knot value */
virtual void addKnot(const DL_KnotData& data) = 0;
/** Called for every insert. */
virtual void addInsert(const DL_InsertData& data) = 0;
/** Called for every trace start */
virtual void addTrace(const DL_TraceData& data) = 0;
/** Called for every 3dface start */
virtual void add3dFace(const DL_3dFaceData& data) = 0;
/** Called for every solid start */
virtual void addSolid(const DL_SolidData& data) = 0;
/** Called for every Multi Text entity. */
virtual void addMText(const DL_MTextData& data) = 0;
/**
* Called for additional text chunks for MTEXT entities.
* The chunks come at 250 character in size each. Note that
* those chunks come <b>before</b> the actual MTEXT entity.
*/
virtual void addMTextChunk(const std::string& text) = 0;
/** Called for every Text entity. */
virtual void addText(const DL_TextData& data) = 0;
/** Called for every Block Attribute entity. */
virtual void addAttribute(const DL_AttributeData& data) = 0;
/**
* Called for every aligned dimension entity.
*/
virtual void addDimAlign(const DL_DimensionData& data,
const DL_DimAlignedData& edata) = 0;
/**
* Called for every linear or rotated dimension entity.
*/
virtual void addDimLinear(const DL_DimensionData& data,
const DL_DimLinearData& edata) = 0;
/**
* Called for every radial dimension entity.
*/
virtual void addDimRadial(const DL_DimensionData& data,
const DL_DimRadialData& edata) = 0;
/**
* Called for every diametric dimension entity.
*/
virtual void addDimDiametric(const DL_DimensionData& data,
const DL_DimDiametricData& edata) = 0;
/**
* Called for every angular dimension (2 lines version) entity.
*/
virtual void addDimAngular(const DL_DimensionData& data,
const DL_DimAngularData& edata) = 0;
/**
* Called for every angular dimension (3 points version) entity.
*/
virtual void addDimAngular3P(const DL_DimensionData& data,
const DL_DimAngular3PData& edata) = 0;
/**
* Called for every ordinate dimension entity.
*/
virtual void addDimOrdinate(const DL_DimensionData& data,
const DL_DimOrdinateData& edata) = 0;
/**
* Called for every leader start.
*/
virtual void addLeader(const DL_LeaderData& data) = 0;
/**
* Called for every leader vertex
*/
virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0;
/**
* Called for every hatch entity.
*/
virtual void addHatch(const DL_HatchData& data) = 0;
/**
* Called for every image entity.
*/
virtual void addImage(const DL_ImageData& data) = 0;
/**
* Called for every image definition.
*/
virtual void linkImage(const DL_ImageDefData& data) = 0;
/**
* Called for every hatch loop.
*/
virtual void addHatchLoop(const DL_HatchLoopData& data) = 0;
/**
* Called for every hatch edge entity.
*/
virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0;
/**
* Called for every XRecord with the given handle.
*/
virtual void addXRecord(const std::string& handle) = 0;
/**
* Called for XRecords of type string.
*/
virtual void addXRecordString(int code, const std::string& value) = 0;
/**
* Called for XRecords of type double.
*/
virtual void addXRecordReal(int code, double value) = 0;
/**
* Called for XRecords of type int.
*/
virtual void addXRecordInt(int code, int value) = 0;
/**
* Called for XRecords of type bool.
*/
virtual void addXRecordBool(int code, bool value) = 0;
/**
* Called for every beginning of an XData section of the given application.
*/
virtual void addXDataApp(const std::string& appId) = 0;
/**
* Called for XData tuples.
*/
virtual void addXDataString(int code, const std::string& value) = 0;
/**
* Called for XData tuples.
*/
virtual void addXDataReal(int code, double value) = 0;
/**
* Called for XData tuples.
*/
virtual void addXDataInt(int code, int value) = 0;
/**
* Called for dictionary objects.
*/
virtual void addDictionary(const DL_DictionaryData& data) = 0;
/**
* Called for dictionary entries.
*/
virtual void addDictionaryEntry(const DL_DictionaryEntryData& data) = 0;
/**
* Called after an entity has been completed.
*/
virtual void endEntity() = 0;
/**
* Called for every comment in the DXF file (code 999).
*/
virtual void addComment(const std::string& comment) = 0;
/**
* Called for every vector variable in the DXF file (e.g. "$EXTMIN").
*/
virtual void setVariableVector(const std::string& key, double v1, double v2, double v3, int code) = 0;
/**
* Called for every string variable in the DXF file (e.g. "$ACADVER").
*/
virtual void setVariableString(const std::string& key, const std::string& value, int code) = 0;
/**
* Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
*/
virtual void setVariableInt(const std::string& key, int value, int code) = 0;
/**
* Called for every double variable in the DXF file (e.g. "$DIMEXO").
*/
virtual void setVariableDouble(const std::string& key, double value, int code) = 0;
#ifdef DL_COMPAT
virtual void setVariableVector(const char* key, double v1, double v2, double v3, int code) = 0;
virtual void setVariableString(const char* key, const char* value, int code) = 0;
virtual void setVariableInt(const char* key, int value, int code) = 0;
virtual void setVariableDouble(const char* key, double value, int code) = 0;
virtual void processCodeValuePair(quint32 groupCode, char* groupValue) = 0;
virtual void addComment(const char* comment) = 0;
virtual void addMTextChunk(const char* text) = 0;
#endif
/**
* Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
*/
virtual void endSequence() = 0;
/** Sets the current attributes for entities. */
void setAttributes(const DL_Attributes& attrib)
{
attributes = attrib;
}
/** @return the current attributes used for new entities. */
DL_Attributes getAttributes() const
{
return attributes;
}
/** Sets the current attributes for entities. */
void setExtrusion(double dx, double dy, double dz, double elevation)
{
extrusion->setDirection(dx, dy, dz);
extrusion->setElevation(elevation);
}
/** @return the current attributes used for new entities. */
DL_Extrusion* getExtrusion()
{
return extrusion;
}
private:
Q_DISABLE_COPY(DL_CreationInterface)
protected:
DL_Extrusion *extrusion;
DL_Attributes attributes;
};
DL_CreationInterface::~DL_CreationInterface()
{
delete extrusion;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,525 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_DXF_H
#define DL_DXF_H
#include <stdio.h>
#include <stdlib.h>
#include <QtGlobal>
#include <algorithm>
#include <limits>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include "dl_attributes.h"
#include "dl_codes.h"
#include "dl_entities.h"
#include "dl_global.h"
#include "dl_writer_ascii.h"
#ifndef DL_NANDOUBLE
#define DL_NANDOUBLE std::numeric_limits<double>::quiet_NaN()
#endif
class DL_CreationInterface;
#define DL_VERSION "3.12.2.0"
#define DL_VERSION_MAJOR 3
#define DL_VERSION_MINOR 12
#define DL_VERSION_REV 2
#define DL_VERSION_BUILD 0
#define DL_UNKNOWN 0
#define DL_LAYER 10
#define DL_BLOCK 11
#define DL_ENDBLK 12
#define DL_LINETYPE 13
#define DL_STYLE 20
#define DL_SETTING 50
#define DL_ENTITY_POINT 100
#define DL_ENTITY_LINE 101
#define DL_ENTITY_POLYLINE 102
#define DL_ENTITY_LWPOLYLINE 103
#define DL_ENTITY_VERTEX 104
#define DL_ENTITY_SPLINE 105
#define DL_ENTITY_KNOT 106
#define DL_ENTITY_CONTROLPOINT 107
#define DL_ENTITY_ARC 108
#define DL_ENTITY_CIRCLE 109
#define DL_ENTITY_ELLIPSE 110
#define DL_ENTITY_INSERT 111
#define DL_ENTITY_TEXT 112
#define DL_ENTITY_MTEXT 113
#define DL_ENTITY_DIMENSION 114
#define DL_ENTITY_LEADER 115
#define DL_ENTITY_HATCH 116
#define DL_ENTITY_ATTRIB 117
#define DL_ENTITY_IMAGE 118
#define DL_ENTITY_IMAGEDEF 119
#define DL_ENTITY_TRACE 120
#define DL_ENTITY_SOLID 121
#define DL_ENTITY_3DFACE 122
#define DL_ENTITY_XLINE 123
#define DL_ENTITY_RAY 124
#define DL_ENTITY_SEQEND 125
#define DL_XRECORD 200
#define DL_DICTIONARY 210
/**
* Reading and writing of DXF files.
*
* This class can read in a DXF file and calls methods from the
* interface DL_EntityContainer to add the entities to the
* contianer provided by the user of the library.
*
* It can also be used to write DXF files to a certain extent.
*
* When saving entities, special values for colors and linetypes
* can be used:
*
* Special colors are 0 (=BYBLOCK) and 256 (=BYLAYER).
* Special linetypes are "BYLAYER" and "BYBLOCK".
*
* @author Andrew Mustun
*/
class DXFLIB_EXPORT DL_Dxf
{
public:
DL_Dxf();
~DL_Dxf();
bool in(const std::string& file, DL_CreationInterface* creationInterface);
bool readDxfGroups(FILE* fp, DL_CreationInterface* creationInterface);
static bool getStrippedLine(std::string& s, quint32 size, FILE* stream, bool stripSpace = true);
bool readDxfGroups(std::stringstream& stream, DL_CreationInterface* creationInterface);
bool in(std::stringstream &stream, DL_CreationInterface* creationInterface);
static bool getStrippedLine(std::string& s, quint32 size, std::stringstream& stream, bool stripSpace = true);
static bool stripWhiteSpace(char** s, bool stripSpace = true);
bool processDXFGroup(DL_CreationInterface* creationInterface, int groupCode, const std::string& groupValue);
void addSetting(DL_CreationInterface* creationInterface);
void addLayer(DL_CreationInterface* creationInterface);
void addLinetype(DL_CreationInterface *creationInterface);
void addBlock(DL_CreationInterface* creationInterface);
static void endBlock(DL_CreationInterface* creationInterface);
void addTextStyle(DL_CreationInterface* creationInterface);
void addPoint(DL_CreationInterface* creationInterface);
void addLine(DL_CreationInterface* creationInterface);
void addXLine(DL_CreationInterface* creationInterface);
void addRay(DL_CreationInterface* creationInterface);
void addPolyline(DL_CreationInterface* creationInterface);
void addVertex(DL_CreationInterface* creationInterface);
void addSpline(DL_CreationInterface* creationInterface);
void addArc(DL_CreationInterface* creationInterface);
void addCircle(DL_CreationInterface* creationInterface);
void addEllipse(DL_CreationInterface* creationInterface);
void addInsert(DL_CreationInterface* creationInterface);
void addTrace(DL_CreationInterface* creationInterface);
void add3dFace(DL_CreationInterface* creationInterface);
void addSolid(DL_CreationInterface* creationInterface);
void addMText(DL_CreationInterface* creationInterface);
void addText(DL_CreationInterface* creationInterface);
void addAttribute(DL_CreationInterface* creationInterface);
DL_DimensionData getDimData();
void addDimLinear(DL_CreationInterface* creationInterface);
void addDimAligned(DL_CreationInterface* creationInterface);
void addDimRadial(DL_CreationInterface* creationInterface);
void addDimDiametric(DL_CreationInterface* creationInterface);
void addDimAngular(DL_CreationInterface* creationInterface);
void addDimAngular3P(DL_CreationInterface* creationInterface);
void addDimOrdinate(DL_CreationInterface* creationInterface);
void addLeader(DL_CreationInterface* creationInterface);
void addHatch(DL_CreationInterface* creationInterface);
void addHatchLoop();
void addHatchEdge();
bool handleHatchData(DL_CreationInterface* creationInterface);
void addImage(DL_CreationInterface* creationInterface);
void addImageDef(DL_CreationInterface* creationInterface);
static void addComment(DL_CreationInterface* creationInterface, const std::string& comment);
void addDictionary(DL_CreationInterface* creationInterface);
void addDictionaryEntry(DL_CreationInterface* creationInterface);
bool handleXRecordData(DL_CreationInterface* creationInterface);
bool handleDictionaryData(DL_CreationInterface* creationInterface);
bool handleXData(DL_CreationInterface *creationInterface);
bool handleMTextData(DL_CreationInterface* creationInterface);
bool handleLWPolylineData(DL_CreationInterface* creationInterface);
bool handleSplineData(DL_CreationInterface* creationInterface);
bool handleLeaderData(DL_CreationInterface* creationInterface);
bool handleLinetypeData(DL_CreationInterface* creationInterface);
static void endEntity(DL_CreationInterface* creationInterface);
static void endSequence(DL_CreationInterface* creationInterface);
//int stringToInt(const char* s, bool* ok=NULL);
DL_WriterA* out(const char* file, DL_Codes::version version=DL_VERSION_2000);
void writeHeader(DL_WriterA& dw) const;
void writePoint(DL_WriterA& dw,
const DL_PointData& data,
const DL_Attributes& attrib);
void writeLine(DL_WriterA& dw,
const DL_LineData& data,
const DL_Attributes& attrib);
void writeXLine(DL_WriterA& dw,
const DL_XLineData& data,
const DL_Attributes& attrib);
void writeRay(DL_WriterA& dw,
const DL_RayData& data,
const DL_Attributes& attrib);
void writePolyline(DL_WriterA& dw,
const DL_PolylineData& data,
const DL_Attributes& attrib);
void writeVertex(DL_WriterA& dw,
const DL_VertexData& data);
void writePolylineEnd(DL_WriterA& dw) const;
void writeSpline(DL_WriterA& dw,
const DL_SplineData& data,
const DL_Attributes& attrib);
static void writeControlPoint(DL_WriterA& dw,
const DL_ControlPointData& data);
static void writeFitPoint(DL_WriterA& dw,
const DL_FitPointData& data);
static void writeKnot(DL_WriterA& dw,
const DL_KnotData& data);
void writeCircle(DL_WriterA& dw,
const DL_CircleData& data,
const DL_Attributes& attrib);
void writeArc(DL_WriterA& dw,
const DL_ArcData& data,
const DL_Attributes& attrib);
void writeEllipse(DL_WriterA& dw,
const DL_EllipseData& data,
const DL_Attributes& attrib);
void writeSolid(DL_WriterA& dw,
const DL_SolidData& data,
const DL_Attributes& attrib);
void writeTrace(DL_WriterA& dw,
const DL_TraceData& data,
const DL_Attributes& attrib);
void write3dFace(DL_WriterA& dw,
const DL_3dFaceData& data,
const DL_Attributes& attrib);
void writeInsert(DL_WriterA& dw,
const DL_InsertData& data,
const DL_Attributes& attrib);
void writeMText(DL_WriterA& dw,
const DL_MTextData& data,
const DL_Attributes& attrib);
void writeText(DL_WriterA& dw,
const DL_TextData& data,
const DL_Attributes& attrib);
void writeAttribute(DL_WriterA& dw,
const DL_AttributeData& data,
const DL_Attributes& attrib);
void writeDimStyleOverrides(DL_WriterA& dw,
const DL_DimensionData& data) const;
void writeDimAligned(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimAlignedData& edata,
const DL_Attributes& attrib);
void writeDimLinear(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimLinearData& edata,
const DL_Attributes& attrib);
void writeDimRadial(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimRadialData& edata,
const DL_Attributes& attrib);
void writeDimDiametric(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimDiametricData& edata,
const DL_Attributes& attrib);
void writeDimAngular(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimAngularData& edata,
const DL_Attributes& attrib);
void writeDimAngular3P(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimAngular3PData& edata,
const DL_Attributes& attrib);
void writeDimOrdinate(DL_WriterA& dw,
const DL_DimensionData& data,
const DL_DimOrdinateData& edata,
const DL_Attributes& attrib);
void writeLeader(DL_WriterA& dw,
const DL_LeaderData& data,
const DL_Attributes& attrib);
void writeLeaderVertex(DL_WriterA& dw,
const DL_LeaderVertexData& data) const;
void writeHatch1(DL_WriterA& dw,
const DL_HatchData& data,
const DL_Attributes& attrib);
void writeHatch2(DL_WriterA& dw,
const DL_HatchData& data,
const DL_Attributes& attrib) const;
static void writeHatchLoop1(DL_WriterA& dw,
const DL_HatchLoopData& data);
static void writeHatchLoop2(DL_WriterA& dw,
const DL_HatchLoopData& data);
static void writeHatchEdge(DL_WriterA& dw,
const DL_HatchEdgeData& data);
int writeImage(DL_WriterA& dw,
const DL_ImageData& data,
const DL_Attributes& attrib);
void writeImageDef(DL_WriterA& dw, int handle,
const DL_ImageData& data) const;
void writeLayer(DL_WriterA& dw,
const DL_LayerData& data,
const DL_Attributes& attrib);
void writeLinetype(DL_WriterA& dw,
const DL_LinetypeData& data) const;
static void writeAppid(DL_WriterA& dw, const std::string& name);
static void writeBlock(DL_WriterA& dw,
const DL_BlockData& data);
static void writeEndBlock(DL_WriterA& dw, const std::string& name);
void writeVPort(DL_WriterA& dw) const;
void writeStyle(DL_WriterA& dw, const DL_StyleData& style);
void writeView(DL_WriterA& dw) const;
void writeUcs(DL_WriterA& dw) const;
void writeDimStyle(DL_WriterA& dw,
double dimasz, double dimexe, double dimexo,
double dimgap, double dimtxt);
void writeBlockRecord(DL_WriterA& dw) const;
void writeBlockRecord(DL_WriterA& dw, const std::string& name) const;
void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = "");
void writeAppDictionary(DL_WriterA& dw);
static int writeDictionaryEntry(DL_WriterA& dw, const std::string& name);
void writeXRecord(DL_WriterA& dw, int handle, int value);
void writeXRecord(DL_WriterA& dw, int handle, double value);
void writeXRecord(DL_WriterA& dw, int handle, bool value);
void writeXRecord(DL_WriterA& dw, int handle, const std::string& value);
static void writeObjectsEnd(DL_WriterA& dw);
static void writeComment(DL_WriterA& dw, const std::string& comment);
/**
* Converts the given string into a double or returns the given
* default valud (def) if value is NULL or empty.
*/
//static double toReal(const char* value, double def=0.0);
/**
* Converts the given string into an int or returns the given
* default valud (def) if value is NULL or empty.
*/
// static int toInt(const char* value, int def=0) {
// if (value!=NULL && value[0] != '\0') {
// return atoi(value);
// }
// return def;
// }
/**
* Converts the given string into a string or returns the given
* default valud (def) if value is NULL or empty.
*/
// static const char* toString(const char* value, const char* def="") {
// if (value!=NULL && value[0] != '\0') {
// return value;
// } else {
// return def;
// }
// }
static bool checkVariable(const char* var, DL_Codes::version version);
DL_Codes::version getVersion() const
{
return version;
}
static int getLibVersion(const std::string &str);
static void test();
bool hasValue(int code)
{
return values.count(code)==1;
}
int getIntValue(int code, int def)
{
if (!hasValue(code))
{
return def;
}
return toInt(values[code]);
}
static int toInt(const std::string& str)
{
char* p;
return static_cast<int>(strtol(str.c_str(), &p, 10));
}
int getInt16Value(int code, int def)
{
if (!hasValue(code))
{
return def;
}
return toInt16(values[code]);
}
static int toInt16(const std::string& str)
{
char* p;
return static_cast<int>(strtol(str.c_str(), &p, 16));
}
static bool toBool(const std::string& str)
{
char* p;
return static_cast<bool>(strtol(str.c_str(), &p, 10));
}
std::string getStringValue(int code, const std::string& def)
{
if (!hasValue(code))
{
return def;
}
return values[code];
}
double getRealValue(int code, double def)
{
if (!hasValue(code))
{
return def;
}
return toReal(values[code]);
}
static double toReal(const std::string& str)
{
double ret;
// make sure the real value uses '.' not ',':
std::string str2 = str;
std::replace(str2.begin(), str2.end(), ',', '.');
// make sure c++ expects '.' not ',':
std::istringstream istr(str2);
istr.imbue(std::locale("C"));
istr >> ret;
return ret;
}
private:
Q_DISABLE_COPY(DL_Dxf)
DL_Codes::version version;
std::string polylineLayer;
double* vertices;
int maxVertices;
int vertexIndex;
double* knots;
int maxKnots;
int knotIndex;
double* weights;
int weightIndex;
double* controlPoints;
int maxControlPoints;
int controlPointIndex;
double* fitPoints;
int maxFitPoints;
int fitPointIndex;
double* leaderVertices;
int maxLeaderVertices;
int leaderVertexIndex;
bool firstHatchLoop;
DL_HatchEdgeData hatchEdge;
std::vector<std::vector<DL_HatchEdgeData> > hatchEdges;
std::string xRecordHandle;
bool xRecordValues;
// Only the useful part of the group code
std::string groupCodeTmp;
// ...same as integer
quint32 groupCode;
// Only the useful part of the group value
std::string groupValue;
// Current entity type
int currentObjectType;
// Value of the current setting
char settingValue[DL_DXF_MAXLINE+1];
// Key of the current setting (e.g. "$ACADVER")
std::string settingKey;
// Stores the group codes
std::map<int, std::string> values;
// First call of this method. We initialize all group values in
// the first call.
bool firstCall;
// Attributes of the current entity (layer, color, width, line type)
DL_Attributes attrib;
// library version. hex: 0x20003001 = 2.0.3.1
int libVersion;
// app specific dictionary handle:
unsigned long appDictionaryHandle;
// handle of standard text style, referenced by dimstyle:
unsigned long styleHandleStd;
};
#endif
// EOF

File diff suppressed because it is too large Load Diff

View File

@ -1,164 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_EXTRUSION_H
#define DL_EXTRUSION_H
#include "dl_global.h"
#include "../vmisc/vmath.h"
/**
* Storing and passing around attributes. Attributes
* are the layer name, color, width and line type.
*
* @author Andrew Mustun
*/
class DXFLIB_EXPORT DL_Extrusion
{
public:
/**
* Default constructor.
*/
DL_Extrusion() : direction(new double[3]), elevation(0.0)
{
setDirection(0.0, 0.0, 1.0);
}
/**
* Destructor.
*/
~DL_Extrusion()
{
delete[] direction ;
}
DL_Extrusion(const DL_Extrusion &L)
: direction(new double[3]), elevation(L.elevation)
{
setDirection(L.direction[0], L.direction[1], L.direction[0]);
}
/**
* Constructor for DXF extrusion.
*
* @param elevation Distance of the entities XY plane from the origin of the
* world coordinate system
*/
DL_Extrusion(double dx, double dy, double dz, double elevation)
: direction(new double[3]), elevation(elevation)
{
setDirection(dx, dy, dz);
}
/**
* Sets the direction vector.
*/
void setDirection(double dx, double dy, double dz)
{
direction[0]=dx;
direction[1]=dy;
direction[2]=dz;
}
/**
* @return direction vector.
*/
double* getDirection() const
{
return direction;
}
/**
* @param dir vector.
*/
void getDirection(double dir[]) const
{
dir[0]=direction[0];
dir[1]=direction[1];
dir[2]=direction[2];
}
/**
* Sets the elevation.
*/
void setElevation(double elevation)
{
this->elevation = elevation;
}
/**
* @return Elevation.
*/
double getElevation() const
{
return elevation;
}
/**
* Copies extrusion (deep copies) from another extrusion object.
*/
DL_Extrusion & operator = (const DL_Extrusion& extru)
{
if ( &extru == this )
{
return *this;
}
setDirection(extru.direction[0], extru.direction[1], extru.direction[2]);
setElevation(extru.elevation);
return *this;
}
private:
/**
* @brief direction Vector of axis along which the entity shall be extruded this is also the Z axis of the Entity
* coordinate system
*/
double *direction;
/**
* @brief elevation Distance of the entities XY plane from the origin of the world coordinate system
*/
double elevation;
};
#endif

View File

@ -1,13 +0,0 @@
#if defined(DXFLIB_DLL)
# ifdef _WIN32
# if defined(DXFLIB_LIBRARY)
# define DXFLIB_EXPORT __declspec(dllexport)
# else
# define DXFLIB_EXPORT __declspec(dllimport)
# endif
# else
# define DXFLIB_EXPORT
# endif
#else
# define DXFLIB_EXPORT
#endif

View File

@ -1,644 +0,0 @@
/****************************************************************************
** Copyright (C) 2015 Roman Telezhynskyi <dismine(at)gmail.com>
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
**********************************************************************/
#include "dl_writer.h"
#include <ctype.h>
#include <algorithm>
#include "dl_attributes.h"
#include "dl_codes.h"
/**
* @param version DXF version. Defaults to DL_VERSION_2002.
*/
DL_Writer::DL_Writer(DL_Codes::version version)
: m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version(version)
{}
DL_Writer::~DL_Writer()
{}
/** Generic section for section 'name'.
*
* <pre>
* 0
* SECTION
* 2
* name
* </pre>
*/
void DL_Writer::section(const char *name) const
{
dxfString(0, "SECTION");
dxfString(2, name);
}
/**
* Section HEADER
*
* <pre>
* 0
* SECTION
* 2
* HEADER
* </pre>
*/
void DL_Writer::sectionHeader() const
{
section("HEADER");
}
/**
* Section TABLES
*
* <pre>
* 0
* SECTION
* 2
* TABLES
* </pre>
*/
void DL_Writer::sectionTables() const
{
section("TABLES");
}
/**
* Section BLOCKS
*
* <pre>
* 0
* SECTION
* 2
* BLOCKS
* </pre>
*/
void DL_Writer::sectionBlocks() const
{
section("BLOCKS");
}
/**
* Section ENTITIES
*
* <pre>
* 0
* SECTION
* 2
* ENTITIES
* </pre>
*/
void DL_Writer::sectionEntities() const
{
section("ENTITIES");
}
/**
* Section CLASSES
*
* <pre>
* 0
* SECTION
* 2
* CLASSES
* </pre>
*/
void DL_Writer::sectionClasses() const
{
section("CLASSES");
}
/**
* Section OBJECTS
*
* <pre>
* 0
* SECTION
* 2
* OBJECTS
* </pre>
*/
void DL_Writer::sectionObjects() const
{
section("OBJECTS");
}
/**
* End of a section.
*
* <pre>
* 0
* ENDSEC
* </pre>
*/
void DL_Writer::sectionEnd() const
{
dxfString(0, "ENDSEC");
}
/**
* Generic table for table 'name' with 'num' entries:
*
* <pre>
* 0
* TABLE
* 2
* name
* 70
* num
* </pre>
*/
void DL_Writer::table(const char *name, int num, int h) const
{
dxfString(0, "TABLE");
dxfString(2, name);
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, h);
}
dxfString(100, "AcDbSymbolTable");
}
dxfInt(70, num);
}
/** Table for layers.
*
* @param num Number of layers in total.
*
* <pre>
* 0
* TABLE
* 2
* LAYER
* 70
* num
* </pre>
*/
void DL_Writer::tableLayers(int num) const
{
table("LAYER", num, 2);
}
/** Table for line types.
*
* @param num Number of line types in total.
*
* <pre>
* 0
* TABLE
* 2
* LTYPE
* 70
* num
* </pre>
*/
void DL_Writer::tableLinetypes(int num) const
{
//linetypeHandle = 5;
table("LTYPE", num, 5);
}
/** Table for application id.
*
* @param num Number of registered applications in total.
*
* <pre>
* 0
* TABLE
* 2
* APPID
* 70
* num
* </pre>
*/
void DL_Writer::tableAppid(int num) const
{
table("APPID", num, 9);
}
/** Table for text style.
*
* @param num Number of text styles.
*
* <pre>
* 0
* TABLE
* 2
* STYLE
* 70
* num
* </pre>
*/
void DL_Writer::tableStyle(int num) const
{
table("STYLE", num, 3);
}
/**
* End of a table.
*
* <pre>
* 0
* ENDTAB
* </pre>
*/
void DL_Writer::tableEnd() const
{
dxfString(0, "ENDTAB");
}
/**
* End of the DXF file.
*
* <pre>
* 0
* EOF
* </pre>
*/
void DL_Writer::dxfEOF() const
{
dxfString(0, "EOF");
}
/**
* Comment.
*
* <pre>
* 999
* text
* </pre>
*/
void DL_Writer::comment(const char *text) const
{
dxfString(999, text);
}
/**
* Entity.
*
* <pre>
* 0
* entTypeName
* </pre>
*
*/
void DL_Writer::entity(const char *entTypeName) const
{
dxfString(0, entTypeName);
if (version>=DL_VERSION_2000)
{
handle();
}
}
/**
* Attributes of an entity.
*
* <pre>
* 8
* layer
* 62
* color
* 39
* width
* 6
* linetype
* </pre>
*/
void DL_Writer::entityAttributes(const DL_Attributes &attrib) const
{
// layer name:
dxfString(8, attrib.getLayer());
// R12 doesn't accept BYLAYER values. The value has to be missing
// in that case.
if (version>=DL_VERSION_2000 || attrib.getColor()!=256)
{
dxfInt(62, attrib.getColor());
}
if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1)
{
dxfInt(420, attrib.getColor24());
}
if (version>=DL_VERSION_2000)
{
dxfInt(370, attrib.getWidth());
}
if (version>=DL_VERSION_2000) //-V581
{
dxfReal(48, attrib.getLinetypeScale());
}
std::string linetype = attrib.getLinetype();
std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);
if (version>=DL_VERSION_2000 || linetype=="BYLAYER")
{
dxfString(6, attrib.getLinetype());
}
}
/**
* Subclass.
*/
void DL_Writer::subClass(const char *sub) const
{
dxfString(100, sub);
}
/**
* Layer (must be in the TABLES section LAYER).
*
* <pre>
* 0
* LAYER
* </pre>
*/
void DL_Writer::tableLayerEntry(unsigned long h) const
{
dxfString(0, "LAYER");
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, static_cast<int>(h));
}
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLayerTableRecord");
}
}
/**
* Line type (must be in the TABLES section LTYPE).
*
* <pre>
* 0
* LTYPE
* </pre>
*/
void DL_Writer::tableLinetypeEntry(unsigned long h) const
{
dxfString(0, "LTYPE");
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, 0x5);
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLinetypeTableRecord");
}
}
/**
* Appid (must be in the TABLES section APPID).
*
* <pre>
* 0
* APPID
* </pre>
*/
void DL_Writer::tableAppidEntry(unsigned long h) const
{
dxfString(0, "APPID");
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, 0x9);
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbRegAppTableRecord");
}
}
/**
* Block (must be in the section BLOCKS).
*
* <pre>
* 0
* BLOCK
* </pre>
*/
void DL_Writer::sectionBlockEntry(unsigned long h) const
{
dxfString(0, "BLOCK");
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
if (h==0x1C)
{
dxfInt(67, 1);
}
dxfString(8, "0"); // TODO: Layer for block
dxfString(100, "AcDbBlockBegin");
}
}
/**
* End of Block (must be in the section BLOCKS).
*
* <pre>
* 0
* ENDBLK
* </pre>
*/
void DL_Writer::sectionBlockEntryEnd(unsigned long h) const
{
dxfString(0, "ENDBLK");
if (version>=DL_VERSION_2000)
{
if (h==0)
{
handle();
}
else
{
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
if (h==0x1D)
{
dxfInt(67, 1);
}
dxfString(8, "0"); // TODO: Layer for block
dxfString(100, "AcDbBlockEnd");
}
}
void DL_Writer::color(int col) const
{
dxfInt(62, col);
}
void DL_Writer::linetype(const char *lt) const
{
dxfString(6, lt);
}
void DL_Writer::linetypeScale(double scale) const
{
dxfReal(48, scale);
}
void DL_Writer::lineWeight(int lw) const
{
dxfInt(370, lw);
}
void DL_Writer::coord(int gc, double x, double y, double z) const
{
dxfReal(gc, x);
dxfReal(gc+10, y);
dxfReal(gc+20, z);
}
void DL_Writer::coordTriplet(int gc, const double *value) const
{
if (value)
{
dxfReal(gc, *value++);
dxfReal(gc+10, *value++);
dxfReal(gc+20, *value++);
}
}
void DL_Writer::resetHandle() const
{
m_handle = 1;
}
/**
* Writes a unique handle and returns it.
*/
unsigned long DL_Writer::handle(int gc) const
{
// handle has to be hex
dxfHex(gc, static_cast<int>(m_handle));
return m_handle++;
}
/**
* @return Next handle that will be written.
*/
unsigned long DL_Writer::getNextHandle() const
{
return m_handle;
}
/**
* Increases handle, so that the handle returned remains available.
*/
unsigned long DL_Writer::incHandle() const
{
return m_handle++;
}
/**
* Sets the handle of the model space. Entities refer to
* this handle.
*/
void DL_Writer::setModelSpaceHandle(unsigned long h) const
{
modelSpaceHandle = h;
}
unsigned long DL_Writer::getModelSpaceHandle() const
{
return modelSpaceHandle;
}
/**
* Sets the handle of the paper space. Some special blocks refer to
* this handle.
*/
void DL_Writer::setPaperSpaceHandle(unsigned long h) const
{
paperSpaceHandle = h;
}
unsigned long DL_Writer::getPaperSpaceHandle() const
{
return paperSpaceHandle;
}
/**
* Sets the handle of the paper space 0. Some special blocks refer to
* this handle.
*/
void DL_Writer::setPaperSpace0Handle(unsigned long h) const
{
paperSpace0Handle = h;
}
/**
* Sets the handle of the paper space 0. Some special blocks refer to
* this handle.
*/
unsigned long DL_Writer::getPaperSpace0Handle() const
{
return paperSpace0Handle;
}
/**
* Can be overwritten by the implementing class to write a
* bool value to the file.
*
* @param gc Group code.
* @param value The bool value.
*/
void DL_Writer::dxfBool(int gc, bool value) const
{
dxfInt(gc, static_cast<int>(value));
}

View File

@ -1,170 +0,0 @@
/****************************************************************************
** Copyright (C) 2015 Roman Telezhynskyi <dismine(at)gmail.com>
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_WRITER_H
#define DL_WRITER_H
#include "dl_global.h"
#ifndef _WIN32
#include <strings.h>
#endif
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <algorithm>
#include <iostream>
#include <string>
#include "dl_attributes.h"
#include "dl_codes.h"
/**
* Defines interface for writing low level DXF constructs to
* a file. Implementation is defined in derived classes that write
* to binary or ASCII files.
*
* Implements functions that write higher level constructs in terms of
* the low level ones.
*
* @todo Add error checking for string/entry length.
*/
class DXFLIB_EXPORT DL_Writer
{
public:
explicit DL_Writer(DL_Codes::version version);
virtual ~DL_Writer();
void section(const char* name) const;
void sectionHeader() const;
void sectionTables() const;
void sectionBlocks() const;
void sectionEntities() const;
void sectionClasses() const;
void sectionObjects() const;
void sectionEnd() const;
void table(const char* name, int num, int h=0) const;
void tableLayers(int num) const;
void tableLinetypes(int num) const;
void tableAppid(int num) const;
void tableStyle(int num) const;
void tableEnd() const;
void dxfEOF() const;
void comment(const char* text) const;
void entity(const char* entTypeName) const;
void entityAttributes(const DL_Attributes& attrib) const;
void subClass(const char* sub) const;
void tableLayerEntry(unsigned long int h=0) const;
void tableLinetypeEntry(unsigned long int h=0) const;
void tableAppidEntry(unsigned long int h=0) const;
void sectionBlockEntry(unsigned long int h=0) const;
void sectionBlockEntryEnd(unsigned long int h=0) const;
void color(int col=256) const;
void linetype(const char *lt) const;
void linetypeScale(double scale) const;
void lineWeight(int lw) const;
void coord(int gc, double x, double y, double z=0) const;
void coordTriplet(int gc, const double* value) const;
void resetHandle() const;
unsigned long handle(int gc=5) const;
unsigned long getNextHandle() const;
unsigned long incHandle() const;
void setModelSpaceHandle(unsigned long h) const;
unsigned long getModelSpaceHandle() const;
void setPaperSpaceHandle(unsigned long h) const;
unsigned long getPaperSpaceHandle() const;
void setPaperSpace0Handle(unsigned long h) const;
unsigned long getPaperSpace0Handle() const;
/**
* Must be overwritten by the implementing class to write a
* real value to the file.
*
* @param gc Group code.
* @param value The real value.
*/
virtual void dxfReal(int gc, double value) const = 0;
/**
* Must be overwritten by the implementing class to write an
* int value to the file.
*
* @param gc Group code.
* @param value The int value.
*/
virtual void dxfInt(int gc, int value) const = 0;
virtual void dxfBool(int gc, bool value) const;
/**
* Must be overwritten by the implementing class to write an
* int value (hex) to the file.
*
* @param gc Group code.
* @param value The int value.
*/
virtual void dxfHex(int gc, int value) const = 0;
/**
* Must be overwritten by the implementing class to write a
* string to the file.
*
* @param gc Group code.
* @param value The string.
*/
virtual void dxfString(int gc, const char* value) const = 0;
/**
* Must be overwritten by the implementing class to write a
* string to the file.
*
* @param gc Group code.
* @param value The string.
*/
virtual void dxfString(int gc, const std::string& value) const = 0;
protected:
mutable unsigned long m_handle;
mutable unsigned long modelSpaceHandle;
mutable unsigned long paperSpaceHandle;
mutable unsigned long paperSpace0Handle;
/**
* DXF version to be created.
*/
DL_Codes::version version;
};
#endif

View File

@ -1,175 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <stdio.h>
#include <string.h>
#include <QtGlobal>
#include "../vmisc/diagnostic.h"
#include "dl_writer_ascii.h"
/**
* Closes the output file.
*/
void DL_WriterA::close() const
{
m_ofile.close();
}
/**
* @retval true Opening file has failed.
* @retval false Otherwise.
*/
bool DL_WriterA::openFailed() const
{
return m_ofile.fail();
}
/**
* Writes a real (double) variable to the DXF file.
*
* @param gc Group code.
* @param value Double value
*/
void DL_WriterA::dxfReal(int gc, double value) const
{
char str[256];
QT_WARNING_PUSH
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 408
QT_WARNING_DISABLE_GCC("-Wformat")
#endif
if (version==DL_Codes::AC1009_MIN)
{
snprintf(str, sizeof(str), "%.6lf", value);
}
else
{
snprintf(str, sizeof(str), "%.16lf", value);
}
QT_WARNING_POP
// fix for german locale:
strReplace(str, ',', '.');
// Cut away those zeros at the end:
bool dot = false;
int end = -1;
for (quint32 i=0, sz = static_cast<quint32>(strlen(str)); i<sz; ++i)
{
if (str[i]=='.')
{
dot = true;
end = static_cast<int>(i)+2;
continue;
}
else if (dot && str[i]!='0')
{
end = static_cast<int>(i)+1;
}
}
if (end>0 && end<static_cast<int>(strlen(str)))
{
str[end] = '\0';
}
dxfString(gc, str);
m_ofile.flush();
}
/**
* Writes an int variable to the DXF file.
*
* @param gc Group code.
* @param value Int value
*/
void DL_WriterA::dxfInt(int gc, int value) const
{
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" << value << "\n";
}
/**
* Writes a hex int variable to the DXF file.
*
* @param gc Group code.
* @param value Int value
*/
void DL_WriterA::dxfHex(int gc, int value) const
{
char str[12];
snprintf(str, sizeof(str), "%0X", value);
dxfString(gc, str);
}
/**
* Writes a string variable to the DXF file.
*
* @param gc Group code.
* @param value String
*/
void DL_WriterA::dxfString(int gc, const char* value) const
{
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
<< value << "\n";
}
void DL_WriterA::dxfString(int gc, const std::string& value) const
{
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
<< value << "\n";
}
/**
* Replaces every occurence of src with dest in the null terminated str.
*/
void DL_WriterA::strReplace(char* str, char src, char dest)
{
size_t i;
for (i=0; i<strlen(str); i++)
{
if (str[i]==src)
{
str[i] = dest;
}
}
}

View File

@ -1,85 +0,0 @@
/****************************************************************************
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
** Copyright (C) 2001 Robert J. Campbell Jr.
**
** This file is part of the dxflib project.
**
** This file is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** Licensees holding valid dxflib Professional Edition licenses may use
** this file in accordance with the dxflib Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.ribbonsoft.com for further details.
**
** Contact info@ribbonsoft.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DL_WRITER_ASCII_H
#define DL_WRITER_ASCII_H
#include "dl_global.h"
#include "dl_codes.h"
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif // Q_CC_MSVC
#include <fstream>
#include <string>
#include "dl_writer.h"
/**
* Implements functions defined in DL_Writer for writing low
* level DXF constructs to an ASCII format DXF file.
*
* @todo What if \c fname is NULL? Or \c fname can't be opened for
* another reason?
*/
class DXFLIB_EXPORT DL_WriterA : public DL_Writer
{
public:
/**
* @brief DL_WriterA contructor
* @param fname File name of the file to be created.
* @param version DXF version. Defaults to DL_VERSION_2002.
*/
explicit DL_WriterA(const char* fname, DL_Codes::version version=DL_VERSION_2000)
: DL_Writer(version), m_ofile(fname) {}
virtual ~DL_WriterA() {}
bool openFailed() const;
void close() const;
void dxfReal(int gc, double value) const;
void dxfInt(int gc, int value) const;
void dxfHex(int gc, int value) const;
void dxfString(int gc, const char* value) const;
void dxfString(int gc, const std::string& value) const;
static void strReplace(char* str, char src, char dest);
private:
/**
* DXF file to be created.
*/
mutable std::ofstream m_ofile;
};
#endif

View File

@ -1,150 +0,0 @@
/************************************************************************
**
** @file strlcpy.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date December 20, 2016
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2016 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VALENTINA_STRLCPY_H
#define VALENTINA_STRLCPY_H
/* This function comes from BSD */
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && \
!defined(__bsdi__) && !defined(__APPLE__)
#include <sys/types.h>
#include <string.h>
#include "../vmisc/diagnostic.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wsign-conversion")
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
inline size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0)
{
while (--n != 0)
{
if ((*d++ = *s++) == '\0')
{
break;
}
}
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0)
{
if (siz != 0)
{
*d = '\0'; /* NUL-terminate dst */
}
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
inline size_t strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
{
d++;
}
dlen = d - dst;
n = siz - dlen;
if (n == 0)
{
return(dlen + strlen(s));
}
while (*s != '\0')
{
if (n != 1)
{
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); /* count does not include NUL */
}
QT_WARNING_POP
#endif /* ! __*BSD__ */
#endif // VALENTINA_STRLCPY_H

View File

@ -2,11 +2,8 @@
# This need for corect working file translations.pro # This need for corect working file translations.pro
SOURCES += \ SOURCES += \
$$PWD/dxflib/dl_dxf.cpp \
$$PWD/dxflib/dl_writer_ascii.cpp \
$$PWD/vdxfengine.cpp \ $$PWD/vdxfengine.cpp \
$$PWD/vdxfpaintdevice.cpp \ $$PWD/vdxfpaintdevice.cpp \
$$PWD/dxflib/dl_writer.cpp \
$$PWD/libdxfrw/intern/drw_dbg.cpp \ $$PWD/libdxfrw/intern/drw_dbg.cpp \
$$PWD/libdxfrw/intern/drw_textcodec.cpp \ $$PWD/libdxfrw/intern/drw_textcodec.cpp \
$$PWD/libdxfrw/intern/dwgbuffer.cpp \ $$PWD/libdxfrw/intern/dwgbuffer.cpp \
@ -32,20 +29,9 @@ win32-msvc*:SOURCES += $$PWD/stable.cpp
HEADERS += \ HEADERS += \
$$PWD/stable.h \ $$PWD/stable.h \
$$PWD/dxflib/dl_attributes.h \
$$PWD/dxflib/dl_codes.h \
$$PWD/dxflib/dl_creationadapter.h \
$$PWD/dxflib/dl_creationinterface.h \
$$PWD/dxflib/dl_dxf.h \
$$PWD/dxflib/dl_entities.h \
$$PWD/dxflib/dl_extrusion.h \
$$PWD/dxflib/dl_global.h \
$$PWD/dxflib/dl_writer.h \
$$PWD/dxflib/dl_writer_ascii.h \
$$PWD/vdxfengine.h \ $$PWD/vdxfengine.h \
$$PWD/vdxfpaintdevice.h \ $$PWD/vdxfpaintdevice.h \
$$PWD/dxfdef.h \ $$PWD/dxfdef.h \
$$PWD/dxflib/strlcpy.h \
$$PWD/libdxfrw/intern/drw_cptable932.h \ $$PWD/libdxfrw/intern/drw_cptable932.h \
$$PWD/libdxfrw/intern/drw_cptable936.h \ $$PWD/libdxfrw/intern/drw_cptable936.h \
$$PWD/libdxfrw/intern/drw_cptable949.h \ $$PWD/libdxfrw/intern/drw_cptable949.h \

View File

@ -48,11 +48,6 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "dxflib/dl_attributes.h"
#include "dxflib/dl_codes.h"
#include "dxflib/dl_dxf.h"
#include "dxflib/dl_entities.h"
#include "dxflib/dl_writer_ascii.h"
#include "dxiface.h" #include "dxiface.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -81,8 +76,6 @@ VDxfEngine::VDxfEngine()
m_version(DRW::AC1014), m_version(DRW::AC1014),
matrix(), matrix(),
input(), input(),
dxf(nullptr),
dw(nullptr),
varMeasurement(VarMeasurement::Metric), varMeasurement(VarMeasurement::Metric),
varInsunits(VarInsunits::Centimeters) varInsunits(VarInsunits::Centimeters)
{ {

View File

@ -41,7 +41,6 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "dxfdef.h" #include "dxfdef.h"
#include "dxflib/dl_dxf.h"
#include "libdxfrw/drw_base.h" #include "libdxfrw/drw_base.h"
class QTextStream; class QTextStream;
@ -93,8 +92,6 @@ private:
DRW::Version m_version; DRW::Version m_version;
QMatrix matrix; QMatrix matrix;
QSharedPointer<dx_iface> input; QSharedPointer<dx_iface> input;
DL_Dxf* dxf;
DL_WriterA* dw;
VarMeasurement varMeasurement; VarMeasurement varMeasurement;
VarInsunits varInsunits; VarInsunits varInsunits;

View File

@ -36,7 +36,6 @@
#include <QtGlobal> #include <QtGlobal>
#include "dxfdef.h" #include "dxfdef.h"
#include "dxflib/../dxfdef.h"
class VDxfEngine; class VDxfEngine;