From baf4f1a08ba45c6d40c06561227105814aef7f59 Mon Sep 17 00:00:00 2001
From: Roman Telezhynskyi
Date: Sat, 12 Aug 2023 10:31:10 +0300
Subject: [PATCH] Refactoring.
Code style.
---
src/app/puzzle/undocommands/vpundocommand.cpp | 12 +-
src/app/tape/dialogs/dialogmdatabase.cpp | 159 +-
.../valentina/dialogs/dialogsavelayout.cpp | 5 +-
src/libs/ifc/xml/vdomdocument.h | 34 +-
src/libs/qmuparser/qmudef.h | 4 +
src/libs/qmuparser/qmuformulabase.cpp | 43 +-
src/libs/qmuparser/qmuformulabase.h | 2 +-
src/libs/qmuparser/text.h | 8 +-
src/libs/vdxf/libdxfrw/drw_entities.cpp | 2016 +++++++-------
src/libs/vdxf/libdxfrw/drw_interface.h | 137 +-
src/libs/vdxf/libdxfrw/libdxfrw.cpp | 2363 +++++++++++------
src/libs/vlayout/vabstractpiece.h | 183 +-
src/libs/vlayout/vlayoutgenerator.cpp | 118 +-
src/libs/vlayout/vlayoutpoint.h | 27 +-
src/libs/vlayout/vprintlayout.cpp | 135 +-
src/libs/vlayout/vrawsapoint.h | 23 +-
src/libs/vlayout/vsapoint.h | 28 +-
src/libs/vmisc/backport/qoverload.h | 39 +-
src/libs/vmisc/backport/text.h | 8 +-
src/libs/vmisc/fpm/fixed.hpp | 254 +-
src/libs/vmisc/fpm/math.hpp | 192 +-
src/libs/vmisc/vtextcodec.cpp | 41 +-
src/libs/vobj/delaunay.cpp | 1152 ++++----
src/libs/vobj/predicates.cpp | 259 +-
src/libs/vobj/vobjpaintdevice.cpp | 5 +-
src/libs/vpatterndb/vpassmark.cpp | 67 +-
.../plugins/vfilepropertyeditor.h | 25 +-
.../vabstractpropertyfactory.h | 2 +-
.../vpropertyexplorer/vpropertyformview_p.h | 40 +-
.../vpropertyexplorer/vpropertyformwidget_p.h | 44 +-
.../vpropertyexplorer/vwidgetproperty_p.h | 16 +-
.../flipping/vtoolflippingbyaxis.cpp | 47 +-
.../flipping/vtoolflippingbyline.cpp | 37 +-
.../tools/drawTools/operation/vtoolmove.cpp | 135 +-
.../drawTools/operation/vtoolrotation.cpp | 14 +-
src/libs/vwidgets/vabstractmainwindow.cpp | 71 +-
src/test/ValentinaTest/tst_vabstractpiece.cpp | 371 +--
src/test/ValentinaTest/tst_varc.cpp | 58 +-
src/test/ValentinaTest/tst_vellipticalarc.cpp | 147 +-
39 files changed, 4461 insertions(+), 3860 deletions(-)
diff --git a/src/app/puzzle/undocommands/vpundocommand.cpp b/src/app/puzzle/undocommands/vpundocommand.cpp
index bf1918940..c6f8786f0 100644
--- a/src/app/puzzle/undocommands/vpundocommand.cpp
+++ b/src/app/puzzle/undocommands/vpundocommand.cpp
@@ -41,11 +41,13 @@ QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(QUndoCommand *parent)
- : QUndoCommand(parent)
-{}
+ : QUndoCommand(parent)
+{
+}
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(bool allowMerge, QUndoCommand *parent)
- : QUndoCommand(parent),
- m_allowMerge(allowMerge)
-{}
+ : QUndoCommand(parent),
+ m_allowMerge(allowMerge)
+{
+}
diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp
index c4c0ea74e..3b0c8526b 100644
--- a/src/app/tape/dialogs/dialogmdatabase.cpp
+++ b/src/app/tape/dialogs/dialogmdatabase.cpp
@@ -27,9 +27,9 @@
*************************************************************************/
#include "dialogmdatabase.h"
-#include "ui_dialogmdatabase.h"
#include "../mapplication.h"
#include "../vpatterndb/measurements.h"
+#include "ui_dialogmdatabase.h"
#include "../vmisc/compatibility.h"
#include
@@ -39,10 +39,10 @@
//---------------------------------------------------------------------------------------------------------------------
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
- :QDialog(parent),
- ui(new Ui::DialogMDataBase),
- m_selectMode(true),
- m_list(list)
+ : QDialog(parent),
+ ui(new Ui::DialogMDataBase),
+ m_selectMode(true),
+ m_list(list)
{
ui->setupUi(this);
@@ -64,9 +64,9 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
//---------------------------------------------------------------------------------------------------------------------
DialogMDataBase::DialogMDataBase(QWidget *parent)
- :QDialog(parent),
- ui(new Ui::DialogMDataBase),
- m_selectMode(false)
+ : QDialog(parent),
+ ui(new Ui::DialogMDataBase),
+ m_selectMode(false)
{
ui->setupUi(this);
@@ -100,7 +100,7 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
{
QStringList newNames;
QTreeWidgetItemIterator it(ui->treeWidget,
- QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked );
+ QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked);
while (*it)
{
const QString name = (*it)->data(0, Qt::UserRole).toString();
@@ -119,22 +119,22 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::RetranslateGroups()
{
- RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
- RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
- RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
- RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
- RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
- RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
- RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
- RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
- RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
- RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
- RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
- RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
- RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
- RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
- RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
- RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
+ RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
+ RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
+ RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
+ RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
+ RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
+ RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
+ RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
+ RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
+ RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
+ RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
+ RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
+ RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
+ RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
+ RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
+ RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
+ RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
ShowDescription(ui->treeWidget->currentItem(), 0);
@@ -144,8 +144,8 @@ void DialogMDataBase::RetranslateGroups()
auto DialogMDataBase::ImgTag(const QString &number) -> QString
{
QString imgUrl(QStringLiteral("")); // In case of error
- const QString filePath = QStringLiteral("://diagrams/%1.svg")
- .arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
+ const QString filePath =
+ QStringLiteral("://diagrams/%1.svg").arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
if (QFileInfo::exists(filePath))
{
// Load your SVG
@@ -203,7 +203,7 @@ auto DialogMDataBase::eventFilter(QObject *target, QEvent *event) -> bool
if (target == ui->treeWidget && event->type() == QEvent::KeyPress)
{
auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
- switch(keyEvent->key())
+ switch (keyEvent->key())
{
case Qt::Key_Up:
{
@@ -262,8 +262,7 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
}
for (int j = 0; j < parent->childCount(); ++j)
{
- if (j != parent->indexOfChild(item)
- && item->checkState(0) != parent->child(j)->checkState(0))
+ if (j != parent->indexOfChild(item) && item->checkState(0) != parent->child(j)->checkState(0))
{
diff = true;
}
@@ -379,22 +378,22 @@ void DialogMDataBase::FilterMeasurements(const QString &search)
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::InitDataBase(const QStringList &list)
{
- InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
- InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
- InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
- InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
- InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
- InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
- InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
- InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
- InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
- InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
- InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
- InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
- InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
- InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
- InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
- InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
+ InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
+ InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
+ InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
+ InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
+ InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
+ InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
+ InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
+ InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
+ InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
+ InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
+ InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
+ InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
+ InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
+ InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
+ InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
+ InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
}
@@ -415,14 +414,14 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
SCASSERT(group != nullptr)
bool match = false;
- for (int i=0; i < group->childCount(); ++i)
+ for (int i = 0; i < group->childCount(); ++i)
{
QTreeWidgetItem *childItem = group->child(i);
- const QString description = QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false))
- .toPlainText();
+ const QString description =
+ QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false)).toPlainText();
- const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive)
- && not description.contains(search, Qt::CaseInsensitive);
+ const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive) &&
+ not description.contains(search, Qt::CaseInsensitive);
childItem->setHidden(hidden);
if (not hidden)
@@ -474,7 +473,7 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name
}
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
- VAbstractApplication::VApp()->TrVars()->MToUser(name);
+ VAbstractApplication::VApp()->TrVars()->MToUser(name);
m->setText(0, text);
m->setToolTip(0, text);
m->setData(0, Qt::UserRole, name);
@@ -518,8 +517,8 @@ auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage)
"normal\"> %1
%2. %3
"
"%4
")
- .arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
- VAbstractApplication::VApp()->TrVars()->Description(name));
+ .arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
+ VAbstractApplication::VApp()->TrVars()->Description(name));
return text;
}
@@ -530,7 +529,7 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr
group->setText(0, groupText);
group->setToolTip(0, groupText);
- for (int i=0; iTrVars()->MNumber(name) + ". " +
- VAbstractApplication::VApp()->TrVars()->MToUser(name);
+ VAbstractApplication::VApp()->TrVars()->MToUser(name);
QTreeWidgetItem *m = group->child(index);
m->setText(0, text);
@@ -577,43 +576,27 @@ auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState
if (m_selectMode)
{
- if (m_groupA->checkState(0) == Qt::Unchecked &&
- m_groupB->checkState(0) == Qt::Unchecked &&
- m_groupC->checkState(0) == Qt::Unchecked &&
- m_groupD->checkState(0) == Qt::Unchecked &&
- m_groupE->checkState(0) == Qt::Unchecked &&
- m_groupF->checkState(0) == Qt::Unchecked &&
- m_groupG->checkState(0) == Qt::Unchecked &&
- m_groupH->checkState(0) == Qt::Unchecked &&
- m_groupI->checkState(0) == Qt::Unchecked &&
- m_groupJ->checkState(0) == Qt::Unchecked &&
- m_groupK->checkState(0) == Qt::Unchecked &&
- m_groupL->checkState(0) == Qt::Unchecked &&
- m_groupM->checkState(0) == Qt::Unchecked &&
- m_groupN->checkState(0) == Qt::Unchecked &&
- m_groupO->checkState(0) == Qt::Unchecked &&
- m_groupP->checkState(0) == Qt::Unchecked &&
+ if (m_groupA->checkState(0) == Qt::Unchecked && m_groupB->checkState(0) == Qt::Unchecked &&
+ m_groupC->checkState(0) == Qt::Unchecked && m_groupD->checkState(0) == Qt::Unchecked &&
+ m_groupE->checkState(0) == Qt::Unchecked && m_groupF->checkState(0) == Qt::Unchecked &&
+ m_groupG->checkState(0) == Qt::Unchecked && m_groupH->checkState(0) == Qt::Unchecked &&
+ m_groupI->checkState(0) == Qt::Unchecked && m_groupJ->checkState(0) == Qt::Unchecked &&
+ m_groupK->checkState(0) == Qt::Unchecked && m_groupL->checkState(0) == Qt::Unchecked &&
+ m_groupM->checkState(0) == Qt::Unchecked && m_groupN->checkState(0) == Qt::Unchecked &&
+ m_groupO->checkState(0) == Qt::Unchecked && m_groupP->checkState(0) == Qt::Unchecked &&
m_groupQ->checkState(0) == Qt::Unchecked)
{
return Qt::Checked;
}
- if (m_groupA->checkState(0) == Qt::Checked &&
- m_groupB->checkState(0) == Qt::Checked &&
- m_groupC->checkState(0) == Qt::Checked &&
- m_groupD->checkState(0) == Qt::Checked &&
- m_groupE->checkState(0) == Qt::Checked &&
- m_groupF->checkState(0) == Qt::Checked &&
- m_groupG->checkState(0) == Qt::Checked &&
- m_groupH->checkState(0) == Qt::Checked &&
- m_groupI->checkState(0) == Qt::Checked &&
- m_groupJ->checkState(0) == Qt::Checked &&
- m_groupK->checkState(0) == Qt::Checked &&
- m_groupL->checkState(0) == Qt::Checked &&
- m_groupM->checkState(0) == Qt::Checked &&
- m_groupN->checkState(0) == Qt::Checked &&
- m_groupO->checkState(0) == Qt::Checked &&
- m_groupP->checkState(0) == Qt::Checked &&
+ if (m_groupA->checkState(0) == Qt::Checked && m_groupB->checkState(0) == Qt::Checked &&
+ m_groupC->checkState(0) == Qt::Checked && m_groupD->checkState(0) == Qt::Checked &&
+ m_groupE->checkState(0) == Qt::Checked && m_groupF->checkState(0) == Qt::Checked &&
+ m_groupG->checkState(0) == Qt::Checked && m_groupH->checkState(0) == Qt::Checked &&
+ m_groupI->checkState(0) == Qt::Checked && m_groupJ->checkState(0) == Qt::Checked &&
+ m_groupK->checkState(0) == Qt::Checked && m_groupL->checkState(0) == Qt::Checked &&
+ m_groupM->checkState(0) == Qt::Checked && m_groupN->checkState(0) == Qt::Checked &&
+ m_groupO->checkState(0) == Qt::Checked && m_groupP->checkState(0) == Qt::Checked &&
m_groupQ->checkState(0) == Qt::Checked)
{
return Qt::Unchecked;
diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp
index 10aa963c0..37256c9cf 100644
--- a/src/app/valentina/dialogs/dialogsavelayout.cpp
+++ b/src/app/valentina/dialogs/dialogsavelayout.cpp
@@ -28,13 +28,14 @@
#include "dialogsavelayout.h"
#include "../core/vapplication.h"
+#include "../ifc/exception/vexception.h"
+#include "../vlayout/vlayoutexporter.h"
#include "../vmisc/vvalentinasettings.h"
#include "ui_dialogsavelayout.h"
+
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
-#include "../ifc/exception/vexception.h"
-#include "../vlayout/vlayoutexporter.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h
index a39530f35..8a534ccc7 100644
--- a/src/libs/ifc/xml/vdomdocument.h
+++ b/src/libs/ifc/xml/vdomdocument.h
@@ -35,20 +35,20 @@
#include
#include
#include
-#include
-#include
#include
#include
-#include
+#include
#include
+#include
+#include
#include "../ifcdef.h"
+#include "../qmuparser/qmudef.h"
#include "../vmisc/def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/literals.h"
-#include "../qmuparser/qmudef.h"
class QDomElement;
class QDomNode;
@@ -84,6 +84,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VDomDocument : public QObject, public QDomDocument
{
Q_OBJECT // NOLINT
+
public:
static const QString AttrId;
static const QString AttrText;
@@ -100,19 +101,18 @@ public:
virtual ~VDomDocument();
auto elementById(quint32 id, const QString &tagName = QString(), bool updateCache = true) -> QDomElement;
- template
- void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
+ template void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
template
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
- const std::function &removeCondition) const;
+ const std::function &removeCondition) const;
static auto GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue) -> quint32;
static auto GetParametrInt(const QDomElement &domElement, const QString &name, const QString &defValue) -> int;
static auto GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) -> bool;
static auto GetParametrUsage(const QDomElement &domElement, const QString &name) -> NodeUsage;
- static void SetParametrUsage(QDomElement& domElement, const QString &name, const NodeUsage &value);
+ static void SetParametrUsage(QDomElement &domElement, const QString &name, const NodeUsage &value);
static auto GetParametrString(const QDomElement &domElement, const QString &name,
const QString &defValue = QString()) -> QString;
@@ -120,7 +120,7 @@ public:
static auto GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) -> qreal;
static auto GetParametrId(const QDomElement &domElement) -> quint32;
- virtual void setXMLContent(const QString &fileName);
+ virtual void setXMLContent(const QString &fileName);
static auto UnitsHelpString() -> QString;
auto CreateElementWithText(const QString &tagName, const QString &text) -> QDomElement;
@@ -131,7 +131,7 @@ public:
auto Patch() const -> QString;
virtual auto GetFormatVersionStr() const -> QString;
static auto GetFormatVersion(const QString &version) -> unsigned;
- static void RemoveAllChildren(QDomElement &domElement);
+ static void RemoveAllChildren(QDomElement &domElement);
auto ParentNodeById(const quint32 &nodeId) -> QDomNode;
auto CloneNodeById(const quint32 &nodeId) -> QDomElement;
@@ -140,9 +140,9 @@ public:
static auto SafeCopy(const QString &source, const QString &destination, QString &error) -> bool;
auto GetLabelTemplate(const QDomElement &element) const -> QVector;
- void SetLabelTemplate(QDomElement &element, const QVector &lines);
+ void SetLabelTemplate(QDomElement &element, const QVector &lines);
- void TestUniqueId() const;
+ void TestUniqueId() const;
void RefreshElementIdCache();
@@ -153,7 +153,7 @@ protected:
auto setTagText(QDomElement &domElement, const QString &text) -> bool;
auto UniqueTag(const QString &tagName) const -> QDomElement;
auto UniqueTagText(const QString &tagName, const QString &defVal = QString()) const -> QString;
- void CollectId(const QDomElement &node, QVector &vector)const;
+ void CollectId(const QDomElement &node, QVector &vector) const;
static void ValidateVersion(const QString &version);
@@ -164,7 +164,7 @@ private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VDomDocument) // NOLINT
/** @brief Map used for finding element by id. */
- QHash m_elementIdCache;
+ QHash m_elementIdCache;
QFutureWatcher> *m_watcher;
static auto find(QHash &cache, const QDomElement &node, quint32 id) -> bool;
@@ -223,14 +223,14 @@ template <>
inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name,
const MeasurementsType &value) const
{
- domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize") :
- QStringLiteral("individual"));
+ domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize")
+ : QStringLiteral("individual"));
}
//---------------------------------------------------------------------------------------------------------------------
template
inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
- const std::function &removeCondition) const
+ const std::function &removeCondition) const
{
not removeCondition(value) ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
}
diff --git a/src/libs/qmuparser/qmudef.h b/src/libs/qmuparser/qmudef.h
index 8e7047e25..cbc3c0042 100644
--- a/src/libs/qmuparser/qmudef.h
+++ b/src/libs/qmuparser/qmudef.h
@@ -90,6 +90,10 @@
Class &operator=(Class &&) = delete;
#endif
+#ifndef Q_DISABLE_ASSIGN
+#define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete;
+#endif
+
#ifndef Q_DISABLE_ASSIGN_MOVE
#define Q_DISABLE_ASSIGN_MOVE(Class) \
Q_DISABLE_ASSIGN(Class) \
diff --git a/src/libs/qmuparser/qmuformulabase.cpp b/src/libs/qmuparser/qmuformulabase.cpp
index 2a4ae5a3b..335e8fded 100644
--- a/src/libs/qmuparser/qmuformulabase.cpp
+++ b/src/libs/qmuparser/qmuformulabase.cpp
@@ -34,7 +34,7 @@ namespace qmu
//---------------------------------------------------------------------------------------------------------------------
QmuFormulaBase::QmuFormulaBase()
- :QmuParser()
+ : QmuParser()
{
}
@@ -55,22 +55,25 @@ void QmuFormulaBase::InitCharSets()
{
QString symbolsStr;
{
- //String with all unique symbols for supported alphabets.
- //See script alphabets.py for generation and more information.
- //Note. MSVC doesn't support normal string concatenation for long string. That's why we use QStringList in this
- //case.
- const QStringList symbols
- {
- QStringLiteral("ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
- QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
- QStringLiteral("ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
- QStringLiteral("æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
- QStringLiteral("ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
- QStringLiteral("ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդﻩjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
- QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")
- };
+ // String with all unique symbols for supported alphabets.
+ // See script alphabets.py for generation and more information.
+ // Note. MSVC doesn't support normal string concatenation for long string. That's why we use QStringList in this
+ // case.
+ const QStringList symbols{
+ QStringLiteral(
+ "ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
+ QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
+ QStringLiteral(
+ "ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
+ QStringLiteral(
+ "æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
+ QStringLiteral(
+ "ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
+ QStringLiteral(
+ "ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդﻩjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
+ QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")};
- symbolsStr = symbols.join(QString());
+ symbolsStr = symbols.join(QString());
}
INIT_LOCALE_VARIABLES(m_locale);
@@ -153,7 +156,7 @@ void QmuFormulaBase::SetSepForTr(bool osSeparator, bool fromUser)
}
}
- SetSepForEval();//Same separators (internal) as for eval.
+ SetSepForEval(); // Same separators (internal) as for eval.
}
//---------------------------------------------------------------------------------------------------------------------
@@ -177,13 +180,13 @@ void QmuFormulaBase::SetSepForEval()
* @param map map with tokens
* @param val token that need delete
*/
-void QmuFormulaBase::RemoveAll(QMap &map, const QString &val)
+void QmuFormulaBase::RemoveAll(QMap &map, const QString &val)
{
- const QList listKeys = map.keys(val);//Take all keys that contain token.
+ const QList listKeys = map.keys(val); // Take all keys that contain token.
for (auto key : listKeys)
{
map.remove(key);
}
}
-}// namespace qmu
+} // namespace qmu
diff --git a/src/libs/qmuparser/qmuformulabase.h b/src/libs/qmuparser/qmuformulabase.h
index 6d7025993..d9e19c92b 100644
--- a/src/libs/qmuparser/qmuformulabase.h
+++ b/src/libs/qmuparser/qmuformulabase.h
@@ -43,7 +43,7 @@ public:
void SetSepForTr(bool osSeparator, bool fromUser);
- static void RemoveAll(QMap &map, const QString &val);
+ static void RemoveAll(QMap &map, const QString &val);
protected:
static auto AddVariable(const QString &a_szName, void *a_pUserData) -> qreal *;
diff --git a/src/libs/qmuparser/text.h b/src/libs/qmuparser/text.h
index 35645bfee..ba801ed85 100644
--- a/src/libs/qmuparser/text.h
+++ b/src/libs/qmuparser/text.h
@@ -43,13 +43,13 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wunused-variable")
QT_WARNING_DISABLE_CLANG("-Wunused-variable")
-//static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
-//static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
+// static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
+// static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
static auto dec Q_DECL_UNUSED = ::dec; // NOLINT
-//static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT
+// static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT
QT_WARNING_POP
-} // namespace Qt
+} // namespace Qt
#endif
diff --git a/src/libs/vdxf/libdxfrw/drw_entities.cpp b/src/libs/vdxf/libdxfrw/drw_entities.cpp
index 6c966569d..9ff45b95b 100644
--- a/src/libs/vdxf/libdxfrw/drw_entities.cpp
+++ b/src/libs/vdxf/libdxfrw/drw_entities.cpp
@@ -11,11 +11,11 @@
** along with this program. If not, see . **
******************************************************************************/
-#include
#include "drw_entities.h"
-#include "intern/dxfreader.h"
-#include "intern/drw_dbg.h"
#include "drw_reserve.h"
+#include "intern/drw_dbg.h"
+#include "intern/dxfreader.h"
+#include
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@@ -23,22 +23,26 @@
//! Calculate arbitrary axis
/*!
-* Calculate arbitrary axis for apply extrusions
-* @author Rallaz
-*/
-void DRW_Entity::calculateAxis(DRW_Coord extPoint){
- //Follow the arbitrary DXF definitions for extrusion axes.
- if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625) {
- //If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
- //The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
- //Factoring in the fixed values for Wy gives N.z,0,-N.x
+ * Calculate arbitrary axis for apply extrusions
+ * @author Rallaz
+ */
+void DRW_Entity::calculateAxis(DRW_Coord extPoint)
+{
+ // Follow the arbitrary DXF definitions for extrusion axes.
+ if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625)
+ {
+ // If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
+ // The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
+ // Factoring in the fixed values for Wy gives N.z,0,-N.x
extAxisX.x = extPoint.z;
extAxisX.y = 0;
extAxisX.z = -extPoint.x;
- } else {
- //Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
- //The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
- //Factoring in the fixed values for Wz gives -N.y,N.x,0.
+ }
+ else
+ {
+ // Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
+ // The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
+ // Factoring in the fixed values for Wz gives -N.y,N.x,0.
extAxisX.x = -extPoint.y;
extAxisX.y = extPoint.x;
extAxisX.z = 0;
@@ -46,7 +50,7 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
extAxisX.unitize();
- //Ay = N x Ax
+ // Ay = N x Ax
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
@@ -56,14 +60,15 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
//! Extrude a point using arbitrary axis
/*!
-* apply extrusion in a point using arbitrary axis (previous calculated)
-* @author Rallaz
-*/
-void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
+ * apply extrusion in a point using arbitrary axis (previous calculated)
+ * @author Rallaz
+ */
+void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const
+{
double px, py, pz;
- px = (extAxisX.x*point->x)+(extAxisY.x*point->y)+(extPoint.x*point->z);
- py = (extAxisX.y*point->x)+(extAxisY.y*point->y)+(extPoint.y*point->z);
- pz = (extAxisX.z*point->x)+(extAxisY.z*point->y)+(extPoint.z*point->z);
+ px = (extAxisX.x * point->x) + (extAxisY.x * point->y) + (extPoint.x * point->z);
+ py = (extAxisX.y * point->x) + (extAxisY.y * point->y) + (extPoint.y * point->z);
+ pz = (extAxisX.z * point->x) + (extAxisY.z * point->y) + (extPoint.z * point->z);
point->x = px;
point->y = py;
@@ -72,124 +77,129 @@ void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 5:
- handle = static_cast(reader->getHandleString());
- break;
- case 330:
- parentHandle = static_cast(reader->getHandleString());
- break;
- case 8:
- layer = reader->getUtf8String();
- break;
- case 6:
- lineType = reader->getUtf8String();
- break;
- case 62:
- color = reader->getInt32();
- break;
- case 370:
- lWeight = DRW_LW_Conv::dxfInt2lineWidth(reader->getInt32());
- break;
- case 48:
- ltypeScale = reader->getDouble();
- break;
- case 60:
- visible = reader->getBool();
- break;
- case 420:
- color24 = reader->getInt32();
- break;
- case 430:
- colorName = reader->getString();
- break;
- case 67:
- space = static_cast(reader->getInt32());
- break;
- case 102:
- parseDxfGroups(code, reader);
- break;
- case 1000:
- case 1001:
- case 1002:
- case 1003:
- case 1004:
- case 1005:
- extData.push_back(new DRW_Variant(code, reader->getString()));
- break;
- case 1010:
- case 1011:
- case 1012:
- case 1013:
- curr = new DRW_Variant();
- curr->addCoord();
- curr->setCoordX(reader->getDouble());
- curr->code = code;
- extData.push_back(curr);
- break;
- case 1020:
- case 1021:
- case 1022:
- case 1023:
- if (curr)
- curr->setCoordY(reader->getDouble());
- break;
- case 1030:
- case 1031:
- case 1032:
- case 1033:
- if (curr)
- curr->setCoordZ(reader->getDouble());
- curr=nullptr;
- break;
- case 1040:
- case 1041:
- case 1042:
- extData.push_back(new DRW_Variant(code, reader->getDouble() ));
- break;
- case 1070:
- case 1071:
- extData.push_back(new DRW_Variant(code, reader->getInt32() ));
- break;
- default:
- break;
+ switch (code)
+ {
+ case 5:
+ handle = static_cast(reader->getHandleString());
+ break;
+ case 330:
+ parentHandle = static_cast(reader->getHandleString());
+ break;
+ case 8:
+ layer = reader->getUtf8String();
+ break;
+ case 6:
+ lineType = reader->getUtf8String();
+ break;
+ case 62:
+ color = reader->getInt32();
+ break;
+ case 370:
+ lWeight = DRW_LW_Conv::dxfInt2lineWidth(reader->getInt32());
+ break;
+ case 48:
+ ltypeScale = reader->getDouble();
+ break;
+ case 60:
+ visible = reader->getBool();
+ break;
+ case 420:
+ color24 = reader->getInt32();
+ break;
+ case 430:
+ colorName = reader->getString();
+ break;
+ case 67:
+ space = static_cast(reader->getInt32());
+ break;
+ case 102:
+ parseDxfGroups(code, reader);
+ break;
+ case 1000:
+ case 1001:
+ case 1002:
+ case 1003:
+ case 1004:
+ case 1005:
+ extData.push_back(new DRW_Variant(code, reader->getString()));
+ break;
+ case 1010:
+ case 1011:
+ case 1012:
+ case 1013:
+ curr = new DRW_Variant();
+ curr->addCoord();
+ curr->setCoordX(reader->getDouble());
+ curr->code = code;
+ extData.push_back(curr);
+ break;
+ case 1020:
+ case 1021:
+ case 1022:
+ case 1023:
+ if (curr)
+ curr->setCoordY(reader->getDouble());
+ break;
+ case 1030:
+ case 1031:
+ case 1032:
+ case 1033:
+ if (curr)
+ curr->setCoordZ(reader->getDouble());
+ curr = nullptr;
+ break;
+ case 1040:
+ case 1041:
+ case 1042:
+ extData.push_back(new DRW_Variant(code, reader->getDouble()));
+ break;
+ case 1070:
+ case 1071:
+ extData.push_back(new DRW_Variant(code, reader->getInt32()));
+ break;
+ default:
+ break;
}
return true;
}
-//parses dxf 102 groups to read entity
+// parses dxf 102 groups to read entity
auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
{
std::list ls;
DRW_Variant c;
int nc;
- std::string appName= reader->getString();
- if (!appName.empty() && appName.at(0)== '{'){
- c.addString(appName.substr(1, static_cast(appName.size()-1)));
+ std::string appName = reader->getString();
+ if (!appName.empty() && appName.at(0) == '{')
+ {
+ c.addString(appName.substr(1, static_cast(appName.size() - 1)));
c.code = code;
ls.push_back(c);
- while (code !=102 && appName.at(0)== '}'){
+ while (code != 102 && appName.at(0) == '}')
+ {
reader->readRec(&nc);
c.code = code;
if (code == 330 || code == 360)
c.addInt(reader->getHandleString());
- else {
- switch (reader->type) {
- case dxfReader::STRING:
- c.addString(reader->getString());
- break;
- case dxfReader::INT32:
- case dxfReader::INT64:
- c.addInt(reader->getInt32());
- break;
- case dxfReader::DOUBLE:
- c.addDouble(reader->getDouble());
- break;
- case dxfReader::BOOL:
- c.addInt(reader->getInt32());
- break;
- default:
- break;
+ else
+ {
+ switch (reader->type)
+ {
+ case dxfReader::STRING:
+ c.addString(reader->getString());
+ break;
+ case dxfReader::INT32:
+ case dxfReader::INT64:
+ c.addInt(reader->getInt32());
+ break;
+ case dxfReader::DOUBLE:
+ c.addDouble(reader->getDouble());
+ break;
+ case dxfReader::BOOL:
+ c.addInt(reader->getInt32());
+ break;
+ default:
+ break;
}
}
ls.push_back(c);
@@ -202,31 +212,32 @@ auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 10:
- basePoint.x = reader->getDouble();
- break;
- case 20:
- basePoint.y = reader->getDouble();
- break;
- case 30:
- basePoint.z = reader->getDouble();
- break;
- case 39:
- thickness = reader->getDouble();
- break;
- case 210:
- haveExtrusion = true;
- extPoint.x = reader->getDouble();
- break;
- case 220:
- extPoint.y = reader->getDouble();
- break;
- case 230:
- extPoint.z = reader->getDouble();
- break;
- default:
- return DRW_Entity::parseCode(code, reader);
+ switch (code)
+ {
+ case 10:
+ basePoint.x = reader->getDouble();
+ break;
+ case 20:
+ basePoint.y = reader->getDouble();
+ break;
+ case 30:
+ basePoint.z = reader->getDouble();
+ break;
+ case 39:
+ thickness = reader->getDouble();
+ break;
+ case 210:
+ haveExtrusion = true;
+ extPoint.x = reader->getDouble();
+ break;
+ case 220:
+ extPoint.y = reader->getDouble();
+ break;
+ case 230:
+ extPoint.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Entity::parseCode(code, reader);
}
return true;
@@ -234,12 +245,13 @@ auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 50:
- angle = reader->getDouble();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 50:
+ angle = reader->getDouble();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
@@ -247,27 +259,30 @@ auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 11:
- secPoint.x = reader->getDouble();
- break;
- case 21:
- secPoint.y = reader->getDouble();
- break;
- case 31:
- secPoint.z = reader->getDouble();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 11:
+ secPoint.x = reader->getDouble();
+ break;
+ case 21:
+ secPoint.y = reader->getDouble();
+ break;
+ case 31:
+ secPoint.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
}
-void DRW_Circle::applyExtrusion(){
- if (haveExtrusion) {
- //NOTE: Commenting these out causes the the arcs being tested to be located
- //on the other side of the y axis (all x dimensions are negated).
+void DRW_Circle::applyExtrusion()
+{
+ if (haveExtrusion)
+ {
+ // NOTE: Commenting these out causes the the arcs being tested to be located
+ // on the other side of the y axis (all x dimensions are negated).
calculateAxis(extPoint);
extrudePoint(extPoint, &basePoint);
}
@@ -275,48 +290,53 @@ void DRW_Circle::applyExtrusion(){
auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 40:
- radious = reader->getDouble();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 40:
+ radious = reader->getDouble();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
}
-void DRW_Arc::applyExtrusion(){
+void DRW_Arc::applyExtrusion()
+{
DRW_Circle::applyExtrusion();
- if(haveExtrusion){
+ if (haveExtrusion)
+ {
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
- if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0) {
- staangle=M_PI-staangle;
- endangle=M_PI-endangle;
+ if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
+ {
+ staangle = M_PI - staangle;
+ endangle = M_PI - endangle;
double temp = staangle;
- staangle=endangle;
- endangle=temp;
+ staangle = endangle;
+ endangle = temp;
}
}
}
auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 50:
- staangle = reader->getDouble()/ ARAD;
- break;
- case 51:
- endangle = reader->getDouble()/ ARAD;
- break;
- default:
- return DRW_Circle::parseCode(code, reader);
+ switch (code)
+ {
+ case 50:
+ staangle = reader->getDouble() / ARAD;
+ break;
+ case 51:
+ endangle = reader->getDouble() / ARAD;
+ break;
+ default:
+ return DRW_Circle::parseCode(code, reader);
}
return true;
@@ -324,86 +344,98 @@ auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 40:
- ratio = reader->getDouble();
- break;
- case 41:
- staparam = reader->getDouble();
- break;
- case 42:
- endparam = reader->getDouble();
- break;
- default:
- return DRW_Line::parseCode(code, reader);
+ switch (code)
+ {
+ case 40:
+ ratio = reader->getDouble();
+ break;
+ case 41:
+ staparam = reader->getDouble();
+ break;
+ case 42:
+ endparam = reader->getDouble();
+ break;
+ default:
+ return DRW_Line::parseCode(code, reader);
}
return true;
}
-void DRW_Ellipse::applyExtrusion(){
- if (haveExtrusion) {
+void DRW_Ellipse::applyExtrusion()
+{
+ if (haveExtrusion)
+ {
calculateAxis(extPoint);
extrudePoint(extPoint, &secPoint);
double intialparam = staparam;
- if (extPoint.z < 0.){
+ if (extPoint.z < 0.)
+ {
staparam = M_PIx2 - endparam;
endparam = M_PIx2 - intialparam;
}
}
}
-//if ratio > 1 minor axis are greather than major axis, correct it
-void DRW_Ellipse::correctAxis(){
+// if ratio > 1 minor axis are greather than major axis, correct it
+void DRW_Ellipse::correctAxis()
+{
bool complete = false;
- if (DRW_FuzzyComparePossibleNulls(staparam, endparam)) {
+ if (DRW_FuzzyComparePossibleNulls(staparam, endparam))
+ {
staparam = 0.0;
- endparam = M_PIx2; //2*M_PI;
+ endparam = M_PIx2; // 2*M_PI;
complete = true;
}
- if (ratio > 1){
- if ( fabs(endparam - staparam - M_PIx2) < 1.0e-10)
+ if (ratio > 1)
+ {
+ if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
complete = true;
double incX = secPoint.x;
secPoint.x = -(secPoint.y * ratio);
- secPoint.y = incX*ratio;
- ratio = 1/ratio;
- if (!complete){
+ secPoint.y = incX * ratio;
+ ratio = 1 / ratio;
+ if (!complete)
+ {
if (staparam < M_PI_2)
- staparam += M_PI *2;
+ staparam += M_PI * 2;
if (endparam < M_PI_2)
- endparam += M_PI *2;
+ endparam += M_PI * 2;
endparam -= M_PI_2;
staparam -= M_PI_2;
}
}
}
-//parts are the number of vertex to split polyline, default 128
-void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
+// parts are the number of vertex to split polyline, default 128
+void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts)
+{
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
- radMajor = sqrt(secPoint.x*secPoint.x + secPoint.y*secPoint.y);
- radMinor = radMajor*ratio;
- //calculate sin & cos of included angle
+ radMajor = sqrt(secPoint.x * secPoint.x + secPoint.y * secPoint.y);
+ radMinor = radMajor * ratio;
+ // calculate sin & cos of included angle
incAngle = atan2(secPoint.y, secPoint.x);
cosRot = cos(incAngle);
sinRot = sin(incAngle);
incAngle = M_PIx2 / parts;
curAngle = staparam;
int i = static_cast(curAngle / incAngle);
- do {
- if (curAngle > endparam) {
+ do
+ {
+ if (curAngle > endparam)
+ {
curAngle = endparam;
- i = parts+2;
+ i = parts + 2;
}
double cosCurr = cos(curAngle);
double sinCurr = sin(curAngle);
- double x = basePoint.x + (cosCurr*cosRot*radMajor) - (sinCurr*sinRot*radMinor);
- double y = basePoint.y + (cosCurr*sinRot*radMajor) + (sinCurr*cosRot*radMinor);
- pol->addVertex( DRW_Vertex(x, y, 0.0, 0.0));
- curAngle = (++i)*incAngle;
- } while (iaddVertex(DRW_Vertex(x, y, 0.0, 0.0));
+ curAngle = (++i) * incAngle;
+ } while (i < parts);
+ if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
+ {
pol->flags = 1;
}
pol->layer = this->layer;
@@ -413,8 +445,10 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
pol->extPoint = this->extPoint;
}
-void DRW_Trace::applyExtrusion(){
- if (haveExtrusion) {
+void DRW_Trace::applyExtrusion()
+{
+ if (haveExtrusion)
+ {
calculateAxis(extPoint);
extrudePoint(extPoint, &basePoint);
extrudePoint(extPoint, &secPoint);
@@ -425,27 +459,28 @@ void DRW_Trace::applyExtrusion(){
auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 12:
- thirdPoint.x = reader->getDouble();
- break;
- case 22:
- thirdPoint.y = reader->getDouble();
- break;
- case 32:
- thirdPoint.z = reader->getDouble();
- break;
- case 13:
- fourPoint.x = reader->getDouble();
- break;
- case 23:
- fourPoint.y = reader->getDouble();
- break;
- case 33:
- fourPoint.z = reader->getDouble();
- break;
- default:
- return DRW_Line::parseCode(code, reader);
+ switch (code)
+ {
+ case 12:
+ thirdPoint.x = reader->getDouble();
+ break;
+ case 22:
+ thirdPoint.y = reader->getDouble();
+ break;
+ case 32:
+ thirdPoint.z = reader->getDouble();
+ break;
+ case 13:
+ fourPoint.x = reader->getDouble();
+ break;
+ case 23:
+ fourPoint.y = reader->getDouble();
+ break;
+ case 33:
+ fourPoint.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Line::parseCode(code, reader);
}
return true;
@@ -453,12 +488,13 @@ auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 70:
- invisibleflag = reader->getInt32();
- break;
- default:
- return DRW_Trace::parseCode(code, reader);
+ switch (code)
+ {
+ case 70:
+ invisibleflag = reader->getInt32();
+ break;
+ default:
+ return DRW_Trace::parseCode(code, reader);
}
return true;
@@ -466,15 +502,16 @@ auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 2:
- name = reader->getUtf8String();
- break;
- case 70:
- flags = reader->getInt32();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 2:
+ name = reader->getUtf8String();
+ break;
+ case 70:
+ flags = reader->getInt32();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
@@ -482,46 +519,50 @@ auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 2:
- name = reader->getUtf8String();
- break;
- case 41:
- xscale = reader->getDouble();
- break;
- case 42:
- yscale = reader->getDouble();
- break;
- case 43:
- zscale = reader->getDouble();
- break;
- case 50:
- angle = reader->getDouble();
- angle = angle/ARAD; //convert to radian
- break;
- case 70:
- colcount = reader->getInt32();
- break;
- case 71:
- rowcount = reader->getInt32();
- break;
- case 44:
- colspace = reader->getDouble();
- break;
- case 45:
- rowspace = reader->getDouble();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 2:
+ name = reader->getUtf8String();
+ break;
+ case 41:
+ xscale = reader->getDouble();
+ break;
+ case 42:
+ yscale = reader->getDouble();
+ break;
+ case 43:
+ zscale = reader->getDouble();
+ break;
+ case 50:
+ angle = reader->getDouble();
+ angle = angle / ARAD; // convert to radian
+ break;
+ case 70:
+ colcount = reader->getInt32();
+ break;
+ case 71:
+ rowcount = reader->getInt32();
+ break;
+ case 44:
+ colspace = reader->getDouble();
+ break;
+ case 45:
+ rowspace = reader->getDouble();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
}
-void DRW_LWPolyline::applyExtrusion(){
- if (haveExtrusion) {
+void DRW_LWPolyline::applyExtrusion()
+{
+ if (haveExtrusion)
+ {
calculateAxis(extPoint);
- for (unsigned int i=0; ix, vert->y, elevation);
extrudePoint(extPoint, &v);
@@ -533,55 +574,58 @@ void DRW_LWPolyline::applyExtrusion(){
auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 10: {
- vertex = new DRW_Vertex2D();
- vertlist.push_back(vertex);
- vertex->x = reader->getDouble();
- break; }
- case 20:
- if(vertex != NULL)
- vertex->y = reader->getDouble();
- break;
- case 40:
- if(vertex != NULL)
- vertex->stawidth = reader->getDouble();
- break;
- case 41:
- if(vertex != NULL)
- vertex->endwidth = reader->getDouble();
- break;
- case 42:
- if(vertex != NULL)
- vertex->bulge = reader->getDouble();
- break;
- case 38:
- elevation = reader->getDouble();
- break;
- case 39:
- thickness = reader->getDouble();
- break;
- case 43:
- width = reader->getDouble();
- break;
- case 70:
- flags = reader->getInt32();
- break;
- case 90:
- vertexnum = reader->getInt32();
- return DRW::reserve( vertlist, vertexnum);
- case 210:
- haveExtrusion = true;
- extPoint.x = reader->getDouble();
- break;
- case 220:
- extPoint.y = reader->getDouble();
- break;
- case 230:
- extPoint.z = reader->getDouble();
- break;
- default:
- return DRW_Entity::parseCode(code, reader);
+ switch (code)
+ {
+ case 10:
+ {
+ vertex = new DRW_Vertex2D();
+ vertlist.push_back(vertex);
+ vertex->x = reader->getDouble();
+ break;
+ }
+ case 20:
+ if (vertex != NULL)
+ vertex->y = reader->getDouble();
+ break;
+ case 40:
+ if (vertex != NULL)
+ vertex->stawidth = reader->getDouble();
+ break;
+ case 41:
+ if (vertex != NULL)
+ vertex->endwidth = reader->getDouble();
+ break;
+ case 42:
+ if (vertex != NULL)
+ vertex->bulge = reader->getDouble();
+ break;
+ case 38:
+ elevation = reader->getDouble();
+ break;
+ case 39:
+ thickness = reader->getDouble();
+ break;
+ case 43:
+ width = reader->getDouble();
+ break;
+ case 70:
+ flags = reader->getInt32();
+ break;
+ case 90:
+ vertexnum = reader->getInt32();
+ return DRW::reserve(vertlist, vertexnum);
+ case 210:
+ haveExtrusion = true;
+ extPoint.x = reader->getDouble();
+ break;
+ case 220:
+ extPoint.y = reader->getDouble();
+ break;
+ case 230:
+ extPoint.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Entity::parseCode(code, reader);
}
return true;
@@ -589,36 +633,37 @@ auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 40:
- height = reader->getDouble();
- break;
- case 41:
- widthscale = reader->getDouble();
- break;
- case 50:
- angle = reader->getDouble();
- break;
- case 51:
- oblique = reader->getDouble();
- break;
- case 71:
- textgen = reader->getInt32();
- break;
- case 72:
- alignH = static_cast(reader->getInt32());
- break;
- case 73:
- alignV = static_cast(reader->getInt32());
- break;
- case 1:
- text = reader->getUtf8String();
- break;
- case 7:
- style = reader->getUtf8String();
- break;
- default:
- return DRW_Line::parseCode(code, reader);
+ switch (code)
+ {
+ case 40:
+ height = reader->getDouble();
+ break;
+ case 41:
+ widthscale = reader->getDouble();
+ break;
+ case 50:
+ angle = reader->getDouble();
+ break;
+ case 51:
+ oblique = reader->getDouble();
+ break;
+ case 71:
+ textgen = reader->getInt32();
+ break;
+ case 72:
+ alignH = static_cast(reader->getInt32());
+ break;
+ case 73:
+ alignV = static_cast(reader->getInt32());
+ break;
+ case 1:
+ text = reader->getUtf8String();
+ break;
+ case 7:
+ style = reader->getUtf8String();
+ break;
+ default:
+ return DRW_Line::parseCode(code, reader);
}
return true;
@@ -626,120 +671,127 @@ auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 1:
- text += reader->getString();
- text = reader->toUtf8String(text);
- break;
- case 11:
- hasXAxisVec = true;
- return DRW_Text::parseCode(code, reader);
- case 3:
- text += reader->getString();
- break;
- case 44:
- interlin = reader->getDouble();
- break;
- case 71: {
- // Attachment point
- Attach a = static_cast(reader->getInt32());
+ switch (code)
+ {
+ case 1:
+ text += reader->getString();
+ text = reader->toUtf8String(text);
+ break;
+ case 11:
+ hasXAxisVec = true;
+ return DRW_Text::parseCode(code, reader);
+ case 3:
+ text += reader->getString();
+ break;
+ case 44:
+ interlin = reader->getDouble();
+ break;
+ case 71:
+ {
+ // Attachment point
+ Attach a = static_cast(reader->getInt32());
- QT_WARNING_PUSH
- QT_WARNING_DISABLE_GCC("-Wswitch-default")
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_GCC("-Wswitch-default")
- switch(a) {
- case TopLeft:
- alignV = VTop;
- alignH = HLeft;
- break;
- case TopCenter:
- alignV = VTop;
- alignH = HCenter;
- break;
- case TopRight:
- alignV = VTop;
- alignH = HRight;
- break;
- case MiddleLeft:
- alignV = VMiddle;
- alignH = HLeft;
- break;
- case MiddleCenter:
- alignV = VMiddle;
- alignH = HCenter;
- break;
- case MiddleRight:
- alignV = VMiddle;
- alignH = HRight;
- break;
- case BottomLeft:
- alignV = VBottom;
- alignH = HLeft;
- break;
- case BottomCenter:
- alignV = VBottom;
- alignH = HCenter;
- break;
- case BottomRight:
- alignV = VBottom;
- alignH = HRight;
- break;
+ switch (a)
+ {
+ case TopLeft:
+ alignV = VTop;
+ alignH = HLeft;
+ break;
+ case TopCenter:
+ alignV = VTop;
+ alignH = HCenter;
+ break;
+ case TopRight:
+ alignV = VTop;
+ alignH = HRight;
+ break;
+ case MiddleLeft:
+ alignV = VMiddle;
+ alignH = HLeft;
+ break;
+ case MiddleCenter:
+ alignV = VMiddle;
+ alignH = HCenter;
+ break;
+ case MiddleRight:
+ alignV = VMiddle;
+ alignH = HRight;
+ break;
+ case BottomLeft:
+ alignV = VBottom;
+ alignH = HLeft;
+ break;
+ case BottomCenter:
+ alignV = VBottom;
+ alignH = HCenter;
+ break;
+ case BottomRight:
+ alignV = VBottom;
+ alignH = HRight;
+ break;
+ }
+
+ QT_WARNING_POP
}
-
- QT_WARNING_POP
- } break;
- case 72:
- // To prevent redirection to DRW_Text::parseCode.
- // This code meaning is different for MTEXT.
- // Actually: Drawing direction
break;
- case 73:
- // To prevent redirection to DRW_Text::parseCode.
- // This code meaning is different for MTEXT.
- // Actually: Mtext line spacing style
- break;
- default:
- return DRW_Text::parseCode(code, reader);
+ case 72:
+ // To prevent redirection to DRW_Text::parseCode.
+ // This code meaning is different for MTEXT.
+ // Actually: Drawing direction
+ break;
+ case 73:
+ // To prevent redirection to DRW_Text::parseCode.
+ // This code meaning is different for MTEXT.
+ // Actually: Mtext line spacing style
+ break;
+ default:
+ return DRW_Text::parseCode(code, reader);
}
return true;
}
-void DRW_MText::updateAngle(){
- if (hasXAxisVec) {
- angle = atan2(secPoint.y, secPoint.x)*180/M_PI;
+void DRW_MText::updateAngle()
+{
+ if (hasXAxisVec)
+ {
+ angle = atan2(secPoint.y, secPoint.x) * 180 / M_PI;
}
}
auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 70:
- flags = reader->getInt32();
- break;
- case 40:
- defstawidth = reader->getDouble();
- break;
- case 41:
- defendwidth = reader->getDouble();
- break;
- case 71:
- vertexcount = reader->getInt32();
- break;
- case 72:
- facecount = reader->getInt32();
- break;
- case 73:
- smoothM = reader->getInt32();
- break;
- case 74:
- smoothN = reader->getInt32();
- break;
- case 75:
- curvetype = reader->getInt32();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 70:
+ flags = reader->getInt32();
+ break;
+ case 40:
+ defstawidth = reader->getDouble();
+ break;
+ case 41:
+ defendwidth = reader->getDouble();
+ break;
+ case 71:
+ vertexcount = reader->getInt32();
+ break;
+ case 72:
+ facecount = reader->getInt32();
+ break;
+ case 73:
+ smoothM = reader->getInt32();
+ break;
+ case 74:
+ smoothN = reader->getInt32();
+ break;
+ case 75:
+ curvetype = reader->getInt32();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
@@ -747,39 +799,40 @@ auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 70:
- flags = reader->getInt32();
- break;
- case 40:
- stawidth = reader->getDouble();
- break;
- case 41:
- endwidth = reader->getDouble();
- break;
- case 42:
- bulge = reader->getDouble();
- break;
- case 50:
- tgdir = reader->getDouble();
- break;
- case 71:
- vindex1 = reader->getInt32();
- break;
- case 72:
- vindex2 = reader->getInt32();
- break;
- case 73:
- vindex3 = reader->getInt32();
- break;
- case 74:
- vindex4 = reader->getInt32();
- break;
- case 91:
- identifier = reader->getInt32();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 70:
+ flags = reader->getInt32();
+ break;
+ case 40:
+ stawidth = reader->getDouble();
+ break;
+ case 41:
+ endwidth = reader->getDouble();
+ break;
+ case 42:
+ bulge = reader->getDouble();
+ break;
+ case 50:
+ tgdir = reader->getDouble();
+ break;
+ case 71:
+ vindex1 = reader->getInt32();
+ break;
+ case 72:
+ vindex2 = reader->getInt32();
+ break;
+ case 73:
+ vindex3 = reader->getInt32();
+ break;
+ case 74:
+ vindex4 = reader->getInt32();
+ break;
+ case 91:
+ identifier = reader->getInt32();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
@@ -787,107 +840,139 @@ auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 2:
- name = reader->getUtf8String();
- break;
- case 70:
- solid = reader->getInt32();
- break;
- case 71:
- associative = reader->getInt32();
- break;
- case 72: /*edge type*/
- if (ispol){ //if is polyline is a as_bulge flag
+ switch (code)
+ {
+ case 2:
+ name = reader->getUtf8String();
break;
- } else if (reader->getInt32() == 1){ //line
- addLine();
- } else if (reader->getInt32() == 2){ //arc
- addArc();
- } else if (reader->getInt32() == 3){ //elliptic arc
- addEllipse();
- } else if (reader->getInt32() == 4){ //spline
- addSpline();
- }
- break;
- case 10:
- if (pt) pt->basePoint.x = reader->getDouble();
- else if (pline) {
- plvert = pline->addVertex();
- plvert->x = reader->getDouble();
- }
- break;
- case 20:
- if (pt) pt->basePoint.y = reader->getDouble();
- else if (plvert) plvert ->y = reader->getDouble();
- break;
- case 11:
- if (line) line->secPoint.x = reader->getDouble();
- else if (ellipse) ellipse->secPoint.x = reader->getDouble();
- break;
- case 21:
- if (line) line->secPoint.y = reader->getDouble();
- else if (ellipse) ellipse->secPoint.y = reader->getDouble();
- break;
- case 40:
- if (arc) arc->radious = reader->getDouble();
- else if (ellipse) ellipse->ratio = reader->getDouble();
- break;
- case 41:
- scale = reader->getDouble();
- break;
- case 42:
- if (plvert) plvert ->bulge = reader->getDouble();
- break;
- case 50:
- if (arc) arc->staangle = reader->getDouble()/ARAD;
- else if (ellipse) ellipse->staparam = reader->getDouble()/ARAD;
- break;
- case 51:
- if (arc) arc->endangle = reader->getDouble()/ARAD;
- else if (ellipse) ellipse->endparam = reader->getDouble()/ARAD;
- break;
- case 52:
- angle = reader->getDouble();
- break;
- case 73:
- if (arc) arc->isccw = reader->getInt32();
- else if (pline) pline->flags = reader->getInt32();
- break;
- case 75:
- hstyle = reader->getInt32();
- break;
- case 76:
- hpattern = reader->getInt32();
- break;
- case 77:
- doubleflag = reader->getInt32();
- break;
- case 78:
- deflines = reader->getInt32();
- break;
- case 91:
- loopsnum = reader->getInt32();
- return DRW::reserve( looplist, loopsnum);
- case 92:
- loop = new DRW_HatchLoop(reader->getInt32());
- looplist.push_back(loop);
- if (reader->getInt32() & 2) {
- ispol = true;
+ case 70:
+ solid = reader->getInt32();
+ break;
+ case 71:
+ associative = reader->getInt32();
+ break;
+ case 72: /*edge type*/
+ if (ispol)
+ { // if is polyline is a as_bulge flag
+ break;
+ }
+ else if (reader->getInt32() == 1)
+ { // line
+ addLine();
+ }
+ else if (reader->getInt32() == 2)
+ { // arc
+ addArc();
+ }
+ else if (reader->getInt32() == 3)
+ { // elliptic arc
+ addEllipse();
+ }
+ else if (reader->getInt32() == 4)
+ { // spline
+ addSpline();
+ }
+ break;
+ case 10:
+ if (pt)
+ pt->basePoint.x = reader->getDouble();
+ else if (pline)
+ {
+ plvert = pline->addVertex();
+ plvert->x = reader->getDouble();
+ }
+ break;
+ case 20:
+ if (pt)
+ pt->basePoint.y = reader->getDouble();
+ else if (plvert)
+ plvert->y = reader->getDouble();
+ break;
+ case 11:
+ if (line)
+ line->secPoint.x = reader->getDouble();
+ else if (ellipse)
+ ellipse->secPoint.x = reader->getDouble();
+ break;
+ case 21:
+ if (line)
+ line->secPoint.y = reader->getDouble();
+ else if (ellipse)
+ ellipse->secPoint.y = reader->getDouble();
+ break;
+ case 40:
+ if (arc)
+ arc->radious = reader->getDouble();
+ else if (ellipse)
+ ellipse->ratio = reader->getDouble();
+ break;
+ case 41:
+ scale = reader->getDouble();
+ break;
+ case 42:
+ if (plvert)
+ plvert->bulge = reader->getDouble();
+ break;
+ case 50:
+ if (arc)
+ arc->staangle = reader->getDouble() / ARAD;
+ else if (ellipse)
+ ellipse->staparam = reader->getDouble() / ARAD;
+ break;
+ case 51:
+ if (arc)
+ arc->endangle = reader->getDouble() / ARAD;
+ else if (ellipse)
+ ellipse->endparam = reader->getDouble() / ARAD;
+ break;
+ case 52:
+ angle = reader->getDouble();
+ break;
+ case 73:
+ if (arc)
+ arc->isccw = reader->getInt32();
+ else if (pline)
+ pline->flags = reader->getInt32();
+ break;
+ case 75:
+ hstyle = reader->getInt32();
+ break;
+ case 76:
+ hpattern = reader->getInt32();
+ break;
+ case 77:
+ doubleflag = reader->getInt32();
+ break;
+ case 78:
+ deflines = reader->getInt32();
+ break;
+ case 91:
+ loopsnum = reader->getInt32();
+ return DRW::reserve(looplist, loopsnum);
+ case 92:
+ loop = new DRW_HatchLoop(reader->getInt32());
+ looplist.push_back(loop);
+ if (reader->getInt32() & 2)
+ {
+ ispol = true;
+ clearEntities();
+ pline = new DRW_LWPolyline;
+ loop->objlist.push_back(pline);
+ }
+ else
+ ispol = false;
+ break;
+ case 93:
+ if (pline)
+ pline->vertexnum = reader->getInt32();
+ else if (loop)
+ loop->numedges = reader->getInt32(); // aqui reserve
+ break;
+ case 98: // seed points ??
clearEntities();
- pline = new DRW_LWPolyline;
- loop->objlist.push_back(pline);
- } else ispol = false;
- break;
- case 93:
- if (pline) pline->vertexnum = reader->getInt32();
- else if (loop) loop->numedges = reader->getInt32();//aqui reserve
- break;
- case 98: //seed points ??
- clearEntities();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
@@ -895,92 +980,97 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 210:
- normalVec.x = reader->getDouble();
- break;
- case 220:
- normalVec.y = reader->getDouble();
- break;
- case 230:
- normalVec.z = reader->getDouble();
- break;
- case 12:
- tgStart.x = reader->getDouble();
- break;
- case 22:
- tgStart.y = reader->getDouble();
- break;
- case 32:
- tgStart.z = reader->getDouble();
- break;
- case 13:
- tgEnd.x = reader->getDouble();
- break;
- case 23:
- tgEnd.y = reader->getDouble();
- break;
- case 33:
- tgEnd.z = reader->getDouble();
- break;
- case 70:
- flags = reader->getInt32();
- break;
- case 71:
- degree = reader->getInt32();
- break;
- case 72:
- nknots = reader->getInt32();
- break;
- case 73:
- ncontrol = reader->getInt32();
- break;
- case 74:
- nfit = reader->getInt32();
- break;
- case 42:
- tolknot = reader->getDouble();
- break;
- case 43:
- tolcontrol = reader->getDouble();
- break;
- case 44:
- tolfit = reader->getDouble();
- break;
- case 10: {
- controlpoint = new DRW_Coord();
- controllist.push_back(controlpoint);
- controlpoint->x = reader->getDouble();
- break; }
- case 20:
- if(controlpoint != NULL)
- controlpoint->y = reader->getDouble();
- break;
- case 30:
- if(controlpoint != NULL)
- controlpoint->z = reader->getDouble();
- break;
- case 11: {
- fitpoint = new DRW_Coord();
- fitlist.push_back(fitpoint);
- fitpoint->x = reader->getDouble();
- break; }
- case 21:
- if(fitpoint != NULL)
- fitpoint->y = reader->getDouble();
- break;
- case 31:
- if(fitpoint != NULL)
- fitpoint->z = reader->getDouble();
- break;
- case 40:
- knotslist.push_back(reader->getDouble());
- break;
- case 41:
- weightlist.push_back(reader->getDouble());
- break;
- default:
- return DRW_Entity::parseCode(code, reader);
+ switch (code)
+ {
+ case 210:
+ normalVec.x = reader->getDouble();
+ break;
+ case 220:
+ normalVec.y = reader->getDouble();
+ break;
+ case 230:
+ normalVec.z = reader->getDouble();
+ break;
+ case 12:
+ tgStart.x = reader->getDouble();
+ break;
+ case 22:
+ tgStart.y = reader->getDouble();
+ break;
+ case 32:
+ tgStart.z = reader->getDouble();
+ break;
+ case 13:
+ tgEnd.x = reader->getDouble();
+ break;
+ case 23:
+ tgEnd.y = reader->getDouble();
+ break;
+ case 33:
+ tgEnd.z = reader->getDouble();
+ break;
+ case 70:
+ flags = reader->getInt32();
+ break;
+ case 71:
+ degree = reader->getInt32();
+ break;
+ case 72:
+ nknots = reader->getInt32();
+ break;
+ case 73:
+ ncontrol = reader->getInt32();
+ break;
+ case 74:
+ nfit = reader->getInt32();
+ break;
+ case 42:
+ tolknot = reader->getDouble();
+ break;
+ case 43:
+ tolcontrol = reader->getDouble();
+ break;
+ case 44:
+ tolfit = reader->getDouble();
+ break;
+ case 10:
+ {
+ controlpoint = new DRW_Coord();
+ controllist.push_back(controlpoint);
+ controlpoint->x = reader->getDouble();
+ break;
+ }
+ case 20:
+ if (controlpoint != NULL)
+ controlpoint->y = reader->getDouble();
+ break;
+ case 30:
+ if (controlpoint != NULL)
+ controlpoint->z = reader->getDouble();
+ break;
+ case 11:
+ {
+ fitpoint = new DRW_Coord();
+ fitlist.push_back(fitpoint);
+ fitpoint->x = reader->getDouble();
+ break;
+ }
+ case 21:
+ if (fitpoint != NULL)
+ fitpoint->y = reader->getDouble();
+ break;
+ case 31:
+ if (fitpoint != NULL)
+ fitpoint->z = reader->getDouble();
+ break;
+ case 40:
+ knotslist.push_back(reader->getDouble());
+ break;
+ case 41:
+ weightlist.push_back(reader->getDouble());
+ break;
+ default:
+ return DRW_Entity::parseCode(code, reader);
}
return true;
@@ -988,39 +1078,40 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 12:
- vVector.x = reader->getDouble();
- break;
- case 22:
- vVector.y = reader->getDouble();
- break;
- case 32:
- vVector.z = reader->getDouble();
- break;
- case 13:
- sizeu = reader->getDouble();
- break;
- case 23:
- sizev = reader->getDouble();
- break;
- case 340:
- ref = static_cast(reader->getHandleString());
- break;
- case 280:
- clip = reader->getInt32();
- break;
- case 281:
- brightness = reader->getInt32();
- break;
- case 282:
- contrast = reader->getInt32();
- break;
- case 283:
- fade = reader->getInt32();
- break;
- default:
- return DRW_Line::parseCode(code, reader);
+ switch (code)
+ {
+ case 12:
+ vVector.x = reader->getDouble();
+ break;
+ case 22:
+ vVector.y = reader->getDouble();
+ break;
+ case 32:
+ vVector.z = reader->getDouble();
+ break;
+ case 13:
+ sizeu = reader->getDouble();
+ break;
+ case 23:
+ sizev = reader->getDouble();
+ break;
+ case 340:
+ ref = static_cast(reader->getHandleString());
+ break;
+ case 280:
+ clip = reader->getInt32();
+ break;
+ case 281:
+ brightness = reader->getInt32();
+ break;
+ case 282:
+ contrast = reader->getInt32();
+ break;
+ case 283:
+ fade = reader->getInt32();
+ break;
+ default:
+ return DRW_Line::parseCode(code, reader);
}
return true;
@@ -1028,121 +1119,122 @@ auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 1:
- text = reader->getUtf8String();
- break;
- case 2:
- name = reader->getString();
- break;
- case 3:
- style = reader->getUtf8String();
- break;
- case 70:
- type = reader->getInt32();
- break;
- case 71:
- align = reader->getInt32();
- break;
- case 72:
- linesty = reader->getInt32();
- break;
- case 10:
- defPoint.x = reader->getDouble();
- break;
- case 20:
- defPoint.y = reader->getDouble();
- break;
- case 30:
- defPoint.z = reader->getDouble();
- break;
- case 11:
- textPoint.x = reader->getDouble();
- break;
- case 21:
- textPoint.y = reader->getDouble();
- break;
- case 31:
- textPoint.z = reader->getDouble();
- break;
- case 12:
- clonePoint.x = reader->getDouble();
- break;
- case 22:
- clonePoint.y = reader->getDouble();
- break;
- case 32:
- clonePoint.z = reader->getDouble();
- break;
- case 13:
- def1.x = reader->getDouble();
- break;
- case 23:
- def1.y = reader->getDouble();
- break;
- case 33:
- def1.z = reader->getDouble();
- break;
- case 14:
- def2.x = reader->getDouble();
- break;
- case 24:
- def2.y = reader->getDouble();
- break;
- case 34:
- def2.z = reader->getDouble();
- break;
- case 15:
- circlePoint.x = reader->getDouble();
- break;
- case 25:
- circlePoint.y = reader->getDouble();
- break;
- case 35:
- circlePoint.z = reader->getDouble();
- break;
- case 16:
- arcPoint.x = reader->getDouble();
- break;
- case 26:
- arcPoint.y = reader->getDouble();
- break;
- case 36:
- arcPoint.z = reader->getDouble();
- break;
- case 41:
- linefactor = reader->getDouble();
- break;
- case 42:
- actual = reader->getDouble();
- hasActual = not qFuzzyIsNull(actual);
- break;
- case 53:
- rot = reader->getDouble();
- break;
- case 50:
- angle = reader->getDouble();
- break;
- case 52:
- oblique = reader->getDouble();
- break;
- case 40:
- length = reader->getDouble();
- break;
- case 51:
- hdir = reader->getDouble();
- break;
- case 210:
- extPoint.x = reader->getDouble();
- break;
- case 220:
- extPoint.y = reader->getDouble();
- break;
- case 230:
- extPoint.z = reader->getDouble();
- break;
- default:
- return DRW_Entity::parseCode(code, reader);
+ switch (code)
+ {
+ case 1:
+ text = reader->getUtf8String();
+ break;
+ case 2:
+ name = reader->getString();
+ break;
+ case 3:
+ style = reader->getUtf8String();
+ break;
+ case 70:
+ type = reader->getInt32();
+ break;
+ case 71:
+ align = reader->getInt32();
+ break;
+ case 72:
+ linesty = reader->getInt32();
+ break;
+ case 10:
+ defPoint.x = reader->getDouble();
+ break;
+ case 20:
+ defPoint.y = reader->getDouble();
+ break;
+ case 30:
+ defPoint.z = reader->getDouble();
+ break;
+ case 11:
+ textPoint.x = reader->getDouble();
+ break;
+ case 21:
+ textPoint.y = reader->getDouble();
+ break;
+ case 31:
+ textPoint.z = reader->getDouble();
+ break;
+ case 12:
+ clonePoint.x = reader->getDouble();
+ break;
+ case 22:
+ clonePoint.y = reader->getDouble();
+ break;
+ case 32:
+ clonePoint.z = reader->getDouble();
+ break;
+ case 13:
+ def1.x = reader->getDouble();
+ break;
+ case 23:
+ def1.y = reader->getDouble();
+ break;
+ case 33:
+ def1.z = reader->getDouble();
+ break;
+ case 14:
+ def2.x = reader->getDouble();
+ break;
+ case 24:
+ def2.y = reader->getDouble();
+ break;
+ case 34:
+ def2.z = reader->getDouble();
+ break;
+ case 15:
+ circlePoint.x = reader->getDouble();
+ break;
+ case 25:
+ circlePoint.y = reader->getDouble();
+ break;
+ case 35:
+ circlePoint.z = reader->getDouble();
+ break;
+ case 16:
+ arcPoint.x = reader->getDouble();
+ break;
+ case 26:
+ arcPoint.y = reader->getDouble();
+ break;
+ case 36:
+ arcPoint.z = reader->getDouble();
+ break;
+ case 41:
+ linefactor = reader->getDouble();
+ break;
+ case 42:
+ actual = reader->getDouble();
+ hasActual = not qFuzzyIsNull(actual);
+ break;
+ case 53:
+ rot = reader->getDouble();
+ break;
+ case 50:
+ angle = reader->getDouble();
+ break;
+ case 52:
+ oblique = reader->getDouble();
+ break;
+ case 40:
+ length = reader->getDouble();
+ break;
+ case 51:
+ hdir = reader->getDouble();
+ break;
+ case 210:
+ extPoint.x = reader->getDouble();
+ break;
+ case 220:
+ extPoint.y = reader->getDouble();
+ break;
+ case 230:
+ extPoint.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Entity::parseCode(code, reader);
}
return true;
@@ -1150,91 +1242,94 @@ auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 3:
- style = reader->getUtf8String();
- break;
- case 71:
- arrow = reader->getInt32();
- break;
- case 72:
- leadertype = reader->getInt32();
- break;
- case 73:
- flag = reader->getInt32();
- break;
- case 74:
- hookline = reader->getInt32();
- break;
- case 75:
- hookflag = reader->getInt32();
- break;
- case 76:
- vertnum = reader->getInt32();
- break;
- case 77:
- coloruse = reader->getInt32();
- break;
- case 40:
- textheight = reader->getDouble();
- break;
- case 41:
- textwidth = reader->getDouble();
- break;
- case 10: {
- vertexpoint = new DRW_Coord();
- vertexlist.push_back(vertexpoint);
- vertexpoint->x = reader->getDouble();
- break; }
- case 20:
- if(vertexpoint != NULL)
- vertexpoint->y = reader->getDouble();
- break;
- case 30:
- if(vertexpoint != NULL)
- vertexpoint->z = reader->getDouble();
- break;
- case 340:
- annotHandle = static_cast(reader->getHandleString());
- break;
- case 210:
- extrusionPoint.x = reader->getDouble();
- break;
- case 220:
- extrusionPoint.y = reader->getDouble();
- break;
- case 230:
- extrusionPoint.z = reader->getDouble();
- break;
- case 211:
- horizdir.x = reader->getDouble();
- break;
- case 221:
- horizdir.y = reader->getDouble();
- break;
- case 231:
- horizdir.z = reader->getDouble();
- break;
- case 212:
- offsetblock.x = reader->getDouble();
- break;
- case 222:
- offsetblock.y = reader->getDouble();
- break;
- case 232:
- offsetblock.z = reader->getDouble();
- break;
- case 213:
- offsettext.x = reader->getDouble();
- break;
- case 223:
- offsettext.y = reader->getDouble();
- break;
- case 233:
- offsettext.z = reader->getDouble();
- break;
- default:
- return DRW_Entity::parseCode(code, reader);
+ switch (code)
+ {
+ case 3:
+ style = reader->getUtf8String();
+ break;
+ case 71:
+ arrow = reader->getInt32();
+ break;
+ case 72:
+ leadertype = reader->getInt32();
+ break;
+ case 73:
+ flag = reader->getInt32();
+ break;
+ case 74:
+ hookline = reader->getInt32();
+ break;
+ case 75:
+ hookflag = reader->getInt32();
+ break;
+ case 76:
+ vertnum = reader->getInt32();
+ break;
+ case 77:
+ coloruse = reader->getInt32();
+ break;
+ case 40:
+ textheight = reader->getDouble();
+ break;
+ case 41:
+ textwidth = reader->getDouble();
+ break;
+ case 10:
+ {
+ vertexpoint = new DRW_Coord();
+ vertexlist.push_back(vertexpoint);
+ vertexpoint->x = reader->getDouble();
+ break;
+ }
+ case 20:
+ if (vertexpoint != NULL)
+ vertexpoint->y = reader->getDouble();
+ break;
+ case 30:
+ if (vertexpoint != NULL)
+ vertexpoint->z = reader->getDouble();
+ break;
+ case 340:
+ annotHandle = static_cast(reader->getHandleString());
+ break;
+ case 210:
+ extrusionPoint.x = reader->getDouble();
+ break;
+ case 220:
+ extrusionPoint.y = reader->getDouble();
+ break;
+ case 230:
+ extrusionPoint.z = reader->getDouble();
+ break;
+ case 211:
+ horizdir.x = reader->getDouble();
+ break;
+ case 221:
+ horizdir.y = reader->getDouble();
+ break;
+ case 231:
+ horizdir.z = reader->getDouble();
+ break;
+ case 212:
+ offsetblock.x = reader->getDouble();
+ break;
+ case 222:
+ offsetblock.y = reader->getDouble();
+ break;
+ case 232:
+ offsetblock.z = reader->getDouble();
+ break;
+ case 213:
+ offsettext.x = reader->getDouble();
+ break;
+ case 223:
+ offsettext.y = reader->getDouble();
+ break;
+ case 233:
+ offsettext.z = reader->getDouble();
+ break;
+ default:
+ return DRW_Entity::parseCode(code, reader);
}
return true;
@@ -1242,27 +1337,30 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
{
- switch (code) {
- case 40:
- pswidth = reader->getDouble();
- break;
- case 41:
- psheight = reader->getDouble();
- break;
- case 68:
- vpstatus = reader->getInt32();
- break;
- case 69:
- vpID = reader->getInt32();
- break;
- case 12: {
- centerPX = reader->getDouble();
- break; }
- case 22:
- centerPY = reader->getDouble();
- break;
- default:
- return DRW_Point::parseCode(code, reader);
+ switch (code)
+ {
+ case 40:
+ pswidth = reader->getDouble();
+ break;
+ case 41:
+ psheight = reader->getDouble();
+ break;
+ case 68:
+ vpstatus = reader->getInt32();
+ break;
+ case 69:
+ vpID = reader->getInt32();
+ break;
+ case 12:
+ {
+ centerPX = reader->getDouble();
+ break;
+ }
+ case 22:
+ centerPY = reader->getDouble();
+ break;
+ default:
+ return DRW_Point::parseCode(code, reader);
}
return true;
diff --git a/src/libs/vdxf/libdxfrw/drw_interface.h b/src/libs/vdxf/libdxfrw/drw_interface.h
index 26c7eb463..a62bb6f50 100644
--- a/src/libs/vdxf/libdxfrw/drw_interface.h
+++ b/src/libs/vdxf/libdxfrw/drw_interface.h
@@ -16,8 +16,8 @@
#include
#include "drw_entities.h"
-#include "drw_objects.h"
#include "drw_header.h"
+#include "drw_objects.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@@ -34,27 +34,27 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
*
* @author Rallaz
*/
-class DRW_Interface {
+class DRW_Interface
+{
public:
- DRW_Interface() {
- }
+ DRW_Interface() {}
virtual ~DRW_Interface() = default;
/** Called when header is parsed. */
- virtual void addHeader(const DRW_Header *) { }
+ virtual void addHeader(const DRW_Header *) {}
/** Called for every line Type. */
- virtual void addLType(const DRW_LType &) { }
+ virtual void addLType(const DRW_LType &) {}
/** Called for every layer. */
- virtual void addLayer(const DRW_Layer &) { }
+ virtual void addLayer(const DRW_Layer &) {}
/** Called for every dim style. */
- virtual void addDimStyle(const DRW_Dimstyle &) { }
+ virtual void addDimStyle(const DRW_Dimstyle &) {}
/** Called for every VPORT table. */
- virtual void addVport(const DRW_Vport &) { }
+ virtual void addVport(const DRW_Vport &) {}
/** Called for every text style. */
- virtual void addTextStyle(const DRW_Textstyle &) { }
+ virtual void addTextStyle(const DRW_Textstyle &) {}
/** Called for every AppId entry. */
- virtual void addAppId(const DRW_AppId &) { }
+ virtual void addAppId(const DRW_AppId &) {}
/**
* Called for every block. Note: all entities added after this
@@ -62,143 +62,142 @@ public:
*
* @see endBlock()
*/
- virtual void addBlock(const DRW_Block &) { }
+ virtual void addBlock(const DRW_Block &) {}
/** Called to end the current block */
- virtual void endBlock() { }
+ virtual void endBlock() {}
/** Called for every point */
- virtual void addPoint(const DRW_Point &) { }
+ virtual void addPoint(const DRW_Point &) {}
/** Called for every line */
- virtual void addLine(const DRW_Line &) { }
+ virtual void addLine(const DRW_Line &) {}
/** Called for every ray */
- virtual void addRay(const DRW_Ray &) { }
+ virtual void addRay(const DRW_Ray &) {}
/** Called for every xline */
- virtual void addXline(const DRW_Xline &) { }
+ virtual void addXline(const DRW_Xline &) {}
/** Called for every arc */
- virtual void addArc(const DRW_Arc &) { }
+ virtual void addArc(const DRW_Arc &) {}
/** Called for every circle */
- virtual void addCircle(const DRW_Circle &) { }
+ virtual void addCircle(const DRW_Circle &) {}
/** Called for every ellipse */
- virtual void addEllipse(const DRW_Ellipse &) { }
+ virtual void addEllipse(const DRW_Ellipse &) {}
/** Called for every lwpolyline */
- virtual void addLWPolyline(const DRW_LWPolyline &) { }
+ virtual void addLWPolyline(const DRW_LWPolyline &) {}
/** Called for every polyline start */
- virtual void addPolyline(const DRW_Polyline &) { }
+ virtual void addPolyline(const DRW_Polyline &) {}
/** Called for every spline */
- virtual void addSpline(const DRW_Spline *) { }
+ virtual void addSpline(const DRW_Spline *) {}
- /** Called for every spline knot value */
- virtual void addKnot(const DRW_Entity &) { }
+ /** Called for every spline knot value */
+ virtual void addKnot(const DRW_Entity &) {}
/** Called for every insert. */
- virtual void addInsert(const DRW_Insert &) { }
+ virtual void addInsert(const DRW_Insert &) {}
/** Called for every trace start */
- virtual void addTrace(const DRW_Trace &) { }
+ virtual void addTrace(const DRW_Trace &) {}
/** Called for every 3dface start */
- virtual void add3dFace(const DRW_3Dface &) { }
+ virtual void add3dFace(const DRW_3Dface &) {}
/** Called for every solid start */
- virtual void addSolid(const DRW_Solid &) { }
-
+ virtual void addSolid(const DRW_Solid &) {}
/** Called for every Multi Text entity. */
- virtual void addMText(const DRW_MText &) { }
+ virtual void addMText(const DRW_MText &) {}
/** Called for every Text entity. */
- virtual void addText(const DRW_Text &) { }
+ virtual void addText(const DRW_Text &) {}
/**
* Called for every aligned dimension entity.
*/
- virtual void addDimAlign(const DRW_DimAligned *) { }
+ virtual void addDimAlign(const DRW_DimAligned *) {}
/**
* Called for every linear or rotated dimension entity.
*/
- virtual void addDimLinear(const DRW_DimLinear *) { }
+ virtual void addDimLinear(const DRW_DimLinear *) {}
- /**
+ /**
* Called for every radial dimension entity.
*/
- virtual void addDimRadial(const DRW_DimRadial *) { }
+ virtual void addDimRadial(const DRW_DimRadial *) {}
- /**
+ /**
* Called for every diametric dimension entity.
*/
- virtual void addDimDiametric(const DRW_DimDiametric *) { }
+ virtual void addDimDiametric(const DRW_DimDiametric *) {}
- /**
+ /**
* Called for every angular dimension (2 lines version) entity.
*/
- virtual void addDimAngular(const DRW_DimAngular *) { }
+ virtual void addDimAngular(const DRW_DimAngular *) {}
- /**
+ /**
* Called for every angular dimension (3 points version) entity.
*/
- virtual void addDimAngular3P(const DRW_DimAngular3p *) { }
+ virtual void addDimAngular3P(const DRW_DimAngular3p *) {}
/**
* Called for every ordinate dimension entity.
*/
- virtual void addDimOrdinate(const DRW_DimOrdinate *) { }
+ virtual void addDimOrdinate(const DRW_DimOrdinate *) {}
/**
- * Called for every leader start.
- */
- virtual void addLeader(const DRW_Leader *) { }
+ * Called for every leader start.
+ */
+ virtual void addLeader(const DRW_Leader *) {}
- /**
- * Called for every hatch entity.
- */
- virtual void addHatch(const DRW_Hatch *) { }
+ /**
+ * Called for every hatch entity.
+ */
+ virtual void addHatch(const DRW_Hatch *) {}
/**
* Called for every viewport entity.
*/
- virtual void addViewport(const DRW_Viewport &) { }
+ virtual void addViewport(const DRW_Viewport &) {}
/**
- * Called for every image entity.
- */
- virtual void addImage(const DRW_Image *) { }
+ * Called for every image entity.
+ */
+ virtual void addImage(const DRW_Image *) {}
- /**
- * Called for every image definition.
- */
- virtual void linkImage(const DRW_ImageDef *) { }
+ /**
+ * Called for every image definition.
+ */
+ virtual void linkImage(const DRW_ImageDef *) {}
/**
* Called for every comment in the DXF file (code 999).
*/
- virtual void addComment(const char *) { }
+ virtual void addComment(const char *) {}
/**
* Called for PLOTSETTINGS object definition.
*/
virtual void addPlotSettings(const DRW_PlotSettings *) {}
- virtual void writeHeader(DRW_Header &) { }
- virtual void writeBlocks() { }
- virtual void writeBlockRecords() { }
- virtual void writeEntities() { }
- virtual void writeLTypes() { }
- virtual void writeLayers() { }
- virtual void writeTextstyles() { }
- virtual void writeVports() { }
- virtual void writeDimstyles() { }
+ virtual void writeHeader(DRW_Header &) {}
+ virtual void writeBlocks() {}
+ virtual void writeBlockRecords() {}
+ virtual void writeEntities() {}
+ virtual void writeLTypes() {}
+ virtual void writeLayers() {}
+ virtual void writeTextstyles() {}
+ virtual void writeVports() {}
+ virtual void writeDimstyles() {}
virtual void writeObjects() {}
- virtual void writeAppId() { }
+ virtual void writeAppId() {}
};
QT_WARNING_POP
diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp
index 4f06abc4e..a89f94107 100644
--- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp
+++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp
@@ -10,18 +10,17 @@
** along with this program. If not, see . **
******************************************************************************/
-
#include "libdxfrw.h"
-#include
-#include
-#include
-#include
-#include
-#include
+#include "intern/drw_dbg.h"
#include "intern/drw_textcodec.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
-#include "intern/drw_dbg.h"
+#include
+#include
+#include
+#include
+#include
+#include
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@@ -37,45 +36,48 @@
secObjects
};*/
-dxfRW::dxfRW(const char* name)
- : version(),
- fileName(name),
- codePage(),
- binFile(),
- reader(nullptr),
- writer(nullptr),
- iface(),
- header(),
- nextentity(),
- entCount(),
- wlayer0(),
- dimstyleStd(),
- applyExt(false),
- writingBlock(),
- elParts(128), //parts number when convert ellipse to polyline
- blockMap(),
- imageDef(),
- currHandle()
+dxfRW::dxfRW(const char *name)
+ : version(),
+ fileName(name),
+ codePage(),
+ binFile(),
+ reader(nullptr),
+ writer(nullptr),
+ iface(),
+ header(),
+ nextentity(),
+ entCount(),
+ wlayer0(),
+ dimstyleStd(),
+ applyExt(false),
+ writingBlock(),
+ elParts(128), // parts number when convert ellipse to polyline
+ blockMap(),
+ imageDef(),
+ currHandle()
{
DRW_DBGSL(DRW_dbg::Level::None);
}
-dxfRW::~dxfRW(){
+dxfRW::~dxfRW()
+{
delete reader;
delete writer;
- for (std::vector::iterator it=imageDef.begin(); it!=imageDef.end(); ++it)
+ for (std::vector::iterator it = imageDef.begin(); it != imageDef.end(); ++it)
delete *it;
imageDef.clear();
}
-void dxfRW::setDebug(DRW::DebugLevel lvl){
- switch (lvl){
- case DRW::DebugLevel::Debug:
- DRW_DBGSL(DRW_dbg::Level::Debug);
- break;
- default:
- DRW_DBGSL(DRW_dbg::Level::None);
+void dxfRW::setDebug(DRW::DebugLevel lvl)
+{
+ switch (lvl)
+ {
+ case DRW::DebugLevel::Debug:
+ DRW_DBGSL(DRW_dbg::Level::Debug);
+ break;
+ default:
+ DRW_DBGSL(DRW_dbg::Level::None);
}
}
@@ -84,12 +86,14 @@ auto dxfRW::read(DRW_Interface *interface_, bool ext) -> bool
drw_assert(fileName.empty() == false);
applyExt = ext;
std::ifstream filestr;
- if (nullptr == interface_) {
+ if (nullptr == interface_)
+ {
return setError(DRW::BAD_UNKNOWN);
}
DRW_DBG("dxfRW::read 1def\n");
- filestr.open (fileName.c_str(), std::ios_base::in | std::ios::binary);
- if (!filestr.is_open() || !filestr.good()) {
+ filestr.open(fileName.c_str(), std::ios_base::in | std::ios::binary);
+ if (!filestr.is_open() || !filestr.good())
+ {
return setError(DRW::BAD_OPEN);
}
@@ -97,20 +101,23 @@ auto dxfRW::read(DRW_Interface *interface_, bool ext) -> bool
char line2[22] = "AutoCAD Binary DXF\r\n";
line2[20] = static_cast(26);
line2[21] = '\0';
- filestr.read (line, 22);
+ filestr.read(line, 22);
filestr.close();
iface = interface_;
DRW_DBG("dxfRW::read 2\n");
- if (strcmp(line, line2) == 0) {
- filestr.open (fileName.c_str(), std::ios_base::in | std::ios::binary);
+ if (strcmp(line, line2) == 0)
+ {
+ filestr.open(fileName.c_str(), std::ios_base::in | std::ios::binary);
binFile = true;
- //skip sentinel
- filestr.seekg (22, std::ios::beg);
+ // skip sentinel
+ filestr.seekg(22, std::ios::beg);
reader = new dxfReaderBinary(&filestr);
DRW_DBG("dxfRW::read binary file\n");
- } else {
+ }
+ else
+ {
binFile = false;
- filestr.open (fileName.c_str(), std::ios_base::in);
+ filestr.open(fileName.c_str(), std::ios_base::in);
reader = new dxfReaderAscii(&filestr);
}
@@ -131,14 +138,17 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
iface = interface_;
try
{
- if (binFile) {
- filestr.open (fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc);
- //write sentinel
+ if (binFile)
+ {
+ 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(26) << '\0';
writer = new dxfWriterBinary(&filestr);
DRW_DBG("dxfRW::read binary file\n");
- } else {
- filestr.open (fileName.c_str(), std::ios_base::out | std::ios::trunc);
+ }
+ else
+ {
+ filestr.open(fileName.c_str(), std::ios_base::out | std::ios::trunc);
writer = new dxfWriterAscii(&filestr);
std::string comm = std::string("dxfrw ") + std::string(DRW_VERSION);
writer->writeString(999, comm);
@@ -149,7 +159,8 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
entCount = FIRSTHANDLE;
header.write(writer, version);
writer->writeString(0, "ENDSEC");
- if (ver > DRW::AC1009) {
+ if (ver > DRW::AC1009)
+ {
writer->writeString(0, "SECTION");
writer->writeString(2, "CLASSES");
writer->writeString(0, "ENDSEC");
@@ -168,7 +179,8 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
iface->writeEntities();
writer->writeString(0, "ENDSEC");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "SECTION");
writer->writeString(2, "OBJECTS");
writeObjects();
@@ -178,7 +190,7 @@ auto dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool
filestr.flush();
filestr.close();
}
- catch(std::ofstream::failure &writeErr)
+ catch (std::ofstream::failure &writeErr)
{
errorString = writeErr.what();
delete writer;
@@ -218,26 +230,33 @@ auto dxfRW::writeEntity(DRW_Entity *ent) -> bool
writer->writeString(5, toHexStr(static_cast(ent->handle)));
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbEntity");
}
if (ent->space == 1)
writer->writeInt16(67, 1);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeUtf8String(8, ent->layer);
writer->writeUtf8String(6, ent->lineType);
- } else {
+ }
+ else
+ {
writer->writeUtf8Caps(8, ent->layer);
writer->writeUtf8Caps(6, ent->lineType);
}
writer->writeInt16(62, ent->color);
- if (version > DRW::AC1015 && ent->color24 >= 0) {
+ if (version > DRW::AC1015 && ent->color24 >= 0)
+ {
writer->writeInt32(420, ent->color24);
}
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(370, DRW_LW_Conv::lineWidth2dxfInt(ent->lWeight));
}
- if (version >= DRW::AC1014) {
+ if (version >= DRW::AC1014)
+ {
writeAppData(ent->appData);
}
return true;
@@ -245,25 +264,32 @@ auto dxfRW::writeEntity(DRW_Entity *ent) -> bool
auto dxfRW::writeAppData(const std::list> &appData) -> bool
{
- for(const auto& group : appData) {
- //Search for application name
+ for (const auto &group : appData)
+ {
+ // Search for application name
bool found = false;
- for(const auto& data : group) {
- if(data.code == 102 && data.type == DRW_Variant::STRING) {
+ for (const auto &data : group)
+ {
+ if (data.code == 102 && data.type == DRW_Variant::STRING)
+ {
writer->writeString(102, "{" + *(data.content.s));
found = true;
break;
}
}
- if(found) {
- for(const auto& data : group) {
- if(data.code == 102) {
+ if (found)
+ {
+ for (const auto &data : group)
+ {
+ if (data.code == 102)
+ {
continue;
}
- switch(data.type) {
+ switch (data.type)
+ {
case DRW_Variant::STRING:
writer->writeString(data.code, *(data.content.s));
break;
@@ -291,21 +317,25 @@ auto dxfRW::writeLineType(DRW_LType *ent) -> bool
{
std::string strname = ent->name;
- transform(strname.begin(), strname.end(), strname.begin(),::toupper);
-//do not write linetypes handled by library
- if (strname == "BYLAYER" || strname == "BYBLOCK" || strname == "CONTINUOUS") {
+ transform(strname.begin(), strname.end(), strname.begin(), ::toupper);
+ // do not write linetypes handled by library
+ if (strname == "BYLAYER" || strname == "BYBLOCK" || strname == "CONTINUOUS")
+ {
return true;
}
writer->writeString(0, "LTYPE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, toHexStr(++entCount));
- if (version > DRW::AC1012) {
+ if (version > DRW::AC1012)
+ {
writer->writeString(330, "5");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbLinetypeTableRecord");
writer->writeUtf8String(2, ent->name);
- } else
+ }
+ else
writer->writeUtf8Caps(2, ent->name);
writer->writeInt16(70, ent->flags);
writer->writeUtf8String(3, ent->desc);
@@ -314,9 +344,11 @@ auto dxfRW::writeLineType(DRW_LType *ent) -> bool
writer->writeInt16(73, ent->size);
writer->writeDouble(40, ent->length);
- for (unsigned int i = 0; i< ent->path.size(); i++){
+ for (unsigned int i = 0; i < ent->path.size(); i++)
+ {
writer->writeDouble(49, ent->path.at(i));
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeInt16(74, 0);
}
}
@@ -326,68 +358,87 @@ auto dxfRW::writeLineType(DRW_LType *ent) -> bool
auto dxfRW::writeLayer(DRW_Layer *ent) -> bool
{
writer->writeString(0, "LAYER");
- if (!wlayer0 && ent->name == "0") {
+ if (!wlayer0 && ent->name == "0")
+ {
wlayer0 = true;
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "10");
}
- } else {
- if (version > DRW::AC1009) {
+ }
+ else
+ {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, toHexStr(++entCount));
}
}
- if (version > DRW::AC1012) {
+ if (version > DRW::AC1012)
+ {
writer->writeString(330, "2");
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbLayerTableRecord");
writer->writeUtf8String(2, ent->name);
- } else {
+ }
+ else
+ {
writer->writeUtf8Caps(2, ent->name);
}
writer->writeInt16(70, ent->flags);
writer->writeInt16(62, ent->color);
- if (version > DRW::AC1015 && ent->color24 >= 0) {
+ if (version > DRW::AC1015 && ent->color24 >= 0)
+ {
writer->writeInt32(420, ent->color24);
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeUtf8String(6, ent->lineType);
- if (! ent->plotF)
+ if (!ent->plotF)
writer->writeBool(290, ent->plotF);
writer->writeInt16(370, DRW_LW_Conv::lineWidth2dxfInt(ent->lWeight));
writer->writeString(390, "F");
- } else
+ }
+ else
writer->writeUtf8Caps(6, ent->lineType);
- if (!ent->extData.empty()){
+ if (!ent->extData.empty())
+ {
writeExtData(ent->extData);
}
-// writer->writeString(347, "10012");
+ // writer->writeString(347, "10012");
return true;
}
auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
{
writer->writeString(0, "STYLE");
- if (!dimstyleStd) {
- //stringstream cause crash in OS/X, bug#3597944
- std::string name=ent->name;
+ if (!dimstyleStd)
+ {
+ // stringstream cause crash in OS/X, bug#3597944
+ std::string name = ent->name;
transform(name.begin(), name.end(), name.begin(), toupper);
if (name == "STANDARD")
dimstyleStd = true;
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, toHexStr(++entCount));
}
- if (version > DRW::AC1012) {
+ if (version > DRW::AC1012)
+ {
writer->writeString(330, "2");
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbTextStyleTableRecord");
writer->writeUtf8String(2, ent->name);
- } else {
+ }
+ else
+ {
writer->writeUtf8Caps(2, ent->name);
}
writer->writeInt16(70, ent->flags);
@@ -396,14 +447,17 @@ auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
writer->writeDouble(50, ent->oblique);
writer->writeInt16(71, ent->genFlag);
writer->writeDouble(42, ent->lastHeight);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeUtf8String(3, ent->font);
writer->writeUtf8String(4, ent->bigFont);
writer->writeUtf8String(1001, "ACAD");
writer->writeUtf8String(1000, ent->font);
if (ent->fontFamily != 0)
writer->writeInt32(1071, ent->fontFamily);
- } else {
+ }
+ else
+ {
writer->writeUtf8Caps(3, ent->font);
writer->writeUtf8Caps(4, ent->bigFont);
}
@@ -412,19 +466,22 @@ auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
auto dxfRW::writeVport(DRW_Vport *ent) -> bool
{
- if (!dimstyleStd) {
+ if (!dimstyleStd)
+ {
ent->name = "*ACTIVE";
dimstyleStd = true;
}
writer->writeString(0, "VPORT");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, toHexStr(++entCount));
if (version > DRW::AC1012)
writer->writeString(330, "2");
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbViewportTableRecord");
writer->writeUtf8String(2, ent->name);
- } else
+ }
+ else
writer->writeUtf8Caps(2, ent->name);
writer->writeInt16(70, ent->flags);
writer->writeDouble(10, ent->lowerLeft.x);
@@ -460,7 +517,8 @@ auto dxfRW::writeVport(DRW_Vport *ent) -> bool
writer->writeInt16(76, ent->grid);
writer->writeInt16(77, ent->snapStyle);
writer->writeInt16(78, ent->snapIsopair);
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(281, 0);
writer->writeInt16(65, 1);
writer->writeDouble(110, 0.0);
@@ -474,9 +532,10 @@ auto dxfRW::writeVport(DRW_Vport *ent) -> bool
writer->writeDouble(132, 0.0);
writer->writeInt16(79, 0);
writer->writeDouble(146, 0.0);
- if (version > DRW::AC1018) {
+ if (version > DRW::AC1018)
+ {
writer->writeString(348, "10020");
- writer->writeInt16(60, ent->gridBehavior);//v2007 undocummented see DRW_Vport class
+ writer->writeInt16(60, ent->gridBehavior); // v2007 undocummented see DRW_Vport class
writer->writeInt16(61, 5);
writer->writeBool(292, 1);
writer->writeInt16(282, 1);
@@ -492,36 +551,41 @@ auto dxfRW::writeVport(DRW_Vport *ent) -> bool
auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
{
writer->writeString(0, "DIMSTYLE");
- if (!dimstyleStd) {
+ if (!dimstyleStd)
+ {
std::string name = ent->name;
- std::transform(name.begin(), name.end(), name.begin(),::toupper);
+ std::transform(name.begin(), name.end(), name.begin(), ::toupper);
if (name == "STANDARD")
dimstyleStd = true;
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(105, toHexStr(++entCount));
}
- if (version > DRW::AC1012) {
+ if (version > DRW::AC1012)
+ {
writer->writeString(330, "A");
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbDimStyleTableRecord");
writer->writeUtf8String(2, ent->name);
- } else
+ }
+ else
writer->writeUtf8Caps(2, ent->name);
writer->writeInt16(70, ent->flags);
- if ( version <= DRW::AC1009 || !(ent->dimpost.empty()) )
+ if (version <= DRW::AC1009 || !(ent->dimpost.empty()))
writer->writeUtf8String(3, ent->dimpost);
- if ( version <= DRW::AC1009 || !(ent->dimapost.empty()) )
+ if (version <= DRW::AC1009 || !(ent->dimapost.empty()))
writer->writeUtf8String(4, ent->dimapost);
- if ( version <= DRW::AC1009 || !(ent->dimblk.empty()) )
+ if (version <= DRW::AC1009 || !(ent->dimblk.empty()))
writer->writeUtf8String(5, ent->dimblk);
- if ( version <= DRW::AC1009 || !(ent->dimblk1.empty()) )
+ if (version <= DRW::AC1009 || !(ent->dimblk1.empty()))
writer->writeUtf8String(6, ent->dimblk1);
- if ( version <= DRW::AC1009 || !(ent->dimblk2.empty()) )
+ if (version <= DRW::AC1009 || !(ent->dimblk2.empty()))
writer->writeUtf8String(7, ent->dimblk2);
writer->writeDouble(40, ent->dimscale);
writer->writeDouble(41, ent->dimasz);
@@ -540,7 +604,8 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeDouble(145, ent->dimtvp);
writer->writeDouble(146, ent->dimtfac);
writer->writeDouble(147, ent->dimgap);
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeDouble(148, ent->dimaltrnd);
}
writer->writeInt16(71, ent->dimtol);
@@ -551,7 +616,8 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeInt16(76, ent->dimse2);
writer->writeInt16(77, ent->dimtad);
writer->writeInt16(78, ent->dimzin);
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(79, ent->dimazin);
}
writer->writeInt16(170, ent->dimalt);
@@ -563,10 +629,12 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeInt16(176, ent->dimclrd);
writer->writeInt16(177, ent->dimclre);
writer->writeInt16(178, ent->dimclrt);
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(179, ent->dimadec);
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
if (version < DRW::AC1015)
writer->writeInt16(270, ent->dimunit);
writer->writeInt16(271, ent->dimdec);
@@ -575,13 +643,15 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeInt16(274, ent->dimalttd);
writer->writeInt16(275, ent->dimaunit);
}
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(276, ent->dimfrac);
writer->writeInt16(277, ent->dimlunit);
writer->writeInt16(278, ent->dimdsep);
writer->writeInt16(279, ent->dimtmove);
}
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeInt16(280, ent->dimjust);
writer->writeInt16(281, ent->dimsd1);
writer->writeInt16(282, ent->dimsd2);
@@ -593,13 +663,16 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeInt16(287, ent->dimfit);
writer->writeInt16(288, ent->dimupt);
}
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeInt16(289, ent->dimatfit);
}
- if (version > DRW::AC1009 && !ent->dimtxsty.empty()) {
+ if (version > DRW::AC1009 && !ent->dimtxsty.empty())
+ {
writer->writeUtf8String(340, ent->dimtxsty);
}
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeUtf8String(341, ent->dimldrblk);
writer->writeInt16(371, ent->dimlwd);
writer->writeInt16(372, ent->dimlwe);
@@ -610,20 +683,24 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
auto dxfRW::writeAppId(DRW_AppId *ent) -> bool
{
std::string strname = ent->name;
- transform(strname.begin(), strname.end(), strname.begin(),::toupper);
-//do not write mandatory ACAD appId, handled by library
+ transform(strname.begin(), strname.end(), strname.begin(), ::toupper);
+ // do not write mandatory ACAD appId, handled by library
if (strname == "ACAD")
return true;
writer->writeString(0, "APPID");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, toHexStr(++entCount));
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "9");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbRegAppTableRecord");
writer->writeUtf8String(2, ent->name);
- } else {
+ }
+ else
+ {
writer->writeUtf8Caps(2, ent->name);
}
writer->writeInt16(70, ent->flags);
@@ -634,12 +711,14 @@ auto dxfRW::writePoint(DRW_Point *ent) -> bool
{
writer->writeString(0, "POINT");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbPoint");
}
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
}
return true;
@@ -661,17 +740,21 @@ auto dxfRW::writeLine(DRW_Line *ent) -> bool
{
writer->writeString(0, "LINE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbLine");
}
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
writer->writeDouble(11, ent->secPoint.x);
writer->writeDouble(21, ent->secPoint.y);
writer->writeDouble(31, ent->secPoint.z);
- } else {
+ }
+ else
+ {
writer->writeDouble(11, ent->secPoint.x);
writer->writeDouble(21, ent->secPoint.y);
}
@@ -682,19 +765,23 @@ auto dxfRW::writeRay(DRW_Ray *ent) -> bool
{
writer->writeString(0, "RAY");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbRay");
}
DRW_Coord crd = ent->secPoint;
crd.unitize();
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
writer->writeDouble(11, crd.x);
writer->writeDouble(21, crd.y);
writer->writeDouble(31, crd.z);
- } else {
+ }
+ else
+ {
writer->writeDouble(11, crd.x);
writer->writeDouble(21, crd.y);
}
@@ -705,19 +792,23 @@ auto dxfRW::writeXline(DRW_Xline *ent) -> bool
{
writer->writeString(0, "XLINE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbXline");
}
DRW_Coord crd = ent->secPoint;
crd.unitize();
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
writer->writeDouble(11, crd.x);
writer->writeDouble(21, crd.y);
writer->writeDouble(31, crd.z);
- } else {
+ }
+ else
+ {
writer->writeDouble(11, crd.x);
writer->writeDouble(21, crd.y);
}
@@ -728,12 +819,14 @@ auto dxfRW::writeCircle(DRW_Circle *ent) -> bool
{
writer->writeString(0, "CIRCLE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbCircle");
}
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
}
writer->writeDouble(40, ent->radious);
@@ -744,31 +837,36 @@ auto dxfRW::writeArc(DRW_Arc *ent) -> bool
{
writer->writeString(0, "ARC");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbCircle");
}
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
- if (not qFuzzyIsNull(ent->basePoint.z)) {
+ if (not qFuzzyIsNull(ent->basePoint.z))
+ {
writer->writeDouble(30, ent->basePoint.z);
}
writer->writeDouble(40, ent->radious);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbArc");
}
- writer->writeDouble(50, ent->staangle*ARAD);
- writer->writeDouble(51, ent->endangle*ARAD);
+ writer->writeDouble(50, ent->staangle * ARAD);
+ writer->writeDouble(51, ent->endangle * ARAD);
return true;
}
auto dxfRW::writeEllipse(DRW_Ellipse *ent) -> bool
{
- //verify axis/ratio and params for full ellipse
+ // verify axis/ratio and params for full ellipse
ent->correctAxis();
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "ELLIPSE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbEllipse");
}
writer->writeDouble(10, ent->basePoint.x);
@@ -780,9 +878,11 @@ auto dxfRW::writeEllipse(DRW_Ellipse *ent) -> bool
writer->writeDouble(40, ent->ratio);
writer->writeDouble(41, ent->staparam);
writer->writeDouble(42, ent->endparam);
- } else {
+ }
+ else
+ {
DRW_Polyline pol;
- //RLZ: copy properties
+ // RLZ: copy properties
ent->toPolyline(&pol, elParts);
writePolyline(&pol);
}
@@ -793,7 +893,8 @@ auto dxfRW::writeTrace(DRW_Trace *ent) -> bool
{
writer->writeString(0, "TRACE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbTrace");
}
writer->writeDouble(10, ent->basePoint.x);
@@ -815,7 +916,8 @@ auto dxfRW::writeSolid(DRW_Solid *ent) -> bool
{
writer->writeString(0, "SOLID");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbTrace");
}
writer->writeDouble(10, ent->basePoint.x);
@@ -837,7 +939,8 @@ auto dxfRW::write3dface(DRW_3Dface *ent) -> bool
{
writer->writeString(0, "3DFACE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbFace");
}
writer->writeDouble(10, ent->basePoint.x);
@@ -858,10 +961,12 @@ auto dxfRW::write3dface(DRW_3Dface *ent) -> bool
auto dxfRW::writeLWPolyline(DRW_LWPolyline *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "LWPOLYLINE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbPolyline");
}
ent->vertexnum = static_cast(ent->vertlist.size());
@@ -872,7 +977,8 @@ auto dxfRW::writeLWPolyline(DRW_LWPolyline *ent) -> bool
writer->writeDouble(38, ent->elevation);
if (not qFuzzyIsNull(ent->thickness))
writer->writeDouble(39, ent->thickness);
- for (int i = 0; i< ent->vertexnum; i++){
+ for (int i = 0; i < ent->vertexnum; i++)
+ {
DRW_Vertex2D *v = ent->vertlist.at(static_cast(i));
writer->writeDouble(10, v->x);
writer->writeDouble(20, v->y);
@@ -883,8 +989,10 @@ auto dxfRW::writeLWPolyline(DRW_LWPolyline *ent) -> bool
if (not qFuzzyIsNull(v->bulge))
writer->writeDouble(42, v->bulge);
}
- } else {
- //RLZ: TODO convert lwpolyline in polyline (not exist in acad 12)
+ }
+ else
+ {
+ // RLZ: TODO convert lwpolyline in polyline (not exist in acad 12)
}
return true;
}
@@ -894,67 +1002,87 @@ auto dxfRW::writePolyline(DRW_Polyline *ent) -> bool
writer->writeString(0, "POLYLINE");
writeEntity(ent);
bool is3d = false;
- if (version > DRW::AC1009) {
- if (ent->flags & 8 || ent->flags & 16) {
+ if (version > DRW::AC1009)
+ {
+ if (ent->flags & 8 || ent->flags & 16)
+ {
writer->writeString(100, "AcDb3dPolyline");
is3d = true;
- } else {
+ }
+ else
+ {
writer->writeString(100, "AcDb2dPolyline");
}
- } else
+ }
+ else
writer->writeInt16(66, 1);
writer->writeDouble(10, 0.0);
writer->writeDouble(20, 0.0);
writer->writeDouble(30, ent->basePoint.z);
- if (not qFuzzyIsNull(ent->thickness)) {
+ if (not qFuzzyIsNull(ent->thickness))
+ {
writer->writeDouble(39, ent->thickness);
}
writer->writeInt16(70, ent->flags);
- if (not qFuzzyIsNull(ent->defstawidth)) {
+ if (not qFuzzyIsNull(ent->defstawidth))
+ {
writer->writeDouble(40, ent->defstawidth);
}
- if (not qFuzzyIsNull(ent->defendwidth)) {
+ if (not qFuzzyIsNull(ent->defendwidth))
+ {
writer->writeDouble(41, ent->defendwidth);
}
- if (ent->flags & 16 || ent->flags & 32) {
+ if (ent->flags & 16 || ent->flags & 32)
+ {
writer->writeInt16(71, ent->vertexcount);
writer->writeInt16(72, ent->facecount);
}
- if (ent->smoothM != 0) {
+ if (ent->smoothM != 0)
+ {
writer->writeInt16(73, ent->smoothM);
}
- if (ent->smoothN != 0) {
+ if (ent->smoothN != 0)
+ {
writer->writeInt16(74, ent->smoothN);
}
- if (ent->curvetype != 0) {
+ if (ent->curvetype != 0)
+ {
writer->writeInt16(75, ent->curvetype);
}
- DRW_Coord crd = ent->extPoint;
- if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not DRW_FuzzyComparePossibleNulls(crd.z, 1)) {
+ DRW_Coord crd = ent->extPoint;
+ if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not DRW_FuzzyComparePossibleNulls(crd.z, 1))
+ {
writer->writeDouble(210, crd.x);
writer->writeDouble(220, crd.y);
writer->writeDouble(230, crd.z);
}
size_t vertexnum = ent->vertlist.size();
- for (size_t i = 0; i < vertexnum; i++) {
+ for (size_t i = 0; i < vertexnum; i++)
+ {
DRW_Vertex *v = ent->vertlist.at(i);
writer->writeString(0, "VERTEX");
writeEntity(ent);
if (version > DRW::AC1009)
{
writer->writeString(100, "AcDbVertex");
- if(is3d) {
+ if (is3d)
+ {
writer->writeString(100, "AcDb3dPolylineVertex");
- } else {
+ }
+ else
+ {
writer->writeString(100, "AcDb2dVertex");
}
}
- if ( (v->flags & 128) && !(v->flags & 64) ) {
+ if ((v->flags & 128) && !(v->flags & 64))
+ {
writer->writeDouble(10, 0);
writer->writeDouble(20, 0);
writer->writeDouble(30, 0);
- } else {
+ }
+ else
+ {
writer->writeDouble(10, v->basePoint.x);
writer->writeDouble(20, v->basePoint.y);
writer->writeDouble(30, v->basePoint.z);
@@ -965,26 +1093,34 @@ auto dxfRW::writePolyline(DRW_Polyline *ent) -> bool
writer->writeDouble(41, v->endwidth);
if (not qFuzzyIsNull(v->bulge))
writer->writeDouble(42, v->bulge);
- if (v->flags != 0) {
+ if (v->flags != 0)
+ {
writer->writeInt16(70, ent->flags);
}
- if (v->flags & 2) {
+ if (v->flags & 2)
+ {
writer->writeDouble(50, v->tgdir);
}
- if ( v->flags & 128 ) {
- if (v->vindex1 != 0) {
+ if (v->flags & 128)
+ {
+ if (v->vindex1 != 0)
+ {
writer->writeInt16(71, v->vindex1);
}
- if (v->vindex2 != 0) {
+ if (v->vindex2 != 0)
+ {
writer->writeInt16(72, v->vindex2);
}
- if (v->vindex3 != 0) {
+ if (v->vindex3 != 0)
+ {
writer->writeInt16(73, v->vindex3);
}
- if (v->vindex4 != 0) {
+ if (v->vindex4 != 0)
+ {
writer->writeInt16(74, v->vindex4);
}
- if ( !(v->flags & 64) ) {
+ if (!(v->flags & 64))
+ {
writer->writeInt32(91, v->identifier);
}
}
@@ -996,10 +1132,12 @@ auto dxfRW::writePolyline(DRW_Polyline *ent) -> bool
auto dxfRW::writeSpline(DRW_Spline *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "SPLINE");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbSpline");
}
writer->writeDouble(210, ent->normalVec.x);
@@ -1012,28 +1150,34 @@ auto dxfRW::writeSpline(DRW_Spline *ent) -> bool
writer->writeInt16(74, ent->nfit);
writer->writeDouble(42, ent->tolknot);
writer->writeDouble(43, ent->tolcontrol);
- //RLZ: warning check if nknots are correct and ncontrol
- for (int i = 0; i< ent->nknots; i++){
+ // RLZ: warning check if nknots are correct and ncontrol
+ for (int i = 0; i < ent->nknots; i++)
+ {
writer->writeDouble(40, ent->knotslist.at(static_cast(i)));
}
- for (int i = 0; i< static_cast(ent->weightlist.size()); i++) {
+ for (int i = 0; i < static_cast(ent->weightlist.size()); i++)
+ {
writer->writeDouble(41, ent->weightlist.at(static_cast(i)));
}
- for (int i = 0; i< ent->ncontrol; i++){
+ for (int i = 0; i < ent->ncontrol; i++)
+ {
DRW_Coord *crd = ent->controllist.at(static_cast(i));
writer->writeDouble(10, crd->x);
writer->writeDouble(20, crd->y);
writer->writeDouble(30, crd->z);
}
- } else {
- //RLZ: TODO convert spline in polyline (not exist in acad 12)
+ }
+ else
+ {
+ // RLZ: TODO convert spline in polyline (not exist in acad 12)
}
return true;
}
auto dxfRW::writeHatch(DRW_Hatch *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "HATCH");
writeEntity(ent);
writer->writeString(100, "AcDbHatch");
@@ -1048,55 +1192,67 @@ auto dxfRW::writeHatch(DRW_Hatch *ent) -> bool
writer->writeInt16(71, ent->associative);
ent->loopsnum = static_cast(ent->looplist.size());
writer->writeInt16(91, ent->loopsnum);
- //write paths data
- for (int i = 0; i< ent->loopsnum; i++){
+ // write paths data
+ for (int i = 0; i < ent->loopsnum; i++)
+ {
DRW_HatchLoop *loop = ent->looplist.at(static_cast(i));
writer->writeInt16(92, loop->type);
- if ( (loop->type & 2) == 2){
- //RLZ: polyline boundary writeme
- } else {
- //boundary path
+ if ((loop->type & 2) == 2)
+ {
+ // RLZ: polyline boundary writeme
+ }
+ else
+ {
+ // boundary path
loop->update();
writer->writeInt16(93, loop->numedges);
- for (int j = 0; jnumedges; ++j) {
- switch ( (loop->objlist.at(static_cast(j)))->eType) {
- case DRW::LINE: {
- writer->writeInt16(72, 1);
- DRW_Line* l = static_cast(loop->objlist.at(static_cast(j)));
- writer->writeDouble(10, l->basePoint.x);
- writer->writeDouble(20, l->basePoint.y);
- writer->writeDouble(11, l->secPoint.x);
- writer->writeDouble(21, l->secPoint.y);
- break; }
- case DRW::ARC: {
- writer->writeInt16(72, 2);
- DRW_Arc* a = static_cast(loop->objlist.at(static_cast(j)));
- writer->writeDouble(10, a->basePoint.x);
- writer->writeDouble(20, a->basePoint.y);
- writer->writeDouble(40, a->radious);
- writer->writeDouble(50, a->staangle*ARAD);
- writer->writeDouble(51, a->endangle*ARAD);
- writer->writeInt16(73, a->isccw);
- break; }
- case DRW::ELLIPSE: {
- writer->writeInt16(72, 3);
- DRW_Ellipse* a = static_cast(loop->objlist.at(static_cast(j)));
- a->correctAxis();
- writer->writeDouble(10, a->basePoint.x);
- writer->writeDouble(20, a->basePoint.y);
- writer->writeDouble(11, a->secPoint.x);
- writer->writeDouble(21, a->secPoint.y);
- writer->writeDouble(40, a->ratio);
- writer->writeDouble(50, a->staparam*ARAD);
- writer->writeDouble(51, a->endparam*ARAD);
- writer->writeInt16(73, a->isccw);
- break; }
- case DRW::SPLINE:
- //RLZ: spline boundary writeme
-// writer->writeInt16(72, 4);
- break;
- default:
- break;
+ for (int j = 0; j < loop->numedges; ++j)
+ {
+ switch ((loop->objlist.at(static_cast(j)))->eType)
+ {
+ case DRW::LINE:
+ {
+ writer->writeInt16(72, 1);
+ DRW_Line *l = static_cast(loop->objlist.at(static_cast(j)));
+ writer->writeDouble(10, l->basePoint.x);
+ writer->writeDouble(20, l->basePoint.y);
+ writer->writeDouble(11, l->secPoint.x);
+ writer->writeDouble(21, l->secPoint.y);
+ break;
+ }
+ case DRW::ARC:
+ {
+ writer->writeInt16(72, 2);
+ DRW_Arc *a = static_cast(loop->objlist.at(static_cast(j)));
+ writer->writeDouble(10, a->basePoint.x);
+ writer->writeDouble(20, a->basePoint.y);
+ writer->writeDouble(40, a->radious);
+ writer->writeDouble(50, a->staangle * ARAD);
+ writer->writeDouble(51, a->endangle * ARAD);
+ writer->writeInt16(73, a->isccw);
+ break;
+ }
+ case DRW::ELLIPSE:
+ {
+ writer->writeInt16(72, 3);
+ DRW_Ellipse *a = static_cast(loop->objlist.at(static_cast(j)));
+ a->correctAxis();
+ writer->writeDouble(10, a->basePoint.x);
+ writer->writeDouble(20, a->basePoint.y);
+ writer->writeDouble(11, a->secPoint.x);
+ writer->writeDouble(21, a->secPoint.y);
+ writer->writeDouble(40, a->ratio);
+ writer->writeDouble(50, a->staparam * ARAD);
+ writer->writeDouble(51, a->endparam * ARAD);
+ writer->writeInt16(73, a->isccw);
+ break;
+ }
+ case DRW::SPLINE:
+ // RLZ: spline boundary writeme
+ // writer->writeInt16(72, 4);
+ break;
+ default:
+ break;
}
}
writer->writeInt16(97, 0);
@@ -1104,25 +1260,29 @@ auto dxfRW::writeHatch(DRW_Hatch *ent) -> bool
}
writer->writeInt16(75, ent->hstyle);
writer->writeInt16(76, ent->hpattern);
- if (!ent->solid){
+ if (!ent->solid)
+ {
writer->writeDouble(52, ent->angle);
writer->writeDouble(41, ent->scale);
writer->writeInt16(77, ent->doubleflag);
writer->writeInt16(78, ent->deflines);
}
-/* if (ent->deflines > 0){
- writer->writeInt16(78, ent->deflines);
- }*/
+ /* if (ent->deflines > 0){
+ writer->writeInt16(78, ent->deflines);
+ }*/
writer->writeInt32(98, 0);
- } else {
- //RLZ: TODO verify in acad12
+ }
+ else
+ {
+ // RLZ: TODO verify in acad12
}
return true;
}
auto dxfRW::writeLeader(DRW_Leader *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "LEADER");
writeEntity(ent);
writer->writeString(100, "AcDbLeader");
@@ -1136,24 +1296,29 @@ auto dxfRW::writeLeader(DRW_Leader *ent) -> bool
writer->writeDouble(41, ent->textwidth);
writer->writeDouble(76, ent->vertnum);
writer->writeDouble(76, static_cast(ent->vertexlist.size()));
- for (unsigned int i=0; ivertexlist.size(); i++) {
+ for (unsigned int i = 0; i < ent->vertexlist.size(); i++)
+ {
DRW_Coord *vert = ent->vertexlist.at(i);
writer->writeDouble(10, vert->x);
writer->writeDouble(20, vert->y);
writer->writeDouble(30, vert->z);
}
- } else {
- //RLZ: todo not supported by acad 12 saved as unnamed block
+ }
+ else
+ {
+ // RLZ: todo not supported by acad 12 saved as unnamed block
}
return true;
}
auto dxfRW::writeDimension(DRW_Dimension *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "DIMENSION");
writeEntity(ent);
writer->writeString(100, "AcDbDimension");
- if (!ent->getName().empty()){
+ if (!ent->getName().empty())
+ {
writer->writeString(2, ent->getName());
}
writer->writeDouble(10, ent->getDefPoint().x);
@@ -1162,110 +1327,127 @@ auto dxfRW::writeDimension(DRW_Dimension *ent) -> bool
writer->writeDouble(11, ent->getTextPoint().x);
writer->writeDouble(21, ent->getTextPoint().y);
writer->writeDouble(31, ent->getTextPoint().z);
- if ( !(ent->type & 32))
- ent->type = ent->type +32;
+ if (!(ent->type & 32))
+ ent->type = ent->type + 32;
writer->writeInt16(70, ent->type);
- if ( !(ent->getText().empty()) )
+ if (!(ent->getText().empty()))
writer->writeUtf8String(1, ent->getText());
writer->writeInt16(71, ent->getAlign());
- if ( ent->getTextLineStyle() != 1)
+ if (ent->getTextLineStyle() != 1)
writer->writeInt16(72, ent->getTextLineStyle());
- if ( not DRW_FuzzyComparePossibleNulls(ent->getTextLineFactor(), 1))
+ if (not DRW_FuzzyComparePossibleNulls(ent->getTextLineFactor(), 1))
writer->writeDouble(41, ent->getTextLineFactor());
writer->writeUtf8String(3, ent->getStyle());
- if ( not qFuzzyIsNull(ent->getTextLineFactor()))
+ if (not qFuzzyIsNull(ent->getTextLineFactor()))
writer->writeDouble(53, ent->getDir());
writer->writeDouble(210, ent->getExtrusion().x);
writer->writeDouble(220, ent->getExtrusion().y);
writer->writeDouble(230, ent->getExtrusion().z);
- if ( ent->hasActualMeasurement())
+ if (ent->hasActualMeasurement())
writer->writeDouble(42, ent->getActualMeasurement());
- switch (ent->eType) {
- case DRW::DIMALIGNED:
- case DRW::DIMLINEAR: {
- DRW_DimAligned * dd = static_cast(ent);
- writer->writeString(100, "AcDbAlignedDimension");
- DRW_Coord crd = dd->getClonepoint();
- if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not qFuzzyIsNull(crd.z)) {
- writer->writeDouble(12, crd.x);
- writer->writeDouble(22, crd.y);
- writer->writeDouble(32, crd.z);
+ switch (ent->eType)
+ {
+ case DRW::DIMALIGNED:
+ case DRW::DIMLINEAR:
+ {
+ DRW_DimAligned *dd = static_cast(ent);
+ writer->writeString(100, "AcDbAlignedDimension");
+ DRW_Coord crd = dd->getClonepoint();
+ if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not qFuzzyIsNull(crd.z))
+ {
+ writer->writeDouble(12, crd.x);
+ writer->writeDouble(22, crd.y);
+ writer->writeDouble(32, crd.z);
+ }
+ writer->writeDouble(13, dd->getDef1Point().x);
+ writer->writeDouble(23, dd->getDef1Point().y);
+ writer->writeDouble(33, dd->getDef1Point().z);
+ writer->writeDouble(14, dd->getDef2Point().x);
+ writer->writeDouble(24, dd->getDef2Point().y);
+ writer->writeDouble(34, dd->getDef2Point().z);
+ if (ent->eType == DRW::DIMLINEAR)
+ {
+ DRW_DimLinear *dl = static_cast(ent);
+ if (not qFuzzyIsNull(dl->getAngle()))
+ writer->writeDouble(50, dl->getAngle());
+ if (not qFuzzyIsNull(dl->getOblique()))
+ writer->writeDouble(52, dl->getOblique());
+ writer->writeString(100, "AcDbRotatedDimension");
+ }
+ break;
}
- writer->writeDouble(13, dd->getDef1Point().x);
- writer->writeDouble(23, dd->getDef1Point().y);
- writer->writeDouble(33, dd->getDef1Point().z);
- writer->writeDouble(14, dd->getDef2Point().x);
- writer->writeDouble(24, dd->getDef2Point().y);
- writer->writeDouble(34, dd->getDef2Point().z);
- if (ent->eType == DRW::DIMLINEAR) {
- DRW_DimLinear * dl = static_cast(ent);
- if (not qFuzzyIsNull(dl->getAngle()))
- writer->writeDouble(50, dl->getAngle());
- if (not qFuzzyIsNull(dl->getOblique()))
- writer->writeDouble(52, dl->getOblique());
- writer->writeString(100, "AcDbRotatedDimension");
+ case DRW::DIMRADIAL:
+ {
+ DRW_DimRadial *dd = static_cast(ent);
+ writer->writeString(100, "AcDbRadialDimension");
+ writer->writeDouble(15, dd->getDiameterPoint().x);
+ writer->writeDouble(25, dd->getDiameterPoint().y);
+ writer->writeDouble(35, dd->getDiameterPoint().z);
+ writer->writeDouble(40, dd->getLeaderLength());
+ break;
}
- break; }
- case DRW::DIMRADIAL: {
- DRW_DimRadial * dd = static_cast(ent);
- writer->writeString(100, "AcDbRadialDimension");
- writer->writeDouble(15, dd->getDiameterPoint().x);
- writer->writeDouble(25, dd->getDiameterPoint().y);
- writer->writeDouble(35, dd->getDiameterPoint().z);
- writer->writeDouble(40, dd->getLeaderLength());
- break; }
- case DRW::DIMDIAMETRIC: {
- DRW_DimDiametric * dd = static_cast(ent);
- writer->writeString(100, "AcDbDiametricDimension");
- writer->writeDouble(15, dd->getDiameter1Point().x);
- writer->writeDouble(25, dd->getDiameter1Point().y);
- writer->writeDouble(35, dd->getDiameter1Point().z);
- writer->writeDouble(40, dd->getLeaderLength());
- break; }
- case DRW::DIMANGULAR: {
- DRW_DimAngular * dd = static_cast(ent);
- writer->writeString(100, "AcDb2LineAngularDimension");
- writer->writeDouble(13, dd->getFirstLine1().x);
- writer->writeDouble(23, dd->getFirstLine1().y);
- writer->writeDouble(33, dd->getFirstLine1().z);
- writer->writeDouble(14, dd->getFirstLine2().x);
- writer->writeDouble(24, dd->getFirstLine2().y);
- writer->writeDouble(34, dd->getFirstLine2().z);
- writer->writeDouble(15, dd->getSecondLine1().x);
- writer->writeDouble(25, dd->getSecondLine1().y);
- writer->writeDouble(35, dd->getSecondLine1().z);
- writer->writeDouble(16, dd->getDimPoint().x);
- writer->writeDouble(26, dd->getDimPoint().y);
- writer->writeDouble(36, dd->getDimPoint().z);
- break; }
- case DRW::DIMANGULAR3P: {
- DRW_DimAngular3p * dd = static_cast(ent);
- writer->writeDouble(13, dd->getFirstLine().x);
- writer->writeDouble(23, dd->getFirstLine().y);
- writer->writeDouble(33, dd->getFirstLine().z);
- writer->writeDouble(14, dd->getSecondLine().x);
- writer->writeDouble(24, dd->getSecondLine().y);
- writer->writeDouble(34, dd->getSecondLine().z);
- writer->writeDouble(15, dd->getVertexPoint().x);
- writer->writeDouble(25, dd->getVertexPoint().y);
- writer->writeDouble(35, dd->getVertexPoint().z);
- break; }
- case DRW::DIMORDINATE: {
- DRW_DimOrdinate * dd = static_cast(ent);
- writer->writeString(100, "AcDbOrdinateDimension");
- writer->writeDouble(13, dd->getFirstLine().x);
- writer->writeDouble(23, dd->getFirstLine().y);
- writer->writeDouble(33, dd->getFirstLine().z);
- writer->writeDouble(14, dd->getSecondLine().x);
- writer->writeDouble(24, dd->getSecondLine().y);
- writer->writeDouble(34, dd->getSecondLine().z);
- break; }
- default:
- break;
+ case DRW::DIMDIAMETRIC:
+ {
+ DRW_DimDiametric *dd = static_cast(ent);
+ writer->writeString(100, "AcDbDiametricDimension");
+ writer->writeDouble(15, dd->getDiameter1Point().x);
+ writer->writeDouble(25, dd->getDiameter1Point().y);
+ writer->writeDouble(35, dd->getDiameter1Point().z);
+ writer->writeDouble(40, dd->getLeaderLength());
+ break;
+ }
+ case DRW::DIMANGULAR:
+ {
+ DRW_DimAngular *dd = static_cast(ent);
+ writer->writeString(100, "AcDb2LineAngularDimension");
+ writer->writeDouble(13, dd->getFirstLine1().x);
+ writer->writeDouble(23, dd->getFirstLine1().y);
+ writer->writeDouble(33, dd->getFirstLine1().z);
+ writer->writeDouble(14, dd->getFirstLine2().x);
+ writer->writeDouble(24, dd->getFirstLine2().y);
+ writer->writeDouble(34, dd->getFirstLine2().z);
+ writer->writeDouble(15, dd->getSecondLine1().x);
+ writer->writeDouble(25, dd->getSecondLine1().y);
+ writer->writeDouble(35, dd->getSecondLine1().z);
+ writer->writeDouble(16, dd->getDimPoint().x);
+ writer->writeDouble(26, dd->getDimPoint().y);
+ writer->writeDouble(36, dd->getDimPoint().z);
+ break;
+ }
+ case DRW::DIMANGULAR3P:
+ {
+ DRW_DimAngular3p *dd = static_cast(ent);
+ writer->writeDouble(13, dd->getFirstLine().x);
+ writer->writeDouble(23, dd->getFirstLine().y);
+ writer->writeDouble(33, dd->getFirstLine().z);
+ writer->writeDouble(14, dd->getSecondLine().x);
+ writer->writeDouble(24, dd->getSecondLine().y);
+ writer->writeDouble(34, dd->getSecondLine().z);
+ writer->writeDouble(15, dd->getVertexPoint().x);
+ writer->writeDouble(25, dd->getVertexPoint().y);
+ writer->writeDouble(35, dd->getVertexPoint().z);
+ break;
+ }
+ case DRW::DIMORDINATE:
+ {
+ DRW_DimOrdinate *dd = static_cast(ent);
+ writer->writeString(100, "AcDbOrdinateDimension");
+ writer->writeDouble(13, dd->getFirstLine().x);
+ writer->writeDouble(23, dd->getFirstLine().y);
+ writer->writeDouble(33, dd->getFirstLine().z);
+ writer->writeDouble(14, dd->getSecondLine().x);
+ writer->writeDouble(24, dd->getSecondLine().y);
+ writer->writeDouble(34, dd->getSecondLine().z);
+ break;
+ }
+ default:
+ break;
}
- } else {
- //RLZ: todo not supported by acad 12 saved as unnamed block
+ }
+ else
+ {
+ // RLZ: todo not supported by acad 12 saved as unnamed block
}
return true;
}
@@ -1279,10 +1461,12 @@ auto dxfRW::writeInsert(DRW_Insert *ent) -> bool
{
writer->writeString(0, "INSERT");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbBlockReference");
writer->writeUtf8String(2, ent->name);
- } else
+ }
+ else
writer->writeUtf8Caps(2, ent->name);
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
@@ -1290,7 +1474,7 @@ auto dxfRW::writeInsert(DRW_Insert *ent) -> bool
writer->writeDouble(41, ent->xscale);
writer->writeDouble(42, ent->yscale);
writer->writeDouble(43, ent->zscale);
- writer->writeDouble(50, (ent->angle)*ARAD); //in dxf angle is writed in degrees
+ writer->writeDouble(50, (ent->angle) * ARAD); // in dxf angle is writed in degrees
writer->writeInt16(70, ent->colcount);
writer->writeInt16(71, ent->rowcount);
writer->writeDouble(44, ent->colspace);
@@ -1302,10 +1486,11 @@ auto dxfRW::writeText(DRW_Text *ent) -> bool
{
writer->writeString(0, "TEXT");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbText");
}
-// writer->writeDouble(39, ent->thickness);
+ // writer->writeDouble(39, ent->thickness);
writer->writeDouble(10, ent->basePoint.x);
writer->writeDouble(20, ent->basePoint.y);
writer->writeDouble(30, ent->basePoint.z);
@@ -1319,10 +1504,12 @@ auto dxfRW::writeText(DRW_Text *ent) -> bool
else
writer->writeUtf8Caps(7, ent->style);
writer->writeInt16(71, ent->textgen);
- if (ent->alignH != DRW_Text::HLeft) {
+ if (ent->alignH != DRW_Text::HLeft)
+ {
writer->writeInt16(72, ent->alignH);
}
- if (ent->alignH != DRW_Text::HLeft || ent->alignV != DRW_Text::VBaseLine) {
+ if (ent->alignH != DRW_Text::HLeft || ent->alignV != DRW_Text::VBaseLine)
+ {
writer->writeDouble(11, ent->secPoint.x);
writer->writeDouble(21, ent->secPoint.y);
writer->writeDouble(31, ent->secPoint.z);
@@ -1330,10 +1517,12 @@ auto dxfRW::writeText(DRW_Text *ent) -> bool
writer->writeDouble(210, ent->extPoint.x);
writer->writeDouble(220, ent->extPoint.y);
writer->writeDouble(230, ent->extPoint.z);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbText");
}
- if (ent->alignV != DRW_Text::VBaseLine) {
+ if (ent->alignV != DRW_Text::VBaseLine)
+ {
writer->writeInt16(73, ent->alignV);
}
return true;
@@ -1341,7 +1530,8 @@ auto dxfRW::writeText(DRW_Text *ent) -> bool
auto dxfRW::writeMText(DRW_MText *ent) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "MTEXT");
writeEntity(ent);
writer->writeString(100, "AcDbMText");
@@ -1355,9 +1545,10 @@ auto dxfRW::writeMText(DRW_MText *ent) -> bool
std::string text = writer->fromUtf8String(ent->text);
int i;
- for(i =0; (text.size()-static_cast(i)) > 250; ) {
+ for (i = 0; (text.size() - static_cast(i)) > 250;)
+ {
writer->writeString(3, text.substr(static_cast(i), 250));
- i +=250;
+ i += 250;
}
writer->writeString(1, text.substr(static_cast(i)));
writer->writeString(7, ent->style);
@@ -1367,9 +1558,11 @@ auto dxfRW::writeMText(DRW_MText *ent) -> bool
writer->writeDouble(50, ent->angle);
writer->writeInt16(73, ent->alignV);
writer->writeDouble(44, ent->interlin);
-//RLZ ... 11, 21, 31 needed?
- } else {
- //RLZ: TODO convert mtext in text lines (not exist in acad 12)
+ // RLZ ... 11, 21, 31 needed?
+ }
+ else
+ {
+ // RLZ: TODO convert mtext in text lines (not exist in acad 12)
}
return true;
}
@@ -1378,7 +1571,8 @@ auto dxfRW::writeViewport(DRW_Viewport *ent) -> bool
{
writer->writeString(0, "VIEWPORT");
writeEntity(ent);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbViewport");
}
writer->writeDouble(10, ent->basePoint.x);
@@ -1389,23 +1583,27 @@ auto dxfRW::writeViewport(DRW_Viewport *ent) -> bool
writer->writeDouble(41, ent->psheight);
writer->writeInt16(68, ent->vpstatus);
writer->writeInt16(69, ent->vpID);
- writer->writeDouble(12, ent->centerPX);//RLZ: verify if exist in V12
- writer->writeDouble(22, ent->centerPY);//RLZ: verify if exist in V12
+ writer->writeDouble(12, ent->centerPX); // RLZ: verify if exist in V12
+ writer->writeDouble(22, ent->centerPY); // RLZ: verify if exist in V12
return true;
}
auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef *
{
- if (version > DRW::AC1009) {
- //search if exist imagedef with this mane (image inserted more than 1 time)
- //RLZ: imagedef_reactor seem needed to read in acad
+ if (version > DRW::AC1009)
+ {
+ // search if exist imagedef with this mane (image inserted more than 1 time)
+ // RLZ: imagedef_reactor seem needed to read in acad
DRW_ImageDef *id = NULL;
- for (unsigned int i=0; iname == name ) {
+ for (unsigned int i = 0; i < imageDef.size(); i++)
+ {
+ if (imageDef.at(i)->name == name)
+ {
id = imageDef.at(i);
}
}
- if (id == NULL) {
+ if (id == NULL)
+ {
id = new DRW_ImageDef();
imageDef.push_back(id);
id->handle = static_cast(++entCount);
@@ -1437,24 +1635,27 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef
id->reactors[idReactor] = toHexStr(static_cast(ent->handle));
return id;
}
- return NULL; //not exist in acad 12
+ return NULL; // not exist in acad 12
}
auto dxfRW::writeBlockRecord(std::string name) -> bool
{
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "BLOCK_RECORD");
writer->writeString(5, toHexStr(++entCount));
blockMap[name] = entCount;
- entCount = 2+entCount;//reserve 2 for BLOCK & ENDBLOCK
- if (version > DRW::AC1014) {
+ entCount = 2 + entCount; // reserve 2 for BLOCK & ENDBLOCK
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "1");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbBlockTableRecord");
writer->writeUtf8String(2, name);
- if (version > DRW::AC1018) {
+ if (version > DRW::AC1018)
+ {
// writer->writeInt16(340, 22);
writer->writeInt16(70, 0);
writer->writeInt16(280, 1);
@@ -1466,40 +1667,49 @@ auto dxfRW::writeBlockRecord(std::string name) -> bool
auto dxfRW::writeBlock(DRW_Block *bk) -> bool
{
- if (writingBlock) {
+ if (writingBlock)
+ {
writer->writeString(0, "ENDBLK");
- if (version > DRW::AC1009) {
- writer->writeString(5, toHexStr(currHandle+2));
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1009)
+ {
+ writer->writeString(5, toHexStr(currHandle + 2));
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, toHexStr(currHandle));
}
writer->writeString(100, "AcDbEntity");
}
writer->writeString(8, bk->layer);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbBlockEnd");
}
}
writingBlock = true;
writer->writeString(0, "BLOCK");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
currHandle = (*(blockMap.find(bk->name))).second;
- writer->writeString(5, toHexStr(currHandle+1));
- if (version > DRW::AC1014) {
+ writer->writeString(5, toHexStr(currHandle + 1));
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, toHexStr(currHandle));
}
writer->writeString(100, "AcDbEntity");
}
writer->writeString(8, bk->layer);
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(100, "AcDbBlockBegin");
writer->writeUtf8String(2, bk->name);
- } else
+ }
+ else
writer->writeUtf8Caps(2, bk->name);
writer->writeInt16(70, bk->flags);
writer->writeDouble(10, bk->basePoint.x);
writer->writeDouble(20, bk->basePoint.y);
- if (not qFuzzyIsNull(bk->basePoint.z)) {
+ if (not qFuzzyIsNull(bk->basePoint.z))
+ {
writer->writeDouble(30, bk->basePoint.z);
}
if (version > DRW::AC1009)
@@ -1515,45 +1725,53 @@ auto dxfRW::writeTables() -> bool
{
writer->writeString(0, "TABLE");
writer->writeString(2, "VPORT");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "8");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 1); //end table def
-/*** VPORT ***/
- dimstyleStd =false;
+ writer->writeInt16(70, 1); // end table def
+ /*** VPORT ***/
+ dimstyleStd = false;
iface->writeVports();
- if (!dimstyleStd) {
+ if (!dimstyleStd)
+ {
DRW_Vport portact;
portact.name = "*ACTIVE";
writeVport(&portact);
}
writer->writeString(0, "ENDTAB");
-/*** LTYPE ***/
+ /*** LTYPE ***/
writer->writeString(0, "TABLE");
writer->writeString(2, "LTYPE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "5");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 4); //end table def
-//Mandatory linetypes
+ writer->writeInt16(70, 4); // end table def
+ // Mandatory linetypes
writer->writeString(0, "LTYPE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "14");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "5");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbLinetypeTableRecord");
writer->writeString(2, "ByBlock");
- } else
+ }
+ else
writer->writeString(2, "BYBLOCK");
writer->writeInt16(70, 0);
writer->writeString(3, "");
@@ -1562,15 +1780,18 @@ auto dxfRW::writeTables() -> bool
writer->writeDouble(40, 0.0);
writer->writeString(0, "LTYPE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "15");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "5");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbLinetypeTableRecord");
writer->writeString(2, "ByLayer");
- } else
+ }
+ else
writer->writeString(2, "BYLAYER");
writer->writeInt16(70, 0);
writer->writeString(3, "");
@@ -1579,15 +1800,19 @@ auto dxfRW::writeTables() -> bool
writer->writeDouble(40, 0.0);
writer->writeString(0, "LTYPE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "16");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "5");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbLinetypeTableRecord");
writer->writeString(2, "Continuous");
- } else {
+ }
+ else
+ {
writer->writeString(2, "CONTINUOUS");
}
writer->writeInt16(70, 0);
@@ -1595,42 +1820,48 @@ auto dxfRW::writeTables() -> bool
writer->writeInt16(72, 65);
writer->writeInt16(73, 0);
writer->writeDouble(40, 0.0);
-//Application linetypes
+ // Application linetypes
iface->writeLTypes();
writer->writeString(0, "ENDTAB");
-/*** LAYER ***/
+ /*** LAYER ***/
writer->writeString(0, "TABLE");
writer->writeString(2, "LAYER");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "2");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 1); //end table def
- wlayer0 =false;
+ writer->writeInt16(70, 1); // end table def
+ wlayer0 = false;
iface->writeLayers();
- if (!wlayer0 && version > DRW::AC1009) {
+ if (!wlayer0 && version > DRW::AC1009)
+ {
DRW_Layer lay0;
lay0.name = '0';
writeLayer(&lay0);
}
writer->writeString(0, "ENDTAB");
-/*** STYLE ***/
+ /*** STYLE ***/
writer->writeString(0, "TABLE");
writer->writeString(2, "STYLE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "3");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 3); //end table def
- dimstyleStd =false;
+ writer->writeInt16(70, 3); // end table def
+ dimstyleStd = false;
iface->writeTextstyles();
- if (!dimstyleStd) {
+ if (!dimstyleStd)
+ {
DRW_Textstyle tsty;
tsty.name = "Standard";
writeTextstyle(&tsty);
@@ -1639,42 +1870,50 @@ auto dxfRW::writeTables() -> bool
writer->writeString(0, "TABLE");
writer->writeString(2, "VIEW");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "6");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 0); //end table def
+ writer->writeInt16(70, 0); // end table def
writer->writeString(0, "ENDTAB");
writer->writeString(0, "TABLE");
writer->writeString(2, "UCS");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "7");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 0); //end table def
+ writer->writeInt16(70, 0); // end table def
writer->writeString(0, "ENDTAB");
writer->writeString(0, "TABLE");
writer->writeString(2, "APPID");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "9");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 1); //end table def
+ writer->writeInt16(70, 1); // end table def
writer->writeString(0, "APPID");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "12");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "9");
}
writer->writeString(100, "AcDbSymbolTableRecord");
@@ -1687,45 +1926,53 @@ auto dxfRW::writeTables() -> bool
writer->writeString(0, "TABLE");
writer->writeString(2, "DIMSTYLE");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(5, "A");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
}
- writer->writeInt16(70, 1); //end table def
- if (version > DRW::AC1014) {
+ writer->writeInt16(70, 1); // end table def
+ if (version > DRW::AC1014)
+ {
writer->writeString(100, "AcDbDimStyleTable");
- writer->writeInt16(71, 1); //end table def
+ writer->writeInt16(71, 1); // end table def
}
- dimstyleStd =false;
+ dimstyleStd = false;
iface->writeDimstyles();
- if (!dimstyleStd) {
+ if (!dimstyleStd)
+ {
DRW_Dimstyle dsty;
dsty.name = "Standard";
writeDimstyle(&dsty);
}
writer->writeString(0, "ENDTAB");
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "TABLE");
writer->writeString(2, "BLOCK_RECORD");
writer->writeString(5, "1");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbSymbolTable");
- writer->writeInt16(70, 2); //end table def
+ writer->writeInt16(70, 2); // end table def
writer->writeString(0, "BLOCK_RECORD");
writer->writeString(5, "1F");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "1");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbBlockTableRecord");
writer->writeString(2, "*Model_Space");
- if (version > DRW::AC1018) {
+ if (version > DRW::AC1018)
+ {
// writer->writeInt16(340, 22);
writer->writeInt16(70, 0);
writer->writeInt16(280, 1);
@@ -1733,13 +1980,15 @@ auto dxfRW::writeTables() -> bool
}
writer->writeString(0, "BLOCK_RECORD");
writer->writeString(5, "1E");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "1");
}
writer->writeString(100, "AcDbSymbolTableRecord");
writer->writeString(100, "AcDbBlockTableRecord");
writer->writeString(2, "*Paper_Space");
- if (version > DRW::AC1018) {
+ if (version > DRW::AC1018)
+ {
// writer->writeInt16(340, 22);
writer->writeInt16(70, 0);
writer->writeInt16(280, 1);
@@ -1748,10 +1997,11 @@ auto dxfRW::writeTables() -> bool
}
/* always call writeBlockRecords to iface for prepare unnamed blocks */
iface->writeBlockRecords();
- if (version > DRW::AC1009) {
+ if (version > DRW::AC1009)
+ {
writer->writeString(0, "ENDTAB");
}
-return true;
+ return true;
}
auto dxfRW::writeBlocks() -> bool
@@ -1864,8 +2114,8 @@ auto dxfRW::writeBlocks() -> bool
writer->writeString(0, "ENDBLK");
if (version > DRW::AC1009)
{
- writer->writeString(5, toHexStr(currHandle+2));
-// writer->writeString(5, "1D");
+ writer->writeString(5, toHexStr(currHandle + 2));
+ // writer->writeString(5, "1D");
if (version > DRW::AC1014)
{
writer->writeString(330, toHexStr(currHandle));
@@ -1886,14 +2136,16 @@ auto dxfRW::writeObjects() -> bool
writer->writeString(0, "DICTIONARY");
std::string imgDictH;
writer->writeString(5, "C");
- if (version > DRW::AC1014) {
+ if (version > DRW::AC1014)
+ {
writer->writeString(330, "0");
}
writer->writeString(100, "AcDbDictionary");
writer->writeInt16(281, 1);
writer->writeString(3, "ACAD_GROUP");
writer->writeString(350, "D");
- if (imageDef.size() != 0) {
+ if (imageDef.size() != 0)
+ {
writer->writeString(3, "ACAD_IMAGE_DICT");
imgDictH = toHexStr(++entCount);
writer->writeString(350, imgDictH);
@@ -1903,47 +2155,54 @@ auto dxfRW::writeObjects() -> bool
writer->writeString(330, "C");
writer->writeString(100, "AcDbDictionary");
writer->writeInt16(281, 1);
-//write IMAGEDEF_REACTOR
- for (unsigned int i=0; ireactors.begin() ; it != id->reactors.end(); ++it ) {
+ for (auto it = id->reactors.begin(); it != id->reactors.end(); ++it)
+ {
writer->writeString(0, "IMAGEDEF_REACTOR");
writer->writeString(5, (*it).first);
writer->writeString(330, (*it).second);
writer->writeString(100, "AcDbRasterImageDefReactor");
- writer->writeInt16(90, 2); //version 2=R14 to v2010
+ writer->writeInt16(90, 2); // version 2=R14 to v2010
writer->writeString(330, (*it).second);
}
}
- if (imageDef.size() != 0) {
+ if (imageDef.size() != 0)
+ {
writer->writeString(0, "DICTIONARY");
writer->writeString(5, imgDictH);
writer->writeString(330, "C");
writer->writeString(100, "AcDbDictionary");
writer->writeInt16(281, 1);
- for (unsigned int i=0; iname.find_last_of("/\\");
- f2 =imageDef.at(i)->name.find_last_of('.');
+ f2 = imageDef.at(i)->name.find_last_of('.');
++f1;
- writer->writeString(3, imageDef.at(i)->name.substr(f1,f2-f1));
- writer->writeString(350, toHexStr(static_cast(imageDef.at(i)->handle)) );
+ writer->writeString(3, imageDef.at(i)->name.substr(f1, f2 - f1));
+ writer->writeString(350, toHexStr(static_cast(imageDef.at(i)->handle)));
}
}
- for (unsigned int i=0; iwriteString(0, "IMAGEDEF");
- writer->writeString(5, toHexStr(static_cast(id->handle)) );
- if (version > DRW::AC1014) {
-// writer->writeString(330, '0'); handle to DICTIONARY
+ writer->writeString(5, toHexStr(static_cast(id->handle)));
+ if (version > DRW::AC1014)
+ {
+ // writer->writeString(330, '0'); handle to DICTIONARY
}
writer->writeString(102, "{ACAD_REACTORS");
- for (auto it=id->reactors.begin() ; it != id->reactors.end(); ++it ) {
+ for (auto it = id->reactors.begin(); it != id->reactors.end(); ++it)
+ {
writer->writeString(330, (*it).first);
}
writer->writeString(102, "}");
writer->writeString(100, "AcDbRasterImageDef");
- writer->writeInt16(90, 0); //version 0=R14 to v2010
+ writer->writeInt16(90, 0); // version 0=R14 to v2010
writer->writeUtf8String(1, id->fileName);
writer->writeDouble(10, id->u);
writer->writeDouble(20, id->v);
@@ -1952,9 +2211,10 @@ auto dxfRW::writeObjects() -> bool
writer->writeInt16(280, id->loaded);
writer->writeInt16(281, id->resolution);
}
- //no more needed imageDef, delete it
- while (!imageDef.empty()) {
- imageDef.pop_back();
+ // no more needed imageDef, delete it
+ while (!imageDef.empty())
+ {
+ imageDef.pop_back();
}
iface->writeObjects();
@@ -1964,45 +2224,50 @@ auto dxfRW::writeObjects() -> bool
auto dxfRW::writeExtData(const std::vector &ed) -> bool
{
- for (std::vector::const_iterator it=ed.begin(); it!=ed.end(); ++it){
- switch ((*it)->code) {
- case 1000:
- case 1001:
- case 1002:
- case 1003:
- case 1004:
- case 1005:
- {int cc = (*it)->code;
- if ((*it)->type == DRW_Variant::STRING)
- writer->writeUtf8String(cc, *(*it)->content.s);
-// writer->writeUtf8String((*it)->code, (*it)->content.s);
- break;}
- case 1010:
- case 1011:
- case 1012:
- case 1013:
- if ((*it)->type == DRW_Variant::COORD) {
- writer->writeDouble((*it)->code, (*it)->content.v->x);
- writer->writeDouble((*it)->code+10 , (*it)->content.v->y);
- writer->writeDouble((*it)->code+20 , (*it)->content.v->z);
+ for (std::vector::const_iterator it = ed.begin(); it != ed.end(); ++it)
+ {
+ switch ((*it)->code)
+ {
+ case 1000:
+ case 1001:
+ case 1002:
+ case 1003:
+ case 1004:
+ case 1005:
+ {
+ int cc = (*it)->code;
+ if ((*it)->type == DRW_Variant::STRING)
+ writer->writeUtf8String(cc, *(*it)->content.s);
+ // writer->writeUtf8String((*it)->code, (*it)->content.s);
+ break;
}
- break;
- case 1040:
- case 1041:
- case 1042:
- if ((*it)->type == DRW_Variant::DOUBLE)
- writer->writeDouble((*it)->code, (*it)->content.d);
- break;
- case 1070:
- if ((*it)->type == DRW_Variant::INTEGER)
- writer->writeInt16((*it)->code, (*it)->content.i);
- break;
- case 1071:
- if ((*it)->type == DRW_Variant::INTEGER)
- writer->writeInt32((*it)->code, (*it)->content.i);
- break;
- default:
- break;
+ case 1010:
+ case 1011:
+ case 1012:
+ case 1013:
+ if ((*it)->type == DRW_Variant::COORD)
+ {
+ writer->writeDouble((*it)->code, (*it)->content.v->x);
+ writer->writeDouble((*it)->code + 10, (*it)->content.v->y);
+ writer->writeDouble((*it)->code + 20, (*it)->content.v->z);
+ }
+ break;
+ case 1040:
+ case 1041:
+ case 1042:
+ if ((*it)->type == DRW_Variant::DOUBLE)
+ writer->writeDouble((*it)->code, (*it)->content.d);
+ break;
+ case 1070:
+ if ((*it)->type == DRW_Variant::INTEGER)
+ writer->writeInt16((*it)->code, (*it)->content.i);
+ break;
+ case 1071:
+ if ((*it)->type == DRW_Variant::INTEGER)
+ writer->writeInt32((*it)->code, (*it)->content.i);
+ break;
+ default:
+ break;
}
}
return true;
@@ -2016,72 +2281,90 @@ auto dxfRW::processDxf() -> bool
int code = -1;
bool inSection = false;
- reader->setIgnoreComments( false);
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG(" code\n");
+ reader->setIgnoreComments(false);
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG(" code\n");
/* at this level we should only get:
999 - Comment
0 - SECTION or EOF
2 - section name
everything else between "2 - section name" and "0 - ENDSEC" is handled in process() methods
*/
- switch (code) {
+ switch (code)
+ {
case 999: // when DXF was created by libdxfrw, first record is a comment with dxfrw version info
- header.addComment( reader->getString());
+ header.addComment(reader->getString());
continue;
case 0:
// ignore further comments, as libdxfrw doesn't support comments in sections
- reader->setIgnoreComments( true);
- if (!inSection) {
- std::string sectionstr {reader->getString()};
+ reader->setIgnoreComments(true);
+ if (!inSection)
+ {
+ std::string sectionstr{reader->getString()};
- if ("SECTION" == sectionstr) {
- DRW_DBG(sectionstr); DRW_DBG(" new section\n");
+ if ("SECTION" == sectionstr)
+ {
+ DRW_DBG(sectionstr);
+ DRW_DBG(" new section\n");
inSection = true;
continue;
}
- if ("EOF" == sectionstr) {
- return true; //found EOF terminate
+ if ("EOF" == sectionstr)
+ {
+ return true; // found EOF terminate
}
}
- else {
+ else
+ {
// in case SECTION was unknown or not supported
- if ("ENDSEC" == reader->getString()) {
+ if ("ENDSEC" == reader->getString())
+ {
inSection = false;
}
}
break;
case 2:
- if (inSection) {
- bool processed {false};
- std::string sectionname {reader->getString()};
+ if (inSection)
+ {
+ bool processed{false};
+ std::string sectionname{reader->getString()};
- DRW_DBG(sectionname); DRW_DBG(" process section\n");
- if ("HEADER" == sectionname) {
+ DRW_DBG(sectionname);
+ DRW_DBG(" process section\n");
+ if ("HEADER" == sectionname)
+ {
processed = processHeader();
}
- else if ("TABLES" == sectionname) {
+ else if ("TABLES" == sectionname)
+ {
processed = processTables();
}
- else if ("BLOCKS" == sectionname) {
+ else if ("BLOCKS" == sectionname)
+ {
processed = processBlocks();
}
- else if ("ENTITIES" == sectionname) {
+ else if ("ENTITIES" == sectionname)
+ {
processed = processEntities(false);
}
- else if ("OBJECTS" == sectionname) {
+ else if ("OBJECTS" == sectionname)
+ {
processed = processObjects();
}
- else {
- //TODO handle CLASSES
+ else
+ {
+ // TODO handle CLASSES
DRW_DBG("section unknown or not supported\n");
continue;
}
- if (!processed) {
+ if (!processed)
+ {
DRW_DBG(" failed\n");
return setError(DRW::BAD_READ_SECTION);
}
@@ -2095,11 +2378,12 @@ auto dxfRW::processDxf() -> bool
inSection = false;
break;
}
-/* if (!more)
- return true;*/
+ /* if (!more)
+ return true;*/
}
- if (0 == code && "EOF" == reader->getString()) {
+ if (0 == code && "EOF" == reader->getString())
+ {
// in case the final EOF has no newline we end up here!
// this is caused by filestr->good() which is false for missing newline on EOF
return true;
@@ -2115,20 +2399,26 @@ auto dxfRW::processHeader() -> bool
DRW_DBG("dxfRW::processHeader\n");
int code;
std::string sectionstr;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG(" processHeader\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG(" processHeader\n");
+ if (code == 0)
+ {
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG(" processHeader\n\n");
- if (sectionstr == "ENDSEC") {
+ DRW_DBG(sectionstr);
+ DRW_DBG(" processHeader\n\n");
+ if (sectionstr == "ENDSEC")
+ {
iface->addHeader(&header);
- return true; //found ENDSEC terminate
+ return true; // found ENDSEC terminate
}
DRW_DBG("unexpected 0 code in header!\n");
return setError(DRW::BAD_READ_HEADER);
}
- if (!header.parseCode(code, reader)) {
+ if (!header.parseCode(code, reader))
+ {
return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2144,43 +2434,71 @@ auto dxfRW::processTables() -> bool
int code;
std::string sectionstr;
bool more = true;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG(" processHeader\n\n");
- if (sectionstr == "TABLE") {
+ DRW_DBG(sectionstr);
+ DRW_DBG(" processHeader\n\n");
+ if (sectionstr == "TABLE")
+ {
more = reader->readRec(&code);
- DRW_DBG(code); DRW_DBG("\n");
- if (!more) {
- return setError(DRW::BAD_READ_TABLES); //wrong dxf file
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (!more)
+ {
+ return setError(DRW::BAD_READ_TABLES); // wrong dxf file
}
- if (code == 2) {
+ if (code == 2)
+ {
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG(" processHeader\n\n");
- //found section, process it
- if (sectionstr == "LTYPE") {
+ DRW_DBG(sectionstr);
+ DRW_DBG(" processHeader\n\n");
+ // found section, process it
+ if (sectionstr == "LTYPE")
+ {
processLType();
- } else if (sectionstr == "LAYER") {
+ }
+ else if (sectionstr == "LAYER")
+ {
processLayer();
- } else if (sectionstr == "STYLE") {
+ }
+ else if (sectionstr == "STYLE")
+ {
processTextStyle();
- } else if (sectionstr == "VPORT") {
+ }
+ else if (sectionstr == "VPORT")
+ {
processVports();
- } else if (sectionstr == "VIEW") {
-// processView();
- } else if (sectionstr == "UCS") {
-// processUCS();
- } else if (sectionstr == "APPID") {
+ }
+ else if (sectionstr == "VIEW")
+ {
+ // processView();
+ }
+ else if (sectionstr == "UCS")
+ {
+ // processUCS();
+ }
+ else if (sectionstr == "APPID")
+ {
processAppId();
- } else if (sectionstr == "DIMSTYLE") {
+ }
+ else if (sectionstr == "DIMSTYLE")
+ {
processDimStyle();
- } else if (sectionstr == "BLOCK_RECORD") {
-// processBlockRecord();
+ }
+ else if (sectionstr == "BLOCK_RECORD")
+ {
+ // processBlockRecord();
}
}
- } else if (sectionstr == "ENDSEC") {
- return true; //found ENDSEC terminate
+ }
+ else if (sectionstr == "ENDSEC")
+ {
+ return true; // found ENDSEC terminate
}
}
}
@@ -2195,24 +2513,35 @@ auto dxfRW::processLType() -> bool
std::string sectionstr;
bool reading = false;
DRW_LType ltype;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
- if (reading) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
+ if (reading)
+ {
ltype.update();
iface->addLType(ltype);
}
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "LTYPE") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "LTYPE")
+ {
reading = true;
ltype.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!ltype.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!ltype.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
}
@@ -2227,22 +2556,32 @@ auto dxfRW::processLayer() -> bool
std::string sectionstr;
bool reading = false;
DRW_Layer layer;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
if (reading)
iface->addLayer(layer);
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "LAYER") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "LAYER")
+ {
reading = true;
layer.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!layer.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!layer.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
}
@@ -2257,21 +2596,31 @@ auto dxfRW::processDimStyle() -> bool
std::string sectionstr;
bool reading = false;
DRW_Dimstyle dimSty;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
if (reading)
iface->addDimStyle(dimSty);
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "DIMSTYLE") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "DIMSTYLE")
+ {
reading = true;
dimSty.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!dimSty.parseCode(code, reader)) {
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!dimSty.parseCode(code, reader))
+ {
return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2287,22 +2636,32 @@ auto dxfRW::processTextStyle() -> bool
std::string sectionstr;
bool reading = false;
DRW_Textstyle TxtSty;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
if (reading)
iface->addTextStyle(TxtSty);
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "STYLE") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "STYLE")
+ {
reading = true;
TxtSty.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!TxtSty.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!TxtSty.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
}
@@ -2317,22 +2676,32 @@ auto dxfRW::processVports() -> bool
std::string sectionstr;
bool reading = false;
DRW_Vport vp;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
if (reading)
iface->addVport(vp);
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "VPORT") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "VPORT")
+ {
reading = true;
vp.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!vp.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!vp.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
}
@@ -2347,21 +2716,31 @@ auto dxfRW::processAppId() -> bool
std::string sectionstr;
bool reading = false;
DRW_AppId vp;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
if (reading)
iface->addAppId(vp);
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "APPID") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "APPID")
+ {
reading = true;
vp.reset();
- } else if (sectionstr == "ENDTAB") {
- return true; //found ENDTAB terminate
}
- } else if (reading) {
- if (!vp.parseCode(code, reader)) {
+ else if (sectionstr == "ENDTAB")
+ {
+ return true; // found ENDTAB terminate
+ }
+ }
+ else if (reading)
+ {
+ if (!vp.parseCode(code, reader))
+ {
return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2377,15 +2756,22 @@ auto dxfRW::processBlocks() -> bool
DRW_DBG("dxfRW::processBlocks\n");
int code;
std::string sectionstr;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (code == 0) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (code == 0)
+ {
sectionstr = reader->getString();
- DRW_DBG(sectionstr); DRW_DBG("\n");
- if (sectionstr == "BLOCK") {
+ DRW_DBG(sectionstr);
+ DRW_DBG("\n");
+ if (sectionstr == "BLOCK")
+ {
processBlock();
- } else if (sectionstr == "ENDSEC") {
- return true; //found ENDSEC terminate
+ }
+ else if (sectionstr == "ENDSEC")
+ {
+ return true; // found ENDSEC terminate
}
}
}
@@ -2398,24 +2784,32 @@ auto dxfRW::processBlock() -> bool
DRW_DBG("dxfRW::processBlock");
int code;
DRW_Block block;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addBlock(block);
- if (nextentity == "ENDBLK") {
+ if (nextentity == "ENDBLK")
+ {
iface->endBlock();
- return true; //found ENDBLK, terminate
- } else {
+ return true; // found ENDBLK, terminate
+ }
+ else
+ {
processEntities(true);
iface->endBlock();
- return true; //found ENDBLK, terminate
+ return true; // found ENDBLK, terminate
}
}
- if (!block.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!block.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2428,68 +2822,120 @@ auto dxfRW::processEntities(bool isblock) -> bool
{
DRW_DBG("dxfRW::processEntities\n");
int code;
- if (!reader->readRec(&code)){
+ if (!reader->readRec(&code))
+ {
return setError(DRW::BAD_READ_ENTITIES);
}
- if (code == 0) {
+ if (code == 0)
+ {
nextentity = reader->getString();
- } else if (!isblock) {
- return setError(DRW::BAD_READ_ENTITIES); //first record in entities is 0
+ }
+ else if (!isblock)
+ {
+ return setError(DRW::BAD_READ_ENTITIES); // first record in entities is 0
}
- bool processed {false};
- do {
- if (nextentity == "ENDSEC" || nextentity == "ENDBLK") {
- return true; //found ENDSEC or ENDBLK terminate
- } else if (nextentity == "POINT") {
+ bool processed{false};
+ do
+ {
+ if (nextentity == "ENDSEC" || nextentity == "ENDBLK")
+ {
+ return true; // found ENDSEC or ENDBLK terminate
+ }
+ else if (nextentity == "POINT")
+ {
processed = processPoint();
- } else if (nextentity == "LINE") {
+ }
+ else if (nextentity == "LINE")
+ {
processed = processLine();
- } else if (nextentity == "CIRCLE") {
+ }
+ else if (nextentity == "CIRCLE")
+ {
processed = processCircle();
- } else if (nextentity == "ARC") {
+ }
+ else if (nextentity == "ARC")
+ {
processed = processArc();
- } else if (nextentity == "ELLIPSE") {
+ }
+ else if (nextentity == "ELLIPSE")
+ {
processed = processEllipse();
- } else if (nextentity == "TRACE") {
+ }
+ else if (nextentity == "TRACE")
+ {
processed = processTrace();
- } else if (nextentity == "SOLID") {
+ }
+ else if (nextentity == "SOLID")
+ {
processed = processSolid();
- } else if (nextentity == "INSERT") {
+ }
+ else if (nextentity == "INSERT")
+ {
processed = processInsert();
- } else if (nextentity == "LWPOLYLINE") {
+ }
+ else if (nextentity == "LWPOLYLINE")
+ {
processed = processLWPolyline();
- } else if (nextentity == "POLYLINE") {
+ }
+ else if (nextentity == "POLYLINE")
+ {
processed = processPolyline();
- } else if (nextentity == "TEXT") {
+ }
+ else if (nextentity == "TEXT")
+ {
processed = processText();
- } else if (nextentity == "MTEXT") {
+ }
+ else if (nextentity == "MTEXT")
+ {
processed = processMText();
- } else if (nextentity == "HATCH") {
+ }
+ else if (nextentity == "HATCH")
+ {
processed = processHatch();
- } else if (nextentity == "SPLINE") {
+ }
+ else if (nextentity == "SPLINE")
+ {
processed = processSpline();
- } else if (nextentity == "3DFACE") {
+ }
+ else if (nextentity == "3DFACE")
+ {
processed = process3dface();
- } else if (nextentity == "VIEWPORT") {
+ }
+ else if (nextentity == "VIEWPORT")
+ {
processed = processViewport();
- } else if (nextentity == "IMAGE") {
+ }
+ else if (nextentity == "IMAGE")
+ {
processed = processImage();
- } else if (nextentity == "DIMENSION") {
+ }
+ else if (nextentity == "DIMENSION")
+ {
processed = processDimension();
- } else if (nextentity == "LEADER") {
+ }
+ else if (nextentity == "LEADER")
+ {
processed = processLeader();
- } else if (nextentity == "RAY") {
+ }
+ else if (nextentity == "RAY")
+ {
processed = processRay();
- } else if (nextentity == "XLINE") {
+ }
+ else if (nextentity == "XLINE")
+ {
processed = processXline();
- } else {
- if (!reader->readRec(&code)) {
- return setError(DRW::BAD_READ_ENTITIES); //end of file without ENDSEC
+ }
+ else
+ {
+ if (!reader->readRec(&code))
+ {
+ return setError(DRW::BAD_READ_ENTITIES); // end of file without ENDSEC
}
- if (code == 0) {
+ if (code == 0)
+ {
nextentity = reader->getString();
}
processed = true;
@@ -2505,19 +2951,24 @@ auto dxfRW::processEllipse() -> bool
DRW_DBG("dxfRW::processEllipse");
int code;
DRW_Ellipse ellipse;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
ellipse.applyExtrusion();
iface->addEllipse(ellipse);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!ellipse.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!ellipse.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2529,19 +2980,24 @@ auto dxfRW::processTrace() -> bool
DRW_DBG("dxfRW::processTrace");
int code;
DRW_Trace trace;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
trace.applyExtrusion();
iface->addTrace(trace);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!trace.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!trace.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2553,19 +3009,24 @@ auto dxfRW::processSolid() -> bool
DRW_DBG("dxfRW::processSolid");
int code;
DRW_Solid solid;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
solid.applyExtrusion();
iface->addSolid(solid);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!solid.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!solid.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2577,17 +3038,22 @@ auto dxfRW::process3dface() -> bool
DRW_DBG("dxfRW::process3dface");
int code;
DRW_3Dface face;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->add3dFace(face);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!face.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!face.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2599,17 +3065,22 @@ auto dxfRW::processViewport() -> bool
DRW_DBG("dxfRW::processViewport");
int code;
DRW_Viewport vp;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addViewport(vp);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!vp.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!vp.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2621,17 +3092,22 @@ auto dxfRW::processPoint() -> bool
DRW_DBG("dxfRW::processPoint\n");
int code;
DRW_Point point;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addPoint(point);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!point.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!point.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2643,17 +3119,22 @@ auto dxfRW::processLine() -> bool
DRW_DBG("dxfRW::processLine\n");
int code;
DRW_Line line;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addLine(line);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!line.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!line.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2665,17 +3146,22 @@ auto dxfRW::processRay() -> bool
DRW_DBG("dxfRW::processRay\n");
int code;
DRW_Ray line;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addRay(line);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!line.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!line.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2687,17 +3173,22 @@ auto dxfRW::processXline() -> bool
DRW_DBG("dxfRW::processXline\n");
int code;
DRW_Xline line;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addXline(line);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!line.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!line.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2709,19 +3200,24 @@ auto dxfRW::processCircle() -> bool
DRW_DBG("dxfRW::processPoint\n");
int code;
DRW_Circle circle;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
circle.applyExtrusion();
iface->addCircle(circle);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!circle.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!circle.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2733,19 +3229,24 @@ auto dxfRW::processArc() -> bool
DRW_DBG("dxfRW::processPoint\n");
int code;
DRW_Arc arc;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
arc.applyExtrusion();
iface->addArc(arc);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!arc.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!arc.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2757,17 +3258,22 @@ auto dxfRW::processInsert() -> bool
DRW_DBG("dxfRW::processInsert");
int code;
DRW_Insert insert;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addInsert(insert);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!insert.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!insert.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2779,19 +3285,24 @@ auto dxfRW::processLWPolyline() -> bool
DRW_DBG("dxfRW::processLWPolyline");
int code;
DRW_LWPolyline pl;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
if (applyExt)
pl.applyExtrusion();
iface->addLWPolyline(pl);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!pl.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!pl.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2803,19 +3314,25 @@ auto dxfRW::processPolyline() -> bool
DRW_DBG("dxfRW::processPolyline");
int code;
DRW_Polyline pl;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
- if (nextentity != "VERTEX") {
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
+ if (nextentity != "VERTEX")
+ {
iface->addPolyline(pl);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
processVertex(&pl);
}
- if (!pl.parseCode(code, reader)) { //parseCode just initialize the members of pl
+ if (!pl.parseCode(code, reader))
+ { // parseCode just initialize the members of pl
return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2828,22 +3345,29 @@ auto dxfRW::processVertex(DRW_Polyline *pl) -> bool
DRW_DBG("dxfRW::processVertex");
int code;
std::unique_ptr v(new DRW_Vertex());
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
pl->appendVertex(v.release());
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
- if (nextentity == "SEQEND") {
- return true; //found SEQEND no more vertex, terminate
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
+ if (nextentity == "SEQEND")
+ {
+ return true; // found SEQEND no more vertex, terminate
}
- if (nextentity == "VERTEX"){
- v.reset(new DRW_Vertex()); //another vertex
+ if (nextentity == "VERTEX")
+ {
+ v.reset(new DRW_Vertex()); // another vertex
}
}
- if (!v->parseCode(code, reader)) { //the members of v are reinitialized here
- return setError( DRW::BAD_CODE_PARSED);
+ if (!v->parseCode(code, reader))
+ { // the members of v are reinitialized here
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2855,17 +3379,22 @@ auto dxfRW::processText() -> bool
DRW_DBG("dxfRW::processText");
int code;
DRW_Text txt;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addText(txt);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!txt.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!txt.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2877,18 +3406,23 @@ auto dxfRW::processMText() -> bool
DRW_DBG("dxfRW::processMText");
int code;
DRW_MText txt;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
txt.updateAngle();
iface->addMText(txt);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!txt.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!txt.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2900,17 +3434,22 @@ auto dxfRW::processHatch() -> bool
DRW_DBG("dxfRW::processHatch");
int code;
DRW_Hatch hatch;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addHatch(&hatch);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!hatch.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!hatch.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2922,17 +3461,22 @@ auto dxfRW::processSpline() -> bool
DRW_DBG("dxfRW::processSpline");
int code;
DRW_Spline sp;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addSpline(&sp);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!sp.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!sp.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2944,17 +3488,22 @@ auto dxfRW::processImage() -> bool
DRW_DBG("dxfRW::processImage");
int code;
DRW_Image img;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addImage(&img);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!img.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!img.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -2966,55 +3515,75 @@ auto dxfRW::processDimension() -> bool
DRW_DBG("dxfRW::processDimension");
int code;
DRW_Dimension dim;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
int type = dim.type & 0x0F;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
- switch (type) {
- case 0: {
- DRW_DimLinear d(dim);
- iface->addDimLinear(&d);
- break; }
- case 1: {
- DRW_DimAligned d(dim);
- iface->addDimAlign(&d);
- break; }
- case 2: {
- DRW_DimAngular d(dim);
- iface->addDimAngular(&d);
- break;}
- case 3: {
- DRW_DimDiametric d(dim);
- iface->addDimDiametric(&d);
- break; }
- case 4: {
- DRW_DimRadial d(dim);
- iface->addDimRadial(&d);
- break; }
- case 5: {
- DRW_DimAngular3p d(dim);
- iface->addDimAngular3P(&d);
- break; }
- case 6: {
- DRW_DimOrdinate d(dim);
- iface->addDimOrdinate(&d);
- break; }
+ switch (type)
+ {
+ case 0:
+ {
+ DRW_DimLinear d(dim);
+ iface->addDimLinear(&d);
+ break;
+ }
+ case 1:
+ {
+ DRW_DimAligned d(dim);
+ iface->addDimAlign(&d);
+ break;
+ }
+ case 2:
+ {
+ DRW_DimAngular d(dim);
+ iface->addDimAngular(&d);
+ break;
+ }
+ case 3:
+ {
+ DRW_DimDiametric d(dim);
+ iface->addDimDiametric(&d);
+ break;
+ }
+ case 4:
+ {
+ DRW_DimRadial d(dim);
+ iface->addDimRadial(&d);
+ break;
+ }
+ case 5:
+ {
+ DRW_DimAngular3p d(dim);
+ iface->addDimAngular3P(&d);
+ break;
+ }
+ case 6:
+ {
+ DRW_DimOrdinate d(dim);
+ iface->addDimOrdinate(&d);
+ break;
+ }
}
// cppcheck-suppress unknownMacro
QT_WARNING_POP
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!dim.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!dim.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -3026,17 +3595,22 @@ auto dxfRW::processLeader() -> bool
DRW_DBG("dxfRW::processLeader");
int code;
DRW_Leader leader;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addLeader(&leader);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!leader.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!leader.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -3049,35 +3623,42 @@ auto dxfRW::processObjects() -> bool
{
DRW_DBG("dxfRW::processObjects\n");
int code;
- if (!reader->readRec(&code) || 0 != code){
- return setError(DRW::BAD_READ_OBJECTS); //first record in objects must be 0
+ if (!reader->readRec(&code) || 0 != code)
+ {
+ return setError(DRW::BAD_READ_OBJECTS); // first record in objects must be 0
}
bool processed = false;
nextentity = reader->getString();
- do {
- if ("ENDSEC" == nextentity) {
- return true; //found ENDSEC terminate
+ do
+ {
+ if ("ENDSEC" == nextentity)
+ {
+ return true; // found ENDSEC terminate
}
- if ("IMAGEDEF" == nextentity) {
+ if ("IMAGEDEF" == nextentity)
+ {
processed = processImageDef();
}
- else if ("PLOTSETTINGS" == nextentity) {
+ else if ("PLOTSETTINGS" == nextentity)
+ {
processed = processPlotSettings();
}
- else {
- if (!reader->readRec(&code)) {
- return setError(DRW::BAD_READ_OBJECTS); //end of file without ENDSEC
+ else
+ {
+ if (!reader->readRec(&code))
+ {
+ return setError(DRW::BAD_READ_OBJECTS); // end of file without ENDSEC
}
- if (code == 0) {
+ if (code == 0)
+ {
nextentity = reader->getString();
}
processed = true;
}
- }
- while (processed);
+ } while (processed);
return setError(DRW::BAD_READ_OBJECTS);
}
@@ -3087,17 +3668,22 @@ auto dxfRW::processImageDef() -> bool
DRW_DBG("dxfRW::processImageDef");
int code;
DRW_ImageDef img;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->linkImage(&img);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!img.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!img.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -3109,17 +3695,22 @@ auto dxfRW::processPlotSettings() -> bool
DRW_DBG("dxfRW::processPlotSettings");
int code;
DRW_PlotSettings ps;
- while (reader->readRec(&code)) {
- DRW_DBG(code); DRW_DBG("\n");
- if (0 == code) {
+ while (reader->readRec(&code))
+ {
+ DRW_DBG(code);
+ DRW_DBG("\n");
+ if (0 == code)
+ {
nextentity = reader->getString();
- DRW_DBG(nextentity); DRW_DBG("\n");
+ DRW_DBG(nextentity);
+ DRW_DBG("\n");
iface->addPlotSettings(&ps);
- return true; //found new entity or ENDSEC, terminate
+ return true; // found new entity or ENDSEC, terminate
}
- if (!ps.parseCode(code, reader)) {
- return setError( DRW::BAD_CODE_PARSED);
+ if (!ps.parseCode(code, reader))
+ {
+ return setError(DRW::BAD_CODE_PARSED);
}
}
@@ -3145,8 +3736,8 @@ auto dxfRW::writePlotSettings(DRW_PlotSettings *ent) -> bool
auto dxfRW::toHexStr(int n) -> std::string
{
#if defined(__APPLE__)
- char buffer[9]= {'\0'};
- snprintf(buffer,9, "%X", n);
+ char buffer[9] = {'\0'};
+ snprintf(buffer, 9, "%X", n);
return std::string(buffer);
#else
std::ostringstream Convert;
diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h
index 027967e89..380558aa3 100644
--- a/src/libs/vlayout/vabstractpiece.h
+++ b/src/libs/vlayout/vabstractpiece.h
@@ -29,17 +29,17 @@
#ifndef VABSTRACTPIECE_H
#define VABSTRACTPIECE_H
-#include
-#include
-#include
-#include
#include
+#include
#include
+#include
+#include
+#include
-#include "../vmisc/compatibility.h"
#include "../vgeometry/vgobject.h"
-#include "vsapoint.h"
+#include "../vmisc/compatibility.h"
#include "vrawsapoint.h"
+#include "vsapoint.h"
class VAbstractPieceData;
class QPainterPath;
@@ -48,11 +48,12 @@ class VContainer;
class VRawSAPoint;
class VLayoutPlaceLabel;
-using PlaceLabelImg = QVector >;
+using PlaceLabelImg = QVector>;
class VAbstractPiece
{
Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT
+
public:
VAbstractPiece();
VAbstractPiece(const VAbstractPiece &piece);
@@ -109,28 +110,27 @@ public:
static auto Equidistant(QVector points, qreal width, const QString &name) -> QVector;
static auto SumTrapezoids(const QVector &points) -> qreal;
- template
- static auto CheckLoops(QVector points) -> QVector;
+ template static auto CheckLoops(QVector points) -> QVector;
static auto EkvPoint(QVector points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
- const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width,
- bool *needRollback = nullptr) -> QVector;
+ const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, bool *needRollback = nullptr)
+ -> QVector;
static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF;
static auto IsAllowanceValid(const QVector &base, const QVector &allowance) -> bool;
template
- static auto IsInsidePolygon(const QVector &path, const QVector &polygon,
- qreal accuracy = accuracyPointOnLine) -> bool;
+ static auto IsInsidePolygon(const QVector &path, const QVector &polygon, qreal accuracy = accuracyPointOnLine)
+ -> bool;
template
static auto CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast = true) -> QVector;
- static auto RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge,
- bool *success) -> QVector;
+ static auto RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge, bool *success)
+ -> QVector;
- static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern,
- const QRectF &boundingRect) -> QLineF;
+ static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern, const QRectF &boundingRect)
+ -> QLineF;
- friend auto operator<< (QDataStream& dataStream, const VAbstractPiece& piece) -> QDataStream&;
- friend auto operator>> (QDataStream& dataStream, VAbstractPiece& piece) -> QDataStream&;
+ friend auto operator<<(QDataStream &dataStream, const VAbstractPiece &piece) -> QDataStream &;
+ friend auto operator>>(QDataStream &dataStream, VAbstractPiece &piece) -> QDataStream &;
static auto PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg;
static auto LabelShapePath(const VLayoutPlaceLabel &label) -> QPainterPath;
@@ -144,19 +144,17 @@ protected:
template
static auto CheckPointOnLine(QVector &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool;
- static auto IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX,
- qreal &dY) -> bool;
+ static auto IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX, qreal &dY)
+ -> bool;
static auto CorrectPosition(const QRectF &parentBoundingRect, QVector points) -> QVector;
- static auto FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length,
+ static auto FindGrainlineGeometry(const VGrainlineData &geom, const VContainer *pattern, qreal &length,
qreal &rotationAngle, QPointF &pos) -> bool;
- template
- static auto ComparePoints(QVector &points, const T &p1, const T &p2, qreal accuracy) -> bool;
- template
- static auto CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void;
- template
- static auto CheckLoop(const QVector &points, bool &loopFound) -> QVector;
+ template static auto ComparePoints(QVector &points, const T &p1, const T &p2, qreal accuracy) -> bool;
+ template static auto CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void;
+ template static auto CheckLoop(const QVector &points, bool &loopFound) -> QVector;
template
static auto IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1, const T &l2p2) -> T;
+
private:
QSharedDataPointer d;
};
@@ -210,17 +208,17 @@ inline auto VAbstractPiece::CheckPointOnLine(QVector &points,
template
inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast) -> QVector
{
-// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
- if (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
+ // DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
+ if (points.size() < 4) // Better don't check if only three points. We can destroy equidistant.
{
- qDebug()<<"Only three points.";
+ qDebug() << "Only three points.";
return points;
}
- //Clear equivalent points
+ // Clear equivalent points
QVector buf1 = RemoveDublicates(points, removeFirstAndLast);
- if (buf1.size()<3)
+ if (buf1.size() < 3)
{
return buf1;
}
@@ -229,10 +227,10 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, b
vsizetype next = -1;
QVector buf2;
- //Remove point on line
+ // Remove point on line
for (qint32 i = 0; i < buf1.size(); ++i)
- {// In this case we alwayse will have bounded intersection, so all is need is to check if point is on line.
- // Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
+ { // In this case we alwayse will have bounded intersection, so all is need is to check if point is on line.
+ // Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
if (prev == -1)
{
if (i == 0)
@@ -247,7 +245,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, b
}
else
{
- prev = i-1;
+ prev = i - 1;
}
}
@@ -263,7 +261,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, b
}
else
{
- next = i+1;
+ next = i + 1;
}
const T &iPoint = buf1.at(i);
@@ -283,7 +281,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, b
buf2 = RemoveDublicates(buf2, false);
-// DumpVector(buf2, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
+ // DumpVector(buf2, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return buf2;
}
@@ -306,11 +304,11 @@ inline auto VAbstractPiece::RemoveDublicates(const QVector &points, bool remo
for (int i = 0; i < points.size(); ++i)
{
- for (int j = i+1; j < points.size(); ++j)
+ for (int j = i + 1; j < points.size(); ++j)
{
if (not ComparePoints(p, points.at(i), points.at(j), accuracy))
{
- i = j-1;
+ i = j - 1;
break;
}
}
@@ -403,16 +401,15 @@ inline auto VAbstractPiece::ComparePoints(QVector &points, con
}
//---------------------------------------------------------------------------------------------------------------------
-template
-inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void
+template inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
return;
}
- const T& first = ConstFirst(points);
- const T& last = ConstLast(points);
+ const T &first = ConstFirst(points);
+ const T &last = ConstLast(points);
qreal testAccuracy = accuracy;
if (last.TurnPoint())
@@ -437,16 +434,15 @@ inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector &points, qreal
}
//---------------------------------------------------------------------------------------------------------------------
-template <>
-inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void
+template <> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
return;
}
- const VRawSAPoint& first = ConstFirst(points);
- const VRawSAPoint& last = ConstLast(points);
+ const VRawSAPoint &first = ConstFirst(points);
+ const VRawSAPoint &last = ConstLast(points);
qreal testAccuracy = accuracy;
if ((first.Primary() && last.Primary()) || last.TurnPoint())
@@ -493,7 +489,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto
for (auto i = 0; i < path.count(); ++i)
{
int nextI = -1;
- if (i < path.count()-1)
+ if (i < path.count() - 1)
{
nextI = i + 1;
}
@@ -511,7 +507,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto
for (auto j = 0; j < polygon.count(); ++j)
{
int nextJ = -1;
- if (j < polygon.count()-1)
+ if (j < polygon.count() - 1)
{
nextJ = j + 1;
}
@@ -529,13 +525,11 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto
QPointF crosPoint;
const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint);
- if (type == QLineF::BoundedIntersection
- && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy)
- && not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy)
- && not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
- accuracy)
- && not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(),
- accuracy))
+ if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy) &&
+ not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy) &&
+ not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
+ accuracy) &&
+ not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(), accuracy))
{
return false;
}
@@ -544,7 +538,8 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto
// Just instersection edges is not enough. The base must be inside of the allowance.
QPolygonF allowancePolygon(polygon);
- return std::all_of(path.begin(), path.end(), [allowancePolygon](const T &point)
+ return std::all_of(path.begin(), path.end(),
+ [allowancePolygon](const T &point)
{ return allowancePolygon.containsPoint(point, Qt::WindingFill); });
}
@@ -554,10 +549,9 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto
* @param points vector of points of equidistant.
* @return vector of points of equidistant.
*/
-template
-inline auto VAbstractPiece::CheckLoops(QVector points) -> QVector
+template inline auto VAbstractPiece::CheckLoops(QVector points) -> QVector
{
-// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
+ // DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
/*If we got less than 4 points no need seek loops.*/
if (points.size() < 4)
@@ -578,13 +572,12 @@ inline auto VAbstractPiece::CheckLoops(QVector points) -> QVector
}
}
-// DumpVector(ekvPoints, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
+ // DumpVector(ekvPoints, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return points;
}
//---------------------------------------------------------------------------------------------------------------------
-template
-inline auto VAbstractPiece::CheckLoop(const QVector &points, bool &loopFound) -> QVector
+template inline auto VAbstractPiece::CheckLoop(const QVector &points, bool &loopFound) -> QVector
{
loopFound = false;
@@ -598,23 +591,28 @@ inline auto VAbstractPiece::CheckLoop(const QVector &points, bool &loopFound)
{
/*Last three points no need to check.*/
/*Triangle can not contain a loop*/
- if (loopFound || i > points.size()-4)
+ if (loopFound || i > points.size() - 4)
{
ekvPoints.append(points.at(i));
continue;
}
- enum LoopIntersectType { NoIntersection, BoundedIntersection, ParallelIntersection };
+ enum LoopIntersectType
+ {
+ NoIntersection,
+ BoundedIntersection,
+ ParallelIntersection
+ };
QPointF crosPoint;
LoopIntersectType status = NoIntersection;
- const QLineF line1(points.at(i), points.at(i+1));
+ const QLineF line1(points.at(i), points.at(i + 1));
const int limit = pathClosed && i == 0 ? 2 : 1;
qint32 j;
- for (j = i+2; j < points.size()-limit; ++j)
+ for (j = i + 2; j < points.size() - limit; ++j)
{
- QLineF line2(points.at(j), points.at(j+1));
+ QLineF line2(points.at(j), points.at(j + 1));
const QLineF::IntersectType intersect = Intersects(line1, line2, &crosPoint);
if (intersect == QLineF::NoIntersection)
@@ -622,7 +620,7 @@ inline auto VAbstractPiece::CheckLoop(const QVector &points, bool &loopFound)
// i.e. they are parallel. But parallel also mean they can be on the same line.
// Method IsLineSegmentOnLineSegment will check it.
if (VGObject::IsLineSegmentOnLineSegment(line1, line2))
- {// Now we really sure that segments are on the same line and have real intersections.
+ { // Now we really sure that segments are on the same line and have real intersections.
status = ParallelIntersection;
break;
}
@@ -636,32 +634,33 @@ inline auto VAbstractPiece::CheckLoop(const QVector &points, bool &loopFound)
switch (status)
{
- case ParallelIntersection:
- /*We have found a loop.*/
- ekvPoints.append(points.at(i));
- ekvPoints.append(points.at(j+1));
- i = j+1; // Skip a loop
- loopFound = true;
- break;
- case BoundedIntersection:
- ekvPoints.append(points.at(i));
- ekvPoints.append(IntersectionPoint(crosPoint, points.at(i), points.at(i+1), points.at(j), points.at(j+1)));
- i = j;
- loopFound = true;
- break;
- case NoIntersection:
- /*We have not found loop.*/
- ekvPoints.append(points.at(i));
- break;
- default:
- break;
+ case ParallelIntersection:
+ /*We have found a loop.*/
+ ekvPoints.append(points.at(i));
+ ekvPoints.append(points.at(j + 1));
+ i = j + 1; // Skip a loop
+ loopFound = true;
+ break;
+ case BoundedIntersection:
+ ekvPoints.append(points.at(i));
+ ekvPoints.append(
+ IntersectionPoint(crosPoint, points.at(i), points.at(i + 1), points.at(j), points.at(j + 1)));
+ i = j;
+ loopFound = true;
+ break;
+ case NoIntersection:
+ /*We have not found loop.*/
+ ekvPoints.append(points.at(i));
+ break;
+ default:
+ break;
}
}
return ekvPoints;
}
//---------------------------------------------------------------------------------------------------------------------
-template
+template
inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1,
const T &l2p2) -> T
{
@@ -683,7 +682,7 @@ inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1,
}
//---------------------------------------------------------------------------------------------------------------------
-template<>
+template <>
inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const QPointF & /*unused*/,
const QPointF & /*unused*/, const QPointF & /*unused*/,
const QPointF & /*unused*/) -> QPointF
diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp
index dac957350..7203a26ba 100644
--- a/src/libs/vlayout/vlayoutgenerator.cpp
+++ b/src/libs/vlayout/vlayoutgenerator.cpp
@@ -33,42 +33,42 @@
#include
#include
-#include "../vmisc/def.h"
-#include "../vmisc/vmath.h"
-#include "../vmisc/compatibility.h"
-#include "vlayoutpiece.h"
-#include "vlayoutpaper.h"
#include "../ifc/exception/vexceptionterminatedposition.h"
+#include "../vmisc/compatibility.h"
+#include "../vmisc/def.h"
+#include "vlayoutpaper.h"
+#include "vlayoutpiece.h"
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::VLayoutGenerator(QObject *parent)
- : QObject(parent),
- papers(),
- bank(new VBank()),
- paperHeight(0),
- paperWidth(0),
- margins(),
- usePrinterFields(true),
+ : QObject(parent),
+ papers(),
+ bank(new VBank()),
+ paperHeight(0),
+ paperWidth(0),
+ margins(),
+ usePrinterFields(true),
#ifdef Q_CC_MSVC
- // See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
- stopGeneration(ATOMIC_VAR_INIT(false)),
+ // See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
+ stopGeneration(ATOMIC_VAR_INIT(false)),
#else
- stopGeneration(false),
+ stopGeneration(false),
#endif
- state(LayoutErrors::NoError),
- shift(0),
- rotate(true),
- followGrainline(false),
- rotationNumber(2),
- autoCropLength(false),
- autoCropWidth(false),
- saveLength(false),
- unitePages(false),
- stripOptimizationEnabled(false),
- multiplier(1),
- stripOptimization(false),
- textAsPaths(false)
-{}
+ state(LayoutErrors::NoError),
+ shift(0),
+ rotate(true),
+ followGrainline(false),
+ rotationNumber(2),
+ autoCropLength(false),
+ autoCropWidth(false),
+ saveLength(false),
+ unitePages(false),
+ stripOptimizationEnabled(false),
+ multiplier(1),
+ stripOptimization(false),
+ textAsPaths(false)
+{
+}
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::~VLayoutGenerator()
@@ -149,10 +149,10 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
auto SetStrip = [this, b](int &side)
{
- if (side >= b*2)
+ if (side >= b * 2)
{
stripOptimizationEnabled = true;
- side = qFloor(side / qFloor(side/b));
+ side = qFloor(side / qFloor(side / b));
}
};
@@ -224,7 +224,7 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
{
return;
}
- } while(bank->LeftToArrange() > 0);
+ } while (bank->LeftToArrange() > 0);
if (stopGeneration.load())
{
@@ -329,7 +329,7 @@ auto VLayoutGenerator::GetGlobalContours() const -> QList
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutGenerator::GetAllDetailsItems() const -> QList>
{
- QList > list;
+ QList> list;
list.reserve(papers.count());
for (const auto &paper : papers)
{
@@ -341,7 +341,7 @@ auto VLayoutGenerator::GetAllDetailsItems() const -> QList QVector>
{
- QVector > list;
+ QVector