2017-06-21 11:34:20 +02:00
|
|
|
/******************************************************************************
|
|
|
|
** **
|
|
|
|
** Copyright (C) 2015 José F. Soriano, rallazz@gmail.com **
|
|
|
|
** **
|
|
|
|
** This library is free software, licensed 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. **
|
|
|
|
** You should have received a copy of the GNU General Public License **
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DX_IFACE_H
|
|
|
|
#define DX_IFACE_H
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
#include "dxfdef.h"
|
2017-06-21 11:34:20 +02:00
|
|
|
#include "libdxfrw/drw_interface.h"
|
|
|
|
#include "libdxfrw/libdxfrw.h"
|
2024-01-06 13:20:56 +01:00
|
|
|
|
|
|
|
#include <Qt>
|
2017-06-21 11:34:20 +02:00
|
|
|
|
2017-06-29 17:56:52 +02:00
|
|
|
class QFont;
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
// class to store image data and path from DRW_ImageDef
|
|
|
|
class dx_ifaceImg : public DRW_Image
|
|
|
|
{
|
2017-06-21 11:34:20 +02:00
|
|
|
public:
|
2017-07-05 18:35:34 +02:00
|
|
|
dx_ifaceImg()
|
2024-01-06 13:20:56 +01:00
|
|
|
: path()
|
|
|
|
{
|
|
|
|
}
|
2017-07-05 18:35:34 +02:00
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
explicit dx_ifaceImg(const DRW_Image &p)
|
|
|
|
: DRW_Image(p),
|
|
|
|
path()
|
|
|
|
{
|
|
|
|
}
|
2017-07-05 18:35:34 +02:00
|
|
|
|
|
|
|
virtual ~dx_ifaceImg() = default;
|
2024-01-06 13:20:56 +01:00
|
|
|
std::string path; // stores the image path
|
2017-06-21 11:34:20 +02:00
|
|
|
};
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
// container class to store entites.
|
|
|
|
class dx_ifaceBlock final : public DRW_Block
|
|
|
|
{
|
2017-06-21 11:34:20 +02:00
|
|
|
public:
|
2017-07-05 18:35:34 +02:00
|
|
|
dx_ifaceBlock()
|
2024-01-06 13:20:56 +01:00
|
|
|
: ent()
|
|
|
|
{
|
|
|
|
}
|
2017-07-05 18:35:34 +02:00
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
explicit dx_ifaceBlock(const DRW_Block &p)
|
|
|
|
: DRW_Block(p),
|
|
|
|
ent()
|
|
|
|
{
|
|
|
|
}
|
2017-07-05 18:35:34 +02:00
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
virtual ~dx_ifaceBlock()
|
|
|
|
{
|
|
|
|
for (std::list<DRW_Entity *>::const_iterator it = ent.begin(); it != ent.end(); ++it)
|
2017-06-21 11:34:20 +02:00
|
|
|
delete *it;
|
|
|
|
}
|
2024-01-06 13:20:56 +01:00
|
|
|
std::list<DRW_Entity *> ent; // stores the entities list
|
2017-06-21 11:34:20 +02:00
|
|
|
};
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
// container class to store full dxf data.
|
|
|
|
class dx_data
|
|
|
|
{
|
2017-06-21 11:34:20 +02:00
|
|
|
public:
|
2017-07-05 18:35:34 +02:00
|
|
|
dx_data()
|
2024-01-06 13:20:56 +01:00
|
|
|
: headerC(),
|
|
|
|
lineTypes(),
|
|
|
|
layers(),
|
|
|
|
dimStyles(),
|
|
|
|
VPorts(),
|
|
|
|
textStyles(),
|
|
|
|
appIds(),
|
|
|
|
blocks(),
|
|
|
|
images(),
|
|
|
|
mBlock(new dx_ifaceBlock())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~dx_data()
|
|
|
|
{
|
|
|
|
// cleanup,
|
|
|
|
for (std::list<dx_ifaceBlock *>::const_iterator it = blocks.begin(); it != blocks.end(); ++it)
|
2017-06-21 11:34:20 +02:00
|
|
|
delete *it;
|
|
|
|
delete mBlock;
|
|
|
|
}
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
DRW_Header headerC; // stores a copy of the header vars
|
|
|
|
std::list<DRW_LType> lineTypes; // stores a copy of all line types
|
|
|
|
std::list<DRW_Layer> layers; // stores a copy of all layers
|
|
|
|
std::list<DRW_Dimstyle> dimStyles; // stores a copy of all dimension styles
|
|
|
|
std::list<DRW_Vport> VPorts; // stores a copy of all vports
|
|
|
|
std::list<DRW_Textstyle> textStyles; // stores a copy of all text styles
|
|
|
|
std::list<DRW_AppId> appIds; // stores a copy of all line types
|
|
|
|
std::list<dx_ifaceBlock *> blocks; // stores a copy of all blocks and the entities in it
|
|
|
|
std::list<dx_ifaceImg *> images; // temporary list to find images for link with DRW_ImageDef. Do not delete it!!
|
|
|
|
|
|
|
|
dx_ifaceBlock *mBlock; // container to store model entities
|
|
|
|
|
2017-07-05 18:35:34 +02:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(dx_data) // NOLINT
|
2017-06-21 11:34:20 +02:00
|
|
|
};
|
|
|
|
|
2021-09-25 10:43:05 +02:00
|
|
|
class dx_iface final : public DRW_Interface
|
2017-06-21 11:34:20 +02:00
|
|
|
{
|
|
|
|
public:
|
2024-01-06 13:20:56 +01:00
|
|
|
dx_iface(const std::string &file, DRW::Version v, VarMeasurement varMeasurement, VarInsunits varInsunits);
|
2017-06-21 11:34:20 +02:00
|
|
|
virtual ~dx_iface();
|
2023-05-03 13:07:02 +02:00
|
|
|
auto fileExport(bool binary) -> bool;
|
2024-01-06 13:20:56 +01:00
|
|
|
void writeEntity(DRW_Entity *e);
|
2017-06-21 11:34:20 +02:00
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
void AddXSpaceBlock(bool add) { dxfW->AddXSpaceBlock(add); }
|
2023-04-01 14:03:34 +02:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto ErrorString() const -> std::string;
|
2021-04-28 19:06:24 +02:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
// reimplement virtual DRW_Interface functions
|
|
|
|
// writer part, send all in class dx_data to writer
|
2024-01-06 13:20:56 +01:00
|
|
|
virtual void writeHeader(DRW_Header &data) override;
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void writeBlocks() override;
|
2024-01-06 13:20:56 +01:00
|
|
|
// only send the name, needed by the reader to prepare handles of blocks & blockRecords
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void writeBlockRecords() override;
|
2024-01-06 13:20:56 +01:00
|
|
|
// write entities of model space and first paper_space
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void writeEntities() override;
|
|
|
|
virtual void writeLTypes() override;
|
|
|
|
virtual void writeLayers() override;
|
|
|
|
virtual void writeTextstyles() override;
|
|
|
|
virtual void writeVports() override;
|
|
|
|
virtual void writeDimstyles() override;
|
2021-11-23 13:43:26 +01:00
|
|
|
virtual void writeObjects() override;
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void writeAppId() override;
|
2017-06-21 11:34:20 +02:00
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
void AddEntity(DRW_Entity *e);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto AddFont(const QFont &f) -> UTF8STRING;
|
2024-01-06 13:20:56 +01:00
|
|
|
void AddBlock(dx_ifaceBlock *block);
|
|
|
|
|
|
|
|
static auto QtPenStyleToString(Qt::PenStyle style) -> UTF8STRING;
|
2017-07-16 20:10:48 +02:00
|
|
|
|
|
|
|
void AddQtLTypes();
|
2017-07-17 16:19:49 +02:00
|
|
|
void AddDefLayers();
|
2017-07-16 20:10:48 +02:00
|
|
|
void AddAAMALayers();
|
2023-04-01 14:03:34 +02:00
|
|
|
void AddDefHeaderData();
|
2017-07-19 09:34:24 +02:00
|
|
|
void AddAAMAHeaderData();
|
2020-03-15 12:35:31 +01:00
|
|
|
void AddASTMLayers();
|
2017-06-29 17:56:52 +02:00
|
|
|
|
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(dx_iface) // NOLINT
|
2024-01-06 13:20:56 +01:00
|
|
|
dxfRW *dxfW; // pointer to writer, needed to send data
|
|
|
|
dx_data cData; // class to store or read data
|
2017-06-29 17:56:52 +02:00
|
|
|
DRW::Version version;
|
|
|
|
|
2017-06-21 11:34:20 +02:00
|
|
|
void InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits);
|
|
|
|
void InitTextstyles();
|
2018-07-16 18:53:15 +02:00
|
|
|
void InitVPorts();
|
2017-06-26 17:06:57 +02:00
|
|
|
void InitAppId();
|
2017-06-21 11:34:20 +02:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
static auto LocaleToISO() -> std::string;
|
2017-06-21 11:34:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DX_IFACE_H
|