libdxfrw. C++14 support

This commit is contained in:
Roman Telezhynskyi 2023-11-20 12:23:56 +02:00
parent d704cf9322
commit f5256c514c
8 changed files with 1556 additions and 1543 deletions

View File

@ -71,7 +71,7 @@ void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const
point->z = pz;
}
auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Entity::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -160,7 +160,7 @@ auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
}
// parses dxf 102 groups to read entity
auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
auto DRW_Entity::parseDxfGroups(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
std::list<DRW_Variant> ls;
DRW_Variant c;
@ -206,7 +206,7 @@ auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Point::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -239,7 +239,7 @@ auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_ASTMNotch::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -253,7 +253,7 @@ auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Line::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -284,7 +284,7 @@ void DRW_Circle::applyExtrusion()
}
}
auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Circle::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -321,7 +321,7 @@ void DRW_Arc::applyExtrusion()
}
}
auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Arc::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -338,7 +338,7 @@ auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Ellipse::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -453,7 +453,7 @@ void DRW_Trace::applyExtrusion()
}
}
auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Trace::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -482,7 +482,7 @@ auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
auto DRW_3Dface::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -496,7 +496,7 @@ auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Block::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -513,7 +513,7 @@ auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Insert::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -568,7 +568,7 @@ void DRW_LWPolyline::applyExtrusion()
}
}
auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_LWPolyline::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -627,7 +627,7 @@ auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Text::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -665,7 +665,7 @@ auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
auto DRW_MText::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -758,7 +758,7 @@ void DRW_MText::updateAngle()
}
}
auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Polyline::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -793,7 +793,7 @@ auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Vertex::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -834,7 +834,7 @@ auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Hatch::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -974,7 +974,7 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Spline::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -1072,7 +1072,7 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Image::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -1113,7 +1113,7 @@ auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Dimension::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -1236,7 +1236,7 @@ auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Leader::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{
@ -1331,7 +1331,7 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Viewport::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code)
{

View File

@ -18,6 +18,7 @@
#include <QtGlobal>
#include <algorithm>
#include <list>
#include <memory>
#include <string>
#include <vector>
@ -195,14 +196,14 @@ public:
protected:
// parses dxf pair to read entity
virtual auto parseCode(int code, dxfReader *reader) -> bool;
virtual auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool;
// calculates extrusion axis (normal vector)
void calculateAxis(DRW_Coord extPoint);
// apply extrusion to @extPoint and return data in @point
void extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const;
// parses dxf 102 groups to read entity
auto parseDxfGroups(int code, dxfReader *reader) -> bool;
auto parseDxfGroups(int code, const std::unique_ptr<dxfReader> &reader) -> bool;
public:
DRW::ETYPE eType; /*!< enum: entity type, code 0 */
@ -249,7 +250,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
DRW_Coord basePoint{}; /*!< base point, code 10, 20 & 30 */
@ -267,7 +268,7 @@ public:
DRW_ASTMNotch() { eType = DRW::ASTMNOTCH; }
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double angle{0}; /*!< angle, code 50 */
@ -292,7 +293,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */
@ -341,7 +342,7 @@ public:
void applyExtrusion() override;
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double radious; /*!< radius, code 40 */
@ -382,7 +383,7 @@ public:
protected:
//! interpret code in dxf reading process or dispatch to inherited class
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double staangle; /*!< start angle, code 50 in radians*/
@ -416,7 +417,7 @@ public:
protected:
//! interpret code in dxf reading process or dispatch to inherited class
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
private:
void correctAxis();
@ -448,7 +449,7 @@ public:
void applyExtrusion() override;
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
@ -525,7 +526,7 @@ public:
protected:
//! interpret code in dxf reading process or dispatch to inherited class
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
int invisibleflag; /*!< invisible edge flag, code 70 */
@ -552,7 +553,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING name; /*!< block name, code 2 */
@ -584,7 +585,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING name; /*!< block name, code 2 */
@ -664,7 +665,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
int vertexnum; /*!< number of vertex, code 90 */
@ -727,7 +728,7 @@ public:
void applyExtrusion() override {} // RLZ TODO
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double height; /*!< height text, code 40 */
@ -775,7 +776,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
void updateAngle(); // recalculate angle if 'haveXAxis' is true
public:
@ -828,7 +829,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double stawidth; /*!< Start width, code 40 */
@ -910,7 +911,7 @@ public:
void appendVertex(DRW_Vertex *v) { vertlist.push_back(v); }
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
int flags; /*!< polyline flag, code 70, default 0 */
@ -1003,7 +1004,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
// double ex; /*!< normal vector x coordinate, code 210 */
@ -1119,7 +1120,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING name; /*!< hatch pattern name, code 2 */
@ -1225,7 +1226,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
duint32 ref; /*!< Hard reference to imagedef object, code 340 */
@ -1307,12 +1308,12 @@ public:
eType = DRW::DIMENSION;
// RLZ needed a def value for this: hdir = ???
}
virtual ~DRW_Dimension() = default;
~DRW_Dimension() override = default;
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
auto getDefPoint() const -> DRW_Coord { return defPoint; } /*!< Definition point, code 10, 20 & 30 */
@ -1671,7 +1672,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING style; /*!< Dimension style name, code 3 */
@ -1734,7 +1735,7 @@ public:
void applyExtrusion() override {}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double pswidth; /*!< Width in paper space units, code 40 */

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
#include <map>
#include <memory>
#include "drw_base.h"
class dxfReader;
@ -111,11 +112,11 @@ public:
void addStr(std::string key, const std::string &value, int code);
void addCoord(std::string key, const DRW_Coord &value, int code);
auto getComments() const -> std::string { return comments; }
void write(dxfWriter *writer, DRW::Version ver);
void write(const std::unique_ptr<dxfWriter>& writer, DRW::Version ver);
void addComment(const std::string &c);
protected:
auto parseCode(int code, dxfReader *reader) -> bool;
auto parseCode(int code, const std::unique_ptr<dxfReader>& reader) -> bool;
private:
auto getDouble(const std::string &key, double *varDouble) const -> bool;

View File

@ -11,22 +11,23 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <iostream>
#include <cmath>
#include "drw_objects.h"
#include "drw_reserve.h"
#include "intern/drw_dbg.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
#include "intern/drw_dbg.h"
#include "drw_reserve.h"
#include <cmath>
#include <iostream>
//! Base class for tables entries
/*!
* Base class for tables entries
* @author Rallaz
*/
auto DRW_TableEntry::parseCode(int code, dxfReader *reader) -> bool
* Base class for tables entries
* @author Rallaz
*/
auto DRW_TableEntry::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 5:
handle = static_cast<duint32>(reader->getHandleString());
break;
@ -58,7 +59,7 @@ auto DRW_TableEntry::parseCode(int code, dxfReader *reader) -> bool
}
else
{
curr = new DRW_Variant( code, DRW_Coord( reader->getDouble(), 0.0, 0.0));
curr = new DRW_Variant(code, DRW_Coord(reader->getDouble(), 0.0, 0.0));
extData.push_back(curr);
}
break;
@ -73,7 +74,7 @@ auto DRW_TableEntry::parseCode(int code, dxfReader *reader) -> bool
}
else
{
curr = new DRW_Variant(code, DRW_Coord( 0.0, reader->getDouble(), 0.0));
curr = new DRW_Variant(code, DRW_Coord(0.0, reader->getDouble(), 0.0));
extData.push_back(curr);
}
break;
@ -99,7 +100,7 @@ auto DRW_TableEntry::parseCode(int code, dxfReader *reader) -> bool
break;
case 1070:
case 1071:
extData.push_back(new DRW_Variant(code, reader->getInt32() ));
extData.push_back(new DRW_Variant(code, reader->getInt32()));
break;
default:
break;
@ -110,12 +111,13 @@ auto DRW_TableEntry::parseCode(int code, dxfReader *reader) -> bool
//! Class to handle dimstyle entries
/*!
* Class to handle ldim style symbol table entries
* @author Rallaz
*/
auto DRW_Dimstyle::parseCode(int code, dxfReader *reader) -> bool
* Class to handle ldim style symbol table entries
* @author Rallaz
*/
auto DRW_Dimstyle::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 105:
handle = static_cast<duint32>(reader->getHandleString());
break;
@ -335,19 +337,21 @@ auto DRW_Dimstyle::parseCode(int code, dxfReader *reader) -> bool
//! Class to handle line type entries
/*!
* Class to handle line type symbol table entries
* @author Rallaz
*/
auto DRW_LType::parseCode(int code, dxfReader *reader) -> bool
* Class to handle line type symbol table entries
* @author Rallaz
*/
auto DRW_LType::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 3:
desc = reader->getUtf8String();
break;
case 73:
size = reader->getInt32();
path.clear();
if (!DRW::reserve( path, size)) {
if (!DRW::reserve(path, size))
{
return false;
}
break;
@ -358,7 +362,7 @@ auto DRW_LType::parseCode(int code, dxfReader *reader) -> bool
path.push_back(reader->getDouble());
pathIdx++;
break;
/* case 74:
/* case 74:
haveShape = reader->getInt32();
break;*/
default:
@ -370,14 +374,16 @@ auto DRW_LType::parseCode(int code, dxfReader *reader) -> bool
//! Update line type
/*!
* Update the size and length of line type according to the path
* @author Rallaz
*/
* Update the size and length of line type according to the path
* @author Rallaz
*/
/*TODO: control max length permited */
void DRW_LType::update(){
double d =0;
void DRW_LType::update()
{
double d = 0;
size = static_cast<int>(path.size());
for (int i = 0; i< size; i++){
for (int i = 0; i < size; i++)
{
d += fabs(path.at(static_cast<size_t>(i)));
}
length = d;
@ -385,12 +391,13 @@ void DRW_LType::update(){
//! Class to handle layer entries
/*!
* Class to handle layer symbol table entries
* @author Rallaz
*/
auto DRW_Layer::parseCode(int code, dxfReader *reader) -> bool
* Class to handle layer symbol table entries
* @author Rallaz
*/
auto DRW_Layer::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 6:
lineType = reader->getUtf8String();
break;
@ -421,12 +428,13 @@ auto DRW_Layer::parseCode(int code, dxfReader *reader) -> bool
//! Class to handle text style entries
/*!
* Class to handle text style symbol table entries
* @author Rallaz
*/
auto DRW_Textstyle::parseCode(int code, dxfReader *reader) -> bool
* Class to handle text style symbol table entries
* @author Rallaz
*/
auto DRW_Textstyle::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 3:
font = reader->getUtf8String();
break;
@ -460,12 +468,13 @@ auto DRW_Textstyle::parseCode(int code, dxfReader *reader) -> bool
//! Class to handle vport entries
/*!
* Class to handle vport symbol table entries
* @author Rallaz
*/
auto DRW_Vport::parseCode(int code, dxfReader *reader) -> bool
* Class to handle vport symbol table entries
* @author Rallaz
*/
auto DRW_Vport::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 10:
lowerLeft.x = reader->getDouble();
break;
@ -572,9 +581,10 @@ auto DRW_Vport::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_ImageDef::parseCode(int code, dxfReader *reader) -> bool
auto DRW_ImageDef::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 1:
fileName = reader->getUtf8String();
break;
@ -609,9 +619,10 @@ auto DRW_ImageDef::parseCode(int code, dxfReader *reader) -> bool
return true;
}
auto DRW_PlotSettings::parseCode(int code, dxfReader *reader) -> bool
auto DRW_PlotSettings::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{
switch (code) {
switch (code)
{
case 5:
handle = static_cast<duint32>(reader->getHandleString());
break;

View File

@ -14,20 +14,22 @@
#ifndef DRW_OBJECTS_H
#define DRW_OBJECTS_H
#include "drw_base.h"
#include <QtGlobal>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <QtGlobal>
#include "drw_base.h"
class dxfReader;
class dxfWriter;
namespace DRW {
namespace DRW
{
//! Table entries type.
enum TTYPE {
enum TTYPE
{
UNKNOWNT,
LTYPE,
LAYER,
@ -38,30 +40,30 @@ namespace DRW {
APPID,
IMAGEDEF,
PLOTSETTINGS
};
};
//pending VIEW, UCS, APPID, VP_ENT_HDR, GROUP, MLINESTYLE, LONG_TRANSACTION, XRECORD,
//ACDBPLACEHOLDER, VBA_PROJECT, ACAD_TABLE, CELLSTYLEMAP, DBCOLOR, DICTIONARYVAR,
//DICTIONARYWDFLT, FIELD, IDBUFFER, IMAGEDEF, IMAGEDEFREACTOR, LAYER_INDEX, LAYOUT
//MATERIAL, PLACEHOLDER, PLOTSETTINGS, RASTERVARIABLES, SCALE, SORTENTSTABLE,
//SPATIAL_INDEX, SPATIAL_FILTER, TABLEGEOMETRY, TABLESTYLES,VISUALSTYLE,
}
// pending VIEW, UCS, APPID, VP_ENT_HDR, GROUP, MLINESTYLE, LONG_TRANSACTION, XRECORD,
// ACDBPLACEHOLDER, VBA_PROJECT, ACAD_TABLE, CELLSTYLEMAP, DBCOLOR, DICTIONARYVAR,
// DICTIONARYWDFLT, FIELD, IDBUFFER, IMAGEDEF, IMAGEDEFREACTOR, LAYER_INDEX, LAYOUT
// MATERIAL, PLACEHOLDER, PLOTSETTINGS, RASTERVARIABLES, SCALE, SORTENTSTABLE,
// SPATIAL_INDEX, SPATIAL_FILTER, TABLEGEOMETRY, TABLESTYLES,VISUALSTYLE,
} // namespace DRW
#define SETOBJFRIENDS friend class dxfRW;
//! Base class for tables entries
/*!
* Base class for tables entries
* @author Rallaz
*/
class DRW_TableEntry {
* Base class for tables entries
* @author Rallaz
*/
class DRW_TableEntry
{
public:
DRW_TableEntry()
{}
DRW_TableEntry() = default;
virtual~DRW_TableEntry()
virtual ~DRW_TableEntry()
{
for (std::vector<DRW_Variant*>::iterator it = extData.begin(); it != extData.end(); ++it)
for (std::vector<DRW_Variant *>::iterator it = extData.begin(); it != extData.end(); ++it)
{
delete *it;
}
@ -69,7 +71,7 @@ public:
extData.clear();
}
DRW_TableEntry(const DRW_TableEntry& e)
DRW_TableEntry(const DRW_TableEntry &e)
: tType(e.tType),
handle(e.handle),
parentHandle(e.parentHandle),
@ -78,7 +80,7 @@ public:
extData(),
curr(nullptr)
{
for (std::vector<DRW_Variant*>::const_iterator it = e.extData.begin(); it != e.extData.end(); ++it)
for (std::vector<DRW_Variant *>::const_iterator it = e.extData.begin(); it != e.extData.end(); ++it)
{
DRW_Variant *src = *it;
DRW_Variant *dst = new DRW_Variant(*src);
@ -91,11 +93,11 @@ public:
}
protected:
virtual auto parseCode(int code, dxfReader *reader) -> bool;
virtual auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool;
void reset()
{
flags = 0;
for (std::vector<DRW_Variant*>::iterator it = extData.begin(); it != extData.end(); ++it)
for (std::vector<DRW_Variant *>::iterator it = extData.begin(); it != extData.end(); ++it)
{
delete *it;
}
@ -104,26 +106,27 @@ protected:
}
public:
DRW::TTYPE tType {DRW::UNKNOWNT}; /*!< enum: entity type, code 0 */
duint32 handle {0}; /*!< entity identifier, code 5 */
int parentHandle {0}; /*!< Soft-pointer ID/handle to owner object, code 330 */
DRW::TTYPE tType{DRW::UNKNOWNT}; /*!< enum: entity type, code 0 */
duint32 handle{0}; /*!< entity identifier, code 5 */
int parentHandle{0}; /*!< Soft-pointer ID/handle to owner object, code 330 */
UTF8STRING name{}; /*!< entry name, code 2 */
int flags {0}; /*!< Flags relevant to entry, code 70 */
std::vector<DRW_Variant*> extData{}; /*!< FIFO list of extended data, codes 1000 to 1071*/
int flags{0}; /*!< Flags relevant to entry, code 70 */
std::vector<DRW_Variant *> extData{}; /*!< FIFO list of extended data, codes 1000 to 1071*/
private:
auto operator=(const DRW_TableEntry &) -> DRW_TableEntry &Q_DECL_EQ_DELETE;
DRW_Variant* curr{nullptr};
DRW_Variant *curr{nullptr};
};
//! Class to handle dimstyle entries
/*!
* Class to handle dim style symbol table entries
* @author Rallaz
*/
class DRW_Dimstyle final : public DRW_TableEntry {
* Class to handle dim style symbol table entries
* @author Rallaz
*/
class DRW_Dimstyle final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_Dimstyle()
: dimpost(),
@ -194,9 +197,12 @@ public:
dimldrblk(),
dimlwd(),
dimlwe()
{ reset();}
{
reset();
}
void reset(){
void reset()
{
tType = DRW::DIMSTYLE;
dimasz = dimtxt = dimcen = 2.5;
dimexe = 1.25;
@ -227,13 +233,13 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
//V12
// V12
UTF8STRING dimpost; /*!< code 3 */
UTF8STRING dimapost; /*!< code 4 */
/* handle are code 105 */
/* handle are code 105 */
UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */
UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */
UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */
@ -302,15 +308,16 @@ public:
int dimlwe; /*!< code 372 V2000+ */
};
//! Class to handle line type entries
/*!
* Class to handle line type symbol table entries
* @author Rallaz
*/
* Class to handle line type symbol table entries
* @author Rallaz
*/
/*TODO: handle complex lineType*/
class DRW_LType final : public DRW_TableEntry {
class DRW_LType final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_LType()
: desc(),
@ -318,9 +325,12 @@ public:
length(),
path(),
pathIdx()
{ reset();}
{
reset();
}
void reset(){
void reset()
{
tType = DRW::LTYPE;
desc = "";
size = 0;
@ -330,28 +340,30 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
void update();
public:
UTF8STRING desc; /*!< descriptive string, code 3 */
// int align; /*!< align code, always 65 ('A') code 72 */
// int align; /*!< align code, always 65 ('A') code 72 */
int size; /*!< element number, code 73 */
double length; /*!< total length of pattern, code 40 */
// int haveShape; /*!< complex linetype type, code 74 */
// int haveShape; /*!< complex linetype type, code 74 */
std::vector<double> path; /*!< trace, point or space length sequence, code 49 */
private:
int pathIdx;
};
//! Class to handle layer entries
/*!
* Class to handle layer symbol table entries
* @author Rallaz
*/
class DRW_Layer final : public DRW_TableEntry {
* Class to handle layer symbol table entries
* @author Rallaz
*/
class DRW_Layer final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_Layer()
: lineType(),
@ -361,20 +373,23 @@ public:
lWeight(),
handlePlotS(),
handleMaterialS()
{ reset();}
{
reset();
}
void reset() {
void reset()
{
tType = DRW::LAYER;
lineType = "CONTINUOUS";
color = 7; // default BYLAYER (256)
plotF = true; // default TRUE (plot yes)
lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31)
color24 = -1; //default -1 not set
color24 = -1; // default -1 not set
DRW_TableEntry::reset();
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING lineType; /*!< line type, code 6 */
@ -388,37 +403,44 @@ public:
//! Class to handle block record entries
/*!
* Class to handle block record table entries
* @author Rallaz
*/
class DRW_Block_Record : public DRW_TableEntry {
* Class to handle block record table entries
* @author Rallaz
*/
class DRW_Block_Record : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_Block_Record()
: insUnits()
{ reset();}
{
reset();
}
void reset() {
void reset()
{
tType = DRW::BLOCK_RECORD;
flags = 0;
DRW_TableEntry::reset();
}
//protected:
// void parseCode(int code, dxfReader *reader);
// protected:
// void parseCode(int code, dxfReader *reader);
public:
//Note: int DRW_TableEntry::flags; contains code 70 of block
// Note: int DRW_TableEntry::flags; contains code 70 of block
int insUnits; /*!< block insertion units, code 70 of block_record*/
};
//! Class to handle text style entries
/*!
* Class to handle text style symbol table entries
* @author Rallaz
*/
class DRW_Textstyle final : public DRW_TableEntry {
* Class to handle text style symbol table entries
* @author Rallaz
*/
class DRW_Textstyle final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_Textstyle()
: height(),
@ -429,20 +451,23 @@ public:
font(),
bigFont(),
fontFamily()
{reset();}
{
reset();
}
void reset(){
void reset()
{
tType = DRW::STYLE;
height = oblique = 0.0;
width = lastHeight = 1.0;
font="txt";
genFlag = 0; //2= X mirror, 4= Y mirror
font = "txt";
genFlag = 0; // 2= X mirror, 4= Y mirror
fontFamily = 0;
DRW_TableEntry::reset();
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
double height; /*!< Fixed text height (0 not set), code 40 */
@ -457,11 +482,13 @@ public:
//! Class to handle vport entries
/*!
* Class to handle vport symbol table entries
* @author Rallaz
*/
class DRW_Vport final : public DRW_TableEntry {
* Class to handle vport symbol table entries
* @author Rallaz
*/
class DRW_Vport final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_Vport()
: lowerLeft(),
@ -488,9 +515,12 @@ public:
snapStyle(),
snapIsopair(),
gridBehavior()
{ reset();}
{
reset();
}
void reset(){
void reset()
{
tType = DRW::VPORT;
UpperRight.x = UpperRight.y = 1.0;
snapSpacing.x = snapSpacing.y = 10.0;
@ -511,7 +541,7 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
DRW_Coord lowerLeft; /*!< Lower left corner, code 10 & 20 */
@ -546,14 +576,15 @@ public:
**/
};
//! Class to handle imagedef entries
/*!
* Class to handle image definitions object entries
* @author Rallaz
*/
class DRW_ImageDef final : public DRW_TableEntry {//
* Class to handle image definitions object entries
* @author Rallaz
*/
class DRW_ImageDef final : public DRW_TableEntry
{ //
SETOBJFRIENDS
public:
DRW_ImageDef()
: fileName(),
@ -569,17 +600,18 @@ public:
reset();
}
void reset(){
void reset()
{
tType = DRW::IMAGEDEF;
imgVersion = 0;
DRW_TableEntry::reset();
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
// std::string handle; /*!< entity identifier, code 5 */
// std::string handle; /*!< entity identifier, code 5 */
UTF8STRING fileName; /*!< File name of image, code 1 */
int imgVersion; /*!< class version, code 90, 0=R14 version */
double u; /*!< image size in pixels U value, code 10 */
@ -589,22 +621,23 @@ public:
int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */
int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */
std::map<std::string,std::string> reactors;
std::map<std::string, std::string> reactors;
};
//! Class to handle plotsettings entries
/*!
* Class to handle plot settings object entries
* @author baranovskiykonstantin@gmail.com
*/
class DRW_PlotSettings : public DRW_TableEntry {
* Class to handle plot settings object entries
* @author baranovskiykonstantin@gmail.com
*/
class DRW_PlotSettings : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_PlotSettings() {
reset();
}
void reset(){
public:
DRW_PlotSettings() { reset(); }
void reset()
{
tType = DRW::PLOTSETTINGS;
marginLeft = 0.0;
marginBottom = 0.0;
@ -614,301 +647,112 @@ public:
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override;
public:
UTF8STRING plotViewName {}; /*!< Plot view name, code 6 */
double marginLeft {0.0}; /*!< Size, in millimeters, of unprintable margin on left side of paper, code 40 */
double marginBottom {0.0}; /*!< Size, in millimeters, of unprintable margin on bottom side of paper, code 41 */
double marginRight {0.0}; /*!< Size, in millimeters, of unprintable margin on right side of paper, code 42 */
double marginTop {0.0}; /*!< Size, in millimeters, of unprintable margin on top side of paper, code 43 */
UTF8STRING plotViewName{}; /*!< Plot view name, code 6 */
double marginLeft{0.0}; /*!< Size, in millimeters, of unprintable margin on left side of paper, code 40 */
double marginBottom{0.0}; /*!< Size, in millimeters, of unprintable margin on bottom side of paper, code 41 */
double marginRight{0.0}; /*!< Size, in millimeters, of unprintable margin on right side of paper, code 42 */
double marginTop{0.0}; /*!< Size, in millimeters, of unprintable margin on top side of paper, code 43 */
};
//! Class to handle AppId entries
/*!
* Class to handle AppId symbol table entries
* @author Rallaz
*/
class DRW_AppId final : public DRW_TableEntry {
* Class to handle AppId symbol table entries
* @author Rallaz
*/
class DRW_AppId final : public DRW_TableEntry
{
SETOBJFRIENDS
public:
DRW_AppId() { reset();}
void reset(){
public:
DRW_AppId() { reset(); }
void reset()
{
tType = DRW::APPID;
flags = 0;
name = "";
}
protected:
auto parseCode(int code, dxfReader *reader) -> bool override { return DRW_TableEntry::parseCode(code, reader); }
auto parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool override
{
return DRW_TableEntry::parseCode(code, reader);
}
};
namespace DRW {
namespace DRW
{
// Extended color palette:
// The first entry is only for direct indexing starting with [1]
// Color 1 is red (1,0,0)
const unsigned char dxfColors[][3] = {
{ 0, 0, 0}, // unused
{0, 0, 0}, // unused
{255, 0, 0}, // 1 red
{255,255, 0}, // 2 yellow
{ 0,255, 0}, // 3 green
{ 0,255,255}, // 4 cyan
{ 0, 0,255}, // 5 blue
{255, 0,255}, // 6 magenta
{ 0, 0, 0}, // 7 black or white
{128,128,128}, // 8 50% gray
{192,192,192}, // 9 75% gray
{255, 255, 0}, // 2 yellow
{0, 255, 0}, // 3 green
{0, 255, 255}, // 4 cyan
{0, 0, 255}, // 5 blue
{255, 0, 255}, // 6 magenta
{0, 0, 0}, // 7 black or white
{128, 128, 128}, // 8 50% gray
{192, 192, 192}, // 9 75% gray
{255, 0, 0}, // 10
{255,127,127},
{204, 0, 0},
{204,102,102},
{153, 0, 0},
{153, 76, 76}, // 15
{127, 0, 0},
{127, 63, 63},
{ 76, 0, 0},
{ 76, 38, 38},
{255, 63, 0}, // 20
{255,159,127},
{204, 51, 0},
{204,127,102},
{153, 38, 0},
{153, 95, 76}, // 25
{127, 31, 0},
{127, 79, 63},
{ 76, 19, 0},
{ 76, 47, 38},
{255,127, 0}, // 30
{255,191,127},
{204,102, 0},
{204,153,102},
{153, 76, 0},
{153,114, 76}, // 35
{127, 63, 0},
{127, 95, 63},
{ 76, 38, 0},
{ 76, 57, 38},
{255,191, 0}, // 40
{255,223,127},
{204,153, 0},
{204,178,102},
{153,114, 0},
{153,133, 76}, // 45
{127, 95, 0},
{127,111, 63},
{ 76, 57, 0},
{ 76, 66, 38},
{255,255, 0}, // 50
{255,255,127},
{204,204, 0},
{204,204,102},
{153,153, 0},
{153,153, 76}, // 55
{127,127, 0},
{127,127, 63},
{ 76, 76, 0},
{ 76, 76, 38},
{191,255, 0}, // 60
{223,255,127},
{153,204, 0},
{178,204,102},
{114,153, 0},
{133,153, 76}, // 65
{ 95,127, 0},
{111,127, 63},
{ 57, 76, 0},
{ 66, 76, 38},
{127,255, 0}, // 70
{191,255,127},
{102,204, 0},
{153,204,102},
{ 76,153, 0},
{114,153, 76}, // 75
{ 63,127, 0},
{ 95,127, 63},
{ 38, 76, 0},
{ 57, 76, 38},
{ 63,255, 0}, // 80
{159,255,127},
{ 51,204, 0},
{127,204,102},
{ 38,153, 0},
{ 95,153, 76}, // 85
{ 31,127, 0},
{ 79,127, 63},
{ 19, 76, 0},
{ 47, 76, 38},
{ 0,255, 0}, // 90
{127,255,127},
{ 0,204, 0},
{102,204,102},
{ 0,153, 0},
{ 76,153, 76}, // 95
{ 0,127, 0},
{ 63,127, 63},
{ 0, 76, 0},
{ 38, 76, 38},
{ 0,255, 63}, // 100
{127,255,159},
{ 0,204, 51},
{102,204,127},
{ 0,153, 38},
{ 76,153, 95}, // 105
{ 0,127, 31},
{ 63,127, 79},
{ 0, 76, 19},
{ 38, 76, 47},
{ 0,255,127}, // 110
{127,255,191},
{ 0,204,102},
{102,204,153},
{ 0,153, 76},
{ 76,153,114}, // 115
{ 0,127, 63},
{ 63,127, 95},
{ 0, 76, 38},
{ 38, 76, 57},
{ 0,255,191}, // 120
{127,255,223},
{ 0,204,153},
{102,204,178},
{ 0,153,114},
{ 76,153,133}, // 125
{ 0,127, 95},
{ 63,127,111},
{ 0, 76, 57},
{ 38, 76, 66},
{ 0,255,255}, // 130
{127,255,255},
{ 0,204,204},
{102,204,204},
{ 0,153,153},
{ 76,153,153}, // 135
{ 0,127,127},
{ 63,127,127},
{ 0, 76, 76},
{ 38, 76, 76},
{ 0,191,255}, // 140
{127,223,255},
{ 0,153,204},
{102,178,204},
{ 0,114,153},
{ 76,133,153}, // 145
{ 0, 95,127},
{ 63,111,127},
{ 0, 57, 76},
{ 38, 66, 76},
{ 0,127,255}, // 150
{127,191,255},
{ 0,102,204},
{102,153,204},
{ 0, 76,153},
{ 76,114,153}, // 155
{ 0, 63,127},
{ 63, 95,127},
{ 0, 38, 76},
{ 38, 57, 76},
{ 0, 66,255}, // 160
{127,159,255},
{ 0, 51,204},
{102,127,204},
{ 0, 38,153},
{ 76, 95,153}, // 165
{ 0, 31,127},
{ 63, 79,127},
{ 0, 19, 76},
{ 38, 47, 76},
{ 0, 0,255}, // 170
{127,127,255},
{ 0, 0,204},
{102,102,204},
{ 0, 0,153},
{ 76, 76,153}, // 175
{ 0, 0,127},
{ 63, 63,127},
{ 0, 0, 76},
{ 38, 38, 76},
{ 63, 0,255}, // 180
{159,127,255},
{ 50, 0,204},
{127,102,204},
{ 38, 0,153},
{ 95, 76,153}, // 185
{ 31, 0,127},
{ 79, 63,127},
{ 19, 0, 76},
{ 47, 38, 76},
{127, 0,255}, // 190
{191,127,255},
{102, 0,204},
{153,102,204},
{ 76, 0,153},
{114, 76,153}, // 195
{ 63, 0,127},
{ 95, 63,127},
{ 38, 0, 76},
{ 57, 38, 76},
{191, 0,255}, // 200
{223,127,255},
{153, 0,204},
{178,102,204},
{114, 0,153},
{133, 76,153}, // 205
{ 95, 0,127},
{111, 63,127},
{ 57, 0, 76},
{ 66, 38, 76},
{255, 0,255}, // 210
{255,127,255},
{204, 0,204},
{204,102,204},
{153, 0,153},
{153, 76,153}, // 215
{127, 0,127},
{127, 63,127},
{ 76, 0, 76},
{ 76, 38, 76},
{255, 0,191}, // 220
{255,127,223},
{204, 0,153},
{204,102,178},
{153, 0,114},
{153, 76,133}, // 225
{127, 0, 95},
{127, 63, 11},
{ 76, 0, 57},
{ 76, 38, 66},
{255, 0,127}, // 230
{255,127,191},
{204, 0,102},
{204,102,153},
{153, 0, 76},
{153, 76,114}, // 235
{127, 0, 63},
{127, 63, 95},
{ 76, 0, 38},
{ 76, 38, 57},
{255, 0, 63}, // 240
{255,127,159},
{204, 0, 51},
{204,102,127},
{153, 0, 38},
{153, 76, 95}, // 245
{127, 0, 31},
{127, 63, 79},
{ 76, 0, 19},
{ 76, 38, 47},
{ 51, 51, 51}, // 250
{ 91, 91, 91},
{132,132,132},
{173,173,173},
{214,214,214},
{255,255,255} // 255
{255, 127, 127}, {204, 0, 0}, {204, 102, 102}, {153, 0, 0}, {153, 76, 76}, // 15
{127, 0, 0}, {127, 63, 63}, {76, 0, 0}, {76, 38, 38}, {255, 63, 0}, // 20
{255, 159, 127}, {204, 51, 0}, {204, 127, 102}, {153, 38, 0}, {153, 95, 76}, // 25
{127, 31, 0}, {127, 79, 63}, {76, 19, 0}, {76, 47, 38}, {255, 127, 0}, // 30
{255, 191, 127}, {204, 102, 0}, {204, 153, 102}, {153, 76, 0}, {153, 114, 76}, // 35
{127, 63, 0}, {127, 95, 63}, {76, 38, 0}, {76, 57, 38}, {255, 191, 0}, // 40
{255, 223, 127}, {204, 153, 0}, {204, 178, 102}, {153, 114, 0}, {153, 133, 76}, // 45
{127, 95, 0}, {127, 111, 63}, {76, 57, 0}, {76, 66, 38}, {255, 255, 0}, // 50
{255, 255, 127}, {204, 204, 0}, {204, 204, 102}, {153, 153, 0}, {153, 153, 76}, // 55
{127, 127, 0}, {127, 127, 63}, {76, 76, 0}, {76, 76, 38}, {191, 255, 0}, // 60
{223, 255, 127}, {153, 204, 0}, {178, 204, 102}, {114, 153, 0}, {133, 153, 76}, // 65
{95, 127, 0}, {111, 127, 63}, {57, 76, 0}, {66, 76, 38}, {127, 255, 0}, // 70
{191, 255, 127}, {102, 204, 0}, {153, 204, 102}, {76, 153, 0}, {114, 153, 76}, // 75
{63, 127, 0}, {95, 127, 63}, {38, 76, 0}, {57, 76, 38}, {63, 255, 0}, // 80
{159, 255, 127}, {51, 204, 0}, {127, 204, 102}, {38, 153, 0}, {95, 153, 76}, // 85
{31, 127, 0}, {79, 127, 63}, {19, 76, 0}, {47, 76, 38}, {0, 255, 0}, // 90
{127, 255, 127}, {0, 204, 0}, {102, 204, 102}, {0, 153, 0}, {76, 153, 76}, // 95
{0, 127, 0}, {63, 127, 63}, {0, 76, 0}, {38, 76, 38}, {0, 255, 63}, // 100
{127, 255, 159}, {0, 204, 51}, {102, 204, 127}, {0, 153, 38}, {76, 153, 95}, // 105
{0, 127, 31}, {63, 127, 79}, {0, 76, 19}, {38, 76, 47}, {0, 255, 127}, // 110
{127, 255, 191}, {0, 204, 102}, {102, 204, 153}, {0, 153, 76}, {76, 153, 114}, // 115
{0, 127, 63}, {63, 127, 95}, {0, 76, 38}, {38, 76, 57}, {0, 255, 191}, // 120
{127, 255, 223}, {0, 204, 153}, {102, 204, 178}, {0, 153, 114}, {76, 153, 133}, // 125
{0, 127, 95}, {63, 127, 111}, {0, 76, 57}, {38, 76, 66}, {0, 255, 255}, // 130
{127, 255, 255}, {0, 204, 204}, {102, 204, 204}, {0, 153, 153}, {76, 153, 153}, // 135
{0, 127, 127}, {63, 127, 127}, {0, 76, 76}, {38, 76, 76}, {0, 191, 255}, // 140
{127, 223, 255}, {0, 153, 204}, {102, 178, 204}, {0, 114, 153}, {76, 133, 153}, // 145
{0, 95, 127}, {63, 111, 127}, {0, 57, 76}, {38, 66, 76}, {0, 127, 255}, // 150
{127, 191, 255}, {0, 102, 204}, {102, 153, 204}, {0, 76, 153}, {76, 114, 153}, // 155
{0, 63, 127}, {63, 95, 127}, {0, 38, 76}, {38, 57, 76}, {0, 66, 255}, // 160
{127, 159, 255}, {0, 51, 204}, {102, 127, 204}, {0, 38, 153}, {76, 95, 153}, // 165
{0, 31, 127}, {63, 79, 127}, {0, 19, 76}, {38, 47, 76}, {0, 0, 255}, // 170
{127, 127, 255}, {0, 0, 204}, {102, 102, 204}, {0, 0, 153}, {76, 76, 153}, // 175
{0, 0, 127}, {63, 63, 127}, {0, 0, 76}, {38, 38, 76}, {63, 0, 255}, // 180
{159, 127, 255}, {50, 0, 204}, {127, 102, 204}, {38, 0, 153}, {95, 76, 153}, // 185
{31, 0, 127}, {79, 63, 127}, {19, 0, 76}, {47, 38, 76}, {127, 0, 255}, // 190
{191, 127, 255}, {102, 0, 204}, {153, 102, 204}, {76, 0, 153}, {114, 76, 153}, // 195
{63, 0, 127}, {95, 63, 127}, {38, 0, 76}, {57, 38, 76}, {191, 0, 255}, // 200
{223, 127, 255}, {153, 0, 204}, {178, 102, 204}, {114, 0, 153}, {133, 76, 153}, // 205
{95, 0, 127}, {111, 63, 127}, {57, 0, 76}, {66, 38, 76}, {255, 0, 255}, // 210
{255, 127, 255}, {204, 0, 204}, {204, 102, 204}, {153, 0, 153}, {153, 76, 153}, // 215
{127, 0, 127}, {127, 63, 127}, {76, 0, 76}, {76, 38, 76}, {255, 0, 191}, // 220
{255, 127, 223}, {204, 0, 153}, {204, 102, 178}, {153, 0, 114}, {153, 76, 133}, // 225
{127, 0, 95}, {127, 63, 11}, {76, 0, 57}, {76, 38, 66}, {255, 0, 127}, // 230
{255, 127, 191}, {204, 0, 102}, {204, 102, 153}, {153, 0, 76}, {153, 76, 114}, // 235
{127, 0, 63}, {127, 63, 95}, {76, 0, 38}, {76, 38, 57}, {255, 0, 63}, // 240
{255, 127, 159}, {204, 0, 51}, {204, 102, 127}, {153, 0, 38}, {153, 76, 95}, // 245
{127, 0, 31}, {127, 63, 79}, {76, 0, 19}, {76, 38, 47}, {51, 51, 51}, // 250
{91, 91, 91}, {132, 132, 132}, {173, 173, 173}, {214, 214, 214}, {255, 255, 255} // 255
};
}
} // namespace DRW
#endif

View File

@ -40,8 +40,6 @@ dxfRW::dxfRW(const char *name)
dxfRW::~dxfRW()
{
delete reader;
delete writer;
for (auto &it : imageDef)
{
delete it;
@ -92,19 +90,19 @@ auto dxfRW::read(DRW_Interface *interface_, bool ext) -> bool
binFile = true;
// skip sentinel
filestr.seekg(22, std::ios::beg);
reader = new dxfReaderBinary(&filestr);
reader = std::make_unique<dxfReaderBinary>(&filestr);
DRW_DBG("dxfRW::read binary file\n");
}
else
{
binFile = false;
filestr.open(fileName.c_str(), std::ios_base::in);
reader = new dxfReaderAscii(&filestr);
reader = std::make_unique<dxfReaderAscii>(&filestr);
}
bool isOk = processDxf();
filestr.close();
delete reader;
reader.reset();
reader = nullptr;
return isOk;
}
@ -124,13 +122,13 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
filestr.open(fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc);
// write sentinel
filestr << "AutoCAD Binary DXF\r\n" << static_cast<char>(26) << '\0';
writer = new dxfWriterBinary(&filestr);
writer = std::make_unique<dxfWriterBinary>(&filestr);
DRW_DBG("dxfRW::read binary file\n");
}
else
{
filestr.open(fileName.c_str(), std::ios_base::out | std::ios::trunc);
writer = new dxfWriterAscii(&filestr);
writer = std::make_unique<dxfWriterAscii>(&filestr);
std::string comm = std::string("dxfrw ") + std::string(DRW_VERSION);
writer->writeString(999, comm);
}
@ -174,13 +172,11 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
catch (std::ofstream::failure &writeErr)
{
errorString = writeErr.what();
delete writer;
writer = nullptr;
writer.reset();
return isOk;
}
isOk = true;
delete writer;
writer = nullptr;
writer.reset();
return isOk;
}

View File

@ -146,8 +146,8 @@ private:
std::string codePage{};
bool binFile{false};
bool m_xSpaceBlock{true};
dxfReader *reader{nullptr};
dxfWriter *writer{nullptr};
std::unique_ptr<dxfReader> reader{};
std::unique_ptr<dxfWriter> writer{};
DRW_Interface *iface{nullptr};
DRW_Header header{};
// int section;