Merged with feature.
--HG-- branch : develop
This commit is contained in:
commit
d25979f054
|
@ -7,6 +7,8 @@
|
||||||
- New feature Zoom Fit Best Current pattern piece.
|
- New feature Zoom Fit Best Current pattern piece.
|
||||||
- [#693] New feature: Sort workpiece "Groups" by name.
|
- [#693] New feature: Sort workpiece "Groups" by name.
|
||||||
- [#712] Default seam allowance setting.
|
- [#712] Default seam allowance setting.
|
||||||
|
- [#630] Improve export: upgrade to DXF r14 format.
|
||||||
|
- [#669] Improve export: export labels as text in DXF.
|
||||||
|
|
||||||
# Version 0.5.1
|
# Version 0.5.1
|
||||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||||
|
|
|
@ -278,7 +278,7 @@ GCC_DEBUG_CXXFLAGS += \
|
||||||
# -Winline \
|
# -Winline \
|
||||||
-Winvalid-pch \
|
-Winvalid-pch \
|
||||||
# -Wunsafe-loop-optimizations \
|
# -Wunsafe-loop-optimizations \
|
||||||
-Wlong-long \
|
# -Wlong-long \ We have been using C++11
|
||||||
-Wmissing-format-attribute \
|
-Wmissing-format-attribute \
|
||||||
-Wswitch-default \
|
-Wswitch-default \
|
||||||
-Wuninitialized \
|
-Wuninitialized \
|
||||||
|
@ -517,7 +517,7 @@ CLANG_DEBUG_CXXFLAGS += \
|
||||||
-Wno-c++98-compat-local-type-template-args \
|
-Wno-c++98-compat-local-type-template-args \
|
||||||
-Wlogical-not-parentheses \
|
-Wlogical-not-parentheses \
|
||||||
-Wlogical-op-parentheses \
|
-Wlogical-op-parentheses \
|
||||||
-Wlong-long \
|
# -Wlong-long \ We have been using C++11
|
||||||
-Wloop-analysis \
|
-Wloop-analysis \
|
||||||
-Wmain \
|
-Wmain \
|
||||||
-Wmain-return-type \
|
-Wmain-return-type \
|
||||||
|
|
32
dist/OBS_debian/debian.valentina.1
vendored
32
dist/OBS_debian/debian.valentina.1
vendored
|
@ -32,7 +32,7 @@ The path to output destination folder. By default the directory at which the app
|
||||||
.BR "*" " PDF files (*.pdf) = 1,"
|
.BR "*" " PDF files (*.pdf) = 1,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " Images (*.png) = 2,"
|
.BR "*" " Image files (*.png) = 2,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " Wavefront OBJ (*.obj) = 3,"
|
.BR "*" " Wavefront OBJ (*.obj) = 3,"
|
||||||
|
@ -44,8 +44,36 @@ The path to output destination folder. By default the directory at which the app
|
||||||
.BR "*" " EPS files (*.eps) = 5,"
|
.BR "*" " EPS files (*.eps) = 5,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " DXF files (*.dxf) = 6."
|
.BR "*" " AutoCAD DXF R10 (flat) files (*.dxf) = 6,"
|
||||||
.RE
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R11/12 (flat) files (*.dxf) = 7,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R13 (flat) files (*.dxf) = 8,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R14 (flat) files (*.dxf) = 9,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2000 (flat) files (*.dxf) = 10,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2004 (flat) files (*.dxf) = 11,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2007 (flat) files (*.dxf) = 12,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2010 (flat) files (*.dxf) = 13,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14."
|
||||||
|
.RE
|
||||||
|
.IP "--bdxf"
|
||||||
|
.RB "Export dxf in binary form."
|
||||||
|
.IP "--text2paths"
|
||||||
|
.RB "Export text as paths."
|
||||||
.IP "-x, --gsize <The size value>"
|
.IP "-x, --gsize <The size value>"
|
||||||
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
|
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
|
||||||
.IP "-e, --gheight <The height value>"
|
.IP "-e, --gheight <The height value>"
|
||||||
|
|
32
dist/debian/valentina.1
vendored
32
dist/debian/valentina.1
vendored
|
@ -32,7 +32,7 @@ The path to output destination folder. By default the directory at which the app
|
||||||
.BR "*" " PDF files (*.pdf) = 1,"
|
.BR "*" " PDF files (*.pdf) = 1,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " Images (*.png) = 2,"
|
.BR "*" " Image files (*.png) = 2,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " Wavefront OBJ (*.obj) = 3,"
|
.BR "*" " Wavefront OBJ (*.obj) = 3,"
|
||||||
|
@ -44,8 +44,36 @@ The path to output destination folder. By default the directory at which the app
|
||||||
.BR "*" " EPS files (*.eps) = 5,"
|
.BR "*" " EPS files (*.eps) = 5,"
|
||||||
.RE
|
.RE
|
||||||
.RS
|
.RS
|
||||||
.BR "*" " DXF files (*.dxf) = 6."
|
.BR "*" " AutoCAD DXF R10 (flat) files (*.dxf) = 6,"
|
||||||
.RE
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R11/12 (flat) files (*.dxf) = 7,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R13 (flat) files (*.dxf) = 8,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF R14 (flat) files (*.dxf) = 9,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2000 (flat) files (*.dxf) = 10,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2004 (flat) files (*.dxf) = 11,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2007 (flat) files (*.dxf) = 12,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2010 (flat) files (*.dxf) = 13,"
|
||||||
|
.RE
|
||||||
|
.RS
|
||||||
|
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14."
|
||||||
|
.RE
|
||||||
|
.IP "--bdxf"
|
||||||
|
.RB "Export dxf in binary form."
|
||||||
|
.IP "--text2paths"
|
||||||
|
.RB "Export text as paths."
|
||||||
.IP "-x, --gsize <The size value>"
|
.IP "-x, --gsize <The size value>"
|
||||||
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
|
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
|
||||||
.IP "-e, --gheight <The height value>"
|
.IP "-e, --gheight <The height value>"
|
||||||
|
|
|
@ -100,6 +100,14 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
|
||||||
DialogSaveLayout::MakeHelpFormatList(),
|
DialogSaveLayout::MakeHelpFormatList(),
|
||||||
translate("VCommandLine", "Format number"), "0"));
|
translate("VCommandLine", "Format number"), "0"));
|
||||||
|
|
||||||
|
optionsIndex.insert(LONG_OPTION_BINARYDXF, index++);
|
||||||
|
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_BINARYDXF,
|
||||||
|
translate("VCommandLine", "Export dxf in binary form.")));
|
||||||
|
|
||||||
|
optionsIndex.insert(LONG_OPTION_TEXT2PATHS, index++);
|
||||||
|
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TEXT2PATHS,
|
||||||
|
translate("VCommandLine", "Export text as paths.")));
|
||||||
|
|
||||||
optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++);
|
optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++);
|
||||||
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
|
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
|
||||||
translate("VCommandLine", "Set size value a pattern file, that was opened "
|
translate("VCommandLine", "Set size value a pattern file, that was opened "
|
||||||
|
@ -617,6 +625,18 @@ int VCommandLine::OptExportType() const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VCommandLine::IsBinaryDXF() const
|
||||||
|
{
|
||||||
|
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BINARYDXF)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VCommandLine::IsTextAsPaths() const
|
||||||
|
{
|
||||||
|
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_TEXT2PATHS)));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VCommandLine::OptInputFileNames() const
|
QStringList VCommandLine::OptInputFileNames() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,9 @@ public:
|
||||||
//@brief returns export type set, defaults 0 - svg
|
//@brief returns export type set, defaults 0 - svg
|
||||||
int OptExportType() const;
|
int OptExportType() const;
|
||||||
|
|
||||||
|
int IsBinaryDXF() const;
|
||||||
|
int IsTextAsPaths() const;
|
||||||
|
|
||||||
//generator creation is moved here ... because most options are for it only, so no need to create extra getters...
|
//generator creation is moved here ... because most options are for it only, so no need to create extra getters...
|
||||||
//@brief creates VLayoutGenerator
|
//@brief creates VLayoutGenerator
|
||||||
VLayoutGeneratorPtr DefaultGenerator() const;
|
VLayoutGeneratorPtr DefaultGenerator() const;
|
||||||
|
|
|
@ -57,6 +57,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
|
||||||
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
|
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
|
||||||
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
|
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
|
||||||
ui->checkBoxHideMainPath->setChecked(qApp->ValentinaSettings()->IsHideMainPath());
|
ui->checkBoxHideMainPath->setChecked(qApp->ValentinaSettings()->IsHideMainPath());
|
||||||
|
ui->fontComboBoxLabelFont->setCurrentFont(qApp->ValentinaSettings()->GetLabelFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -85,6 +86,7 @@ void PreferencesPatternPage::Apply()
|
||||||
|
|
||||||
settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked());
|
settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked());
|
||||||
settings->SetHideMainPath(ui->checkBoxHideMainPath->isChecked());
|
settings->SetHideMainPath(ui->checkBoxHideMainPath->isChecked());
|
||||||
|
qApp->ValentinaSettings()->SetLabelFont(ui->fontComboBoxLabelFont->currentFont());
|
||||||
|
|
||||||
if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked())
|
if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked())
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>327</width>
|
<width>381</width>
|
||||||
<height>482</height>
|
<height>444</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -133,6 +133,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Label font:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFontComboBox" name="fontComboBoxLabelFont"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -337,6 +337,18 @@ void DialogLayoutSettings::SetIgnoreAllFields(bool value)
|
||||||
ui->checkBoxIgnoreFileds->setChecked(value);
|
ui->checkBoxIgnoreFileds->setChecked(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogLayoutSettings::IsTextAsPaths() const
|
||||||
|
{
|
||||||
|
return ui->checkBoxTextAsPaths->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLayoutSettings::SetTextAsPaths(bool value)
|
||||||
|
{
|
||||||
|
ui->checkBoxTextAsPaths->setChecked(value);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogLayoutSettings::SelectedPrinter() const
|
QString DialogLayoutSettings::SelectedPrinter() const
|
||||||
{
|
{
|
||||||
|
@ -568,6 +580,7 @@ void DialogLayoutSettings::DialogAccepted()
|
||||||
generator->SetUnitePages(IsUnitePages());
|
generator->SetUnitePages(IsUnitePages());
|
||||||
generator->SetStripOptimization(IsStripOptimization());
|
generator->SetStripOptimization(IsStripOptimization());
|
||||||
generator->SetMultiplier(GetMultiplier());
|
generator->SetMultiplier(GetMultiplier());
|
||||||
|
generator->SetTestAsPaths(IsTextAsPaths());
|
||||||
|
|
||||||
if (IsIgnoreAllFields())
|
if (IsIgnoreAllFields())
|
||||||
{
|
{
|
||||||
|
@ -659,6 +672,8 @@ void DialogLayoutSettings::RestoreDefaults()
|
||||||
|
|
||||||
CorrectMaxFileds();
|
CorrectMaxFileds();
|
||||||
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
|
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
|
||||||
|
|
||||||
|
ui->checkBoxTextAsPaths->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1070,6 +1085,7 @@ void DialogLayoutSettings::ReadSettings()
|
||||||
SetIgnoreAllFields(settings->GetIgnoreAllFields());
|
SetIgnoreAllFields(settings->GetIgnoreAllFields());
|
||||||
SetStripOptimization(settings->GetStripOptimization());
|
SetStripOptimization(settings->GetStripOptimization());
|
||||||
SetMultiplier(settings->GetMultiplier());
|
SetMultiplier(settings->GetMultiplier());
|
||||||
|
SetTextAsPaths(settings->GetTextAsPaths());
|
||||||
|
|
||||||
FindTemplate();
|
FindTemplate();
|
||||||
|
|
||||||
|
@ -1095,6 +1111,7 @@ void DialogLayoutSettings::WriteSettings() const
|
||||||
settings->SetIgnoreAllFields(IsIgnoreAllFields());
|
settings->SetIgnoreAllFields(IsIgnoreAllFields());
|
||||||
settings->SetStripOptimization(IsStripOptimization());
|
settings->SetStripOptimization(IsStripOptimization());
|
||||||
settings->SetMultiplier(GetMultiplier());
|
settings->SetMultiplier(GetMultiplier());
|
||||||
|
settings->SetTextAsPaths(IsTextAsPaths());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -110,6 +110,9 @@ public:
|
||||||
bool IsIgnoreAllFields() const;
|
bool IsIgnoreAllFields() const;
|
||||||
void SetIgnoreAllFields(bool value);
|
void SetIgnoreAllFields(bool value);
|
||||||
|
|
||||||
|
bool IsTextAsPaths() const;
|
||||||
|
void SetTextAsPaths(bool value);
|
||||||
|
|
||||||
QString SelectedPrinter() const;
|
QString SelectedPrinter() const;
|
||||||
|
|
||||||
//support functions for the command line parser which uses invisible dialog to properly build layout generator
|
//support functions for the command line parser which uses invisible dialog to properly build layout generator
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>600</width>
|
||||||
<height>531</height>
|
<height>533</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
|
@ -308,6 +308,29 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBoxText">
|
||||||
|
<property name="title">
|
||||||
|
<string>Text</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxTextAsPaths">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Text will be converted to paths</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export text as paths</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -732,7 +755,7 @@
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroupPrinciple"/>
|
|
||||||
<buttongroup name="buttonGroup"/>
|
<buttongroup name="buttonGroup"/>
|
||||||
|
<buttongroup name="buttonGroupPrinciple"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -40,6 +40,7 @@ class PreferencesConfigurationPage;
|
||||||
class PreferencesPatternPage;
|
class PreferencesPatternPage;
|
||||||
class PreferencesPathPage;
|
class PreferencesPathPage;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
class VPattern;
|
||||||
|
|
||||||
class DialogPreferences : public QDialog
|
class DialogPreferences : public QDialog
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,10 @@ bool DialogSaveLayout::tested = false;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *parent)
|
DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *parent)
|
||||||
:QDialog(parent), ui(new Ui::DialogSaveLAyout), count(count), isInitialized(false), availFormats(InitAvailFormats())
|
: QDialog(parent),
|
||||||
|
ui(new Ui::DialogSaveLAyout),
|
||||||
|
count(count),
|
||||||
|
isInitialized(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -80,20 +83,14 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (auto& v , availFormats)
|
foreach (auto& v, InitFormats())
|
||||||
{
|
{
|
||||||
ui->comboBoxFormat->addItem(v.first, QVariant(v.second));
|
ui->comboBoxFormat->addItem(v.first, QVariant(static_cast<int>(v.second)));
|
||||||
}
|
}
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
|
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
|
||||||
|
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample);
|
||||||
auto ShowExample = [this]()
|
|
||||||
{
|
|
||||||
ui->labelExample->setText(tr("Example:") + FileName() + QLatin1String("1") + Format());
|
|
||||||
};
|
|
||||||
|
|
||||||
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, ShowExample);
|
|
||||||
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, ShowExample);
|
this, &DialogSaveLayout::ShowExample);
|
||||||
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]()
|
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]()
|
||||||
{
|
{
|
||||||
const QString dirPath = qApp->ValentinaSettings()->GetPathLayout();
|
const QString dirPath = qApp->ValentinaSettings()->GetPathLayout();
|
||||||
|
@ -126,15 +123,15 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void DialogSaveLayout::SelectFormate(const int formate)
|
void DialogSaveLayout::SelectFormat(LayoutExportFormats format)
|
||||||
{
|
{
|
||||||
if (formate >= availFormats.size())
|
if (static_cast<int>(format) < 0 || format >= LayoutExportFormats::COUNT)
|
||||||
{
|
{
|
||||||
VException e(tr("Tried to use out of range format number."));
|
VException e(tr("Tried to use out of range format number."));
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int i = ui->comboBoxFormat->findData(availFormats.at(formate).second);
|
const int i = ui->comboBoxFormat->findData(static_cast<int>(format));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
VException e(tr("Selected not present format."));
|
VException e(tr("Selected not present format."));
|
||||||
|
@ -143,15 +140,104 @@ void DialogSaveLayout::SelectFormate(const int formate)
|
||||||
ui->comboBoxFormat->setCurrentIndex(i);
|
ui->comboBoxFormat->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveLayout::SetBinaryDXFFormat(bool binary)
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
ui->checkBoxBinaryDXF->setChecked(binary);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
default:
|
||||||
|
ui->checkBoxBinaryDXF->setChecked(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSaveLayout::IsBinaryDXFFormat() const
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
return ui->checkBoxBinaryDXF->isChecked();
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogSaveLayout::MakeHelpFormatList()
|
QString DialogSaveLayout::MakeHelpFormatList()
|
||||||
{
|
{
|
||||||
QString out("\n");
|
QString out("\n");
|
||||||
int cntr = 0;
|
foreach(auto& v, InitFormats())
|
||||||
const QVector<std::pair<QString, QString>> availFormats = InitAvailFormats();
|
|
||||||
foreach(auto& v, availFormats)
|
|
||||||
{
|
{
|
||||||
out += QLatin1String("\t") + v.first+QLatin1String(" = ") + QString::number(cntr++) + QLatin1String("\n");
|
out += QLatin1String("\t") + v.first + QLatin1String(" = ") + QString::number(static_cast<int>(v.second))
|
||||||
|
+ QLatin1String("\n");
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +269,136 @@ void DialogSaveLayout::SetDestinationPath(const QString &cmdDestinationPath)
|
||||||
ui->lineEditPath->setText(path);
|
ui->lineEditPath->setText(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format)
|
||||||
|
{
|
||||||
|
const QString dxfSuffix = QStringLiteral("(*.dxf)");
|
||||||
|
const QString dxfFlatFilesStr = tr("(flat) files");
|
||||||
|
const QString filesStr = tr("files");
|
||||||
|
|
||||||
|
switch(format)
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
return QString("Svg %1 (*.svg)").arg(filesStr);
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
return QString("PDF %1 (*.pdf)").arg(filesStr);
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
return tr("Image files") + QLatin1String(" (*.png)");
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
return "Wavefront OBJ (*.obj)";
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
return QString("PS %1 (*.ps)").arg(filesStr);
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
return QString("EPS %1 (*.eps)").arg(filesStr);
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
return QString("AutoCAD DXF R10 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
return QString("AutoCAD DXF R11/12 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
return QString("AutoCAD DXF R13 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
return QString("AutoCAD DXF R14 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
return QString("AutoCAD DXF 2000 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
return QString("AutoCAD DXF 2004 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
return QString("AutoCAD DXF 2007 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
return QString("AutoCAD DXF 2010 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
return QString("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
return QString("AutoCAD DXF R10 AAMA %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
return QString("AutoCAD DXF R11/12 AAMA %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
return QString("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
return QString("AutoCAD DXF R14 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
return QString("AutoCAD DXF 2000 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
return QString("AutoCAD DXF 2004 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
return QString("AutoCAD DXF 2007 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
return QString("AutoCAD DXF 2010 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
return QString("AutoCAD DXF 2013 AAMA %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
return QString("AutoCAD DXF R10 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
return QString("AutoCAD DXF R11/12 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
return QString("AutoCAD DXF R13 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
return QString("AutoCAD DXF R14 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
return QString("AutoCAD DXF 2000 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
return QString("AutoCAD DXF 2004 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
return QString("AutoCAD DXF 2007 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
return QString("AutoCAD DXF 2010 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
return QString("AutoCAD DXF 2013 ASTM %1 %2").arg(filesStr, dxfSuffix);
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogSaveLayout::ExportFromatSuffix(LayoutExportFormats format)
|
||||||
|
{
|
||||||
|
switch(format)
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
return ".svg";
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
return ".pdf";
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
return ".png";
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
return ".obj";
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
return ".ps";
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
return ".eps";
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
return ".dxf";
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogSaveLayout::~DialogSaveLayout()
|
DialogSaveLayout::~DialogSaveLayout()
|
||||||
{
|
{
|
||||||
|
@ -202,9 +418,9 @@ QString DialogSaveLayout::FileName() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogSaveLayout::Format() const
|
LayoutExportFormats DialogSaveLayout::Format() const
|
||||||
{
|
{
|
||||||
return ui->comboBoxFormat->currentData().toString();
|
return static_cast<LayoutExportFormats>(ui->comboBoxFormat->currentData().toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -212,7 +428,7 @@ void DialogSaveLayout::Save()
|
||||||
{
|
{
|
||||||
for (int i=0; i < count; ++i)
|
for (int i=0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const QString name = Path()+QLatin1Literal("/")+FileName()+QString::number(i+1)+Format();
|
const QString name = Path()+QLatin1Literal("/")+FileName()+QString::number(i+1)+ExportFromatSuffix(Format());
|
||||||
if (QFile::exists(name))
|
if (QFile::exists(name))
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
|
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
|
||||||
|
@ -256,6 +472,55 @@ void DialogSaveLayout::PathChanged(const QString &text)
|
||||||
ui->lineEditPath->setPalette(palette);
|
ui->lineEditPath->setPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveLayout::ShowExample()
|
||||||
|
{
|
||||||
|
const LayoutExportFormats currentFormat = Format();
|
||||||
|
ui->labelExample->setText(tr("Example:") + FileName() + QLatin1String("1") + ExportFromatSuffix(currentFormat));
|
||||||
|
|
||||||
|
switch(currentFormat)
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
ui->checkBoxBinaryDXF->setEnabled(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
default:
|
||||||
|
ui->checkBoxBinaryDXF->setEnabled(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSaveLayout::showEvent(QShowEvent *event)
|
void DialogSaveLayout::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -311,22 +576,55 @@ bool DialogSaveLayout::TestPdf()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<std::pair<QString, QString>> DialogSaveLayout::InitAvailFormats()
|
QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats()
|
||||||
{
|
{
|
||||||
QVector<std::pair<QString, QString>> list;
|
QVector<std::pair<QString, LayoutExportFormats>> list;
|
||||||
list.append(std::make_pair(QLatin1String("Svg ") + tr("files") + QLatin1String(" (*.svg)"), QLatin1String(".svg")));
|
|
||||||
list.append(std::make_pair(QLatin1String("PDF ") + tr("files") + QLatin1String(" (*.pdf)"), QLatin1String(".pdf")));
|
auto InitFormat = [&list](LayoutExportFormats format)
|
||||||
list.append(std::make_pair(QLatin1String("Images") + QLatin1String(" (*.png)"), QLatin1String(".png")));
|
{
|
||||||
|
list.append(std::make_pair(ExportFormatDescription(format), format));
|
||||||
|
};
|
||||||
|
|
||||||
|
InitFormat(LayoutExportFormats::SVG);
|
||||||
|
InitFormat(LayoutExportFormats::PDF);
|
||||||
|
InitFormat(LayoutExportFormats::PNG);
|
||||||
#ifndef V_NO_ASSERT // Temporarily unavailable
|
#ifndef V_NO_ASSERT // Temporarily unavailable
|
||||||
list.append(std::make_pair(QLatin1String("Wavefront OBJ (*.obj)"), QLatin1String(".obj")));
|
InitFormat(LayoutExportFormats::OBJ);
|
||||||
#endif
|
#endif
|
||||||
if (SupportPSTest())
|
if (SupportPSTest())
|
||||||
{
|
{
|
||||||
list.append(std::make_pair(QLatin1String("PS ") + tr("files") + QLatin1String(" (*.ps)"),
|
InitFormat(LayoutExportFormats::PS);
|
||||||
QLatin1String(".ps")));
|
InitFormat(LayoutExportFormats::EPS);
|
||||||
list.append(std::make_pair(QLatin1String("EPS ") + tr("files") + QLatin1String(" (*.eps)"),
|
|
||||||
QLatin1String(".eps")));
|
|
||||||
}
|
}
|
||||||
list.append(std::make_pair(QLatin1String("DXF ") + tr("files") + QLatin1String(" (*.dxf)"), QLatin1String(".dxf")));
|
InitFormat(LayoutExportFormats::DXF_AC1006_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1009_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1012_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1014_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1015_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1018_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1021_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1024_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1027_Flat);
|
||||||
|
|
||||||
|
// We will support them anyway
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1006_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1009_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1012_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1014_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1015_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1018_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1021_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1024_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1027_AAMA);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1006_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1009_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1012_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1014_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1015_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1018_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1021_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1024_ASTM);
|
||||||
|
// InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,38 +42,82 @@ namespace Ui
|
||||||
class DialogSaveLAyout;
|
class DialogSaveLAyout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class LayoutExportFormats : char
|
||||||
|
{
|
||||||
|
SVG = 0,
|
||||||
|
PDF = 1,
|
||||||
|
PNG = 2,
|
||||||
|
OBJ = 3, /* Wavefront OBJ*/
|
||||||
|
PS = 4,
|
||||||
|
EPS = 5,
|
||||||
|
DXF_AC1006_Flat = 6, /*< R10. */
|
||||||
|
DXF_AC1009_Flat = 7, /*< R11 & R12. */
|
||||||
|
DXF_AC1012_Flat = 8, /*< R13. */
|
||||||
|
DXF_AC1014_Flat = 9, /*< R14. */
|
||||||
|
DXF_AC1015_Flat = 10, /*< ACAD 2000. */
|
||||||
|
DXF_AC1018_Flat = 11, /*< ACAD 2004. */
|
||||||
|
DXF_AC1021_Flat = 12, /*< ACAD 2007. */
|
||||||
|
DXF_AC1024_Flat = 13, /*< ACAD 2010. */
|
||||||
|
DXF_AC1027_Flat = 14, /*< ACAD 2013. */
|
||||||
|
DXF_AC1006_AAMA = 15, /*< R10. */
|
||||||
|
DXF_AC1009_AAMA = 16, /*< R11 & R12. */
|
||||||
|
DXF_AC1012_AAMA = 17, /*< R13. */
|
||||||
|
DXF_AC1014_AAMA = 18, /*< R14. */
|
||||||
|
DXF_AC1015_AAMA = 19, /*< ACAD 2000. */
|
||||||
|
DXF_AC1018_AAMA = 20, /*< ACAD 2004. */
|
||||||
|
DXF_AC1021_AAMA = 21, /*< ACAD 2007. */
|
||||||
|
DXF_AC1024_AAMA = 22, /*< ACAD 2010. */
|
||||||
|
DXF_AC1027_AAMA = 23, /*< ACAD 2013. */
|
||||||
|
DXF_AC1006_ASTM = 24, /*< R10. */
|
||||||
|
DXF_AC1009_ASTM = 25, /*< R11 & R12. */
|
||||||
|
DXF_AC1012_ASTM = 26, /*< R13. */
|
||||||
|
DXF_AC1014_ASTM = 27, /*< R14. */
|
||||||
|
DXF_AC1015_ASTM = 28, /*< ACAD 2000. */
|
||||||
|
DXF_AC1018_ASTM = 29, /*< ACAD 2004. */
|
||||||
|
DXF_AC1021_ASTM = 30, /*< ACAD 2007. */
|
||||||
|
DXF_AC1024_ASTM = 31, /*< ACAD 2010. */
|
||||||
|
DXF_AC1027_ASTM = 32, /*< ACAD 2013. */
|
||||||
|
COUNT /*Use only for validation*/
|
||||||
|
};
|
||||||
|
|
||||||
class DialogSaveLayout : public QDialog
|
class DialogSaveLayout : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogSaveLayout(int count, const QString &fileName = QString(),
|
explicit DialogSaveLayout(int count, const QString &fileName = QString(), QWidget *parent = nullptr);
|
||||||
QWidget *parent = 0);
|
virtual ~DialogSaveLayout();
|
||||||
~DialogSaveLayout();
|
|
||||||
|
|
||||||
QString Path() const;
|
QString Path() const;
|
||||||
QString FileName() const;
|
QString FileName() const;
|
||||||
QString Format() const;
|
|
||||||
void SelectFormate(const int formate);
|
LayoutExportFormats Format() const;
|
||||||
|
void SelectFormat(LayoutExportFormats format);
|
||||||
|
|
||||||
|
void SetBinaryDXFFormat(bool binary);
|
||||||
|
bool IsBinaryDXFFormat() const;
|
||||||
|
|
||||||
static QString MakeHelpFormatList();
|
static QString MakeHelpFormatList();
|
||||||
void SetDestinationPath(const QString& cmdDestinationPath);
|
void SetDestinationPath(const QString& cmdDestinationPath);
|
||||||
|
|
||||||
|
static QString ExportFormatDescription(LayoutExportFormats format);
|
||||||
|
static QString ExportFromatSuffix(LayoutExportFormats format);
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||||
private slots:
|
private slots:
|
||||||
void Save();
|
void Save();
|
||||||
void PathChanged(const QString &text);
|
void PathChanged(const QString &text);
|
||||||
|
void ShowExample();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogSaveLayout)
|
Q_DISABLE_COPY(DialogSaveLayout)
|
||||||
Ui::DialogSaveLAyout *ui;
|
Ui::DialogSaveLAyout *ui;
|
||||||
int count;
|
int count;
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
// Note. We can't make availFormats static because MSVC doesn't support C++11 list initialization
|
|
||||||
QVector<std::pair<QString, QString>> availFormats;
|
|
||||||
static bool havePdf;
|
static bool havePdf;
|
||||||
static bool tested;
|
static bool tested;
|
||||||
static bool SupportPSTest();
|
static bool SupportPSTest();
|
||||||
static bool TestPdf();
|
static bool TestPdf();
|
||||||
static QVector<std::pair<QString, QString> > InitAvailFormats();
|
static QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGSAVELAYOUT_H
|
#endif // DIALOGSAVELAYOUT_H
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>748</width>
|
<width>748</width>
|
||||||
<height>150</height>
|
<height>178</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -92,14 +92,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>File name:</string>
|
<string>File name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEditFileName">
|
<widget class="QLineEdit" name="lineEditFileName">
|
||||||
|
@ -135,6 +135,23 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkBoxBinaryDXF">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Binary form</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "ui_vwidgetgroups.h"
|
#include "ui_vwidgetgroups.h"
|
||||||
#include "../vtools/dialogs/tools/dialoggroup.h"
|
#include "../vtools/dialogs/tools/dialoggroup.h"
|
||||||
#include "../vtools/undocommands/delgroup.h"
|
#include "../vtools/undocommands/delgroup.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
|
@ -4350,6 +4350,7 @@ void MainWindow::Preferences()
|
||||||
connect(dlg.data(), &DialogPreferences::UpdateProperties, toolOptions,
|
connect(dlg.data(), &DialogPreferences::UpdateProperties, toolOptions,
|
||||||
&VToolOptionsPropertyBrowser::RefreshOptions);
|
&VToolOptionsPropertyBrowser::RefreshOptions);
|
||||||
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles);
|
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles);
|
||||||
|
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::RefreshDetailsLabel);
|
||||||
QGuiApplication::restoreOverrideCursor();
|
QGuiApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
if (guard->exec() == QDialog::Accepted)
|
if (guard->exec() == QDialog::Accepted)
|
||||||
|
@ -4677,8 +4678,6 @@ void MainWindow::ZoomFirstShow()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::DoExport(const VCommandLinePtr &expParams)
|
void MainWindow::DoExport(const VCommandLinePtr &expParams)
|
||||||
{
|
{
|
||||||
auto settings = expParams->DefaultGenerator();
|
|
||||||
|
|
||||||
const QHash<quint32, VPiece> *details = pattern->DataPieces();
|
const QHash<quint32, VPiece> *details = pattern->DataPieces();
|
||||||
if(not qApp->getOpeningPattern())
|
if(not qApp->getOpeningPattern())
|
||||||
{
|
{
|
||||||
|
@ -4690,13 +4689,18 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrepareDetailsForLayout(details);
|
PrepareDetailsForLayout(details);
|
||||||
|
|
||||||
|
auto settings = expParams->DefaultGenerator();
|
||||||
|
settings->SetTestAsPaths(expParams->IsTextAsPaths());
|
||||||
|
|
||||||
if (LayoutSettings(*settings.get()))
|
if (LayoutSettings(*settings.get()))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DialogSaveLayout dialog(scenes.size(), expParams->OptBaseName(), this);
|
DialogSaveLayout dialog(scenes.size(), expParams->OptBaseName(), this);
|
||||||
dialog.SetDestinationPath(expParams->OptDestinationPath());
|
dialog.SetDestinationPath(expParams->OptDestinationPath());
|
||||||
dialog.SelectFormate(expParams->OptExportType());
|
dialog.SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
|
||||||
|
dialog.SetBinaryDXFFormat(expParams->IsBinaryDXF());
|
||||||
ExportLayout(dialog);
|
ExportLayout(dialog);
|
||||||
}
|
}
|
||||||
catch (const VException &e)
|
catch (const VException &e)
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
|
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
|
||||||
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
|
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
|
||||||
#include "../vtools/tools/vabstracttool.h"
|
#include "../vtools/tools/vabstracttool.h"
|
||||||
|
#include "../vtools/tools/vtoolseamallowance.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -200,8 +201,6 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
|
void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
|
||||||
{
|
{
|
||||||
|
|
||||||
const QString suf = dialog.Format().replace(".", "");
|
|
||||||
const QString path = dialog.Path();
|
const QString path = dialog.Path();
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
dir.setPath(path);
|
dir.setPath(path);
|
||||||
|
@ -215,51 +214,108 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
|
||||||
}
|
}
|
||||||
qApp->ValentinaSettings()->SetPathLayout(path);
|
qApp->ValentinaSettings()->SetPathLayout(path);
|
||||||
const QString mask = dialog.FileName();
|
const QString mask = dialog.FileName();
|
||||||
|
const LayoutExportFormats format = dialog.Format();
|
||||||
|
|
||||||
for (int i=0; i < scenes.size(); ++i)
|
for (int i=0; i < scenes.size(); ++i)
|
||||||
{
|
{
|
||||||
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
|
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
|
||||||
if (paper)
|
if (paper)
|
||||||
{
|
{
|
||||||
const QString name = path + QLatin1String("/") + mask+QString::number(i+1) + dialog.Format();
|
const QString name = path + QLatin1String("/") + mask+QString::number(i+1)
|
||||||
|
+ DialogSaveLayout::ExportFromatSuffix(format);
|
||||||
QBrush *brush = new QBrush();
|
QBrush *brush = new QBrush();
|
||||||
brush->setColor( QColor( Qt::white ) );
|
brush->setColor( QColor( Qt::white ) );
|
||||||
scenes[i]->setBackgroundBrush( *brush );
|
scenes[i]->setBackgroundBrush( *brush );
|
||||||
shadows[i]->setVisible(false);
|
shadows[i]->setVisible(false);
|
||||||
paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), 0.1, Qt::NoPen));
|
paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), 0.1, Qt::NoPen));
|
||||||
const QStringList suffix = QStringList() << QLatin1String("svg")
|
|
||||||
<< QLatin1String("png")
|
switch (format)
|
||||||
<< QLatin1String("pdf")
|
|
||||||
<< QLatin1String("eps")
|
|
||||||
<< QLatin1String("ps")
|
|
||||||
<< QLatin1String("obj")
|
|
||||||
<< QLatin1String("dxf");
|
|
||||||
switch (suffix.indexOf(suf))
|
|
||||||
{
|
{
|
||||||
case 0: //svg
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
Q_UNREACHABLE(); // For now not supported
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
SvgFile(name, i);
|
SvgFile(name, i);
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case 1: //png
|
case LayoutExportFormats::PDF:
|
||||||
PngFile(name, i);
|
|
||||||
break;
|
|
||||||
case 2: //pdf
|
|
||||||
PdfFile(name, i);
|
PdfFile(name, i);
|
||||||
break;
|
break;
|
||||||
case 3: //eps
|
case LayoutExportFormats::PNG:
|
||||||
EpsFile(name, i);
|
PngFile(name, i);
|
||||||
break;
|
break;
|
||||||
case 4: //ps
|
case LayoutExportFormats::OBJ:
|
||||||
PsFile(name, i);
|
|
||||||
break;
|
|
||||||
case 5: //obj
|
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
ObjFile(name, i);
|
ObjFile(name, i);
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case 6: //dxf
|
case LayoutExportFormats::PS:
|
||||||
DxfFile(name, i);
|
PsFile(name, i);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
EpsFile(name, i);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
paper->setVisible(false);
|
||||||
|
DxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), i);
|
||||||
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Can't recognize file suffix." << Q_FUNC_INFO;
|
qDebug() << "Can't recognize file suffix." << Q_FUNC_INFO;
|
||||||
|
@ -473,6 +529,25 @@ void MainWindowsNoGUI::PrintTiled()
|
||||||
LayoutPrint();
|
LayoutPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief RefreshDetailsLabel call to ecalculate piece labels. For example after changing a font.
|
||||||
|
*/
|
||||||
|
void MainWindowsNoGUI::RefreshDetailsLabel()
|
||||||
|
{
|
||||||
|
const QHash<quint32, VPiece> *list = pattern->DataPieces();
|
||||||
|
QHash<quint32, VPiece>::const_iterator i = list->constBegin();
|
||||||
|
while (i != list->constEnd())
|
||||||
|
{
|
||||||
|
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(i.key())))
|
||||||
|
{
|
||||||
|
tool->UpdatePatternInfo();
|
||||||
|
tool->UpdateDetailLabel();
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VPiece> *details)
|
void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VPiece> *details)
|
||||||
{
|
{
|
||||||
|
@ -763,15 +838,18 @@ void MainWindowsNoGUI::ObjFile(const QString &name, int i) const
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
|
|
||||||
void MainWindowsNoGUI::DxfFile(const QString &name, int i) const
|
void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, int i) const
|
||||||
{
|
{
|
||||||
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
|
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
|
||||||
if (paper)
|
if (paper)
|
||||||
{
|
{
|
||||||
|
PrepareTextForDXF(endStringPlaceholder);
|
||||||
VDxfPaintDevice generator;
|
VDxfPaintDevice generator;
|
||||||
generator.setFileName(name);
|
generator.setFileName(name);
|
||||||
generator.setSize(paper->rect().size().toSize());
|
generator.setSize(paper->rect().size().toSize());
|
||||||
generator.setResolution(PrintDPI);
|
generator.setResolution(PrintDPI);
|
||||||
|
generator.SetVersion(static_cast<DRW::Version>(version));
|
||||||
|
generator.SetBinaryFormat(binary);
|
||||||
|
|
||||||
switch (*pattern->GetPatternUnit())
|
switch (*pattern->GetPatternUnit())
|
||||||
{
|
{
|
||||||
|
@ -796,6 +874,7 @@ void MainWindowsNoGUI::DxfFile(const QString &name, int i) const
|
||||||
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
|
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
RestoreTextAfterDXF(endStringPlaceholder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,6 +908,72 @@ void MainWindowsNoGUI::RestorePaper(int index) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf.
|
||||||
|
*
|
||||||
|
* Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special
|
||||||
|
* placholder. This method append it.
|
||||||
|
*
|
||||||
|
* @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string.
|
||||||
|
*/
|
||||||
|
void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < details.size(); ++i)
|
||||||
|
{
|
||||||
|
const QList<QGraphicsItem *> &paperItems = details.at(i);
|
||||||
|
for (int j = 0; j < paperItems.size(); ++j)
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem *> pieceChildren = paperItems.at(i)->childItems();
|
||||||
|
for (int k = 0; k < pieceChildren.size(); ++k)
|
||||||
|
{
|
||||||
|
QGraphicsItem *item = pieceChildren.at(k);
|
||||||
|
if (item->type() == QGraphicsSimpleTextItem::Type)
|
||||||
|
{
|
||||||
|
if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item))
|
||||||
|
{
|
||||||
|
textItem->setText(textItem->text() + placeholder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief MainWindowsNoGUI::RestoreTextAfterDXF restore QGraphicsSimpleTextItem items after export to flat dxf.
|
||||||
|
*
|
||||||
|
* Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special
|
||||||
|
* placholder. This method remove it.
|
||||||
|
*
|
||||||
|
* @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string.
|
||||||
|
*/
|
||||||
|
void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < details.size(); ++i)
|
||||||
|
{
|
||||||
|
const QList<QGraphicsItem *> &paperItems = details.at(i);
|
||||||
|
for (int j = 0; j < paperItems.size(); ++j)
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem *> pieceChildren = paperItems.at(i)->childItems();
|
||||||
|
for (int k = 0; k < pieceChildren.size(); ++k)
|
||||||
|
{
|
||||||
|
QGraphicsItem *item = pieceChildren.at(k);
|
||||||
|
if (item->type() == QGraphicsSimpleTextItem::Type)
|
||||||
|
{
|
||||||
|
if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item))
|
||||||
|
{
|
||||||
|
QString text = textItem->text();
|
||||||
|
text.replace(placeholder, "");
|
||||||
|
textItem->setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindowsNoGUI::SaveLayoutAs()
|
void MainWindowsNoGUI::SaveLayoutAs()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ public slots:
|
||||||
void PrintPreviewTiled();
|
void PrintPreviewTiled();
|
||||||
void PrintOrigin();
|
void PrintOrigin();
|
||||||
void PrintTiled();
|
void PrintTiled();
|
||||||
|
void RefreshDetailsLabel();
|
||||||
protected:
|
protected:
|
||||||
QVector<VLayoutPiece> listDetails;
|
QVector<VLayoutPiece> listDetails;
|
||||||
|
|
||||||
|
@ -120,11 +121,14 @@ private:
|
||||||
void PsFile(const QString &name, int i)const;
|
void PsFile(const QString &name, int i)const;
|
||||||
void PdfToPs(const QStringList ¶ms)const;
|
void PdfToPs(const QStringList ¶ms)const;
|
||||||
void ObjFile(const QString &name, int i)const;
|
void ObjFile(const QString &name, int i)const;
|
||||||
void DxfFile(const QString &name, int i)const;
|
void DxfFile(const QString &name, int version, bool binary, int i)const;
|
||||||
|
|
||||||
void PreparePaper(int index) const;
|
void PreparePaper(int index) const;
|
||||||
void RestorePaper(int index) const;
|
void RestorePaper(int index) const;
|
||||||
|
|
||||||
|
void PrepareTextForDXF(const QString &placeholder) const;
|
||||||
|
void RestoreTextAfterDXF(const QString &placeholder) const;
|
||||||
|
|
||||||
void SaveLayoutAs();
|
void SaveLayoutAs();
|
||||||
void PrintPreview();
|
void PrintPreview();
|
||||||
void LayoutPrint();
|
void LayoutPrint();
|
||||||
|
|
33
src/libs/vdxf/dxfdef.cpp
Normal file
33
src/libs/vdxf/dxfdef.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 29 6, 2017
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2017 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "dxfdef.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
const QString endStringPlaceholder = QStringLiteral("%&?_?&%");
|
|
@ -1,6 +1,6 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file def.h
|
** @file dxfdef.h
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
** @date 31 8, 2015
|
** @date 31 8, 2015
|
||||||
**
|
**
|
||||||
|
@ -40,6 +40,9 @@ enum class VarMeasurement : unsigned char { English=0, Metric=1 };
|
||||||
//Default drawing units for AutoCAD DesignCenter blocks:
|
//Default drawing units for AutoCAD DesignCenter blocks:
|
||||||
enum class VarInsunits : unsigned char { Inches=1, Millimeters=4, Centimeters=5 };
|
enum class VarInsunits : unsigned char { Inches=1, Millimeters=4, Centimeters=5 };
|
||||||
|
|
||||||
|
// Helps mark end of string. See VDxfEngine::drawTextItem for more details
|
||||||
|
extern const QString endStringPlaceholder;
|
||||||
|
|
||||||
Q_REQUIRED_RESULT static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2);
|
Q_REQUIRED_RESULT static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2);
|
||||||
static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2)
|
static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,260 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_ATTRIBUTES_H
|
|
||||||
#define DL_ATTRIBUTES_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dl_codes.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Storing and passing around attributes. Attributes
|
|
||||||
* are the layer name, color, width and line type.
|
|
||||||
*
|
|
||||||
* @author Andrew Mustun
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_Attributes
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
DL_Attributes() :
|
|
||||||
layer(""),
|
|
||||||
color(0),
|
|
||||||
color24(-1),
|
|
||||||
width(0),
|
|
||||||
linetype("BYLAYER"),
|
|
||||||
linetypeScale(1.0),
|
|
||||||
handle(-1),
|
|
||||||
inPaperSpace(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DXF attributes.
|
|
||||||
*
|
|
||||||
* @param layer Layer name for this entity or NULL for no layer
|
|
||||||
* (every entity should be on a named layer!).
|
|
||||||
* @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
|
|
||||||
* @param width Line thickness. Defaults to zero. -1 = BYLAYER,
|
|
||||||
* -2 = BYBLOCK, -3 = default width
|
|
||||||
* @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults
|
|
||||||
* to "BYLAYER"
|
|
||||||
*/
|
|
||||||
DL_Attributes(const std::string& layer,
|
|
||||||
int color, int width,
|
|
||||||
const std::string& linetype,
|
|
||||||
double linetypeScale) :
|
|
||||||
layer(layer),
|
|
||||||
color(color),
|
|
||||||
color24(-1),
|
|
||||||
width(width),
|
|
||||||
linetype(linetype),
|
|
||||||
linetypeScale(linetypeScale),
|
|
||||||
handle(-1),
|
|
||||||
inPaperSpace(false)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DXF attributes.
|
|
||||||
*
|
|
||||||
* @param layer Layer name for this entity or NULL for no layer
|
|
||||||
* (every entity should be on a named layer!).
|
|
||||||
* @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
|
|
||||||
* @param color24 24 bit color (0x00RRGGBB, see DXF reference).
|
|
||||||
* @param width Line thickness. Defaults to zero. -1 = BYLAYER,
|
|
||||||
* -2 = BYBLOCK, -3 = default width
|
|
||||||
* @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults
|
|
||||||
* to "BYLAYER"
|
|
||||||
*/
|
|
||||||
DL_Attributes(const std::string& layer,
|
|
||||||
int color, int color24, int width,
|
|
||||||
const std::string& linetype,
|
|
||||||
int handle=-1) :
|
|
||||||
layer(layer),
|
|
||||||
color(color),
|
|
||||||
color24(color24),
|
|
||||||
width(width),
|
|
||||||
linetype(linetype),
|
|
||||||
linetypeScale(1.0),
|
|
||||||
handle(handle),
|
|
||||||
inPaperSpace(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the layer. If the given pointer points to NULL, the
|
|
||||||
* new layer name will be an empty but valid string.
|
|
||||||
*/
|
|
||||||
void setLayer(const std::string& layer)
|
|
||||||
{
|
|
||||||
this->layer = layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Layer name.
|
|
||||||
*/
|
|
||||||
std::string getLayer() const
|
|
||||||
{
|
|
||||||
return layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the color.
|
|
||||||
*
|
|
||||||
* @see DL_Codes, dxfColors
|
|
||||||
*/
|
|
||||||
void setColor(int color)
|
|
||||||
{
|
|
||||||
this->color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the 24bit color.
|
|
||||||
*
|
|
||||||
* @see DL_Codes, dxfColors
|
|
||||||
*/
|
|
||||||
void setColor24(int color)
|
|
||||||
{
|
|
||||||
this->color24 = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Color.
|
|
||||||
*
|
|
||||||
* @see DL_Codes, dxfColors
|
|
||||||
*/
|
|
||||||
int getColor() const
|
|
||||||
{
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return 24 bit color or -1 if no 24bit color is defined.
|
|
||||||
*
|
|
||||||
* @see DL_Codes, dxfColors
|
|
||||||
*/
|
|
||||||
int getColor24() const
|
|
||||||
{
|
|
||||||
return color24;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the width.
|
|
||||||
*/
|
|
||||||
void setWidth(int width)
|
|
||||||
{
|
|
||||||
this->width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Width.
|
|
||||||
*/
|
|
||||||
int getWidth() const
|
|
||||||
{
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the line type. This can be any string and is not
|
|
||||||
* checked to be a valid line type.
|
|
||||||
*/
|
|
||||||
void setLinetype(const std::string& linetype)
|
|
||||||
{
|
|
||||||
this->linetype = linetype;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the entity specific line type scale.
|
|
||||||
*/
|
|
||||||
void setLinetypeScale(double linetypeScale)
|
|
||||||
{
|
|
||||||
this->linetypeScale = linetypeScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
double getLinetypeScale() const
|
|
||||||
{
|
|
||||||
return linetypeScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Line type.
|
|
||||||
*/
|
|
||||||
std::string getLinetype() const
|
|
||||||
{
|
|
||||||
if (linetype.length()==0)
|
|
||||||
{
|
|
||||||
return "BYLAYER";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return linetype;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHandle(int h)
|
|
||||||
{
|
|
||||||
handle = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getHandle() const
|
|
||||||
{
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setInPaperSpace(bool on)
|
|
||||||
{
|
|
||||||
inPaperSpace = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isInPaperSpace() const
|
|
||||||
{
|
|
||||||
return inPaperSpace;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string layer;
|
|
||||||
int color;
|
|
||||||
int color24;
|
|
||||||
int width;
|
|
||||||
std::string linetype;
|
|
||||||
double linetypeScale;
|
|
||||||
int handle;
|
|
||||||
|
|
||||||
// DXF code 67 (true: entity in paper space, false: entity in model space (default):
|
|
||||||
bool inPaperSpace;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// EOF
|
|
|
@ -1,556 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
** Copyright (C) 2001 Robert J. Campbell Jr.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines common DXF codes and constants.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef DXF_CODES_H
|
|
||||||
#define DXF_CODES_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
#include "../vmisc/diagnostic.h"
|
|
||||||
|
|
||||||
#if defined(Q_CC_MSVC)
|
|
||||||
#if (_MSC_VER > 1000)
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
#endif // Q_CC_MSVC
|
|
||||||
|
|
||||||
#define DL_DXF_MAXLINE 1024
|
|
||||||
#define DL_DXF_MAXGROUPCODE 1100
|
|
||||||
|
|
||||||
// used to mark invalid vectors:
|
|
||||||
//#define DL_DXF_MAXDOUBLE 1.0E+10
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Codes for colors and DXF versions.
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_Codes
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Standard DXF colors.
|
|
||||||
*/
|
|
||||||
enum color
|
|
||||||
{
|
|
||||||
black = 250,
|
|
||||||
green = 3,
|
|
||||||
red = 1,
|
|
||||||
brown = 15,
|
|
||||||
yellow = 2,
|
|
||||||
cyan = 4,
|
|
||||||
magenta = 6,
|
|
||||||
gray = 8,
|
|
||||||
blue = 5,
|
|
||||||
l_blue = 163,
|
|
||||||
l_green = 121,
|
|
||||||
l_cyan = 131,
|
|
||||||
l_red = 23,
|
|
||||||
l_magenta = 221,
|
|
||||||
l_gray = 252,
|
|
||||||
white = 7,
|
|
||||||
bylayer = 256,
|
|
||||||
byblock = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Version numbers for the DXF Format.
|
|
||||||
*/
|
|
||||||
enum version
|
|
||||||
{
|
|
||||||
AC1009_MIN, // R12, minimalistic
|
|
||||||
AC1009, // R12
|
|
||||||
AC1012,
|
|
||||||
AC1014,
|
|
||||||
AC1015 // R2000
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Extended color palette:
|
|
||||||
// The first entry is only for direct indexing starting with [1]
|
|
||||||
// Color 1 is red (1,0,0)
|
|
||||||
const double dxfColors[][3] =
|
|
||||||
{
|
|
||||||
{0,0,0}, // unused
|
|
||||||
{1,0,0}, // 1
|
|
||||||
{1,1,0},
|
|
||||||
{0,1,0},
|
|
||||||
{0,1,1},
|
|
||||||
{0,0,1},
|
|
||||||
{1,0,1},
|
|
||||||
{1,1,1}, // black or white
|
|
||||||
{0.5,0.5,0.5},
|
|
||||||
{0.75,0.75,0.75},
|
|
||||||
{1,0,0}, // 10
|
|
||||||
{1,0.5,0.5},
|
|
||||||
{0.65,0,0},
|
|
||||||
{0.65,0.325,0.325},
|
|
||||||
{0.5,0,0},
|
|
||||||
{0.5,0.25,0.25},
|
|
||||||
{0.3,0,0},
|
|
||||||
{0.3,0.15,0.15},
|
|
||||||
{0.15,0,0},
|
|
||||||
{0.15,0.075,0.075},
|
|
||||||
{1,0.25,0}, // 20
|
|
||||||
{1,0.625,0.5},
|
|
||||||
{0.65,0.1625,0},
|
|
||||||
{0.65,0.4063,0.325},
|
|
||||||
{0.5,0.125,0},
|
|
||||||
{0.5,0.3125,0.25},
|
|
||||||
{0.3,0.075,0},
|
|
||||||
{0.3,0.1875,0.15},
|
|
||||||
{0.15,0.0375,0},
|
|
||||||
{0.15,0.0938,0.075},
|
|
||||||
{1,0.5,0}, // 30
|
|
||||||
{1,0.75,0.5},
|
|
||||||
{0.65,0.325,0},
|
|
||||||
{0.65,0.4875,0.325},
|
|
||||||
{0.5,0.25,0},
|
|
||||||
{0.5,0.375,0.25},
|
|
||||||
{0.3,0.15,0},
|
|
||||||
{0.3,0.225,0.15},
|
|
||||||
{0.15,0.075,0},
|
|
||||||
{0.15,0.1125,0.075},
|
|
||||||
{1,0.75,0}, // 40
|
|
||||||
{1,0.875,0.5},
|
|
||||||
{0.65,0.4875,0},
|
|
||||||
{0.65,0.5688,0.325},
|
|
||||||
{0.5,0.375,0},
|
|
||||||
{0.5,0.4375,0.25},
|
|
||||||
{0.3,0.225,0},
|
|
||||||
{0.3,0.2625,0.15},
|
|
||||||
{0.15,0.1125,0},
|
|
||||||
{0.15,0.1313,0.075},
|
|
||||||
{1,1,0}, // 50
|
|
||||||
{1,1,0.5},
|
|
||||||
{0.65,0.65,0},
|
|
||||||
{0.65,0.65,0.325},
|
|
||||||
{0.5,0.5,0},
|
|
||||||
{0.5,0.5,0.25},
|
|
||||||
{0.3,0.3,0},
|
|
||||||
{0.3,0.3,0.15},
|
|
||||||
{0.15,0.15,0},
|
|
||||||
{0.15,0.15,0.075},
|
|
||||||
{0.75,1,0}, // 60
|
|
||||||
{0.875,1,0.5},
|
|
||||||
{0.4875,0.65,0},
|
|
||||||
{0.5688,0.65,0.325},
|
|
||||||
{0.375,0.5,0},
|
|
||||||
{0.4375,0.5,0.25},
|
|
||||||
{0.225,0.3,0},
|
|
||||||
{0.2625,0.3,0.15},
|
|
||||||
{0.1125,0.15,0},
|
|
||||||
{0.1313,0.15,0.075},
|
|
||||||
{0.5,1,0}, // 70
|
|
||||||
{0.75,1,0.5},
|
|
||||||
{0.325,0.65,0},
|
|
||||||
{0.4875,0.65,0.325},
|
|
||||||
{0.25,0.5,0},
|
|
||||||
{0.375,0.5,0.25},
|
|
||||||
{0.15,0.3,0},
|
|
||||||
{0.225,0.3,0.15},
|
|
||||||
{0.075,0.15,0},
|
|
||||||
{0.1125,0.15,0.075},
|
|
||||||
{0.25,1,0}, // 80
|
|
||||||
{0.625,1,0.5},
|
|
||||||
{0.1625,0.65,0},
|
|
||||||
{0.4063,0.65,0.325},
|
|
||||||
{0.125,0.5,0},
|
|
||||||
{0.3125,0.5,0.25},
|
|
||||||
{0.075,0.3,0},
|
|
||||||
{0.1875,0.3,0.15},
|
|
||||||
{0.0375,0.15,0},
|
|
||||||
{0.0938,0.15,0.075},
|
|
||||||
{0,1,0}, // 90
|
|
||||||
{0.5,1,0.5},
|
|
||||||
{0,0.65,0},
|
|
||||||
{0.325,0.65,0.325},
|
|
||||||
{0,0.5,0},
|
|
||||||
{0.25,0.5,0.25},
|
|
||||||
{0,0.3,0},
|
|
||||||
{0.15,0.3,0.15},
|
|
||||||
{0,0.15,0},
|
|
||||||
{0.075,0.15,0.075},
|
|
||||||
{0,1,0.25}, // 100
|
|
||||||
{0.5,1,0.625},
|
|
||||||
{0,0.65,0.1625},
|
|
||||||
{0.325,0.65,0.4063},
|
|
||||||
{0,0.5,0.125},
|
|
||||||
{0.25,0.5,0.3125},
|
|
||||||
{0,0.3,0.075},
|
|
||||||
{0.15,0.3,0.1875},
|
|
||||||
{0,0.15,0.0375},
|
|
||||||
{0.075,0.15,0.0938},
|
|
||||||
{0,1,0.5}, // 110
|
|
||||||
{0.5,1,0.75},
|
|
||||||
{0,0.65,0.325},
|
|
||||||
{0.325,0.65,0.4875},
|
|
||||||
{0,0.5,0.25},
|
|
||||||
{0.25,0.5,0.375},
|
|
||||||
{0,0.3,0.15},
|
|
||||||
{0.15,0.3,0.225},
|
|
||||||
{0,0.15,0.075},
|
|
||||||
{0.075,0.15,0.1125},
|
|
||||||
{0,1,0.75}, // 120
|
|
||||||
{0.5,1,0.875},
|
|
||||||
{0,0.65,0.4875},
|
|
||||||
{0.325,0.65,0.5688},
|
|
||||||
{0,0.5,0.375},
|
|
||||||
{0.25,0.5,0.4375},
|
|
||||||
{0,0.3,0.225},
|
|
||||||
{0.15,0.3,0.2625},
|
|
||||||
{0,0.15,0.1125},
|
|
||||||
{0.075,0.15,0.1313},
|
|
||||||
{0,1,1}, // 130
|
|
||||||
{0.5,1,1},
|
|
||||||
{0,0.65,0.65},
|
|
||||||
{0.325,0.65,0.65},
|
|
||||||
{0,0.5,0.5},
|
|
||||||
{0.25,0.5,0.5},
|
|
||||||
{0,0.3,0.3},
|
|
||||||
{0.15,0.3,0.3},
|
|
||||||
{0,0.15,0.15},
|
|
||||||
{0.075,0.15,0.15},
|
|
||||||
{0,0.75,1}, // 140
|
|
||||||
{0.5,0.875,1},
|
|
||||||
{0,0.4875,0.65},
|
|
||||||
{0.325,0.5688,0.65},
|
|
||||||
{0,0.375,0.5},
|
|
||||||
{0.25,0.4375,0.5},
|
|
||||||
{0,0.225,0.3},
|
|
||||||
{0.15,0.2625,0.3},
|
|
||||||
{0,0.1125,0.15},
|
|
||||||
{0.075,0.1313,0.15},
|
|
||||||
{0,0.5,1}, // 150
|
|
||||||
{0.5,0.75,1},
|
|
||||||
{0,0.325,0.65},
|
|
||||||
{0.325,0.4875,0.65},
|
|
||||||
{0,0.25,0.5},
|
|
||||||
{0.25,0.375,0.5},
|
|
||||||
{0,0.15,0.3},
|
|
||||||
{0.15,0.225,0.3},
|
|
||||||
{0,0.075,0.15},
|
|
||||||
{0.075,0.1125,0.15},
|
|
||||||
{0,0.25,1}, // 160
|
|
||||||
{0.5,0.625,1},
|
|
||||||
{0,0.1625,0.65},
|
|
||||||
{0.325,0.4063,0.65},
|
|
||||||
{0,0.125,0.5},
|
|
||||||
{0.25,0.3125,0.5},
|
|
||||||
{0,0.075,0.3},
|
|
||||||
{0.15,0.1875,0.3},
|
|
||||||
{0,0.0375,0.15},
|
|
||||||
{0.075,0.0938,0.15},
|
|
||||||
{0,0,1}, // 170
|
|
||||||
{0.5,0.5,1},
|
|
||||||
{0,0,0.65},
|
|
||||||
{0.325,0.325,0.65},
|
|
||||||
{0,0,0.5},
|
|
||||||
{0.25,0.25,0.5},
|
|
||||||
{0,0,0.3},
|
|
||||||
{0.15,0.15,0.3},
|
|
||||||
{0,0,0.15},
|
|
||||||
{0.075,0.075,0.15},
|
|
||||||
{0.25,0,1}, // 180
|
|
||||||
{0.625,0.5,1},
|
|
||||||
{0.1625,0,0.65},
|
|
||||||
{0.4063,0.325,0.65},
|
|
||||||
{0.125,0,0.5},
|
|
||||||
{0.3125,0.25,0.5},
|
|
||||||
{0.075,0,0.3},
|
|
||||||
{0.1875,0.15,0.3},
|
|
||||||
{0.0375,0,0.15},
|
|
||||||
{0.0938,0.075,0.15},
|
|
||||||
{0.5,0,1}, // 190
|
|
||||||
{0.75,0.5,1},
|
|
||||||
{0.325,0,0.65},
|
|
||||||
{0.4875,0.325,0.65},
|
|
||||||
{0.25,0,0.5},
|
|
||||||
{0.375,0.25,0.5},
|
|
||||||
{0.15,0,0.3},
|
|
||||||
{0.225,0.15,0.3},
|
|
||||||
{0.075,0,0.15},
|
|
||||||
{0.1125,0.075,0.15},
|
|
||||||
{0.75,0,1}, // 200
|
|
||||||
{0.875,0.5,1},
|
|
||||||
{0.4875,0,0.65},
|
|
||||||
{0.5688,0.325,0.65},
|
|
||||||
{0.375,0,0.5},
|
|
||||||
{0.4375,0.25,0.5},
|
|
||||||
{0.225,0,0.3},
|
|
||||||
{0.2625,0.15,0.3},
|
|
||||||
{0.1125,0,0.15},
|
|
||||||
{0.1313,0.075,0.15},
|
|
||||||
{1,0,1}, // 210
|
|
||||||
{1,0.5,1},
|
|
||||||
{0.65,0,0.65},
|
|
||||||
{0.65,0.325,0.65},
|
|
||||||
{0.5,0,0.5},
|
|
||||||
{0.5,0.25,0.5},
|
|
||||||
{0.3,0,0.3},
|
|
||||||
{0.3,0.15,0.3},
|
|
||||||
{0.15,0,0.15},
|
|
||||||
{0.15,0.075,0.15},
|
|
||||||
{1,0,0.75}, // 220
|
|
||||||
{1,0.5,0.875},
|
|
||||||
{0.65,0,0.4875},
|
|
||||||
{0.65,0.325,0.5688},
|
|
||||||
{0.5,0,0.375},
|
|
||||||
{0.5,0.25,0.4375},
|
|
||||||
{0.3,0,0.225},
|
|
||||||
{0.3,0.15,0.2625},
|
|
||||||
{0.15,0,0.1125},
|
|
||||||
{0.15,0.075,0.1313},
|
|
||||||
{1,0,0.5}, // 230
|
|
||||||
{1,0.5,0.75},
|
|
||||||
{0.65,0,0.325},
|
|
||||||
{0.65,0.325,0.4875},
|
|
||||||
{0.5,0,0.25},
|
|
||||||
{0.5,0.25,0.375},
|
|
||||||
{0.3,0,0.15},
|
|
||||||
{0.3,0.15,0.225},
|
|
||||||
{0.15,0,0.075},
|
|
||||||
{0.15,0.075,0.1125},
|
|
||||||
{1,0,0.25}, // 240
|
|
||||||
{1,0.5,0.625},
|
|
||||||
{0.65,0,0.1625},
|
|
||||||
{0.65,0.325,0.4063},
|
|
||||||
{0.5,0,0.125},
|
|
||||||
{0.5,0.25,0.3125},
|
|
||||||
{0.3,0,0.075},
|
|
||||||
{0.3,0.15,0.1875},
|
|
||||||
{0.15,0,0.0375},
|
|
||||||
{0.15,0.075,0.0938},
|
|
||||||
{0.33,0.33,0.33}, // 250
|
|
||||||
{0.464,0.464,0.464},
|
|
||||||
{0.598,0.598,0.598},
|
|
||||||
{0.732,0.732,0.732},
|
|
||||||
{0.866,0.866,0.866},
|
|
||||||
{1,1,1} // 255
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
// AutoCAD VERSION aliases
|
|
||||||
#define DL_VERSION_R12 DL_Codes::AC1009
|
|
||||||
#define DL_VERSION_LT2 DL_Codes::AC1009
|
|
||||||
#define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet
|
|
||||||
#define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet
|
|
||||||
#define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet
|
|
||||||
#define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet
|
|
||||||
#define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet
|
|
||||||
#define DL_VERSION_2000 DL_Codes::AC1015
|
|
||||||
#define DL_VERSION_2002 DL_Codes::AC1015
|
|
||||||
|
|
||||||
|
|
||||||
// DXF Group Codes:
|
|
||||||
|
|
||||||
// Strings
|
|
||||||
#define DL_STRGRP_START 0
|
|
||||||
#define DL_STRGRP_END 9
|
|
||||||
|
|
||||||
// Coordinates
|
|
||||||
#define DL_CRDGRP_START 10
|
|
||||||
#define DL_CRDGRP_END 19
|
|
||||||
|
|
||||||
// Real values
|
|
||||||
#define DL_RLGRP_START 38
|
|
||||||
#define DL_RLGRP_END 59
|
|
||||||
|
|
||||||
// Short integer values
|
|
||||||
#define DL_SHOGRP_START 60
|
|
||||||
#define DL_SHOGRP_END 79
|
|
||||||
|
|
||||||
// New in Release 13,
|
|
||||||
#define DL_SUBCLASS 100
|
|
||||||
|
|
||||||
// More coordinates
|
|
||||||
#define DL_CRD2GRP_START 210
|
|
||||||
#define DL_CRD2GRP_END 239
|
|
||||||
|
|
||||||
// Extended data strings
|
|
||||||
#define DL_ESTRGRP_START 1000
|
|
||||||
#define DL_ESTRGRP_END 1009
|
|
||||||
|
|
||||||
// Extended data reals
|
|
||||||
#define DL_ERLGRP_START 1010
|
|
||||||
#define DL_ERLGRP_END 1059
|
|
||||||
|
|
||||||
|
|
||||||
#define DL_Y8_COORD_CODE 28
|
|
||||||
#define DL_Z0_COORD_CODE 30
|
|
||||||
#define DL_Z8_COORD_CODE 38
|
|
||||||
|
|
||||||
#define DL_POINT_COORD_CODE 10
|
|
||||||
#define DL_INSERT_COORD_CODE 10
|
|
||||||
|
|
||||||
#define DL_CRD2GRP_START 210
|
|
||||||
#define DL_CRD2GRP_END 239
|
|
||||||
|
|
||||||
#define DL_THICKNESS 39
|
|
||||||
#define DL_FIRST_REAL_CODE THICKNESS
|
|
||||||
#define DL_LAST_REAL_CODE 59
|
|
||||||
#define DL_FIRST_INT_CODE 60
|
|
||||||
#define DL_ATTFLAGS_CODE 70
|
|
||||||
#define DL_PLINE_FLAGS_CODE 70
|
|
||||||
#define DL_LAYER_FLAGS_CODE 70
|
|
||||||
#define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf
|
|
||||||
#define DL_LAST_INT_CODE 79
|
|
||||||
#define DL_X_EXTRU_CODE 210
|
|
||||||
#define DL_Y_EXTRU_CODE 220
|
|
||||||
#define DL_Z_EXTRU_CODE 230
|
|
||||||
#define DL_COMMENT_CODE 999
|
|
||||||
|
|
||||||
// Start and endpoints of a line
|
|
||||||
#define DL_LINE_START_CODE 10 // Followed by x coord
|
|
||||||
#define DL_LINE_END_CODE 11 // Followed by x coord
|
|
||||||
|
|
||||||
// Some codes used by blocks
|
|
||||||
#define DL_BLOCK_FLAGS_CODE 70 // An int containing flags
|
|
||||||
#define DL_BLOCK_BASE_CODE 10 // Origin of block definition
|
|
||||||
#define DL_XREF_DEPENDENT 16 // If a block contains an XREF
|
|
||||||
#define DL_XREF_RESOLVED 32 // If a XREF resolved ok
|
|
||||||
#define DL_REFERENCED 64 // If a block is ref'd in DWG
|
|
||||||
|
|
||||||
#define DL_XSCALE_CODE 41
|
|
||||||
#define DL_YSCALE_CODE 42
|
|
||||||
#define DL_ANGLE_CODE 50
|
|
||||||
#define DL_INS_POINT_CODE 10 // Followed by x of ins pnt
|
|
||||||
#define DL_NAME2_CODE 3 // Second appearance of name
|
|
||||||
|
|
||||||
// Some codes used by circle entities
|
|
||||||
#define DL_CENTER_CODE 10 // Followed by x of center
|
|
||||||
#define DL_RADIUS_CODE 40 // Followd by radius of circle
|
|
||||||
|
|
||||||
#define DL_COND_OP_CODE -4 // Conditional op,ads_ssget
|
|
||||||
|
|
||||||
// When using ads_buildlist you MUST use RTDXF0 instead of these
|
|
||||||
#define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE..
|
|
||||||
#define DL_SES_CODE 0 // Start End String Code
|
|
||||||
#define DL_FILE_SEP_CODE 0 // File separator
|
|
||||||
#define DL_SOT_CODE 0 // Start Of Table
|
|
||||||
#define DL_TEXTVAL_CODE 1
|
|
||||||
#define DL_NAME_CODE 2
|
|
||||||
#define DL_BLOCK_NAME_CODE 2
|
|
||||||
#define DL_SECTION_NAME_CODE 2
|
|
||||||
#define DL_ENT_HAND_CODE 5 // What follows is hexa string
|
|
||||||
#define DL_TXT_STYLE_CODE 7 // Inside attributes
|
|
||||||
#define DL_LAYER_NAME_CODE 8 // What follows is layer name
|
|
||||||
#define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord
|
|
||||||
#define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord
|
|
||||||
#define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord
|
|
||||||
#define DL_L_START_CODE 10
|
|
||||||
#define DL_L_END_CODE 11
|
|
||||||
#define DL_TXTHI_CODE 40
|
|
||||||
#define DL_SCALE_X_CODE 41
|
|
||||||
#define DL_SCALE_Y_CODE 42
|
|
||||||
#define DL_SCALE_Z_CODE 43
|
|
||||||
#define DL_BULGE_CODE 42 // Used in PLINE verts for arcs
|
|
||||||
#define DL_ROTATION_CODE 50
|
|
||||||
#define DL_COLOUR_CODE 62 // What follows is a color int
|
|
||||||
#define DL_LTYPE_CODE 6 // What follows is a linetype
|
|
||||||
|
|
||||||
|
|
||||||
// Attribute flags
|
|
||||||
#define DL_ATTS_FOLLOW_CODE 66
|
|
||||||
#define DL_ATT_TAG_CODE 2
|
|
||||||
#define DL_ATT_VAL_CODE 1
|
|
||||||
#define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows...
|
|
||||||
#define DL_ATT_INVIS_FLAG 1
|
|
||||||
#define DL_ATT_CONST_FLAG 2
|
|
||||||
#define DL_ATT_VERIFY_FLAG 4 // Prompt and verify
|
|
||||||
#define DL_ATT_PRESET_FLAG 8 // No prompt and no verify
|
|
||||||
|
|
||||||
// PLINE defines
|
|
||||||
// Flags
|
|
||||||
#define DL_OPEN_PLINE 0x00
|
|
||||||
#define DL_CLOSED_PLINE 0x01
|
|
||||||
#define DL_POLYLINE3D 0x80
|
|
||||||
#define DL_PFACE_MESH 0x40
|
|
||||||
#define DL_PGON_MESH 0x10
|
|
||||||
// Vertices follow entity, required in POLYLINES
|
|
||||||
#define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1
|
|
||||||
#define DL_VERTEX_COORD_CODE 10
|
|
||||||
|
|
||||||
|
|
||||||
// LAYER flags
|
|
||||||
#define DL_FROZEN 1
|
|
||||||
#define DL_FROZEN_BY_DEF 2
|
|
||||||
#define DL_LOCKED 4
|
|
||||||
#define DL_OBJECT_USED 64 // Object is ref'd in the dwg
|
|
||||||
|
|
||||||
#define DL_BLOCK_EN_CODE -2 // Block entity definition
|
|
||||||
#define DL_E_NAME -1 // Entity name
|
|
||||||
|
|
||||||
// Extended data codes
|
|
||||||
#define DL_EXTD_SENTINEL (-3)
|
|
||||||
#define DL_EXTD_STR 1000
|
|
||||||
#define DL_EXTD_APP_NAME 1001
|
|
||||||
#define DL_EXTD_CTL_STR 1002
|
|
||||||
#define DL_EXTD_LYR_STR 1003
|
|
||||||
#define DL_EXTD_CHUNK 1004
|
|
||||||
#define DL_EXTD_HANDLE 1005
|
|
||||||
#define DL_EXTD_POINT 1010
|
|
||||||
#define DL_EXTD_POS 1011
|
|
||||||
#define DL_EXTD_DISP 1012
|
|
||||||
#define DL_EXTD_DIR 1013
|
|
||||||
#define DL_EXTD_FLOAT 1040
|
|
||||||
#define DL_EXTD_DIST 1041
|
|
||||||
#define DL_EXTD_SCALE 1042
|
|
||||||
#define DL_EXTD_INT16 1070
|
|
||||||
#define DL_EXTD_INT32 1071
|
|
||||||
|
|
||||||
// UCS codes for use in ads_trans
|
|
||||||
#define DL_WCS_TRANS_CODE 0
|
|
||||||
#define DL_UCS_TRANS_CODE 1
|
|
||||||
#define DL_DCS_TRANS_CODE 2
|
|
||||||
#define DL_PCS_TRANS_CODE 3
|
|
||||||
|
|
||||||
#ifndef __has_cpp_attribute
|
|
||||||
# define __has_cpp_attribute(x) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
|
|
||||||
# define DL_FALLTHROUGH [[fallthrough]];
|
|
||||||
#elif defined(Q_CC_CLANG) && __cplusplus >= 201103L
|
|
||||||
/* clang's fallthrough annotations are only available starting in C++11. */
|
|
||||||
# define DL_FALLTHROUGH [[clang::fallthrough]];
|
|
||||||
#elif defined(Q_CC_MSVC)
|
|
||||||
/*
|
|
||||||
* MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
|
|
||||||
* https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx
|
|
||||||
*/
|
|
||||||
# include <sal.h>
|
|
||||||
# define DL_FALLTHROUGH __fallthrough;
|
|
||||||
#elif defined(Q_CC_GNU) && (__GNUC__ >= 7)
|
|
||||||
# define DL_FALLTHROUGH [[gnu::fallthrough]];
|
|
||||||
#else
|
|
||||||
# define DL_FALLTHROUGH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_CREATIONADAPTER_H
|
|
||||||
#define DL_CREATIONADAPTER_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
|
|
||||||
#include "dl_creationinterface.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstract adapter class for receiving DXF events when a DXF file is being read.
|
|
||||||
* The methods in this class are empty. This class exists as convenience for creating
|
|
||||||
* listener objects.
|
|
||||||
*
|
|
||||||
* @author Andrew Mustun
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_CreationAdapter : public DL_CreationInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DL_CreationAdapter() {}
|
|
||||||
virtual ~DL_CreationAdapter();
|
|
||||||
virtual void processCodeValuePair(quint32, const std::string&) {}
|
|
||||||
virtual void endSection() {}
|
|
||||||
virtual void addLayer(const DL_LayerData&) {}
|
|
||||||
virtual void addLinetype(const DL_LinetypeData&) {}
|
|
||||||
virtual void addLinetypeDash(double) {}
|
|
||||||
virtual void addBlock(const DL_BlockData&) {}
|
|
||||||
virtual void endBlock() {}
|
|
||||||
virtual void addTextStyle(const DL_StyleData&) {}
|
|
||||||
virtual void addPoint(const DL_PointData&) {}
|
|
||||||
virtual void addLine(const DL_LineData&) {}
|
|
||||||
virtual void addXLine(const DL_XLineData&) {}
|
|
||||||
virtual void addRay(const DL_RayData&) {}
|
|
||||||
|
|
||||||
virtual void addArc(const DL_ArcData&) {}
|
|
||||||
virtual void addCircle(const DL_CircleData&) {}
|
|
||||||
virtual void addEllipse(const DL_EllipseData&) {}
|
|
||||||
|
|
||||||
virtual void addPolyline(const DL_PolylineData&) {}
|
|
||||||
virtual void addVertex(const DL_VertexData&) {}
|
|
||||||
|
|
||||||
virtual void addSpline(const DL_SplineData&) {}
|
|
||||||
virtual void addControlPoint(const DL_ControlPointData&) {}
|
|
||||||
virtual void addFitPoint(const DL_FitPointData&) {}
|
|
||||||
virtual void addKnot(const DL_KnotData&) {}
|
|
||||||
|
|
||||||
virtual void addInsert(const DL_InsertData&) {}
|
|
||||||
|
|
||||||
virtual void addMText(const DL_MTextData&) {}
|
|
||||||
virtual void addMTextChunk(const std::string&) {}
|
|
||||||
virtual void addText(const DL_TextData&) {}
|
|
||||||
virtual void addAttribute(const DL_AttributeData&) {}
|
|
||||||
|
|
||||||
virtual void addDimAlign(const DL_DimensionData&,
|
|
||||||
const DL_DimAlignedData&) {}
|
|
||||||
virtual void addDimLinear(const DL_DimensionData&,
|
|
||||||
const DL_DimLinearData&) {}
|
|
||||||
virtual void addDimRadial(const DL_DimensionData&,
|
|
||||||
const DL_DimRadialData&) {}
|
|
||||||
virtual void addDimDiametric(const DL_DimensionData&,
|
|
||||||
const DL_DimDiametricData&) {}
|
|
||||||
virtual void addDimAngular(const DL_DimensionData&,
|
|
||||||
const DL_DimAngularData&) {}
|
|
||||||
virtual void addDimAngular3P(const DL_DimensionData&,
|
|
||||||
const DL_DimAngular3PData&) {}
|
|
||||||
virtual void addDimOrdinate(const DL_DimensionData&,
|
|
||||||
const DL_DimOrdinateData&) {}
|
|
||||||
virtual void addLeader(const DL_LeaderData&) {}
|
|
||||||
virtual void addLeaderVertex(const DL_LeaderVertexData&) {}
|
|
||||||
|
|
||||||
virtual void addHatch(const DL_HatchData&) {}
|
|
||||||
|
|
||||||
virtual void addTrace(const DL_TraceData&) {}
|
|
||||||
virtual void add3dFace(const DL_3dFaceData&) {}
|
|
||||||
virtual void addSolid(const DL_SolidData&) {}
|
|
||||||
|
|
||||||
virtual void addImage(const DL_ImageData&) {}
|
|
||||||
virtual void linkImage(const DL_ImageDefData&) {}
|
|
||||||
virtual void addHatchLoop(const DL_HatchLoopData&) {}
|
|
||||||
virtual void addHatchEdge(const DL_HatchEdgeData&) {}
|
|
||||||
|
|
||||||
virtual void addXRecord(const std::string&) {}
|
|
||||||
virtual void addXRecordString(int, const std::string&) {}
|
|
||||||
virtual void addXRecordReal(int, double) {}
|
|
||||||
virtual void addXRecordInt(int, int) {}
|
|
||||||
virtual void addXRecordBool(int, bool) {}
|
|
||||||
|
|
||||||
virtual void addXDataApp(const std::string&) {}
|
|
||||||
virtual void addXDataString(int, const std::string&) {}
|
|
||||||
virtual void addXDataReal(int, double) {}
|
|
||||||
virtual void addXDataInt(int, int) {}
|
|
||||||
|
|
||||||
virtual void addDictionary(const DL_DictionaryData&) {}
|
|
||||||
virtual void addDictionaryEntry(const DL_DictionaryEntryData&) {}
|
|
||||||
|
|
||||||
virtual void endEntity() {}
|
|
||||||
|
|
||||||
virtual void addComment(const std::string&) {}
|
|
||||||
|
|
||||||
virtual void setVariableVector(const std::string&, double, double, double, int) {}
|
|
||||||
virtual void setVariableString(const std::string&, const std::string&, int) {}
|
|
||||||
virtual void setVariableInt(const std::string&, int, int) {}
|
|
||||||
virtual void setVariableDouble(const std::string&, double, int) {}
|
|
||||||
#ifdef DL_COMPAT
|
|
||||||
virtual void setVariableVector(const char*, double, double, double, int) {}
|
|
||||||
virtual void setVariableString(const char*, const char*, int) {}
|
|
||||||
virtual void setVariableInt(const char*, int, int) {}
|
|
||||||
virtual void setVariableDouble(const char*, double, int) {}
|
|
||||||
virtual void processCodeValuePair(quint32, char*) {}
|
|
||||||
virtual void addComment(const char*) {}
|
|
||||||
virtual void addMTextChunk(const char*) {}
|
|
||||||
#endif
|
|
||||||
virtual void endSequence() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
DL_CreationAdapter::~DL_CreationAdapter()
|
|
||||||
{}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,378 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_CREATIONINTERFACE_H
|
|
||||||
#define DL_CREATIONINTERFACE_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "dl_attributes.h"
|
|
||||||
#include "dl_codes.h"
|
|
||||||
#include "dl_entities.h"
|
|
||||||
#include "dl_extrusion.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract class (interface) for the creation of new entities.
|
|
||||||
* Inherit your class which takes care of the entities in the
|
|
||||||
* processed DXF file from this interface.
|
|
||||||
*
|
|
||||||
* Double arrays passed to your implementation contain 3 double
|
|
||||||
* values for x, y, z coordinates unless stated differently.
|
|
||||||
*
|
|
||||||
* @author Andrew Mustun
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_CreationInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DL_CreationInterface() : extrusion(new DL_Extrusion), attributes()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DL_CreationInterface();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every code / value tuple of the DXF file. The complete DXF file
|
|
||||||
* contents can be handled by the implemetation of this function.
|
|
||||||
*/
|
|
||||||
virtual void processCodeValuePair(quint32 groupCode, const std::string& groupValue) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a section (entity, table entry, etc.) is finished.
|
|
||||||
*/
|
|
||||||
virtual void endSection() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every layer.
|
|
||||||
*/
|
|
||||||
virtual void addLayer(const DL_LayerData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every linetype.
|
|
||||||
*/
|
|
||||||
virtual void addLinetype(const DL_LinetypeData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every dash in linetype pattern
|
|
||||||
*/
|
|
||||||
virtual void addLinetypeDash(double length) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every block. Note: all entities added after this
|
|
||||||
* command go into this block until endBlock() is called.
|
|
||||||
*
|
|
||||||
* @see endBlock()
|
|
||||||
*/
|
|
||||||
virtual void addBlock(const DL_BlockData& data) = 0;
|
|
||||||
|
|
||||||
/** Called to end the current block */
|
|
||||||
virtual void endBlock() = 0;
|
|
||||||
|
|
||||||
/** Called for every text style */
|
|
||||||
virtual void addTextStyle(const DL_StyleData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every point */
|
|
||||||
virtual void addPoint(const DL_PointData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every line */
|
|
||||||
virtual void addLine(const DL_LineData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every xline */
|
|
||||||
virtual void addXLine(const DL_XLineData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every ray */
|
|
||||||
virtual void addRay(const DL_RayData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every arc */
|
|
||||||
virtual void addArc(const DL_ArcData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every circle */
|
|
||||||
virtual void addCircle(const DL_CircleData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every ellipse */
|
|
||||||
virtual void addEllipse(const DL_EllipseData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every polyline start */
|
|
||||||
virtual void addPolyline(const DL_PolylineData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every polyline vertex */
|
|
||||||
virtual void addVertex(const DL_VertexData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every spline */
|
|
||||||
virtual void addSpline(const DL_SplineData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every spline control point */
|
|
||||||
virtual void addControlPoint(const DL_ControlPointData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every spline fit point */
|
|
||||||
virtual void addFitPoint(const DL_FitPointData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every spline knot value */
|
|
||||||
virtual void addKnot(const DL_KnotData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every insert. */
|
|
||||||
virtual void addInsert(const DL_InsertData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every trace start */
|
|
||||||
virtual void addTrace(const DL_TraceData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every 3dface start */
|
|
||||||
virtual void add3dFace(const DL_3dFaceData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every solid start */
|
|
||||||
virtual void addSolid(const DL_SolidData& data) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/** Called for every Multi Text entity. */
|
|
||||||
virtual void addMText(const DL_MTextData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for additional text chunks for MTEXT entities.
|
|
||||||
* The chunks come at 250 character in size each. Note that
|
|
||||||
* those chunks come <b>before</b> the actual MTEXT entity.
|
|
||||||
*/
|
|
||||||
virtual void addMTextChunk(const std::string& text) = 0;
|
|
||||||
|
|
||||||
/** Called for every Text entity. */
|
|
||||||
virtual void addText(const DL_TextData& data) = 0;
|
|
||||||
|
|
||||||
/** Called for every Block Attribute entity. */
|
|
||||||
virtual void addAttribute(const DL_AttributeData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every aligned dimension entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimAlign(const DL_DimensionData& data,
|
|
||||||
const DL_DimAlignedData& edata) = 0;
|
|
||||||
/**
|
|
||||||
* Called for every linear or rotated dimension entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimLinear(const DL_DimensionData& data,
|
|
||||||
const DL_DimLinearData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every radial dimension entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimRadial(const DL_DimensionData& data,
|
|
||||||
const DL_DimRadialData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every diametric dimension entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimDiametric(const DL_DimensionData& data,
|
|
||||||
const DL_DimDiametricData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every angular dimension (2 lines version) entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimAngular(const DL_DimensionData& data,
|
|
||||||
const DL_DimAngularData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every angular dimension (3 points version) entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimAngular3P(const DL_DimensionData& data,
|
|
||||||
const DL_DimAngular3PData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every ordinate dimension entity.
|
|
||||||
*/
|
|
||||||
virtual void addDimOrdinate(const DL_DimensionData& data,
|
|
||||||
const DL_DimOrdinateData& edata) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every leader start.
|
|
||||||
*/
|
|
||||||
virtual void addLeader(const DL_LeaderData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every leader vertex
|
|
||||||
*/
|
|
||||||
virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every hatch entity.
|
|
||||||
*/
|
|
||||||
virtual void addHatch(const DL_HatchData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every image entity.
|
|
||||||
*/
|
|
||||||
virtual void addImage(const DL_ImageData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every image definition.
|
|
||||||
*/
|
|
||||||
virtual void linkImage(const DL_ImageDefData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every hatch loop.
|
|
||||||
*/
|
|
||||||
virtual void addHatchLoop(const DL_HatchLoopData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every hatch edge entity.
|
|
||||||
*/
|
|
||||||
virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every XRecord with the given handle.
|
|
||||||
*/
|
|
||||||
virtual void addXRecord(const std::string& handle) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XRecords of type string.
|
|
||||||
*/
|
|
||||||
virtual void addXRecordString(int code, const std::string& value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XRecords of type double.
|
|
||||||
*/
|
|
||||||
virtual void addXRecordReal(int code, double value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XRecords of type int.
|
|
||||||
*/
|
|
||||||
virtual void addXRecordInt(int code, int value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XRecords of type bool.
|
|
||||||
*/
|
|
||||||
virtual void addXRecordBool(int code, bool value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every beginning of an XData section of the given application.
|
|
||||||
*/
|
|
||||||
virtual void addXDataApp(const std::string& appId) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XData tuples.
|
|
||||||
*/
|
|
||||||
virtual void addXDataString(int code, const std::string& value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XData tuples.
|
|
||||||
*/
|
|
||||||
virtual void addXDataReal(int code, double value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for XData tuples.
|
|
||||||
*/
|
|
||||||
virtual void addXDataInt(int code, int value) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for dictionary objects.
|
|
||||||
*/
|
|
||||||
virtual void addDictionary(const DL_DictionaryData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for dictionary entries.
|
|
||||||
*/
|
|
||||||
virtual void addDictionaryEntry(const DL_DictionaryEntryData& data) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after an entity has been completed.
|
|
||||||
*/
|
|
||||||
virtual void endEntity() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every comment in the DXF file (code 999).
|
|
||||||
*/
|
|
||||||
virtual void addComment(const std::string& comment) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every vector variable in the DXF file (e.g. "$EXTMIN").
|
|
||||||
*/
|
|
||||||
virtual void setVariableVector(const std::string& key, double v1, double v2, double v3, int code) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every string variable in the DXF file (e.g. "$ACADVER").
|
|
||||||
*/
|
|
||||||
virtual void setVariableString(const std::string& key, const std::string& value, int code) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
|
|
||||||
*/
|
|
||||||
virtual void setVariableInt(const std::string& key, int value, int code) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called for every double variable in the DXF file (e.g. "$DIMEXO").
|
|
||||||
*/
|
|
||||||
virtual void setVariableDouble(const std::string& key, double value, int code) = 0;
|
|
||||||
|
|
||||||
#ifdef DL_COMPAT
|
|
||||||
virtual void setVariableVector(const char* key, double v1, double v2, double v3, int code) = 0;
|
|
||||||
virtual void setVariableString(const char* key, const char* value, int code) = 0;
|
|
||||||
virtual void setVariableInt(const char* key, int value, int code) = 0;
|
|
||||||
virtual void setVariableDouble(const char* key, double value, int code) = 0;
|
|
||||||
virtual void processCodeValuePair(quint32 groupCode, char* groupValue) = 0;
|
|
||||||
virtual void addComment(const char* comment) = 0;
|
|
||||||
virtual void addMTextChunk(const char* text) = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
|
|
||||||
*/
|
|
||||||
virtual void endSequence() = 0;
|
|
||||||
|
|
||||||
/** Sets the current attributes for entities. */
|
|
||||||
void setAttributes(const DL_Attributes& attrib)
|
|
||||||
{
|
|
||||||
attributes = attrib;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return the current attributes used for new entities. */
|
|
||||||
DL_Attributes getAttributes() const
|
|
||||||
{
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the current attributes for entities. */
|
|
||||||
void setExtrusion(double dx, double dy, double dz, double elevation)
|
|
||||||
{
|
|
||||||
extrusion->setDirection(dx, dy, dz);
|
|
||||||
extrusion->setElevation(elevation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return the current attributes used for new entities. */
|
|
||||||
DL_Extrusion* getExtrusion()
|
|
||||||
{
|
|
||||||
return extrusion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(DL_CreationInterface)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DL_Extrusion *extrusion;
|
|
||||||
DL_Attributes attributes;
|
|
||||||
};
|
|
||||||
|
|
||||||
DL_CreationInterface::~DL_CreationInterface()
|
|
||||||
{
|
|
||||||
delete extrusion;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,525 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_DXF_H
|
|
||||||
#define DL_DXF_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <limits>
|
|
||||||
#include <map>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dl_attributes.h"
|
|
||||||
#include "dl_codes.h"
|
|
||||||
#include "dl_entities.h"
|
|
||||||
#include "dl_global.h"
|
|
||||||
#include "dl_writer_ascii.h"
|
|
||||||
|
|
||||||
#ifndef DL_NANDOUBLE
|
|
||||||
#define DL_NANDOUBLE std::numeric_limits<double>::quiet_NaN()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class DL_CreationInterface;
|
|
||||||
|
|
||||||
#define DL_VERSION "3.12.2.0"
|
|
||||||
|
|
||||||
#define DL_VERSION_MAJOR 3
|
|
||||||
#define DL_VERSION_MINOR 12
|
|
||||||
#define DL_VERSION_REV 2
|
|
||||||
#define DL_VERSION_BUILD 0
|
|
||||||
|
|
||||||
#define DL_UNKNOWN 0
|
|
||||||
#define DL_LAYER 10
|
|
||||||
#define DL_BLOCK 11
|
|
||||||
#define DL_ENDBLK 12
|
|
||||||
#define DL_LINETYPE 13
|
|
||||||
#define DL_STYLE 20
|
|
||||||
#define DL_SETTING 50
|
|
||||||
#define DL_ENTITY_POINT 100
|
|
||||||
#define DL_ENTITY_LINE 101
|
|
||||||
#define DL_ENTITY_POLYLINE 102
|
|
||||||
#define DL_ENTITY_LWPOLYLINE 103
|
|
||||||
#define DL_ENTITY_VERTEX 104
|
|
||||||
#define DL_ENTITY_SPLINE 105
|
|
||||||
#define DL_ENTITY_KNOT 106
|
|
||||||
#define DL_ENTITY_CONTROLPOINT 107
|
|
||||||
#define DL_ENTITY_ARC 108
|
|
||||||
#define DL_ENTITY_CIRCLE 109
|
|
||||||
#define DL_ENTITY_ELLIPSE 110
|
|
||||||
#define DL_ENTITY_INSERT 111
|
|
||||||
#define DL_ENTITY_TEXT 112
|
|
||||||
#define DL_ENTITY_MTEXT 113
|
|
||||||
#define DL_ENTITY_DIMENSION 114
|
|
||||||
#define DL_ENTITY_LEADER 115
|
|
||||||
#define DL_ENTITY_HATCH 116
|
|
||||||
#define DL_ENTITY_ATTRIB 117
|
|
||||||
#define DL_ENTITY_IMAGE 118
|
|
||||||
#define DL_ENTITY_IMAGEDEF 119
|
|
||||||
#define DL_ENTITY_TRACE 120
|
|
||||||
#define DL_ENTITY_SOLID 121
|
|
||||||
#define DL_ENTITY_3DFACE 122
|
|
||||||
#define DL_ENTITY_XLINE 123
|
|
||||||
#define DL_ENTITY_RAY 124
|
|
||||||
#define DL_ENTITY_SEQEND 125
|
|
||||||
#define DL_XRECORD 200
|
|
||||||
#define DL_DICTIONARY 210
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reading and writing of DXF files.
|
|
||||||
*
|
|
||||||
* This class can read in a DXF file and calls methods from the
|
|
||||||
* interface DL_EntityContainer to add the entities to the
|
|
||||||
* contianer provided by the user of the library.
|
|
||||||
*
|
|
||||||
* It can also be used to write DXF files to a certain extent.
|
|
||||||
*
|
|
||||||
* When saving entities, special values for colors and linetypes
|
|
||||||
* can be used:
|
|
||||||
*
|
|
||||||
* Special colors are 0 (=BYBLOCK) and 256 (=BYLAYER).
|
|
||||||
* Special linetypes are "BYLAYER" and "BYBLOCK".
|
|
||||||
*
|
|
||||||
* @author Andrew Mustun
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_Dxf
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DL_Dxf();
|
|
||||||
~DL_Dxf();
|
|
||||||
|
|
||||||
bool in(const std::string& file, DL_CreationInterface* creationInterface);
|
|
||||||
bool readDxfGroups(FILE* fp, DL_CreationInterface* creationInterface);
|
|
||||||
static bool getStrippedLine(std::string& s, quint32 size, FILE* stream, bool stripSpace = true);
|
|
||||||
|
|
||||||
bool readDxfGroups(std::stringstream& stream, DL_CreationInterface* creationInterface);
|
|
||||||
bool in(std::stringstream &stream, DL_CreationInterface* creationInterface);
|
|
||||||
static bool getStrippedLine(std::string& s, quint32 size, std::stringstream& stream, bool stripSpace = true);
|
|
||||||
|
|
||||||
static bool stripWhiteSpace(char** s, bool stripSpace = true);
|
|
||||||
|
|
||||||
bool processDXFGroup(DL_CreationInterface* creationInterface, int groupCode, const std::string& groupValue);
|
|
||||||
void addSetting(DL_CreationInterface* creationInterface);
|
|
||||||
void addLayer(DL_CreationInterface* creationInterface);
|
|
||||||
void addLinetype(DL_CreationInterface *creationInterface);
|
|
||||||
void addBlock(DL_CreationInterface* creationInterface);
|
|
||||||
static void endBlock(DL_CreationInterface* creationInterface);
|
|
||||||
void addTextStyle(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addPoint(DL_CreationInterface* creationInterface);
|
|
||||||
void addLine(DL_CreationInterface* creationInterface);
|
|
||||||
void addXLine(DL_CreationInterface* creationInterface);
|
|
||||||
void addRay(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addPolyline(DL_CreationInterface* creationInterface);
|
|
||||||
void addVertex(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addSpline(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addArc(DL_CreationInterface* creationInterface);
|
|
||||||
void addCircle(DL_CreationInterface* creationInterface);
|
|
||||||
void addEllipse(DL_CreationInterface* creationInterface);
|
|
||||||
void addInsert(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addTrace(DL_CreationInterface* creationInterface);
|
|
||||||
void add3dFace(DL_CreationInterface* creationInterface);
|
|
||||||
void addSolid(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addMText(DL_CreationInterface* creationInterface);
|
|
||||||
void addText(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addAttribute(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
DL_DimensionData getDimData();
|
|
||||||
void addDimLinear(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimAligned(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimRadial(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimDiametric(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimAngular(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimAngular3P(DL_CreationInterface* creationInterface);
|
|
||||||
void addDimOrdinate(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addLeader(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addHatch(DL_CreationInterface* creationInterface);
|
|
||||||
void addHatchLoop();
|
|
||||||
void addHatchEdge();
|
|
||||||
bool handleHatchData(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
void addImage(DL_CreationInterface* creationInterface);
|
|
||||||
void addImageDef(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
static void addComment(DL_CreationInterface* creationInterface, const std::string& comment);
|
|
||||||
|
|
||||||
void addDictionary(DL_CreationInterface* creationInterface);
|
|
||||||
void addDictionaryEntry(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
bool handleXRecordData(DL_CreationInterface* creationInterface);
|
|
||||||
bool handleDictionaryData(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
bool handleXData(DL_CreationInterface *creationInterface);
|
|
||||||
bool handleMTextData(DL_CreationInterface* creationInterface);
|
|
||||||
bool handleLWPolylineData(DL_CreationInterface* creationInterface);
|
|
||||||
bool handleSplineData(DL_CreationInterface* creationInterface);
|
|
||||||
bool handleLeaderData(DL_CreationInterface* creationInterface);
|
|
||||||
bool handleLinetypeData(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
static void endEntity(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
static void endSequence(DL_CreationInterface* creationInterface);
|
|
||||||
|
|
||||||
//int stringToInt(const char* s, bool* ok=NULL);
|
|
||||||
|
|
||||||
DL_WriterA* out(const char* file, DL_Codes::version version=DL_VERSION_2000);
|
|
||||||
|
|
||||||
void writeHeader(DL_WriterA& dw) const;
|
|
||||||
|
|
||||||
void writePoint(DL_WriterA& dw,
|
|
||||||
const DL_PointData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeLine(DL_WriterA& dw,
|
|
||||||
const DL_LineData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeXLine(DL_WriterA& dw,
|
|
||||||
const DL_XLineData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeRay(DL_WriterA& dw,
|
|
||||||
const DL_RayData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writePolyline(DL_WriterA& dw,
|
|
||||||
const DL_PolylineData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeVertex(DL_WriterA& dw,
|
|
||||||
const DL_VertexData& data);
|
|
||||||
void writePolylineEnd(DL_WriterA& dw) const;
|
|
||||||
void writeSpline(DL_WriterA& dw,
|
|
||||||
const DL_SplineData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
static void writeControlPoint(DL_WriterA& dw,
|
|
||||||
const DL_ControlPointData& data);
|
|
||||||
static void writeFitPoint(DL_WriterA& dw,
|
|
||||||
const DL_FitPointData& data);
|
|
||||||
static void writeKnot(DL_WriterA& dw,
|
|
||||||
const DL_KnotData& data);
|
|
||||||
void writeCircle(DL_WriterA& dw,
|
|
||||||
const DL_CircleData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeArc(DL_WriterA& dw,
|
|
||||||
const DL_ArcData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeEllipse(DL_WriterA& dw,
|
|
||||||
const DL_EllipseData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeSolid(DL_WriterA& dw,
|
|
||||||
const DL_SolidData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeTrace(DL_WriterA& dw,
|
|
||||||
const DL_TraceData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void write3dFace(DL_WriterA& dw,
|
|
||||||
const DL_3dFaceData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeInsert(DL_WriterA& dw,
|
|
||||||
const DL_InsertData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeMText(DL_WriterA& dw,
|
|
||||||
const DL_MTextData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeText(DL_WriterA& dw,
|
|
||||||
const DL_TextData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeAttribute(DL_WriterA& dw,
|
|
||||||
const DL_AttributeData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimStyleOverrides(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data) const;
|
|
||||||
void writeDimAligned(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimAlignedData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimLinear(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimLinearData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimRadial(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimRadialData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimDiametric(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimDiametricData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimAngular(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimAngularData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimAngular3P(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimAngular3PData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeDimOrdinate(DL_WriterA& dw,
|
|
||||||
const DL_DimensionData& data,
|
|
||||||
const DL_DimOrdinateData& edata,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeLeader(DL_WriterA& dw,
|
|
||||||
const DL_LeaderData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeLeaderVertex(DL_WriterA& dw,
|
|
||||||
const DL_LeaderVertexData& data) const;
|
|
||||||
void writeHatch1(DL_WriterA& dw,
|
|
||||||
const DL_HatchData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
void writeHatch2(DL_WriterA& dw,
|
|
||||||
const DL_HatchData& data,
|
|
||||||
const DL_Attributes& attrib) const;
|
|
||||||
static void writeHatchLoop1(DL_WriterA& dw,
|
|
||||||
const DL_HatchLoopData& data);
|
|
||||||
static void writeHatchLoop2(DL_WriterA& dw,
|
|
||||||
const DL_HatchLoopData& data);
|
|
||||||
static void writeHatchEdge(DL_WriterA& dw,
|
|
||||||
const DL_HatchEdgeData& data);
|
|
||||||
|
|
||||||
int writeImage(DL_WriterA& dw,
|
|
||||||
const DL_ImageData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
|
|
||||||
void writeImageDef(DL_WriterA& dw, int handle,
|
|
||||||
const DL_ImageData& data) const;
|
|
||||||
|
|
||||||
void writeLayer(DL_WriterA& dw,
|
|
||||||
const DL_LayerData& data,
|
|
||||||
const DL_Attributes& attrib);
|
|
||||||
|
|
||||||
void writeLinetype(DL_WriterA& dw,
|
|
||||||
const DL_LinetypeData& data) const;
|
|
||||||
|
|
||||||
static void writeAppid(DL_WriterA& dw, const std::string& name);
|
|
||||||
|
|
||||||
static void writeBlock(DL_WriterA& dw,
|
|
||||||
const DL_BlockData& data);
|
|
||||||
static void writeEndBlock(DL_WriterA& dw, const std::string& name);
|
|
||||||
|
|
||||||
void writeVPort(DL_WriterA& dw) const;
|
|
||||||
void writeStyle(DL_WriterA& dw, const DL_StyleData& style);
|
|
||||||
void writeView(DL_WriterA& dw) const;
|
|
||||||
void writeUcs(DL_WriterA& dw) const;
|
|
||||||
void writeDimStyle(DL_WriterA& dw,
|
|
||||||
double dimasz, double dimexe, double dimexo,
|
|
||||||
double dimgap, double dimtxt);
|
|
||||||
void writeBlockRecord(DL_WriterA& dw) const;
|
|
||||||
void writeBlockRecord(DL_WriterA& dw, const std::string& name) const;
|
|
||||||
void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = "");
|
|
||||||
void writeAppDictionary(DL_WriterA& dw);
|
|
||||||
static int writeDictionaryEntry(DL_WriterA& dw, const std::string& name);
|
|
||||||
void writeXRecord(DL_WriterA& dw, int handle, int value);
|
|
||||||
void writeXRecord(DL_WriterA& dw, int handle, double value);
|
|
||||||
void writeXRecord(DL_WriterA& dw, int handle, bool value);
|
|
||||||
void writeXRecord(DL_WriterA& dw, int handle, const std::string& value);
|
|
||||||
static void writeObjectsEnd(DL_WriterA& dw);
|
|
||||||
|
|
||||||
static void writeComment(DL_WriterA& dw, const std::string& comment);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the given string into a double or returns the given
|
|
||||||
* default valud (def) if value is NULL or empty.
|
|
||||||
*/
|
|
||||||
//static double toReal(const char* value, double def=0.0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the given string into an int or returns the given
|
|
||||||
* default valud (def) if value is NULL or empty.
|
|
||||||
*/
|
|
||||||
// static int toInt(const char* value, int def=0) {
|
|
||||||
// if (value!=NULL && value[0] != '\0') {
|
|
||||||
// return atoi(value);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return def;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the given string into a string or returns the given
|
|
||||||
* default valud (def) if value is NULL or empty.
|
|
||||||
*/
|
|
||||||
// static const char* toString(const char* value, const char* def="") {
|
|
||||||
// if (value!=NULL && value[0] != '\0') {
|
|
||||||
// return value;
|
|
||||||
// } else {
|
|
||||||
// return def;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
static bool checkVariable(const char* var, DL_Codes::version version);
|
|
||||||
|
|
||||||
DL_Codes::version getVersion() const
|
|
||||||
{
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getLibVersion(const std::string &str);
|
|
||||||
|
|
||||||
static void test();
|
|
||||||
|
|
||||||
bool hasValue(int code)
|
|
||||||
{
|
|
||||||
return values.count(code)==1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getIntValue(int code, int def)
|
|
||||||
{
|
|
||||||
if (!hasValue(code))
|
|
||||||
{
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
return toInt(values[code]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int toInt(const std::string& str)
|
|
||||||
{
|
|
||||||
char* p;
|
|
||||||
return static_cast<int>(strtol(str.c_str(), &p, 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
int getInt16Value(int code, int def)
|
|
||||||
{
|
|
||||||
if (!hasValue(code))
|
|
||||||
{
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
return toInt16(values[code]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int toInt16(const std::string& str)
|
|
||||||
{
|
|
||||||
char* p;
|
|
||||||
return static_cast<int>(strtol(str.c_str(), &p, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool toBool(const std::string& str)
|
|
||||||
{
|
|
||||||
char* p;
|
|
||||||
return static_cast<bool>(strtol(str.c_str(), &p, 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getStringValue(int code, const std::string& def)
|
|
||||||
{
|
|
||||||
if (!hasValue(code))
|
|
||||||
{
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
return values[code];
|
|
||||||
}
|
|
||||||
|
|
||||||
double getRealValue(int code, double def)
|
|
||||||
{
|
|
||||||
if (!hasValue(code))
|
|
||||||
{
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
return toReal(values[code]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static double toReal(const std::string& str)
|
|
||||||
{
|
|
||||||
double ret;
|
|
||||||
// make sure the real value uses '.' not ',':
|
|
||||||
std::string str2 = str;
|
|
||||||
std::replace(str2.begin(), str2.end(), ',', '.');
|
|
||||||
// make sure c++ expects '.' not ',':
|
|
||||||
std::istringstream istr(str2);
|
|
||||||
istr.imbue(std::locale("C"));
|
|
||||||
istr >> ret;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_DISABLE_COPY(DL_Dxf)
|
|
||||||
DL_Codes::version version;
|
|
||||||
|
|
||||||
std::string polylineLayer;
|
|
||||||
double* vertices;
|
|
||||||
int maxVertices;
|
|
||||||
int vertexIndex;
|
|
||||||
|
|
||||||
double* knots;
|
|
||||||
int maxKnots;
|
|
||||||
int knotIndex;
|
|
||||||
|
|
||||||
double* weights;
|
|
||||||
int weightIndex;
|
|
||||||
|
|
||||||
double* controlPoints;
|
|
||||||
int maxControlPoints;
|
|
||||||
int controlPointIndex;
|
|
||||||
|
|
||||||
double* fitPoints;
|
|
||||||
int maxFitPoints;
|
|
||||||
int fitPointIndex;
|
|
||||||
|
|
||||||
double* leaderVertices;
|
|
||||||
int maxLeaderVertices;
|
|
||||||
int leaderVertexIndex;
|
|
||||||
|
|
||||||
bool firstHatchLoop;
|
|
||||||
DL_HatchEdgeData hatchEdge;
|
|
||||||
std::vector<std::vector<DL_HatchEdgeData> > hatchEdges;
|
|
||||||
|
|
||||||
std::string xRecordHandle;
|
|
||||||
bool xRecordValues;
|
|
||||||
|
|
||||||
// Only the useful part of the group code
|
|
||||||
std::string groupCodeTmp;
|
|
||||||
// ...same as integer
|
|
||||||
quint32 groupCode;
|
|
||||||
// Only the useful part of the group value
|
|
||||||
std::string groupValue;
|
|
||||||
// Current entity type
|
|
||||||
int currentObjectType;
|
|
||||||
// Value of the current setting
|
|
||||||
char settingValue[DL_DXF_MAXLINE+1];
|
|
||||||
// Key of the current setting (e.g. "$ACADVER")
|
|
||||||
std::string settingKey;
|
|
||||||
// Stores the group codes
|
|
||||||
std::map<int, std::string> values;
|
|
||||||
// First call of this method. We initialize all group values in
|
|
||||||
// the first call.
|
|
||||||
bool firstCall;
|
|
||||||
// Attributes of the current entity (layer, color, width, line type)
|
|
||||||
DL_Attributes attrib;
|
|
||||||
// library version. hex: 0x20003001 = 2.0.3.1
|
|
||||||
int libVersion;
|
|
||||||
// app specific dictionary handle:
|
|
||||||
unsigned long appDictionaryHandle;
|
|
||||||
// handle of standard text style, referenced by dimstyle:
|
|
||||||
unsigned long styleHandleStd;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// EOF
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,164 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_EXTRUSION_H
|
|
||||||
#define DL_EXTRUSION_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
|
|
||||||
#include "../vmisc/vmath.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Storing and passing around attributes. Attributes
|
|
||||||
* are the layer name, color, width and line type.
|
|
||||||
*
|
|
||||||
* @author Andrew Mustun
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_Extrusion
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
DL_Extrusion() : direction(new double[3]), elevation(0.0)
|
|
||||||
{
|
|
||||||
setDirection(0.0, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor.
|
|
||||||
*/
|
|
||||||
~DL_Extrusion()
|
|
||||||
{
|
|
||||||
delete[] direction ;
|
|
||||||
}
|
|
||||||
|
|
||||||
DL_Extrusion(const DL_Extrusion &L)
|
|
||||||
: direction(new double[3]), elevation(L.elevation)
|
|
||||||
{
|
|
||||||
setDirection(L.direction[0], L.direction[1], L.direction[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DXF extrusion.
|
|
||||||
*
|
|
||||||
* @param elevation Distance of the entities XY plane from the origin of the
|
|
||||||
* world coordinate system
|
|
||||||
*/
|
|
||||||
DL_Extrusion(double dx, double dy, double dz, double elevation)
|
|
||||||
: direction(new double[3]), elevation(elevation)
|
|
||||||
{
|
|
||||||
setDirection(dx, dy, dz);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the direction vector.
|
|
||||||
*/
|
|
||||||
void setDirection(double dx, double dy, double dz)
|
|
||||||
{
|
|
||||||
direction[0]=dx;
|
|
||||||
direction[1]=dy;
|
|
||||||
direction[2]=dz;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return direction vector.
|
|
||||||
*/
|
|
||||||
double* getDirection() const
|
|
||||||
{
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dir vector.
|
|
||||||
*/
|
|
||||||
void getDirection(double dir[]) const
|
|
||||||
{
|
|
||||||
dir[0]=direction[0];
|
|
||||||
dir[1]=direction[1];
|
|
||||||
dir[2]=direction[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the elevation.
|
|
||||||
*/
|
|
||||||
void setElevation(double elevation)
|
|
||||||
{
|
|
||||||
this->elevation = elevation;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Elevation.
|
|
||||||
*/
|
|
||||||
double getElevation() const
|
|
||||||
{
|
|
||||||
return elevation;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies extrusion (deep copies) from another extrusion object.
|
|
||||||
*/
|
|
||||||
DL_Extrusion & operator = (const DL_Extrusion& extru)
|
|
||||||
{
|
|
||||||
if ( &extru == this )
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
setDirection(extru.direction[0], extru.direction[1], extru.direction[2]);
|
|
||||||
setElevation(extru.elevation);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* @brief direction Vector of axis along which the entity shall be extruded this is also the Z axis of the Entity
|
|
||||||
* coordinate system
|
|
||||||
*/
|
|
||||||
double *direction;
|
|
||||||
/**
|
|
||||||
* @brief elevation Distance of the entities XY plane from the origin of the world coordinate system
|
|
||||||
*/
|
|
||||||
double elevation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#if defined(DXFLIB_DLL)
|
|
||||||
# ifdef _WIN32
|
|
||||||
# if defined(DXFLIB_LIBRARY)
|
|
||||||
# define DXFLIB_EXPORT __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define DXFLIB_EXPORT __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define DXFLIB_EXPORT
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define DXFLIB_EXPORT
|
|
||||||
#endif
|
|
|
@ -1,644 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2015 Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
** Copyright (C) 2001 Robert J. Campbell Jr.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#include "dl_writer.h"
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "dl_attributes.h"
|
|
||||||
#include "dl_codes.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param version DXF version. Defaults to DL_VERSION_2002.
|
|
||||||
*/
|
|
||||||
DL_Writer::DL_Writer(DL_Codes::version version)
|
|
||||||
: m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version(version)
|
|
||||||
{}
|
|
||||||
|
|
||||||
DL_Writer::~DL_Writer()
|
|
||||||
{}
|
|
||||||
|
|
||||||
/** Generic section for section 'name'.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* name
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::section(const char *name) const
|
|
||||||
{
|
|
||||||
dxfString(0, "SECTION");
|
|
||||||
dxfString(2, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section HEADER
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* HEADER
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionHeader() const
|
|
||||||
{
|
|
||||||
section("HEADER");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section TABLES
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* TABLES
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionTables() const
|
|
||||||
{
|
|
||||||
section("TABLES");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section BLOCKS
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* BLOCKS
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionBlocks() const
|
|
||||||
{
|
|
||||||
section("BLOCKS");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section ENTITIES
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* ENTITIES
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionEntities() const
|
|
||||||
{
|
|
||||||
section("ENTITIES");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section CLASSES
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* CLASSES
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionClasses() const
|
|
||||||
{
|
|
||||||
section("CLASSES");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section OBJECTS
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* SECTION
|
|
||||||
* 2
|
|
||||||
* OBJECTS
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionObjects() const
|
|
||||||
{
|
|
||||||
section("OBJECTS");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of a section.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* ENDSEC
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionEnd() const
|
|
||||||
{
|
|
||||||
dxfString(0, "ENDSEC");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic table for table 'name' with 'num' entries:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* TABLE
|
|
||||||
* 2
|
|
||||||
* name
|
|
||||||
* 70
|
|
||||||
* num
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::table(const char *name, int num, int h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "TABLE");
|
|
||||||
dxfString(2, name);
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, h);
|
|
||||||
}
|
|
||||||
dxfString(100, "AcDbSymbolTable");
|
|
||||||
}
|
|
||||||
dxfInt(70, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Table for layers.
|
|
||||||
*
|
|
||||||
* @param num Number of layers in total.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* TABLE
|
|
||||||
* 2
|
|
||||||
* LAYER
|
|
||||||
* 70
|
|
||||||
* num
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableLayers(int num) const
|
|
||||||
{
|
|
||||||
table("LAYER", num, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Table for line types.
|
|
||||||
*
|
|
||||||
* @param num Number of line types in total.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* TABLE
|
|
||||||
* 2
|
|
||||||
* LTYPE
|
|
||||||
* 70
|
|
||||||
* num
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableLinetypes(int num) const
|
|
||||||
{
|
|
||||||
//linetypeHandle = 5;
|
|
||||||
table("LTYPE", num, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Table for application id.
|
|
||||||
*
|
|
||||||
* @param num Number of registered applications in total.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* TABLE
|
|
||||||
* 2
|
|
||||||
* APPID
|
|
||||||
* 70
|
|
||||||
* num
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableAppid(int num) const
|
|
||||||
{
|
|
||||||
table("APPID", num, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Table for text style.
|
|
||||||
*
|
|
||||||
* @param num Number of text styles.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* TABLE
|
|
||||||
* 2
|
|
||||||
* STYLE
|
|
||||||
* 70
|
|
||||||
* num
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableStyle(int num) const
|
|
||||||
{
|
|
||||||
table("STYLE", num, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of a table.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* ENDTAB
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableEnd() const
|
|
||||||
{
|
|
||||||
dxfString(0, "ENDTAB");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of the DXF file.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* EOF
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::dxfEOF() const
|
|
||||||
{
|
|
||||||
dxfString(0, "EOF");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Comment.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 999
|
|
||||||
* text
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::comment(const char *text) const
|
|
||||||
{
|
|
||||||
dxfString(999, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entity.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* entTypeName
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void DL_Writer::entity(const char *entTypeName) const
|
|
||||||
{
|
|
||||||
dxfString(0, entTypeName);
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attributes of an entity.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 8
|
|
||||||
* layer
|
|
||||||
* 62
|
|
||||||
* color
|
|
||||||
* 39
|
|
||||||
* width
|
|
||||||
* 6
|
|
||||||
* linetype
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::entityAttributes(const DL_Attributes &attrib) const
|
|
||||||
{
|
|
||||||
|
|
||||||
// layer name:
|
|
||||||
dxfString(8, attrib.getLayer());
|
|
||||||
|
|
||||||
// R12 doesn't accept BYLAYER values. The value has to be missing
|
|
||||||
// in that case.
|
|
||||||
if (version>=DL_VERSION_2000 || attrib.getColor()!=256)
|
|
||||||
{
|
|
||||||
dxfInt(62, attrib.getColor());
|
|
||||||
}
|
|
||||||
if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1)
|
|
||||||
{
|
|
||||||
dxfInt(420, attrib.getColor24());
|
|
||||||
}
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
dxfInt(370, attrib.getWidth());
|
|
||||||
}
|
|
||||||
if (version>=DL_VERSION_2000) //-V581
|
|
||||||
{
|
|
||||||
dxfReal(48, attrib.getLinetypeScale());
|
|
||||||
}
|
|
||||||
std::string linetype = attrib.getLinetype();
|
|
||||||
std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper);
|
|
||||||
if (version>=DL_VERSION_2000 || linetype=="BYLAYER")
|
|
||||||
{
|
|
||||||
dxfString(6, attrib.getLinetype());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclass.
|
|
||||||
*/
|
|
||||||
void DL_Writer::subClass(const char *sub) const
|
|
||||||
{
|
|
||||||
dxfString(100, sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Layer (must be in the TABLES section LAYER).
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* LAYER
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableLayerEntry(unsigned long h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "LAYER");
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, static_cast<int>(h));
|
|
||||||
}
|
|
||||||
dxfString(100, "AcDbSymbolTableRecord");
|
|
||||||
dxfString(100, "AcDbLayerTableRecord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Line type (must be in the TABLES section LTYPE).
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* LTYPE
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableLinetypeEntry(unsigned long h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "LTYPE");
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, static_cast<int>(h));
|
|
||||||
}
|
|
||||||
//dxfHex(330, 0x5);
|
|
||||||
dxfString(100, "AcDbSymbolTableRecord");
|
|
||||||
dxfString(100, "AcDbLinetypeTableRecord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appid (must be in the TABLES section APPID).
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* APPID
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::tableAppidEntry(unsigned long h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "APPID");
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, static_cast<int>(h));
|
|
||||||
}
|
|
||||||
//dxfHex(330, 0x9);
|
|
||||||
dxfString(100, "AcDbSymbolTableRecord");
|
|
||||||
dxfString(100, "AcDbRegAppTableRecord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Block (must be in the section BLOCKS).
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* BLOCK
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionBlockEntry(unsigned long h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "BLOCK");
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, static_cast<int>(h));
|
|
||||||
}
|
|
||||||
//dxfHex(330, blockHandle);
|
|
||||||
dxfString(100, "AcDbEntity");
|
|
||||||
if (h==0x1C)
|
|
||||||
{
|
|
||||||
dxfInt(67, 1);
|
|
||||||
}
|
|
||||||
dxfString(8, "0"); // TODO: Layer for block
|
|
||||||
dxfString(100, "AcDbBlockBegin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of Block (must be in the section BLOCKS).
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* 0
|
|
||||||
* ENDBLK
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
void DL_Writer::sectionBlockEntryEnd(unsigned long h) const
|
|
||||||
{
|
|
||||||
dxfString(0, "ENDBLK");
|
|
||||||
if (version>=DL_VERSION_2000)
|
|
||||||
{
|
|
||||||
if (h==0)
|
|
||||||
{
|
|
||||||
handle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dxfHex(5, static_cast<int>(h));
|
|
||||||
}
|
|
||||||
//dxfHex(330, blockHandle);
|
|
||||||
dxfString(100, "AcDbEntity");
|
|
||||||
if (h==0x1D)
|
|
||||||
{
|
|
||||||
dxfInt(67, 1);
|
|
||||||
}
|
|
||||||
dxfString(8, "0"); // TODO: Layer for block
|
|
||||||
dxfString(100, "AcDbBlockEnd");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::color(int col) const
|
|
||||||
{
|
|
||||||
dxfInt(62, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::linetype(const char *lt) const
|
|
||||||
{
|
|
||||||
dxfString(6, lt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::linetypeScale(double scale) const
|
|
||||||
{
|
|
||||||
dxfReal(48, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::lineWeight(int lw) const
|
|
||||||
{
|
|
||||||
dxfInt(370, lw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::coord(int gc, double x, double y, double z) const
|
|
||||||
{
|
|
||||||
dxfReal(gc, x);
|
|
||||||
dxfReal(gc+10, y);
|
|
||||||
dxfReal(gc+20, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::coordTriplet(int gc, const double *value) const
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
dxfReal(gc, *value++);
|
|
||||||
dxfReal(gc+10, *value++);
|
|
||||||
dxfReal(gc+20, *value++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DL_Writer::resetHandle() const
|
|
||||||
{
|
|
||||||
m_handle = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a unique handle and returns it.
|
|
||||||
*/
|
|
||||||
unsigned long DL_Writer::handle(int gc) const
|
|
||||||
{
|
|
||||||
// handle has to be hex
|
|
||||||
dxfHex(gc, static_cast<int>(m_handle));
|
|
||||||
return m_handle++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Next handle that will be written.
|
|
||||||
*/
|
|
||||||
unsigned long DL_Writer::getNextHandle() const
|
|
||||||
{
|
|
||||||
return m_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increases handle, so that the handle returned remains available.
|
|
||||||
*/
|
|
||||||
unsigned long DL_Writer::incHandle() const
|
|
||||||
{
|
|
||||||
return m_handle++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the handle of the model space. Entities refer to
|
|
||||||
* this handle.
|
|
||||||
*/
|
|
||||||
void DL_Writer::setModelSpaceHandle(unsigned long h) const
|
|
||||||
{
|
|
||||||
modelSpaceHandle = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long DL_Writer::getModelSpaceHandle() const
|
|
||||||
{
|
|
||||||
return modelSpaceHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the handle of the paper space. Some special blocks refer to
|
|
||||||
* this handle.
|
|
||||||
*/
|
|
||||||
void DL_Writer::setPaperSpaceHandle(unsigned long h) const
|
|
||||||
{
|
|
||||||
paperSpaceHandle = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long DL_Writer::getPaperSpaceHandle() const
|
|
||||||
{
|
|
||||||
return paperSpaceHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the handle of the paper space 0. Some special blocks refer to
|
|
||||||
* this handle.
|
|
||||||
*/
|
|
||||||
void DL_Writer::setPaperSpace0Handle(unsigned long h) const
|
|
||||||
{
|
|
||||||
paperSpace0Handle = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the handle of the paper space 0. Some special blocks refer to
|
|
||||||
* this handle.
|
|
||||||
*/
|
|
||||||
unsigned long DL_Writer::getPaperSpace0Handle() const
|
|
||||||
{
|
|
||||||
return paperSpace0Handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be overwritten by the implementing class to write a
|
|
||||||
* bool value to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The bool value.
|
|
||||||
*/
|
|
||||||
void DL_Writer::dxfBool(int gc, bool value) const
|
|
||||||
{
|
|
||||||
dxfInt(gc, static_cast<int>(value));
|
|
||||||
}
|
|
|
@ -1,170 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2015 Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
** Copyright (C) 2001 Robert J. Campbell Jr.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_WRITER_H
|
|
||||||
#define DL_WRITER_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_CC_MSVC)
|
|
||||||
#if (_MSC_VER > 1000)
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
#endif // Q_CC_MSVC
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "dl_attributes.h"
|
|
||||||
#include "dl_codes.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines interface for writing low level DXF constructs to
|
|
||||||
* a file. Implementation is defined in derived classes that write
|
|
||||||
* to binary or ASCII files.
|
|
||||||
*
|
|
||||||
* Implements functions that write higher level constructs in terms of
|
|
||||||
* the low level ones.
|
|
||||||
*
|
|
||||||
* @todo Add error checking for string/entry length.
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_Writer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit DL_Writer(DL_Codes::version version);
|
|
||||||
virtual ~DL_Writer();
|
|
||||||
|
|
||||||
void section(const char* name) const;
|
|
||||||
void sectionHeader() const;
|
|
||||||
void sectionTables() const;
|
|
||||||
void sectionBlocks() const;
|
|
||||||
void sectionEntities() const;
|
|
||||||
void sectionClasses() const;
|
|
||||||
void sectionObjects() const;
|
|
||||||
void sectionEnd() const;
|
|
||||||
void table(const char* name, int num, int h=0) const;
|
|
||||||
void tableLayers(int num) const;
|
|
||||||
void tableLinetypes(int num) const;
|
|
||||||
void tableAppid(int num) const;
|
|
||||||
void tableStyle(int num) const;
|
|
||||||
void tableEnd() const;
|
|
||||||
void dxfEOF() const;
|
|
||||||
void comment(const char* text) const;
|
|
||||||
void entity(const char* entTypeName) const;
|
|
||||||
void entityAttributes(const DL_Attributes& attrib) const;
|
|
||||||
void subClass(const char* sub) const;
|
|
||||||
void tableLayerEntry(unsigned long int h=0) const;
|
|
||||||
void tableLinetypeEntry(unsigned long int h=0) const;
|
|
||||||
void tableAppidEntry(unsigned long int h=0) const;
|
|
||||||
void sectionBlockEntry(unsigned long int h=0) const;
|
|
||||||
void sectionBlockEntryEnd(unsigned long int h=0) const;
|
|
||||||
void color(int col=256) const;
|
|
||||||
void linetype(const char *lt) const;
|
|
||||||
void linetypeScale(double scale) const;
|
|
||||||
void lineWeight(int lw) const;
|
|
||||||
void coord(int gc, double x, double y, double z=0) const;
|
|
||||||
void coordTriplet(int gc, const double* value) const;
|
|
||||||
void resetHandle() const;
|
|
||||||
|
|
||||||
unsigned long handle(int gc=5) const;
|
|
||||||
unsigned long getNextHandle() const;
|
|
||||||
unsigned long incHandle() const;
|
|
||||||
|
|
||||||
void setModelSpaceHandle(unsigned long h) const;
|
|
||||||
unsigned long getModelSpaceHandle() const;
|
|
||||||
|
|
||||||
void setPaperSpaceHandle(unsigned long h) const;
|
|
||||||
unsigned long getPaperSpaceHandle() const;
|
|
||||||
|
|
||||||
void setPaperSpace0Handle(unsigned long h) const;
|
|
||||||
unsigned long getPaperSpace0Handle() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be overwritten by the implementing class to write a
|
|
||||||
* real value to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The real value.
|
|
||||||
*/
|
|
||||||
virtual void dxfReal(int gc, double value) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be overwritten by the implementing class to write an
|
|
||||||
* int value to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The int value.
|
|
||||||
*/
|
|
||||||
virtual void dxfInt(int gc, int value) const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
virtual void dxfBool(int gc, bool value) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be overwritten by the implementing class to write an
|
|
||||||
* int value (hex) to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The int value.
|
|
||||||
*/
|
|
||||||
virtual void dxfHex(int gc, int value) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be overwritten by the implementing class to write a
|
|
||||||
* string to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The string.
|
|
||||||
*/
|
|
||||||
virtual void dxfString(int gc, const char* value) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be overwritten by the implementing class to write a
|
|
||||||
* string to the file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value The string.
|
|
||||||
*/
|
|
||||||
virtual void dxfString(int gc, const std::string& value) const = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
mutable unsigned long m_handle;
|
|
||||||
mutable unsigned long modelSpaceHandle;
|
|
||||||
mutable unsigned long paperSpaceHandle;
|
|
||||||
mutable unsigned long paperSpace0Handle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DXF version to be created.
|
|
||||||
*/
|
|
||||||
DL_Codes::version version;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,175 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
** Copyright (C) 2001 Robert J. Campbell Jr.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#if defined(Q_CC_MSVC)
|
|
||||||
#if (_MSC_VER > 1000)
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
#endif // Q_CC_MSVC
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "../vmisc/diagnostic.h"
|
|
||||||
#include "dl_writer_ascii.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the output file.
|
|
||||||
*/
|
|
||||||
void DL_WriterA::close() const
|
|
||||||
{
|
|
||||||
m_ofile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @retval true Opening file has failed.
|
|
||||||
* @retval false Otherwise.
|
|
||||||
*/
|
|
||||||
bool DL_WriterA::openFailed() const
|
|
||||||
{
|
|
||||||
return m_ofile.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a real (double) variable to the DXF file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value Double value
|
|
||||||
*/
|
|
||||||
void DL_WriterA::dxfReal(int gc, double value) const
|
|
||||||
{
|
|
||||||
char str[256];
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 408
|
|
||||||
QT_WARNING_DISABLE_GCC("-Wformat")
|
|
||||||
#endif
|
|
||||||
if (version==DL_Codes::AC1009_MIN)
|
|
||||||
{
|
|
||||||
snprintf(str, sizeof(str), "%.6lf", value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf(str, sizeof(str), "%.16lf", value);
|
|
||||||
}
|
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
// fix for german locale:
|
|
||||||
strReplace(str, ',', '.');
|
|
||||||
|
|
||||||
// Cut away those zeros at the end:
|
|
||||||
bool dot = false;
|
|
||||||
int end = -1;
|
|
||||||
for (quint32 i=0, sz = static_cast<quint32>(strlen(str)); i<sz; ++i)
|
|
||||||
{
|
|
||||||
if (str[i]=='.')
|
|
||||||
{
|
|
||||||
dot = true;
|
|
||||||
end = static_cast<int>(i)+2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (dot && str[i]!='0')
|
|
||||||
{
|
|
||||||
end = static_cast<int>(i)+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (end>0 && end<static_cast<int>(strlen(str)))
|
|
||||||
{
|
|
||||||
str[end] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
dxfString(gc, str);
|
|
||||||
m_ofile.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes an int variable to the DXF file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value Int value
|
|
||||||
*/
|
|
||||||
void DL_WriterA::dxfInt(int gc, int value) const
|
|
||||||
{
|
|
||||||
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" << value << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a hex int variable to the DXF file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value Int value
|
|
||||||
*/
|
|
||||||
void DL_WriterA::dxfHex(int gc, int value) const
|
|
||||||
{
|
|
||||||
char str[12];
|
|
||||||
snprintf(str, sizeof(str), "%0X", value);
|
|
||||||
dxfString(gc, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a string variable to the DXF file.
|
|
||||||
*
|
|
||||||
* @param gc Group code.
|
|
||||||
* @param value String
|
|
||||||
*/
|
|
||||||
void DL_WriterA::dxfString(int gc, const char* value) const
|
|
||||||
{
|
|
||||||
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
|
|
||||||
<< value << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DL_WriterA::dxfString(int gc, const std::string& value) const
|
|
||||||
{
|
|
||||||
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
|
|
||||||
<< value << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces every occurence of src with dest in the null terminated str.
|
|
||||||
*/
|
|
||||||
void DL_WriterA::strReplace(char* str, char src, char dest)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
for (i=0; i<strlen(str); i++)
|
|
||||||
{
|
|
||||||
if (str[i]==src)
|
|
||||||
{
|
|
||||||
str[i] = dest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
|
|
||||||
** Copyright (C) 2001 Robert J. Campbell Jr.
|
|
||||||
**
|
|
||||||
** This file is part of the dxflib project.
|
|
||||||
**
|
|
||||||
** This file is free software; you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation; either version 2 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Licensees holding valid dxflib Professional Edition licenses may use
|
|
||||||
** this file in accordance with the dxflib Commercial License
|
|
||||||
** Agreement provided with the Software.
|
|
||||||
**
|
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
**
|
|
||||||
** See http://www.ribbonsoft.com for further details.
|
|
||||||
**
|
|
||||||
** Contact info@ribbonsoft.com if any conditions of this licensing are
|
|
||||||
** not clear to you.
|
|
||||||
**
|
|
||||||
**********************************************************************/
|
|
||||||
|
|
||||||
#ifndef DL_WRITER_ASCII_H
|
|
||||||
#define DL_WRITER_ASCII_H
|
|
||||||
|
|
||||||
#include "dl_global.h"
|
|
||||||
#include "dl_codes.h"
|
|
||||||
|
|
||||||
#if defined(Q_CC_MSVC)
|
|
||||||
#if (_MSC_VER > 1000)
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#if _MSC_VER < 1900
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
#endif // Q_CC_MSVC
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "dl_writer.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements functions defined in DL_Writer for writing low
|
|
||||||
* level DXF constructs to an ASCII format DXF file.
|
|
||||||
*
|
|
||||||
* @todo What if \c fname is NULL? Or \c fname can't be opened for
|
|
||||||
* another reason?
|
|
||||||
*/
|
|
||||||
class DXFLIB_EXPORT DL_WriterA : public DL_Writer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief DL_WriterA contructor
|
|
||||||
* @param fname File name of the file to be created.
|
|
||||||
* @param version DXF version. Defaults to DL_VERSION_2002.
|
|
||||||
*/
|
|
||||||
explicit DL_WriterA(const char* fname, DL_Codes::version version=DL_VERSION_2000)
|
|
||||||
: DL_Writer(version), m_ofile(fname) {}
|
|
||||||
virtual ~DL_WriterA() {}
|
|
||||||
|
|
||||||
bool openFailed() const;
|
|
||||||
void close() const;
|
|
||||||
void dxfReal(int gc, double value) const;
|
|
||||||
void dxfInt(int gc, int value) const;
|
|
||||||
void dxfHex(int gc, int value) const;
|
|
||||||
void dxfString(int gc, const char* value) const;
|
|
||||||
void dxfString(int gc, const std::string& value) const;
|
|
||||||
|
|
||||||
static void strReplace(char* str, char src, char dest);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* DXF file to be created.
|
|
||||||
*/
|
|
||||||
mutable std::ofstream m_ofile;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,150 +0,0 @@
|
||||||
/************************************************************************
|
|
||||||
**
|
|
||||||
** @file strlcpy.h
|
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
||||||
** @date December 20, 2016
|
|
||||||
**
|
|
||||||
** @brief
|
|
||||||
** @copyright
|
|
||||||
** This source code is part of the Valentine project, a pattern making
|
|
||||||
** program, whose allow create and modeling patterns of clothing.
|
|
||||||
** Copyright (C) 2013-2016 Valentina project
|
|
||||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
||||||
**
|
|
||||||
** Valentina is free software: you can redistribute it and/or modify
|
|
||||||
** it under the terms of the GNU General Public License as published by
|
|
||||||
** the Free Software Foundation, either version 3 of the License, or
|
|
||||||
** (at your option) any later version.
|
|
||||||
**
|
|
||||||
** Valentina is distributed in the hope that it will be useful,
|
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
** GNU General Public License for more details.
|
|
||||||
**
|
|
||||||
** You should have received a copy of the GNU General Public License
|
|
||||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
**
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VALENTINA_STRLCPY_H
|
|
||||||
#define VALENTINA_STRLCPY_H
|
|
||||||
|
|
||||||
/* This function comes from BSD */
|
|
||||||
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && \
|
|
||||||
!defined(__bsdi__) && !defined(__APPLE__)
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "../vmisc/diagnostic.h"
|
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_CLANG("-Wsign-conversion")
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy src to string dst of size siz. At most siz-1 characters
|
|
||||||
* will be copied. Always NUL terminates (unless siz == 0).
|
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
|
||||||
*/
|
|
||||||
inline size_t strlcpy(char *dst, const char *src, size_t siz)
|
|
||||||
{
|
|
||||||
char *d = dst;
|
|
||||||
const char *s = src;
|
|
||||||
size_t n = siz;
|
|
||||||
|
|
||||||
/* Copy as many bytes as will fit */
|
|
||||||
if (n != 0)
|
|
||||||
{
|
|
||||||
while (--n != 0)
|
|
||||||
{
|
|
||||||
if ((*d++ = *s++) == '\0')
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
|
||||||
if (n == 0)
|
|
||||||
{
|
|
||||||
if (siz != 0)
|
|
||||||
{
|
|
||||||
*d = '\0'; /* NUL-terminate dst */
|
|
||||||
}
|
|
||||||
while (*s++)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(s - src - 1); /* count does not include NUL */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
|
||||||
* full size of dst, not space left). At most siz-1 characters
|
|
||||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
|
||||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
|
||||||
* If retval >= siz, truncation occurred.
|
|
||||||
*/
|
|
||||||
inline size_t strlcat(char *dst, const char *src, size_t siz)
|
|
||||||
{
|
|
||||||
char *d = dst;
|
|
||||||
const char *s = src;
|
|
||||||
size_t n = siz;
|
|
||||||
size_t dlen;
|
|
||||||
|
|
||||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
|
||||||
while (n-- != 0 && *d != '\0')
|
|
||||||
{
|
|
||||||
d++;
|
|
||||||
}
|
|
||||||
dlen = d - dst;
|
|
||||||
n = siz - dlen;
|
|
||||||
|
|
||||||
if (n == 0)
|
|
||||||
{
|
|
||||||
return(dlen + strlen(s));
|
|
||||||
}
|
|
||||||
while (*s != '\0')
|
|
||||||
{
|
|
||||||
if (n != 1)
|
|
||||||
{
|
|
||||||
*d++ = *s;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
*d = '\0';
|
|
||||||
|
|
||||||
return(dlen + (s - src)); /* count does not include NUL */
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
#endif /* ! __*BSD__ */
|
|
||||||
#endif // VALENTINA_STRLCPY_H
|
|
434
src/libs/vdxf/dxiface.cpp
Normal file
434
src/libs/vdxf/dxiface.cpp
Normal file
|
@ -0,0 +1,434 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** dwg2dxf - Program to convert dwg/dxf to dxf(ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "dxiface.h"
|
||||||
|
#include "libdxfrw/libdwgr.h"
|
||||||
|
#include "libdxfrw/libdxfrw.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
|
dx_iface::dx_iface(const std::string &file, DRW::Version v, VarMeasurement varMeasurement, VarInsunits varInsunits)
|
||||||
|
: dxfW(new dxfRW(file.c_str())),
|
||||||
|
cData(),
|
||||||
|
version(v)
|
||||||
|
{
|
||||||
|
InitHeader(varMeasurement, varInsunits);
|
||||||
|
InitLTypes();
|
||||||
|
InitLayers();
|
||||||
|
InitTextstyles();
|
||||||
|
InitAppId();
|
||||||
|
}
|
||||||
|
|
||||||
|
dx_iface::~dx_iface()
|
||||||
|
{
|
||||||
|
delete dxfW;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dx_iface::fileExport(bool binary)
|
||||||
|
{
|
||||||
|
bool success = dxfW->write(this, version, binary);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeEntity(DRW_Entity* e){
|
||||||
|
switch (e->eType) {
|
||||||
|
case DRW::POINT:
|
||||||
|
dxfW->writePoint(static_cast<DRW_Point*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::LINE:
|
||||||
|
dxfW->writeLine(static_cast<DRW_Line*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::CIRCLE:
|
||||||
|
dxfW->writeCircle(static_cast<DRW_Circle*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::ARC:
|
||||||
|
dxfW->writeArc(static_cast<DRW_Arc*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::SOLID:
|
||||||
|
dxfW->writeSolid(static_cast<DRW_Solid*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::ELLIPSE:
|
||||||
|
dxfW->writeEllipse(static_cast<DRW_Ellipse*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::LWPOLYLINE:
|
||||||
|
dxfW->writeLWPolyline(static_cast<DRW_LWPolyline*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::POLYLINE:
|
||||||
|
dxfW->writePolyline(static_cast<DRW_Polyline*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::SPLINE:
|
||||||
|
dxfW->writeSpline(static_cast<DRW_Spline*>(e));
|
||||||
|
break;
|
||||||
|
// case RS2::EntitySplinePoints:
|
||||||
|
// writeSplinePoints(static_cast<DRW_Point*>(e));
|
||||||
|
// break;
|
||||||
|
// case RS2::EntityVertex:
|
||||||
|
// break;
|
||||||
|
case DRW::INSERT:
|
||||||
|
dxfW->writeInsert(static_cast<DRW_Insert*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::MTEXT:
|
||||||
|
dxfW->writeMText(static_cast<DRW_MText*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::TEXT:
|
||||||
|
dxfW->writeText(static_cast<DRW_Text*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::DIMLINEAR:
|
||||||
|
case DRW::DIMALIGNED:
|
||||||
|
case DRW::DIMANGULAR:
|
||||||
|
case DRW::DIMANGULAR3P:
|
||||||
|
case DRW::DIMRADIAL:
|
||||||
|
case DRW::DIMDIAMETRIC:
|
||||||
|
case DRW::DIMORDINATE:
|
||||||
|
dxfW->writeDimension(static_cast<DRW_Dimension*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::LEADER:
|
||||||
|
dxfW->writeLeader(static_cast<DRW_Leader*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::HATCH:
|
||||||
|
dxfW->writeHatch(static_cast<DRW_Hatch*>(e));
|
||||||
|
break;
|
||||||
|
case DRW::IMAGE:
|
||||||
|
dxfW->writeImage(static_cast<DRW_Image*>(e), static_cast<dx_ifaceImg*>(e)->path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeHeader(DRW_Header &data){
|
||||||
|
//complete copy of header vars:
|
||||||
|
data = cData.headerC;
|
||||||
|
//or copy one by one:
|
||||||
|
// for (std::map<std::string,DRW_Variant*>::iterator it=cData->headerC.vars.begin(); it != cData->headerC.vars.end(); ++it)
|
||||||
|
// data.vars[it->first] = new DRW_Variant( *(it->second) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeBlocks(){
|
||||||
|
//write each block
|
||||||
|
for (std::list<dx_ifaceBlock*>::iterator it=cData.blocks.begin(); it != cData.blocks.end(); ++it){
|
||||||
|
dx_ifaceBlock* bk = *it;
|
||||||
|
dxfW->writeBlock(bk);
|
||||||
|
//and write each entity in block
|
||||||
|
for (std::list<DRW_Entity*>::const_iterator it=bk->ent.begin(); it!=bk->ent.end(); ++it)
|
||||||
|
writeEntity(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeBlockRecords(){
|
||||||
|
for (std::list<dx_ifaceBlock*>::iterator it=cData.blocks.begin(); it != cData.blocks.end(); ++it)
|
||||||
|
dxfW->writeBlockRecord((*it)->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeEntities(){
|
||||||
|
for (std::list<DRW_Entity*>::const_iterator it=cData.mBlock->ent.begin(); it!=cData.mBlock->ent.end(); ++it)
|
||||||
|
writeEntity(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeLTypes(){
|
||||||
|
for (std::list<DRW_LType>::iterator it=cData.lineTypes.begin(); it != cData.lineTypes.end(); ++it)
|
||||||
|
dxfW->writeLineType(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeLayers(){
|
||||||
|
for (std::list<DRW_Layer>::iterator it=cData.layers.begin(); it != cData.layers.end(); ++it)
|
||||||
|
dxfW->writeLayer(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeTextstyles(){
|
||||||
|
for (std::list<DRW_Textstyle>::iterator it=cData.textStyles.begin(); it != cData.textStyles.end(); ++it)
|
||||||
|
dxfW->writeTextstyle(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeVports(){
|
||||||
|
for (std::list<DRW_Vport>::iterator it=cData.VPorts.begin(); it != cData.VPorts.end(); ++it)
|
||||||
|
dxfW->writeVport(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeDimstyles(){
|
||||||
|
for (std::list<DRW_Dimstyle>::iterator it=cData.dimStyles.begin(); it != cData.dimStyles.end(); ++it)
|
||||||
|
dxfW->writeDimstyle(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::writeAppId(){
|
||||||
|
for (std::list<DRW_AppId>::iterator it=cData.appIds.begin(); it != cData.appIds.end(); ++it)
|
||||||
|
dxfW->writeAppId(&(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits)
|
||||||
|
{
|
||||||
|
cData.headerC.addComment("Valentina DXF File");
|
||||||
|
|
||||||
|
// 1 = Clockwise angles, 0 = Counterclockwise
|
||||||
|
cData.headerC.addInt("$ANGDIR", 0, 70);// Qt use counterclockwise
|
||||||
|
|
||||||
|
// Sets drawing units: 0 = English; 1 = Metric
|
||||||
|
cData.headerC.addInt("$MEASUREMENT", static_cast<int>(varMeasurement), 70);
|
||||||
|
cData.headerC.addInt("$INSUNITS", static_cast<int>(varInsunits), 70);
|
||||||
|
|
||||||
|
QString dateTime = QDateTime::currentDateTime().toString("yyyyMMdd.HHmmsszzz");
|
||||||
|
dateTime.chop(1);// we need hundredths of a second
|
||||||
|
cData.headerC.addStr("$TDCREATE", dateTime.toStdString(), 40);
|
||||||
|
|
||||||
|
if (version >= DRW::AC1021)
|
||||||
|
{ // Full support Unicode
|
||||||
|
cData.headerC.addStr("$DWGCODEPAGE", "UTF-8", 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cData.headerC.addStr("$DWGCODEPAGE", LocaleToISO(), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::InitLTypes()
|
||||||
|
{
|
||||||
|
DRW_LType ltype;
|
||||||
|
ltype.name = "DOT";
|
||||||
|
ltype.desc = "Dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .";
|
||||||
|
ltype.size = 2;
|
||||||
|
ltype.length = 0.125;
|
||||||
|
ltype.path.push_back(0.0);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
cData.lineTypes.push_back(ltype);
|
||||||
|
|
||||||
|
ltype.path.clear();
|
||||||
|
ltype.name = "DASHED";
|
||||||
|
ltype.desc = "Dashed _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _";
|
||||||
|
ltype.size = 2;
|
||||||
|
ltype.length = 0.375;
|
||||||
|
ltype.path.push_back(0.25);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
cData.lineTypes.push_back(ltype);
|
||||||
|
|
||||||
|
ltype.path.clear();
|
||||||
|
ltype.name = "DASHDOT2";
|
||||||
|
ltype.desc = "Dash dot2 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.";
|
||||||
|
ltype.size = 4;
|
||||||
|
ltype.length = 0.5;
|
||||||
|
ltype.path.push_back(0.25);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
ltype.path.push_back(0.0);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
cData.lineTypes.push_back(ltype);
|
||||||
|
|
||||||
|
ltype.path.clear();
|
||||||
|
ltype.name = "DIVIDE2";
|
||||||
|
ltype.desc = "Divide2 __..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..";
|
||||||
|
ltype.size = 6;
|
||||||
|
ltype.length = 0.625;
|
||||||
|
ltype.path.push_back(0.25);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
ltype.path.push_back(0.0);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
ltype.path.push_back(0.0);
|
||||||
|
ltype.path.push_back(-0.125);
|
||||||
|
cData.lineTypes.push_back(ltype);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::InitLayers()
|
||||||
|
{
|
||||||
|
DRW_Layer defLayer;
|
||||||
|
defLayer.name = "0";
|
||||||
|
defLayer.color = DRW::black; // default color
|
||||||
|
defLayer.lWeight = DRW_LW_Conv::width17; // default width
|
||||||
|
defLayer.lineType = "CONTINUOUS"; // default line style
|
||||||
|
cData.layers.push_back(defLayer);
|
||||||
|
|
||||||
|
// DRW_Layer mLayer;
|
||||||
|
// mLayer.name = "mainlayer";
|
||||||
|
// mLayer.color = DRW::black; // default color
|
||||||
|
// mLayer.lWeight = 100; // default width
|
||||||
|
// mLayer.lineType = "CONTINUOUS"; // default line style
|
||||||
|
// cData.lineTypes.push_back(mLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::InitTextstyles()
|
||||||
|
{
|
||||||
|
DRW_Textstyle style;
|
||||||
|
style.name = "Standard";
|
||||||
|
style.lastHeight = 2.5;
|
||||||
|
style.font = "txt";
|
||||||
|
|
||||||
|
cData.textStyles.push_back(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::InitAppId()
|
||||||
|
{
|
||||||
|
DRW_AppId ai;
|
||||||
|
ai.name ="Valentina";
|
||||||
|
cData.appIds.push_back(ai);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dx_iface::AddEntity(DRW_Entity *e)
|
||||||
|
{
|
||||||
|
cData.mBlock->ent.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
UTF8STRING dx_iface::AddFont(const QFont &f)
|
||||||
|
{
|
||||||
|
DRW_Textstyle ts;
|
||||||
|
ts.name = f.family().toUpper().toStdString();
|
||||||
|
|
||||||
|
// Idea source https://stackoverflow.com/questions/20111522/writing-text-styles-into-dxf-from-a-delphi-application
|
||||||
|
if (f.bold())
|
||||||
|
{
|
||||||
|
ts.name += "_BOLD";
|
||||||
|
ts.fontFamily += 0x2000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.italic())
|
||||||
|
{
|
||||||
|
ts.name += "_ITALIC";
|
||||||
|
ts.fontFamily += 0x1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto it = cData.textStyles.begin() ; it !=cData.textStyles.end() ; ++it)
|
||||||
|
{
|
||||||
|
if ((*it).name == ts.name)
|
||||||
|
{
|
||||||
|
return ts.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.font = f.family().toStdString();
|
||||||
|
|
||||||
|
cData.textStyles.push_back(ts);
|
||||||
|
|
||||||
|
return ts.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string dx_iface::LocaleToISO() const
|
||||||
|
{
|
||||||
|
QMap <std::string, std::string> locMap;
|
||||||
|
locMap["croatian"] = "ISO8859-2";
|
||||||
|
locMap["cs"] = "ISO8859-2";
|
||||||
|
locMap["cs_CS"] = "ISO8859-2";
|
||||||
|
locMap["cs_CZ"] = "ISO8859-2";
|
||||||
|
locMap["cz"] = "ISO8859-2";
|
||||||
|
locMap["cz_CZ"] = "ISO8859-2";
|
||||||
|
locMap["czech"] = "ISO8859-2";
|
||||||
|
locMap["hr"] = "ISO8859-2";
|
||||||
|
locMap["hr_HR"] = "ISO8859-2";
|
||||||
|
locMap["hu"] = "ISO8859-2";
|
||||||
|
locMap["hu_HU"] = "ISO8859-2";
|
||||||
|
locMap["hungarian"] = "ISO8859-2";
|
||||||
|
locMap["pl"] = "ISO8859-2";
|
||||||
|
locMap["pl_PL"] = "ISO8859-2";
|
||||||
|
locMap["polish"] = "ISO8859-2";
|
||||||
|
locMap["ro"] = "ISO8859-2";
|
||||||
|
locMap["ro_RO"] = "ISO8859-2";
|
||||||
|
locMap["rumanian"] = "ISO8859-2";
|
||||||
|
locMap["serbocroatian"] = "ISO8859-2";
|
||||||
|
locMap["sh"] = "ISO8859-2";
|
||||||
|
locMap["sh_SP"] = "ISO8859-2";
|
||||||
|
locMap["sh_YU"] = "ISO8859-2";
|
||||||
|
locMap["sk"] = "ISO8859-2";
|
||||||
|
locMap["sk_SK"] = "ISO8859-2";
|
||||||
|
locMap["sl"] = "ISO8859-2";
|
||||||
|
locMap["sl_CS"] = "ISO8859-2";
|
||||||
|
locMap["sl_SI"] = "ISO8859-2";
|
||||||
|
locMap["slovak"] = "ISO8859-2";
|
||||||
|
locMap["slovene"] = "ISO8859-2";
|
||||||
|
locMap["sr_SP"] = "ISO8859-2";
|
||||||
|
|
||||||
|
locMap["eo"] = "ISO8859-3";
|
||||||
|
|
||||||
|
locMap["ee"] = "ISO8859-4";
|
||||||
|
locMap["ee_EE"] = "ISO8859-4";
|
||||||
|
|
||||||
|
locMap["mk"] = "ISO8859-5";
|
||||||
|
locMap["mk_MK"] = "ISO8859-5";
|
||||||
|
locMap["sp"] = "ISO8859-5";
|
||||||
|
locMap["sp_YU"] = "ISO8859-5";
|
||||||
|
|
||||||
|
locMap["ar_AA"] = "ISO8859-6";
|
||||||
|
locMap["ar_SA"] = "ISO8859-6";
|
||||||
|
locMap["arabic"] = "ISO8859-6";
|
||||||
|
|
||||||
|
locMap["el"] = "ISO8859-7";
|
||||||
|
locMap["el_GR"] = "ISO8859-7";
|
||||||
|
locMap["greek"] = "ISO8859-7";
|
||||||
|
|
||||||
|
locMap["hebrew"] = "ISO8859-8";
|
||||||
|
locMap["he"] = "ISO8859-8";
|
||||||
|
locMap["he_IL"] = "ISO8859-8";
|
||||||
|
locMap["iw"] = "ISO8859-8";
|
||||||
|
locMap["iw_IL"] = "ISO8859-8";
|
||||||
|
|
||||||
|
locMap["tr"] = "ISO8859-9";
|
||||||
|
locMap["tr_TR"] = "ISO8859-9";
|
||||||
|
locMap["turkish"] = "ISO8859-9";
|
||||||
|
|
||||||
|
locMap["lt"] = "ISO8859-13";
|
||||||
|
locMap["lt_LT"] = "ISO8859-13";
|
||||||
|
locMap["lv"] = "ISO8859-13";
|
||||||
|
locMap["lv_LV"] = "ISO8859-13";
|
||||||
|
|
||||||
|
locMap["et"] = "ISO8859-15";
|
||||||
|
locMap["et_EE"] = "ISO8859-15";
|
||||||
|
locMap["br_FR"] = "ISO8859-15";
|
||||||
|
locMap["ca_ES"] = "ISO8859-15";
|
||||||
|
locMap["de"] = "ISO8859-15";
|
||||||
|
locMap["de_AT"] = "ISO8859-15";
|
||||||
|
locMap["de_BE"] = "ISO8859-15";
|
||||||
|
locMap["de_DE"] = "ISO8859-15";
|
||||||
|
locMap["de_LU"] = "ISO8859-15";
|
||||||
|
locMap["en_IE"] = "ISO8859-15";
|
||||||
|
locMap["es"] = "ISO8859-15";
|
||||||
|
locMap["es_ES"] = "ISO8859-15";
|
||||||
|
locMap["eu_ES"] = "ISO8859-15";
|
||||||
|
locMap["fi"] = "ISO8859-15";
|
||||||
|
locMap["fi_FI"] = "ISO8859-15";
|
||||||
|
locMap["finnish"] = "ISO8859-15";
|
||||||
|
locMap["fr"] = "ISO8859-15";
|
||||||
|
locMap["fr_FR"] = "ISO8859-15";
|
||||||
|
locMap["fr_BE"] = "ISO8859-15";
|
||||||
|
locMap["fr_LU"] = "ISO8859-15";
|
||||||
|
locMap["french"] = "ISO8859-15";
|
||||||
|
locMap["ga_IE"] = "ISO8859-15";
|
||||||
|
locMap["gl_ES"] = "ISO8859-15";
|
||||||
|
locMap["it"] = "ISO8859-15";
|
||||||
|
locMap["it_IT"] = "ISO8859-15";
|
||||||
|
locMap["oc_FR"] = "ISO8859-15";
|
||||||
|
locMap["nl"] = "ISO8859-15";
|
||||||
|
locMap["nl_BE"] = "ISO8859-15";
|
||||||
|
locMap["nl_NL"] = "ISO8859-15";
|
||||||
|
locMap["pt"] = "ISO8859-15";
|
||||||
|
locMap["pt_PT"] = "ISO8859-15";
|
||||||
|
locMap["sv_FI"] = "ISO8859-15";
|
||||||
|
locMap["wa_BE"] = "ISO8859-15";
|
||||||
|
|
||||||
|
locMap["uk"] = "KOI8-U";
|
||||||
|
locMap["uk_UA"] = "KOI8-U";
|
||||||
|
locMap["ru_YA"] = "KOI8-U";
|
||||||
|
locMap["ukrainian"] = "KOI8-U";
|
||||||
|
locMap["ru_RU"] = "KOI8-U";
|
||||||
|
|
||||||
|
locMap["be"] = "KOI8-R";
|
||||||
|
locMap["be_BY"] = "KOI8-R";
|
||||||
|
locMap["bg"] = "KOI8-R";
|
||||||
|
locMap["bg_BG"] = "KOI8-R";
|
||||||
|
locMap["bulgarian"] = "KOI8-R";
|
||||||
|
locMap["ba_RU"] = "KOI8-R";
|
||||||
|
locMap["ky"] = "KOI8-R";
|
||||||
|
locMap["ky_KG"] = "KOI8-R";
|
||||||
|
locMap["kk"] = "KOI8-R";
|
||||||
|
locMap["kk_KZ"] = "KOI8-R";
|
||||||
|
|
||||||
|
QLocale locale(qApp->Settings()->GetLocale());
|
||||||
|
return locMap.value(locale.name().toStdString(), "ISO8859-1");
|
||||||
|
}
|
112
src/libs/vdxf/dxiface.h
Normal file
112
src/libs/vdxf/dxiface.h
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** dwg2dxf - Program to convert dwg/dxf to dxf(ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DX_IFACE_H
|
||||||
|
#define DX_IFACE_H
|
||||||
|
|
||||||
|
#include "libdxfrw/drw_interface.h"
|
||||||
|
#include "libdxfrw/libdxfrw.h"
|
||||||
|
#include "dxfdef.h"
|
||||||
|
|
||||||
|
class QFont;
|
||||||
|
|
||||||
|
//class to store image data and path from DRW_ImageDef
|
||||||
|
class dx_ifaceImg : public DRW_Image {
|
||||||
|
public:
|
||||||
|
dx_ifaceImg(){}
|
||||||
|
dx_ifaceImg(const DRW_Image& p):DRW_Image(p){}
|
||||||
|
~dx_ifaceImg(){}
|
||||||
|
std::string path; //stores the image path
|
||||||
|
};
|
||||||
|
|
||||||
|
//container class to store entites.
|
||||||
|
class dx_ifaceBlock : public DRW_Block {
|
||||||
|
public:
|
||||||
|
dx_ifaceBlock(){}
|
||||||
|
dx_ifaceBlock(const DRW_Block& p):DRW_Block(p){}
|
||||||
|
~dx_ifaceBlock(){
|
||||||
|
for (std::list<DRW_Entity*>::const_iterator it=ent.begin(); it!=ent.end(); ++it)
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
std::list<DRW_Entity*>ent; //stores the entities list
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//container class to store full dwg/dxf data.
|
||||||
|
class dx_data {
|
||||||
|
public:
|
||||||
|
dx_data(){
|
||||||
|
mBlock = new dx_ifaceBlock();
|
||||||
|
}
|
||||||
|
~dx_data(){
|
||||||
|
//cleanup,
|
||||||
|
for (std::list<dx_ifaceBlock*>::const_iterator it=blocks.begin(); it!=blocks.end(); ++it)
|
||||||
|
delete *it;
|
||||||
|
delete mBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_Header headerC; //stores a copy of the header vars
|
||||||
|
std::list<DRW_LType>lineTypes; //stores a copy of all line types
|
||||||
|
std::list<DRW_Layer>layers; //stores a copy of all layers
|
||||||
|
std::list<DRW_Dimstyle>dimStyles; //stores a copy of all dimension styles
|
||||||
|
std::list<DRW_Vport>VPorts; //stores a copy of all vports
|
||||||
|
std::list<DRW_Textstyle>textStyles; //stores a copy of all text styles
|
||||||
|
std::list<DRW_AppId>appIds; //stores a copy of all line types
|
||||||
|
std::list<dx_ifaceBlock*>blocks; //stores a copy of all blocks and the entities in it
|
||||||
|
std::list<dx_ifaceImg*>images; //temporary list to find images for link with DRW_ImageDef. Do not delete it!!
|
||||||
|
|
||||||
|
dx_ifaceBlock* mBlock; //container to store model entities
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class dx_iface : public DRW_Interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
dx_iface(const std::string& file, DRW::Version v, VarMeasurement varMeasurement, VarInsunits varInsunits);
|
||||||
|
virtual ~dx_iface();
|
||||||
|
bool fileExport(bool binary);
|
||||||
|
void writeEntity(DRW_Entity* e);
|
||||||
|
|
||||||
|
//reimplement virtual DRW_Interface functions
|
||||||
|
//writer part, send all in class dx_data to writer
|
||||||
|
virtual void writeHeader(DRW_Header& data);
|
||||||
|
virtual void writeBlocks();
|
||||||
|
//only send the name, needed by the reader to prepare handles of blocks & blockRecords
|
||||||
|
virtual void writeBlockRecords();
|
||||||
|
//write entities of model space and first paper_space
|
||||||
|
virtual void writeEntities();
|
||||||
|
virtual void writeLTypes();
|
||||||
|
virtual void writeLayers();
|
||||||
|
virtual void writeTextstyles();
|
||||||
|
virtual void writeVports();
|
||||||
|
virtual void writeDimstyles();
|
||||||
|
virtual void writeAppId();
|
||||||
|
|
||||||
|
void AddEntity(DRW_Entity* e);
|
||||||
|
UTF8STRING AddFont(const QFont &f);
|
||||||
|
|
||||||
|
private:
|
||||||
|
dxfRW* dxfW; //pointer to writer, needed to send data
|
||||||
|
dx_data cData; // class to store or read data
|
||||||
|
DRW::Version version;
|
||||||
|
|
||||||
|
void InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits);
|
||||||
|
void InitLTypes();
|
||||||
|
void InitLayers();
|
||||||
|
void InitTextstyles();
|
||||||
|
void InitAppId();
|
||||||
|
|
||||||
|
std::string LocaleToISO() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DX_IFACE_H
|
7
src/libs/vdxf/libdxfrw/AUTHORS
Normal file
7
src/libs/vdxf/libdxfrw/AUTHORS
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
Rallaz <rallazz@gmail.com>
|
||||||
|
Original author.
|
||||||
|
Nicu Tofan <nicu.tofan@gmail.com>
|
||||||
|
contributor.
|
||||||
|
Miguel E. Hernández Cuervo <mhcuervo@gmail.com>
|
||||||
|
contributor.
|
339
src/libs/vdxf/libdxfrw/COPYING
Normal file
339
src/libs/vdxf/libdxfrw/COPYING
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
29
src/libs/vdxf/libdxfrw/README
Normal file
29
src/libs/vdxf/libdxfrw/README
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
libdxfrw
|
||||||
|
|
||||||
|
libdxfrw is a free C++ library to read and write DXF files in both formats, ascii and binary form.
|
||||||
|
Also can read DWG files from R14 to the last V2015.
|
||||||
|
It is licensed under the terms of the GNU General Public License version 2 (or at you option
|
||||||
|
any later version).
|
||||||
|
|
||||||
|
|
||||||
|
If you are looking for general information about the project, check our website:
|
||||||
|
http://sourceforge.net/projects/libdxfrw
|
||||||
|
|
||||||
|
== Building and installing the library ==
|
||||||
|
|
||||||
|
Use the tipical
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install (as root)
|
||||||
|
|
||||||
|
[VC++]
|
||||||
|
- Open vs2013\libdxfrw.sln with VS2013
|
||||||
|
- Build Solution
|
||||||
|
There is also a dwg to dxf converter that depends on libdxfrw that can be built the same way.
|
||||||
|
- Open dwg2dxf\vs2013\dwg2dxf.sln with VS2013
|
||||||
|
- Build Solution
|
||||||
|
|
||||||
|
== Example usage of the library ==
|
||||||
|
|
||||||
|
The dwg to dxf converter (dwg2dxf) included in this package can be used as reference.
|
||||||
|
|
496
src/libs/vdxf/libdxfrw/drw_base.h
Normal file
496
src/libs/vdxf/libdxfrw/drw_base.h
Normal file
|
@ -0,0 +1,496 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_BASE_H
|
||||||
|
#define DRW_BASE_H
|
||||||
|
|
||||||
|
#define DRW_VERSION "0.6.3"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#ifdef DRW_ASSERTS
|
||||||
|
# define drw_assert(a) assert(a)
|
||||||
|
#else
|
||||||
|
# define drw_assert(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define UTF8STRING std::string
|
||||||
|
#define DRW_UNUSED(x) (void)x
|
||||||
|
|
||||||
|
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
|
||||||
|
# define DRW_WIN
|
||||||
|
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||||
|
# define DRW_WIN
|
||||||
|
#elif defined(__MWERKS__) && defined(__INTEL__)
|
||||||
|
# define DRW_WIN
|
||||||
|
#else
|
||||||
|
# define DRW_POSIX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.141592653589793238462643
|
||||||
|
#endif
|
||||||
|
#ifndef M_PI_2
|
||||||
|
#define M_PI_2 1.57079632679489661923
|
||||||
|
#endif
|
||||||
|
#define M_PIx2 6.283185307179586 // 2*PI
|
||||||
|
#define ARAD 57.29577951308232
|
||||||
|
|
||||||
|
typedef signed char dint8; /* 8 bit signed */
|
||||||
|
typedef signed short dint16; /* 16 bit signed */
|
||||||
|
typedef signed int dint32; /* 32 bit signed */
|
||||||
|
typedef long long int dint64; /* 64 bit signed */
|
||||||
|
|
||||||
|
typedef unsigned char duint8; /* 8 bit unsigned */
|
||||||
|
typedef unsigned short duint16; /* 16 bit unsigned */
|
||||||
|
typedef unsigned int duint32; /* 32 bit unsigned */
|
||||||
|
typedef unsigned long long int duint64; /* 64 bit unsigned */
|
||||||
|
|
||||||
|
typedef float dfloat32; /* 32 bit floating point */
|
||||||
|
typedef double ddouble64; /* 64 bit floating point */
|
||||||
|
typedef long double ddouble80; /* 80 bit floating point */
|
||||||
|
|
||||||
|
|
||||||
|
namespace DRW {
|
||||||
|
|
||||||
|
//! Version numbers for the DXF Format.
|
||||||
|
enum Version {
|
||||||
|
UNKNOWNV, /*!< UNKNOWN VERSION. */
|
||||||
|
AC1006, /*!< R10. */
|
||||||
|
AC1009, /*!< R11 & R12. */
|
||||||
|
AC1012, /*!< R13. */
|
||||||
|
AC1014, /*!< R14. */
|
||||||
|
AC1015, /*!< ACAD 2000. */
|
||||||
|
AC1018, /*!< ACAD 2004. */
|
||||||
|
AC1021, /*!< ACAD 2007. */
|
||||||
|
AC1024, /*!< ACAD 2010. */
|
||||||
|
AC1027 /*!< ACAD 2013. */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum error {
|
||||||
|
BAD_NONE, /*!< No error. */
|
||||||
|
BAD_UNKNOWN, /*!< UNKNOWN. */
|
||||||
|
BAD_OPEN, /*!< error opening file. */
|
||||||
|
BAD_VERSION, /*!< unsupported version. */
|
||||||
|
BAD_READ_METADATA, /*!< error reading matadata. */
|
||||||
|
BAD_READ_FILE_HEADER, /*!< error in file header read process. */
|
||||||
|
BAD_READ_HEADER, /*!< error in header vars read process. */
|
||||||
|
BAD_READ_HANDLES, /*!< error in object map read process. */
|
||||||
|
BAD_READ_CLASSES, /*!< error in classes read process. */
|
||||||
|
BAD_READ_TABLES, /*!< error in tables read process. */
|
||||||
|
BAD_READ_BLOCKS, /*!< error in block read process. */
|
||||||
|
BAD_READ_ENTITIES, /*!< error in entities read process. */
|
||||||
|
BAD_READ_OBJECTS /*!< error in objects read process. */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DBG_LEVEL {
|
||||||
|
NONE,
|
||||||
|
DEBUG
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Special codes for colors
|
||||||
|
enum ColorCodes {
|
||||||
|
black = 250,
|
||||||
|
green = 3,
|
||||||
|
red = 1,
|
||||||
|
brown = 15,
|
||||||
|
yellow = 2,
|
||||||
|
cyan = 4,
|
||||||
|
magenta = 6,
|
||||||
|
gray = 8,
|
||||||
|
blue = 5,
|
||||||
|
l_blue = 163,
|
||||||
|
l_green = 121,
|
||||||
|
l_cyan = 131,
|
||||||
|
l_red = 23,
|
||||||
|
l_magenta = 221,
|
||||||
|
l_gray = 252,
|
||||||
|
white = 7,
|
||||||
|
ColorByLayer = 256,
|
||||||
|
ColorByBlock = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Spaces
|
||||||
|
enum Space {
|
||||||
|
ModelSpace = 0,
|
||||||
|
PaperSpace = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Special kinds of handles
|
||||||
|
enum HandleCodes {
|
||||||
|
NoHandle = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Shadow mode
|
||||||
|
enum ShadowMode {
|
||||||
|
CastAndReceieveShadows = 0,
|
||||||
|
CastShadows = 1,
|
||||||
|
ReceiveShadows = 2,
|
||||||
|
IgnoreShadows = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Special kinds of materials
|
||||||
|
enum MaterialCodes {
|
||||||
|
MaterialByLayer = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Special kinds of plot styles
|
||||||
|
enum PlotStyleCodes {
|
||||||
|
DefaultPlotStyle = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Special kinds of transparencies
|
||||||
|
enum TransparencyCodes {
|
||||||
|
Opaque = 0,
|
||||||
|
Transparent = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DRW
|
||||||
|
|
||||||
|
//! Class to handle 3D coordinate point
|
||||||
|
/*!
|
||||||
|
* Class to handle 3D coordinate point
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Coord {
|
||||||
|
public:
|
||||||
|
DRW_Coord() { x = 0; y = 0; z = 0; }
|
||||||
|
DRW_Coord(double ix, double iy, double iz) {
|
||||||
|
x = ix; y = iy; z = iz;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_Coord operator = (const DRW_Coord& data) {
|
||||||
|
x = data.x; y = data.y; z = data.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/*!< convert to unitary vector */
|
||||||
|
void unitize(){
|
||||||
|
double dist;
|
||||||
|
dist = sqrt(x*x + y*y + z*z);
|
||||||
|
if (dist > 0.0) {
|
||||||
|
x= x/dist;
|
||||||
|
y= y/dist;
|
||||||
|
z= z/dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double z;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle vertex
|
||||||
|
/*!
|
||||||
|
* Class to handle vertex for lwpolyline entity
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Vertex2D {
|
||||||
|
public:
|
||||||
|
DRW_Vertex2D() {
|
||||||
|
// eType = DRW::LWPOLYLINE;
|
||||||
|
stawidth = endwidth = bulge = 0;
|
||||||
|
}
|
||||||
|
DRW_Vertex2D(double sx, double sy, double b) {
|
||||||
|
stawidth = endwidth = 0;
|
||||||
|
x = sx;
|
||||||
|
y =sy;
|
||||||
|
bulge = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
double x; /*!< x coordinate, code 10 */
|
||||||
|
double y; /*!< y coordinate, code 20 */
|
||||||
|
double stawidth; /*!< Start width, code 40 */
|
||||||
|
double endwidth; /*!< End width, code 41 */
|
||||||
|
double bulge; /*!< bulge, code 42 */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle header vars
|
||||||
|
/*!
|
||||||
|
* Class to handle header vars
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Variant {
|
||||||
|
public:
|
||||||
|
enum TYPE {
|
||||||
|
STRING,
|
||||||
|
INTEGER,
|
||||||
|
DOUBLE,
|
||||||
|
COORD,
|
||||||
|
INVALID
|
||||||
|
};
|
||||||
|
//TODO: add INT64 support
|
||||||
|
DRW_Variant() {
|
||||||
|
type = INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_Variant(int c, dint32 i) {
|
||||||
|
code = c; addInt(i);
|
||||||
|
}
|
||||||
|
DRW_Variant(int c, duint32 i) {
|
||||||
|
code = c; addInt(static_cast<dint32>(i));//RLZ: verify if worrk with big numbers
|
||||||
|
}
|
||||||
|
DRW_Variant(int c, double d) {
|
||||||
|
code = c; addDouble(d);
|
||||||
|
}
|
||||||
|
DRW_Variant(int c, UTF8STRING s) {
|
||||||
|
code = c; addString(s);
|
||||||
|
}
|
||||||
|
DRW_Variant(int c, DRW_Coord crd) {
|
||||||
|
code = c; addCoord(crd);
|
||||||
|
}
|
||||||
|
DRW_Variant(const DRW_Variant& d) {
|
||||||
|
code = d.code;
|
||||||
|
type = d.type;
|
||||||
|
content = d.content;
|
||||||
|
if (d.type == COORD) {
|
||||||
|
vdata = d.vdata;
|
||||||
|
content.v = &vdata;
|
||||||
|
}
|
||||||
|
if (d.type == STRING) {
|
||||||
|
sdata = d.sdata;
|
||||||
|
content.s = &sdata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~DRW_Variant() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void addString(UTF8STRING s) {setType(STRING); sdata = s; content.s = &sdata;}
|
||||||
|
void addInt(int i) {setType(INTEGER); content.i = i;}
|
||||||
|
void addDouble(double d) {setType(DOUBLE); content.d = d;}
|
||||||
|
void addCoord() {setType(COORD); vdata.x=0.0; vdata.y=0.0; vdata.z=0.0; content.v = &vdata;}
|
||||||
|
void addCoord(DRW_Coord v) {setType(COORD); vdata = v; content.v = &vdata;}
|
||||||
|
void setType(enum TYPE t) { type = t;}
|
||||||
|
void setCoordX(double d) { if (type == COORD) vdata.x = d;}
|
||||||
|
void setCoordY(double d) { if (type == COORD) vdata.y = d;}
|
||||||
|
void setCoordZ(double d) { if (type == COORD) vdata.z = d;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef union {
|
||||||
|
UTF8STRING *s;
|
||||||
|
dint32 i;
|
||||||
|
double d;
|
||||||
|
DRW_Coord *v;
|
||||||
|
} DRW_VarContent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DRW_VarContent content;
|
||||||
|
enum TYPE type;
|
||||||
|
int code; /*!< dxf code of this value*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string sdata;
|
||||||
|
DRW_Coord vdata;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to handle dwg handles
|
||||||
|
/*!
|
||||||
|
* Class to handle dwg handles
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class dwgHandle{
|
||||||
|
public:
|
||||||
|
dwgHandle(){
|
||||||
|
code=0;
|
||||||
|
size=0;
|
||||||
|
ref=0;
|
||||||
|
}
|
||||||
|
~dwgHandle(){}
|
||||||
|
duint8 code;
|
||||||
|
duint8 size;
|
||||||
|
duint32 ref;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to convert between line width and integer
|
||||||
|
/*!
|
||||||
|
* Class to convert between line width and integer
|
||||||
|
* verifing valid values, if value is not valid
|
||||||
|
* returns widthDefault.
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_LW_Conv{
|
||||||
|
public:
|
||||||
|
enum lineWidth {
|
||||||
|
width00 = 0, /*!< 0.00mm (dxf 0)*/
|
||||||
|
width01 = 1, /*!< 0.05mm (dxf 5)*/
|
||||||
|
width02 = 2, /*!< 0.09mm (dxf 9)*/
|
||||||
|
width03 = 3, /*!< 0.13mm (dxf 13)*/
|
||||||
|
width04 = 4, /*!< 0.15mm (dxf 15)*/
|
||||||
|
width05 = 5, /*!< 0.18mm (dxf 18)*/
|
||||||
|
width06 = 6, /*!< 0.20mm (dxf 20)*/
|
||||||
|
width07 = 7, /*!< 0.25mm (dxf 25)*/
|
||||||
|
width08 = 8, /*!< 0.30mm (dxf 30)*/
|
||||||
|
width09 = 9, /*!< 0.35mm (dxf 35)*/
|
||||||
|
width10 = 10, /*!< 0.40mm (dxf 40)*/
|
||||||
|
width11 = 11, /*!< 0.50mm (dxf 50)*/
|
||||||
|
width12 = 12, /*!< 0.53mm (dxf 53)*/
|
||||||
|
width13 = 13, /*!< 0.60mm (dxf 60)*/
|
||||||
|
width14 = 14, /*!< 0.70mm (dxf 70)*/
|
||||||
|
width15 = 15, /*!< 0.80mm (dxf 80)*/
|
||||||
|
width16 = 16, /*!< 0.90mm (dxf 90)*/
|
||||||
|
width17 = 17, /*!< 1.00mm (dxf 100)*/
|
||||||
|
width18 = 18, /*!< 1.06mm (dxf 106)*/
|
||||||
|
width19 = 19, /*!< 1.20mm (dxf 120)*/
|
||||||
|
width20 = 20, /*!< 1.40mm (dxf 140)*/
|
||||||
|
width21 = 21, /*!< 1.58mm (dxf 158)*/
|
||||||
|
width22 = 22, /*!< 2.00mm (dxf 200)*/
|
||||||
|
width23 = 23, /*!< 2.11mm (dxf 211)*/
|
||||||
|
widthByLayer = 29, /*!< by layer (dxf -1) */
|
||||||
|
widthByBlock = 30, /*!< by block (dxf -2) */
|
||||||
|
widthDefault = 31 /*!< by default (dxf -3) */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int lineWidth2dxfInt(enum lineWidth lw){
|
||||||
|
switch (lw){
|
||||||
|
case widthByLayer:
|
||||||
|
return -1;
|
||||||
|
case widthByBlock:
|
||||||
|
return -2;
|
||||||
|
case widthDefault:
|
||||||
|
return -3;
|
||||||
|
case width00:
|
||||||
|
return 0;
|
||||||
|
case width01:
|
||||||
|
return 5;
|
||||||
|
case width02:
|
||||||
|
return 9;
|
||||||
|
case width03:
|
||||||
|
return 13;
|
||||||
|
case width04:
|
||||||
|
return 15;
|
||||||
|
case width05:
|
||||||
|
return 18;
|
||||||
|
case width06:
|
||||||
|
return 20;
|
||||||
|
case width07:
|
||||||
|
return 25;
|
||||||
|
case width08:
|
||||||
|
return 30;
|
||||||
|
case width09:
|
||||||
|
return 35;
|
||||||
|
case width10:
|
||||||
|
return 40;
|
||||||
|
case width11:
|
||||||
|
return 50;
|
||||||
|
case width12:
|
||||||
|
return 53;
|
||||||
|
case width13:
|
||||||
|
return 60;
|
||||||
|
case width14:
|
||||||
|
return 70;
|
||||||
|
case width15:
|
||||||
|
return 80;
|
||||||
|
case width16:
|
||||||
|
return 90;
|
||||||
|
case width17:
|
||||||
|
return 100;
|
||||||
|
case width18:
|
||||||
|
return 106;
|
||||||
|
case width19:
|
||||||
|
return 120;
|
||||||
|
case width20:
|
||||||
|
return 140;
|
||||||
|
case width21:
|
||||||
|
return 158;
|
||||||
|
case width22:
|
||||||
|
return 200;
|
||||||
|
case width23:
|
||||||
|
return 211;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lineWidth2dwgInt(enum lineWidth lw){
|
||||||
|
return static_cast<int> (lw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum lineWidth dxfInt2lineWidth(int i){
|
||||||
|
if (i<0) {
|
||||||
|
if (i==-1)
|
||||||
|
return widthByLayer;
|
||||||
|
else if (i==-2)
|
||||||
|
return widthByBlock;
|
||||||
|
else if (i==-3)
|
||||||
|
return widthDefault;
|
||||||
|
} else if (i<3) {
|
||||||
|
return width00;
|
||||||
|
} else if (i<7) {
|
||||||
|
return width01;
|
||||||
|
} else if (i<11) {
|
||||||
|
return width02;
|
||||||
|
} else if (i<14) {
|
||||||
|
return width03;
|
||||||
|
} else if (i<16) {
|
||||||
|
return width04;
|
||||||
|
} else if (i<19) {
|
||||||
|
return width05;
|
||||||
|
} else if (i<22) {
|
||||||
|
return width06;
|
||||||
|
} else if (i<27) {
|
||||||
|
return width07;
|
||||||
|
} else if (i<32) {
|
||||||
|
return width08;
|
||||||
|
} else if (i<37) {
|
||||||
|
return width09;
|
||||||
|
} else if (i<45) {
|
||||||
|
return width10;
|
||||||
|
} else if (i<52) {
|
||||||
|
return width11;
|
||||||
|
} else if (i<57) {
|
||||||
|
return width12;
|
||||||
|
} else if (i<65) {
|
||||||
|
return width13;
|
||||||
|
} else if (i<75) {
|
||||||
|
return width14;
|
||||||
|
} else if (i<85) {
|
||||||
|
return width15;
|
||||||
|
} else if (i<95) {
|
||||||
|
return width16;
|
||||||
|
} else if (i<103) {
|
||||||
|
return width17;
|
||||||
|
} else if (i<112) {
|
||||||
|
return width18;
|
||||||
|
} else if (i<130) {
|
||||||
|
return width19;
|
||||||
|
} else if (i<149) {
|
||||||
|
return width20;
|
||||||
|
} else if (i<180) {
|
||||||
|
return width21;
|
||||||
|
} else if (i<205) {
|
||||||
|
return width22;
|
||||||
|
} else {
|
||||||
|
return width23;
|
||||||
|
}
|
||||||
|
//default by default
|
||||||
|
return widthDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum lineWidth dwgInt2lineWidth(int i){
|
||||||
|
if ( (i>-1 && i<24) || (i>28 && i<32) ) {
|
||||||
|
return static_cast<lineWidth> (i);
|
||||||
|
}
|
||||||
|
//default by default
|
||||||
|
return widthDefault;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// EOF
|
115
src/libs/vdxf/libdxfrw/drw_classes.cpp
Normal file
115
src/libs/vdxf/libdxfrw/drw_classes.cpp
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "drw_classes.h"
|
||||||
|
#include "intern/dxfreader.h"
|
||||||
|
#include "intern/dxfwriter.h"
|
||||||
|
#include "intern/dwgbuffer.h"
|
||||||
|
#include "intern/drw_dbg.h"
|
||||||
|
|
||||||
|
void DRW_Class::parseCode(int code, dxfReader *reader){
|
||||||
|
switch (code) {
|
||||||
|
case 1:
|
||||||
|
recName = reader->getUtf8String();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
className = reader->getUtf8String();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
appName = reader->getUtf8String();
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
proxyFlag = reader->getInt32();
|
||||||
|
break;
|
||||||
|
case 91:
|
||||||
|
instanceCount = reader->getInt32();
|
||||||
|
break;
|
||||||
|
case 280:
|
||||||
|
wasaProxyFlag = reader->getInt32();
|
||||||
|
break;
|
||||||
|
case 281:
|
||||||
|
entityFlag = reader->getInt32();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DRW_Class::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf){
|
||||||
|
DRW_DBG("\n***************************** parsing Class *********************************************\n");
|
||||||
|
|
||||||
|
classNum = buf->getBitShort();
|
||||||
|
DRW_DBG("Class number: "); DRW_DBG(classNum);
|
||||||
|
proxyFlag = buf->getBitShort(); //in dwg specs says "version"
|
||||||
|
|
||||||
|
appName = strBuf->getVariableText(version, false);
|
||||||
|
className = strBuf->getVariableText(version, false);
|
||||||
|
recName = strBuf->getVariableText(version, false);
|
||||||
|
|
||||||
|
DRW_DBG("\napp name: "); DRW_DBG(appName.c_str());
|
||||||
|
DRW_DBG("\nclass name: "); DRW_DBG(className.c_str());
|
||||||
|
DRW_DBG("\ndxf rec name: "); DRW_DBG(recName.c_str());
|
||||||
|
wasaProxyFlag = buf->getBit(); //in dwg says wasazombie
|
||||||
|
entityFlag = buf->getBitShort();
|
||||||
|
entityFlag = entityFlag == 0x1F2 ? 1: 0;
|
||||||
|
|
||||||
|
DRW_DBG("\nProxy capabilities flag: "); DRW_DBG(proxyFlag);
|
||||||
|
DRW_DBG(", proxy flag (280): "); DRW_DBG(wasaProxyFlag);
|
||||||
|
DRW_DBG(", entity flag: "); DRW_DBGH(entityFlag);
|
||||||
|
|
||||||
|
if (version > DRW::AC1015) {//2004+
|
||||||
|
instanceCount = buf->getBitLong();
|
||||||
|
DRW_DBG("\nInstance Count: "); DRW_DBG(instanceCount);
|
||||||
|
duint32 dwgVersion = buf->getBitLong();
|
||||||
|
DRW_DBG("\nDWG version: "); DRW_DBG(dwgVersion);
|
||||||
|
DRW_DBG("\nmaintenance version: "); DRW_DBG(buf->getBitLong());
|
||||||
|
DRW_DBG("\nunknown 1: "); DRW_DBG(buf->getBitLong());
|
||||||
|
DRW_DBG("\nunknown 2: "); DRW_DBG(buf->getBitLong());
|
||||||
|
}
|
||||||
|
DRW_DBG("\n");
|
||||||
|
toDwgType();
|
||||||
|
return buf->isGood();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_Class::write(dxfWriter *writer, DRW::Version ver){
|
||||||
|
if (ver > DRW::AC1009) {
|
||||||
|
writer->writeString(0, "CLASS");
|
||||||
|
writer->writeString(1, recName);
|
||||||
|
writer->writeString(2, className);
|
||||||
|
writer->writeString(3, appName);
|
||||||
|
writer->writeInt32(90, proxyFlag);
|
||||||
|
if (ver > DRW::AC1015) { //2004+
|
||||||
|
writer->writeInt32(91, instanceCount);
|
||||||
|
}
|
||||||
|
writer->writeInt16(280, wasaProxyFlag);
|
||||||
|
writer->writeInt16(281, entityFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_Class::toDwgType(){
|
||||||
|
if (recName == "LWPOLYLINE")
|
||||||
|
dwgType = 77;
|
||||||
|
else if (recName == "HATCH")
|
||||||
|
dwgType = 78;
|
||||||
|
else if (recName == "GROUP")
|
||||||
|
dwgType = 72;
|
||||||
|
/* else if (recName == "GROUP")
|
||||||
|
dwgType = 72;*/
|
||||||
|
else if (recName == "LAYOUT")
|
||||||
|
dwgType = 82;
|
||||||
|
else if (recName == "IMAGE")
|
||||||
|
dwgType = 101;
|
||||||
|
else if (recName == "IMAGEDEF")
|
||||||
|
dwgType = 102;
|
||||||
|
else
|
||||||
|
dwgType =0;
|
||||||
|
}
|
58
src/libs/vdxf/libdxfrw/drw_classes.h
Normal file
58
src/libs/vdxf/libdxfrw/drw_classes.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_CLASSES_H
|
||||||
|
#define DRW_CLASSES_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "drw_base.h"
|
||||||
|
//#include "libdwgr.h"
|
||||||
|
|
||||||
|
class dxfReader;
|
||||||
|
class dxfWriter;
|
||||||
|
class dwgBuffer;
|
||||||
|
|
||||||
|
//! Class to handle classes entries
|
||||||
|
/*!
|
||||||
|
* Class to handle classes table entries
|
||||||
|
* TODO: verify the dxf read/write part
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Class {
|
||||||
|
public:
|
||||||
|
DRW_Class() {
|
||||||
|
}
|
||||||
|
~DRW_Class() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
void write(dxfWriter *writer, DRW::Version ver);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void toDwgType();
|
||||||
|
public:
|
||||||
|
UTF8STRING recName; /*!< record name, code 1 */
|
||||||
|
UTF8STRING className; /*!< C++ class name, code 2 */
|
||||||
|
UTF8STRING appName; /*!< app name, code 3 */
|
||||||
|
int proxyFlag; /*!< Proxy capabilities flag, code 90 */
|
||||||
|
int instanceCount; /*!< number of instances for a custom class, code 91*/
|
||||||
|
int wasaProxyFlag; /*!< proxy flag (app loaded on save), code 280 */
|
||||||
|
int entityFlag; /*!< entity flag, code 281 (0 object, 1 entity)*/
|
||||||
|
public: //only for read dwg
|
||||||
|
duint16 classNum;
|
||||||
|
int dwgType;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// EOF
|
3064
src/libs/vdxf/libdxfrw/drw_entities.cpp
Normal file
3064
src/libs/vdxf/libdxfrw/drw_entities.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1572
src/libs/vdxf/libdxfrw/drw_entities.h
Normal file
1572
src/libs/vdxf/libdxfrw/drw_entities.h
Normal file
File diff suppressed because it is too large
Load Diff
2480
src/libs/vdxf/libdxfrw/drw_header.cpp
Normal file
2480
src/libs/vdxf/libdxfrw/drw_header.cpp
Normal file
File diff suppressed because it is too large
Load Diff
107
src/libs/vdxf/libdxfrw/drw_header.h
Normal file
107
src/libs/vdxf/libdxfrw/drw_header.h
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_HEADER_H
|
||||||
|
#define DRW_HEADER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include "drw_base.h"
|
||||||
|
|
||||||
|
class dxfReader;
|
||||||
|
class dxfWriter;
|
||||||
|
class dwgBuffer;
|
||||||
|
|
||||||
|
#define SETHDRFRIENDS friend class dxfRW; \
|
||||||
|
friend class dwgReader;
|
||||||
|
|
||||||
|
//! Class to handle header entries
|
||||||
|
/*!
|
||||||
|
* Class to handle header vars, to read iterate over "std::map vars"
|
||||||
|
* to write add a DRW_Variant* into "std::map vars" (do not delete it, are cleared in dtor)
|
||||||
|
* or use add* helper functions.
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Header {
|
||||||
|
SETHDRFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Header();
|
||||||
|
~DRW_Header() {
|
||||||
|
clearVars();
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_Header(const DRW_Header& h){
|
||||||
|
this->version = h.version;
|
||||||
|
this->comments = h.comments;
|
||||||
|
for (std::map<std::string,DRW_Variant*>::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){
|
||||||
|
this->vars[it->first] = new DRW_Variant( *(it->second) );
|
||||||
|
}
|
||||||
|
this->curr = NULL;
|
||||||
|
}
|
||||||
|
DRW_Header& operator=(const DRW_Header &h) {
|
||||||
|
if(this != &h) {
|
||||||
|
clearVars();
|
||||||
|
this->version = h.version;
|
||||||
|
this->comments = h.comments;
|
||||||
|
for (std::map<std::string,DRW_Variant*>::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){
|
||||||
|
this->vars[it->first] = new DRW_Variant( *(it->second) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addDouble(std::string key, double value, int code);
|
||||||
|
void addInt(std::string key, int value, int code);
|
||||||
|
void addStr(std::string key, std::string value, int code);
|
||||||
|
void addCoord(std::string key, DRW_Coord value, int code);
|
||||||
|
std::string getComments() const {return comments;}
|
||||||
|
void write(dxfWriter *writer, DRW::Version ver);
|
||||||
|
void addComment(std::string c);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 mv=0);
|
||||||
|
private:
|
||||||
|
bool getDouble(std::string key, double *varDouble);
|
||||||
|
bool getInt(std::string key, int *varInt);
|
||||||
|
bool getStr(std::string key, std::string *varStr);
|
||||||
|
bool getCoord(std::string key, DRW_Coord *varStr);
|
||||||
|
void clearVars(){
|
||||||
|
for (std::map<std::string,DRW_Variant*>::iterator it=vars.begin(); it!=vars.end(); ++it)
|
||||||
|
delete it->second;
|
||||||
|
|
||||||
|
vars.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::map<std::string,DRW_Variant*> vars;
|
||||||
|
private:
|
||||||
|
std::string comments;
|
||||||
|
std::string name;
|
||||||
|
DRW_Variant* curr;
|
||||||
|
int version; //to use on read
|
||||||
|
|
||||||
|
duint32 linetypeCtrl;
|
||||||
|
duint32 layerCtrl;
|
||||||
|
duint32 styleCtrl;
|
||||||
|
duint32 dimstyleCtrl;
|
||||||
|
duint32 appidCtrl;
|
||||||
|
duint32 blockCtrl;
|
||||||
|
duint32 viewCtrl;
|
||||||
|
duint32 ucsCtrl;
|
||||||
|
duint32 vportCtrl;
|
||||||
|
duint32 vpEntHeaderCtrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// EOF
|
190
src/libs/vdxf/libdxfrw/drw_interface.h
Normal file
190
src/libs/vdxf/libdxfrw/drw_interface.h
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_INTERFACE_H
|
||||||
|
#define DRW_INTERFACE_H
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "drw_entities.h"
|
||||||
|
#include "drw_objects.h"
|
||||||
|
#include "drw_header.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class (interface) for comunicate dxfReader with the application.
|
||||||
|
* Inherit your class which takes care of the entities in the
|
||||||
|
* processed DXF file from this interface.
|
||||||
|
*
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Interface {
|
||||||
|
public:
|
||||||
|
DRW_Interface() {
|
||||||
|
}
|
||||||
|
virtual ~DRW_Interface() = default;
|
||||||
|
|
||||||
|
/** Called when header is parsed. */
|
||||||
|
virtual void addHeader(const DRW_Header *) { }
|
||||||
|
|
||||||
|
/** Called for every line Type. */
|
||||||
|
virtual void addLType(const DRW_LType &) { }
|
||||||
|
/** Called for every layer. */
|
||||||
|
virtual void addLayer(const DRW_Layer &) { }
|
||||||
|
/** Called for every dim style. */
|
||||||
|
virtual void addDimStyle(const DRW_Dimstyle &) { }
|
||||||
|
/** Called for every VPORT table. */
|
||||||
|
virtual void addVport(const DRW_Vport &) { }
|
||||||
|
/** Called for every text style. */
|
||||||
|
virtual void addTextStyle(const DRW_Textstyle &) { }
|
||||||
|
/** Called for every AppId entry. */
|
||||||
|
virtual void addAppId(const DRW_AppId &) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every block. Note: all entities added after this
|
||||||
|
* command go into this block until endBlock() is called.
|
||||||
|
*
|
||||||
|
* @see endBlock()
|
||||||
|
*/
|
||||||
|
virtual void addBlock(const DRW_Block &) { }
|
||||||
|
|
||||||
|
/** Called to end the current block */
|
||||||
|
virtual void endBlock() { }
|
||||||
|
|
||||||
|
/** Called for every point */
|
||||||
|
virtual void addPoint(const DRW_Point &) { }
|
||||||
|
|
||||||
|
/** Called for every line */
|
||||||
|
virtual void addLine(const DRW_Line &) { }
|
||||||
|
|
||||||
|
/** Called for every ray */
|
||||||
|
virtual void addRay(const DRW_Ray &) { }
|
||||||
|
|
||||||
|
/** Called for every xline */
|
||||||
|
virtual void addXline(const DRW_Xline &) { }
|
||||||
|
|
||||||
|
/** Called for every arc */
|
||||||
|
virtual void addArc(const DRW_Arc &) { }
|
||||||
|
|
||||||
|
/** Called for every circle */
|
||||||
|
virtual void addCircle(const DRW_Circle &) { }
|
||||||
|
|
||||||
|
/** Called for every ellipse */
|
||||||
|
virtual void addEllipse(const DRW_Ellipse &) { }
|
||||||
|
|
||||||
|
/** Called for every lwpolyline */
|
||||||
|
virtual void addLWPolyline(const DRW_LWPolyline &) { }
|
||||||
|
|
||||||
|
/** Called for every polyline start */
|
||||||
|
virtual void addPolyline(const DRW_Polyline &) { }
|
||||||
|
|
||||||
|
/** Called for every spline */
|
||||||
|
virtual void addSpline(const DRW_Spline *) { }
|
||||||
|
|
||||||
|
/** Called for every spline knot value */
|
||||||
|
virtual void addKnot(const DRW_Entity &) { }
|
||||||
|
|
||||||
|
/** Called for every insert. */
|
||||||
|
virtual void addInsert(const DRW_Insert &) { }
|
||||||
|
|
||||||
|
/** Called for every trace start */
|
||||||
|
virtual void addTrace(const DRW_Trace &) { }
|
||||||
|
|
||||||
|
/** Called for every 3dface start */
|
||||||
|
virtual void add3dFace(const DRW_3Dface &) { }
|
||||||
|
|
||||||
|
/** Called for every solid start */
|
||||||
|
virtual void addSolid(const DRW_Solid &) { }
|
||||||
|
|
||||||
|
|
||||||
|
/** Called for every Multi Text entity. */
|
||||||
|
virtual void addMText(const DRW_MText &) { }
|
||||||
|
|
||||||
|
/** Called for every Text entity. */
|
||||||
|
virtual void addText(const DRW_Text &) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every aligned dimension entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimAlign(const DRW_DimAligned *) { }
|
||||||
|
/**
|
||||||
|
* Called for every linear or rotated dimension entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimLinear(const DRW_DimLinear *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every radial dimension entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimRadial(const DRW_DimRadial *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every diametric dimension entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimDiametric(const DRW_DimDiametric *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every angular dimension (2 lines version) entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimAngular(const DRW_DimAngular *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every angular dimension (3 points version) entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimAngular3P(const DRW_DimAngular3p *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for every ordinate dimension entity.
|
||||||
|
*/
|
||||||
|
virtual void addDimOrdinate(const DRW_DimOrdinate *) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 viewport entity.
|
||||||
|
*/
|
||||||
|
virtual void addViewport(const DRW_Viewport &) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 comment in the DXF file (code 999).
|
||||||
|
*/
|
||||||
|
virtual void addComment(const char *) { }
|
||||||
|
|
||||||
|
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 writeAppId() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
1236
src/libs/vdxf/libdxfrw/drw_objects.cpp
Normal file
1236
src/libs/vdxf/libdxfrw/drw_objects.cpp
Normal file
File diff suppressed because it is too large
Load Diff
772
src/libs/vdxf/libdxfrw/drw_objects.h
Normal file
772
src/libs/vdxf/libdxfrw/drw_objects.h
Normal file
|
@ -0,0 +1,772 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_OBJECTS_H
|
||||||
|
#define DRW_OBJECTS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include "drw_base.h"
|
||||||
|
|
||||||
|
class dxfReader;
|
||||||
|
class dxfWriter;
|
||||||
|
class dwgBuffer;
|
||||||
|
|
||||||
|
namespace DRW {
|
||||||
|
|
||||||
|
//! Table entries type.
|
||||||
|
enum TTYPE {
|
||||||
|
UNKNOWNT,
|
||||||
|
LTYPE,
|
||||||
|
LAYER,
|
||||||
|
STYLE,
|
||||||
|
DIMSTYLE,
|
||||||
|
VPORT,
|
||||||
|
BLOCK_RECORD,
|
||||||
|
APPID,
|
||||||
|
IMAGEDEF
|
||||||
|
};
|
||||||
|
|
||||||
|
//pending VIEW, UCS, APPID, VP_ENT_HDR, GROUP, MLINESTYLE, LONG_TRANSACTION, XRECORD,
|
||||||
|
//ACDBPLACEHOLDER, VBA_PROJECT, ACAD_TABLE, CELLSTYLEMAP, DBCOLOR, DICTIONARYVAR,
|
||||||
|
//DICTIONARYWDFLT, FIELD, IDBUFFER, IMAGEDEF, IMAGEDEFREACTOR, LAYER_INDEX, LAYOUT
|
||||||
|
//MATERIAL, PLACEHOLDER, PLOTSETTINGS, RASTERVARIABLES, SCALE, SORTENTSTABLE,
|
||||||
|
//SPATIAL_INDEX, SPATIAL_FILTER, TABLEGEOMETRY, TABLESTYLES,VISUALSTYLE,
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SETOBJFRIENDS friend class dxfRW; \
|
||||||
|
friend class dwgReader;
|
||||||
|
|
||||||
|
//! Base class for tables entries
|
||||||
|
/*!
|
||||||
|
* Base class for tables entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_TableEntry {
|
||||||
|
public:
|
||||||
|
//initializes default values
|
||||||
|
DRW_TableEntry() {
|
||||||
|
tType = DRW::UNKNOWNT;
|
||||||
|
flags = 0;
|
||||||
|
numReactors = xDictFlag = 0;
|
||||||
|
parentHandle = 0;
|
||||||
|
curr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual~DRW_TableEntry() {
|
||||||
|
for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it)
|
||||||
|
delete *it;
|
||||||
|
|
||||||
|
extData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_TableEntry(const DRW_TableEntry& e) {
|
||||||
|
tType = e.tType;
|
||||||
|
handle = e.handle;
|
||||||
|
parentHandle = e.parentHandle;
|
||||||
|
name = e.name;
|
||||||
|
flags = e.flags;
|
||||||
|
numReactors = e.numReactors;
|
||||||
|
xDictFlag = e.xDictFlag;
|
||||||
|
curr = e.curr;
|
||||||
|
for (std::vector<DRW_Variant*>::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){
|
||||||
|
extData.push_back(new DRW_Variant(*(*it)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0) = 0;
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0);
|
||||||
|
void reset(){
|
||||||
|
flags =0;
|
||||||
|
for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it)
|
||||||
|
delete *it;
|
||||||
|
extData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DRW::TTYPE tType; /*!< enum: entity type, code 0 */
|
||||||
|
duint32 handle; /*!< entity identifier, code 5 */
|
||||||
|
int parentHandle; /*!< Soft-pointer ID/handle to owner object, code 330 */
|
||||||
|
UTF8STRING name; /*!< entry name, code 2 */
|
||||||
|
int flags; /*!< Flags relevant to entry, code 70 */
|
||||||
|
std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
DRW_Variant* curr;
|
||||||
|
|
||||||
|
//***** dwg parse ********/
|
||||||
|
protected:
|
||||||
|
dint16 oType;
|
||||||
|
duint8 xDictFlag;
|
||||||
|
dint32 numReactors; //
|
||||||
|
duint32 objSize; //RL 32bits object data size in bits
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle dimstyle entries
|
||||||
|
/*!
|
||||||
|
* Class to handle dim style symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Dimstyle : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Dimstyle() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::DIMSTYLE;
|
||||||
|
dimasz = dimtxt = dimcen = 2.5;
|
||||||
|
dimexe = 1.25;
|
||||||
|
dimexo = dimgap = 0.625;
|
||||||
|
dimtxsty = "";
|
||||||
|
dimscale = dimlfac = dimtfac = dimfxl = 1.0;
|
||||||
|
dimdli = 3.75;
|
||||||
|
dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0;
|
||||||
|
dimaltf = 1.0 / 25.4;
|
||||||
|
dimtol = dimlim = dimse1 = dimse2 = 0;
|
||||||
|
dimtad = 1;
|
||||||
|
dimzin = 8;
|
||||||
|
dimtoh = dimtolj = 0;
|
||||||
|
dimalt = dimsah = dimtix = dimsoxd = dimfxlon = 0;
|
||||||
|
dimtofl = 1;
|
||||||
|
dimunit = dimaltu = dimlunit = 2;
|
||||||
|
dimaltd = dimalttd = 3;
|
||||||
|
dimclrd = dimclre = dimclrt = dimjust = dimupt = 0;
|
||||||
|
dimtzin = 8;
|
||||||
|
dimazin = dimaltz = dimaltttz = dimfrac = 0;
|
||||||
|
dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0;
|
||||||
|
dimaltrnd = 0.0;
|
||||||
|
dimdec = dimtdec = 2;
|
||||||
|
dimfit = dimatfit = 3;
|
||||||
|
dimdsep = ',';
|
||||||
|
dimlwd = dimlwe = -2;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//V12
|
||||||
|
UTF8STRING dimpost; /*!< code 3 */
|
||||||
|
UTF8STRING dimapost; /*!< code 4 */
|
||||||
|
/* handle are code 105 */
|
||||||
|
UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */
|
||||||
|
UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */
|
||||||
|
UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */
|
||||||
|
double dimscale; /*!< code 40 */
|
||||||
|
double dimasz; /*!< code 41 */
|
||||||
|
double dimexo; /*!< code 42 */
|
||||||
|
double dimdli; /*!< code 43 */
|
||||||
|
double dimexe; /*!< code 44 */
|
||||||
|
double dimrnd; /*!< code 45 */
|
||||||
|
double dimdle; /*!< code 46 */
|
||||||
|
double dimtp; /*!< code 47 */
|
||||||
|
double dimtm; /*!< code 48 */
|
||||||
|
double dimfxl; /*!< code 49 V2007+ */
|
||||||
|
double dimtxt; /*!< code 140 */
|
||||||
|
double dimcen; /*!< code 141 */
|
||||||
|
double dimtsz; /*!< code 142 */
|
||||||
|
double dimaltf; /*!< code 143 */
|
||||||
|
double dimlfac; /*!< code 144 */
|
||||||
|
double dimtvp; /*!< code 145 */
|
||||||
|
double dimtfac; /*!< code 146 */
|
||||||
|
double dimgap; /*!< code 147 */
|
||||||
|
double dimaltrnd; /*!< code 148 V2000+ */
|
||||||
|
int dimtol; /*!< code 71 */
|
||||||
|
int dimlim; /*!< code 72 */
|
||||||
|
int dimtih; /*!< code 73 */
|
||||||
|
int dimtoh; /*!< code 74 */
|
||||||
|
int dimse1; /*!< code 75 */
|
||||||
|
int dimse2; /*!< code 76 */
|
||||||
|
int dimtad; /*!< code 77 */
|
||||||
|
int dimzin; /*!< code 78 */
|
||||||
|
int dimazin; /*!< code 79 V2000+ */
|
||||||
|
int dimalt; /*!< code 170 */
|
||||||
|
int dimaltd; /*!< code 171 */
|
||||||
|
int dimtofl; /*!< code 172 */
|
||||||
|
int dimsah; /*!< code 173 */
|
||||||
|
int dimtix; /*!< code 174 */
|
||||||
|
int dimsoxd; /*!< code 175 */
|
||||||
|
int dimclrd; /*!< code 176 */
|
||||||
|
int dimclre; /*!< code 177 */
|
||||||
|
int dimclrt; /*!< code 178 */
|
||||||
|
int dimadec; /*!< code 179 V2000+ */
|
||||||
|
int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */
|
||||||
|
int dimdec; /*!< code 271 R13+ */
|
||||||
|
int dimtdec; /*!< code 272 R13+ */
|
||||||
|
int dimaltu; /*!< code 273 R13+ */
|
||||||
|
int dimalttd; /*!< code 274 R13+ */
|
||||||
|
int dimaunit; /*!< code 275 R13+ */
|
||||||
|
int dimfrac; /*!< code 276 V2000+ */
|
||||||
|
int dimlunit; /*!< code 277 V2000+ */
|
||||||
|
int dimdsep; /*!< code 278 V2000+ */
|
||||||
|
int dimtmove; /*!< code 279 V2000+ */
|
||||||
|
int dimjust; /*!< code 280 R13+ */
|
||||||
|
int dimsd1; /*!< code 281 R13+ */
|
||||||
|
int dimsd2; /*!< code 282 R13+ */
|
||||||
|
int dimtolj; /*!< code 283 R13+ */
|
||||||
|
int dimtzin; /*!< code 284 R13+ */
|
||||||
|
int dimaltz; /*!< code 285 R13+ */
|
||||||
|
int dimaltttz; /*!< code 286 R13+ */
|
||||||
|
int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/
|
||||||
|
int dimupt; /*!< code 288 R13+ */
|
||||||
|
int dimatfit; /*!< code 289 V2000+ */
|
||||||
|
int dimfxlon; /*!< code 290 V2007+ */
|
||||||
|
UTF8STRING dimtxsty; /*!< code 340 R13+ */
|
||||||
|
UTF8STRING dimldrblk; /*!< code 341 V2000+ */
|
||||||
|
int dimlwd; /*!< code 371 V2000+ */
|
||||||
|
int dimlwe; /*!< code 372 V2000+ */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle line type entries
|
||||||
|
/*!
|
||||||
|
* Class to handle line type symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
/*TODO: handle complex lineType*/
|
||||||
|
class DRW_LType : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_LType() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::LTYPE;
|
||||||
|
desc = "";
|
||||||
|
size = 0;
|
||||||
|
length = 0.0;
|
||||||
|
pathIdx = 0;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
void update();
|
||||||
|
|
||||||
|
public:
|
||||||
|
UTF8STRING desc; /*!< descriptive string, code 3 */
|
||||||
|
// int align; /*!< align code, always 65 ('A') code 72 */
|
||||||
|
int size; /*!< element number, code 73 */
|
||||||
|
double length; /*!< total length of pattern, code 40 */
|
||||||
|
// int haveShape; /*!< complex linetype type, code 74 */
|
||||||
|
std::vector<double> path; /*!< trace, point or space length sequence, code 49 */
|
||||||
|
private:
|
||||||
|
int pathIdx;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle layer entries
|
||||||
|
/*!
|
||||||
|
* Class to handle layer symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Layer : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Layer() { reset();}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
tType = DRW::LAYER;
|
||||||
|
lineType = "CONTINUOUS";
|
||||||
|
color = 7; // default BYLAYER (256)
|
||||||
|
plotF = true; // default TRUE (plot yes)
|
||||||
|
lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31)
|
||||||
|
color24 = -1; //default -1 not set
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
UTF8STRING lineType; /*!< line type, code 6 */
|
||||||
|
int color; /*!< layer color, code 62 */
|
||||||
|
int color24; /*!< 24-bit color, code 420 */
|
||||||
|
bool plotF; /*!< Plot flag, code 290 */
|
||||||
|
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
|
||||||
|
std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
|
||||||
|
std::string handleMaterialS; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
|
||||||
|
/*only used for read dwg*/
|
||||||
|
dwgHandle lTypeH;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to handle block record entries
|
||||||
|
/*!
|
||||||
|
* Class to handle block record table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Block_Record : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Block_Record() { reset();}
|
||||||
|
void reset() {
|
||||||
|
tType = DRW::BLOCK_RECORD;
|
||||||
|
flags = 0;
|
||||||
|
firstEH = lastEH = DRW::NoHandle;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//Note: int DRW_TableEntry::flags; contains code 70 of block
|
||||||
|
int insUnits; /*!< block insertion units, code 70 of block_record*/
|
||||||
|
DRW_Coord basePoint; /*!< block insertion base point dwg only */
|
||||||
|
protected:
|
||||||
|
//dwg parser
|
||||||
|
private:
|
||||||
|
duint32 block; //handle for block entity
|
||||||
|
duint32 endBlock;//handle for end block entity
|
||||||
|
duint32 firstEH; //handle of first entity, only in pre-2004
|
||||||
|
duint32 lastEH; //handle of last entity, only in pre-2004
|
||||||
|
std::vector<duint32>entMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to handle text style entries
|
||||||
|
/*!
|
||||||
|
* Class to handle text style symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Textstyle : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Textstyle() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::STYLE;
|
||||||
|
height = oblique = 0.0;
|
||||||
|
width = lastHeight = 1.0;
|
||||||
|
font="txt";
|
||||||
|
genFlag = 0; //2= X mirror, 4= Y mirror
|
||||||
|
fontFamily = 0;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
double height; /*!< Fixed text height (0 not set), code 40 */
|
||||||
|
double width; /*!< Width factor, code 41 */
|
||||||
|
double oblique; /*!< Oblique angle, code 50 */
|
||||||
|
int genFlag; /*!< Text generation flags, code 71 */
|
||||||
|
double lastHeight; /*!< Last height used, code 42 */
|
||||||
|
UTF8STRING font; /*!< primary font file name, code 3 */
|
||||||
|
UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */
|
||||||
|
int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to handle vport entries
|
||||||
|
/*!
|
||||||
|
* Class to handle vport symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_Vport : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_Vport() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::VPORT;
|
||||||
|
UpperRight.x = UpperRight.y = 1.0;
|
||||||
|
snapSpacing.x = snapSpacing.y = 10.0;
|
||||||
|
gridSpacing = snapSpacing;
|
||||||
|
center.x = 0.651828;
|
||||||
|
center.y = -0.16;
|
||||||
|
viewDir.z = 1;
|
||||||
|
height = 5.13732;
|
||||||
|
ratio = 2.4426877;
|
||||||
|
lensHeight = 50;
|
||||||
|
frontClip = backClip = snapAngle = twistAngle = 0.0;
|
||||||
|
viewMode = snap = grid = snapStyle = snapIsopair = 0;
|
||||||
|
fastZoom = 1;
|
||||||
|
circleZoom = 100;
|
||||||
|
ucsIcon = 3;
|
||||||
|
gridBehavior = 7;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
DRW_Coord lowerLeft; /*!< Lower left corner, code 10 & 20 */
|
||||||
|
DRW_Coord UpperRight; /*!< Upper right corner, code 11 & 21 */
|
||||||
|
DRW_Coord center; /*!< center point in WCS, code 12 & 22 */
|
||||||
|
DRW_Coord snapBase; /*!< snap base point in DCS, code 13 & 23 */
|
||||||
|
DRW_Coord snapSpacing; /*!< snap Spacing, code 14 & 24 */
|
||||||
|
DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */
|
||||||
|
DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */
|
||||||
|
DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */
|
||||||
|
double height; /*!< view height, code 40 */
|
||||||
|
double ratio; /*!< viewport aspect ratio, code 41 */
|
||||||
|
double lensHeight; /*!< lens height, code 42 */
|
||||||
|
double frontClip; /*!< front clipping plane, code 43 */
|
||||||
|
double backClip; /*!< back clipping plane, code 44 */
|
||||||
|
double snapAngle; /*!< snap rotation angle, code 50 */
|
||||||
|
double twistAngle; /*!< view twist angle, code 51 */
|
||||||
|
int viewMode; /*!< view mode, code 71 */
|
||||||
|
int circleZoom; /*!< circle zoom percent, code 72 */
|
||||||
|
int fastZoom; /*!< fast zoom setting, code 73 */
|
||||||
|
int ucsIcon; /*!< UCSICON setting, code 74 */
|
||||||
|
int snap; /*!< snap on/off, code 75 */
|
||||||
|
int grid; /*!< grid on/off, code 76 */
|
||||||
|
int snapStyle; /*!< snap style, code 77 */
|
||||||
|
int snapIsopair; /*!< snap isopair, code 78 */
|
||||||
|
int gridBehavior; /*!< grid behavior, code 60, undocummented */
|
||||||
|
/** code 60, bit coded possible value are
|
||||||
|
* bit 1 (1) show out of limits
|
||||||
|
* bit 2 (2) adaptive grid
|
||||||
|
* bit 3 (4) allow subdivision
|
||||||
|
* bit 4 (8) follow dinamic SCP
|
||||||
|
**/
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle imagedef entries
|
||||||
|
/*!
|
||||||
|
* Class to handle image definitions object entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_ImageDef : public DRW_TableEntry {//
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_ImageDef() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::IMAGEDEF;
|
||||||
|
imgVersion = 0;
|
||||||
|
DRW_TableEntry::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader);
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// std::string handle; /*!< entity identifier, code 5 */
|
||||||
|
UTF8STRING name; /*!< File name of image, code 1 */
|
||||||
|
int imgVersion; /*!< class version, code 90, 0=R14 version */
|
||||||
|
double u; /*!< image size in pixels U value, code 10 */
|
||||||
|
double v; /*!< image size in pixels V value, code 20 */
|
||||||
|
double up; /*!< default size of one pixel U value, code 11 */
|
||||||
|
double vp; /*!< default size of one pixel V value, code 12 really is 21*/
|
||||||
|
int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */
|
||||||
|
int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */
|
||||||
|
|
||||||
|
std::map<std::string,std::string> reactors;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Class to handle AppId entries
|
||||||
|
/*!
|
||||||
|
* Class to handle AppId symbol table entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_AppId : public DRW_TableEntry {
|
||||||
|
SETOBJFRIENDS
|
||||||
|
public:
|
||||||
|
DRW_AppId() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
tType = DRW::APPID;
|
||||||
|
flags = 0;
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parseCode(int code, dxfReader *reader){DRW_TableEntry::parseCode(code, reader);}
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace DRW {
|
||||||
|
|
||||||
|
// Extended color palette:
|
||||||
|
// The first entry is only for direct indexing starting with [1]
|
||||||
|
// Color 1 is red (1,0,0)
|
||||||
|
const unsigned char dxfColors[][3] = {
|
||||||
|
{ 0, 0, 0}, // unused
|
||||||
|
{255, 0, 0}, // 1 red
|
||||||
|
{255,255, 0}, // 2 yellow
|
||||||
|
{ 0,255, 0}, // 3 green
|
||||||
|
{ 0,255,255}, // 4 cyan
|
||||||
|
{ 0, 0,255}, // 5 blue
|
||||||
|
{255, 0,255}, // 6 magenta
|
||||||
|
{ 0, 0, 0}, // 7 black or white
|
||||||
|
{128,128,128}, // 8 50% gray
|
||||||
|
{192,192,192}, // 9 75% gray
|
||||||
|
{255, 0, 0}, // 10
|
||||||
|
{255,127,127},
|
||||||
|
{204, 0, 0},
|
||||||
|
{204,102,102},
|
||||||
|
{153, 0, 0},
|
||||||
|
{153, 76, 76}, // 15
|
||||||
|
{127, 0, 0},
|
||||||
|
{127, 63, 63},
|
||||||
|
{ 76, 0, 0},
|
||||||
|
{ 76, 38, 38},
|
||||||
|
{255, 63, 0}, // 20
|
||||||
|
{255,159,127},
|
||||||
|
{204, 51, 0},
|
||||||
|
{204,127,102},
|
||||||
|
{153, 38, 0},
|
||||||
|
{153, 95, 76}, // 25
|
||||||
|
{127, 31, 0},
|
||||||
|
{127, 79, 63},
|
||||||
|
{ 76, 19, 0},
|
||||||
|
{ 76, 47, 38},
|
||||||
|
{255,127, 0}, // 30
|
||||||
|
{255,191,127},
|
||||||
|
{204,102, 0},
|
||||||
|
{204,153,102},
|
||||||
|
{153, 76, 0},
|
||||||
|
{153,114, 76}, // 35
|
||||||
|
{127, 63, 0},
|
||||||
|
{127, 95, 63},
|
||||||
|
{ 76, 38, 0},
|
||||||
|
{ 76, 57, 38},
|
||||||
|
{255,191, 0}, // 40
|
||||||
|
{255,223,127},
|
||||||
|
{204,153, 0},
|
||||||
|
{204,178,102},
|
||||||
|
{153,114, 0},
|
||||||
|
{153,133, 76}, // 45
|
||||||
|
{127, 95, 0},
|
||||||
|
{127,111, 63},
|
||||||
|
{ 76, 57, 0},
|
||||||
|
{ 76, 66, 38},
|
||||||
|
{255,255, 0}, // 50
|
||||||
|
{255,255,127},
|
||||||
|
{204,204, 0},
|
||||||
|
{204,204,102},
|
||||||
|
{153,153, 0},
|
||||||
|
{153,153, 76}, // 55
|
||||||
|
{127,127, 0},
|
||||||
|
{127,127, 63},
|
||||||
|
{ 76, 76, 0},
|
||||||
|
{ 76, 76, 38},
|
||||||
|
{191,255, 0}, // 60
|
||||||
|
{223,255,127},
|
||||||
|
{153,204, 0},
|
||||||
|
{178,204,102},
|
||||||
|
{114,153, 0},
|
||||||
|
{133,153, 76}, // 65
|
||||||
|
{ 95,127, 0},
|
||||||
|
{111,127, 63},
|
||||||
|
{ 57, 76, 0},
|
||||||
|
{ 66, 76, 38},
|
||||||
|
{127,255, 0}, // 70
|
||||||
|
{191,255,127},
|
||||||
|
{102,204, 0},
|
||||||
|
{153,204,102},
|
||||||
|
{ 76,153, 0},
|
||||||
|
{114,153, 76}, // 75
|
||||||
|
{ 63,127, 0},
|
||||||
|
{ 95,127, 63},
|
||||||
|
{ 38, 76, 0},
|
||||||
|
{ 57, 76, 38},
|
||||||
|
{ 63,255, 0}, // 80
|
||||||
|
{159,255,127},
|
||||||
|
{ 51,204, 0},
|
||||||
|
{127,204,102},
|
||||||
|
{ 38,153, 0},
|
||||||
|
{ 95,153, 76}, // 85
|
||||||
|
{ 31,127, 0},
|
||||||
|
{ 79,127, 63},
|
||||||
|
{ 19, 76, 0},
|
||||||
|
{ 47, 76, 38},
|
||||||
|
{ 0,255, 0}, // 90
|
||||||
|
{127,255,127},
|
||||||
|
{ 0,204, 0},
|
||||||
|
{102,204,102},
|
||||||
|
{ 0,153, 0},
|
||||||
|
{ 76,153, 76}, // 95
|
||||||
|
{ 0,127, 0},
|
||||||
|
{ 63,127, 63},
|
||||||
|
{ 0, 76, 0},
|
||||||
|
{ 38, 76, 38},
|
||||||
|
{ 0,255, 63}, // 100
|
||||||
|
{127,255,159},
|
||||||
|
{ 0,204, 51},
|
||||||
|
{102,204,127},
|
||||||
|
{ 0,153, 38},
|
||||||
|
{ 76,153, 95}, // 105
|
||||||
|
{ 0,127, 31},
|
||||||
|
{ 63,127, 79},
|
||||||
|
{ 0, 76, 19},
|
||||||
|
{ 38, 76, 47},
|
||||||
|
{ 0,255,127}, // 110
|
||||||
|
{127,255,191},
|
||||||
|
{ 0,204,102},
|
||||||
|
{102,204,153},
|
||||||
|
{ 0,153, 76},
|
||||||
|
{ 76,153,114}, // 115
|
||||||
|
{ 0,127, 63},
|
||||||
|
{ 63,127, 95},
|
||||||
|
{ 0, 76, 38},
|
||||||
|
{ 38, 76, 57},
|
||||||
|
{ 0,255,191}, // 120
|
||||||
|
{127,255,223},
|
||||||
|
{ 0,204,153},
|
||||||
|
{102,204,178},
|
||||||
|
{ 0,153,114},
|
||||||
|
{ 76,153,133}, // 125
|
||||||
|
{ 0,127, 95},
|
||||||
|
{ 63,127,111},
|
||||||
|
{ 0, 76, 57},
|
||||||
|
{ 38, 76, 66},
|
||||||
|
{ 0,255,255}, // 130
|
||||||
|
{127,255,255},
|
||||||
|
{ 0,204,204},
|
||||||
|
{102,204,204},
|
||||||
|
{ 0,153,153},
|
||||||
|
{ 76,153,153}, // 135
|
||||||
|
{ 0,127,127},
|
||||||
|
{ 63,127,127},
|
||||||
|
{ 0, 76, 76},
|
||||||
|
{ 38, 76, 76},
|
||||||
|
{ 0,191,255}, // 140
|
||||||
|
{127,223,255},
|
||||||
|
{ 0,153,204},
|
||||||
|
{102,178,204},
|
||||||
|
{ 0,114,153},
|
||||||
|
{ 76,133,153}, // 145
|
||||||
|
{ 0, 95,127},
|
||||||
|
{ 63,111,127},
|
||||||
|
{ 0, 57, 76},
|
||||||
|
{ 38, 66, 76},
|
||||||
|
{ 0,127,255}, // 150
|
||||||
|
{127,191,255},
|
||||||
|
{ 0,102,204},
|
||||||
|
{102,153,204},
|
||||||
|
{ 0, 76,153},
|
||||||
|
{ 76,114,153}, // 155
|
||||||
|
{ 0, 63,127},
|
||||||
|
{ 63, 95,127},
|
||||||
|
{ 0, 38, 76},
|
||||||
|
{ 38, 57, 76},
|
||||||
|
{ 0, 66,255}, // 160
|
||||||
|
{127,159,255},
|
||||||
|
{ 0, 51,204},
|
||||||
|
{102,127,204},
|
||||||
|
{ 0, 38,153},
|
||||||
|
{ 76, 95,153}, // 165
|
||||||
|
{ 0, 31,127},
|
||||||
|
{ 63, 79,127},
|
||||||
|
{ 0, 19, 76},
|
||||||
|
{ 38, 47, 76},
|
||||||
|
{ 0, 0,255}, // 170
|
||||||
|
{127,127,255},
|
||||||
|
{ 0, 0,204},
|
||||||
|
{102,102,204},
|
||||||
|
{ 0, 0,153},
|
||||||
|
{ 76, 76,153}, // 175
|
||||||
|
{ 0, 0,127},
|
||||||
|
{ 63, 63,127},
|
||||||
|
{ 0, 0, 76},
|
||||||
|
{ 38, 38, 76},
|
||||||
|
{ 63, 0,255}, // 180
|
||||||
|
{159,127,255},
|
||||||
|
{ 50, 0,204},
|
||||||
|
{127,102,204},
|
||||||
|
{ 38, 0,153},
|
||||||
|
{ 95, 76,153}, // 185
|
||||||
|
{ 31, 0,127},
|
||||||
|
{ 79, 63,127},
|
||||||
|
{ 19, 0, 76},
|
||||||
|
{ 47, 38, 76},
|
||||||
|
{127, 0,255}, // 190
|
||||||
|
{191,127,255},
|
||||||
|
{102, 0,204},
|
||||||
|
{153,102,204},
|
||||||
|
{ 76, 0,153},
|
||||||
|
{114, 76,153}, // 195
|
||||||
|
{ 63, 0,127},
|
||||||
|
{ 95, 63,127},
|
||||||
|
{ 38, 0, 76},
|
||||||
|
{ 57, 38, 76},
|
||||||
|
{191, 0,255}, // 200
|
||||||
|
{223,127,255},
|
||||||
|
{153, 0,204},
|
||||||
|
{178,102,204},
|
||||||
|
{114, 0,153},
|
||||||
|
{133, 76,153}, // 205
|
||||||
|
{ 95, 0,127},
|
||||||
|
{111, 63,127},
|
||||||
|
{ 57, 0, 76},
|
||||||
|
{ 66, 38, 76},
|
||||||
|
{255, 0,255}, // 210
|
||||||
|
{255,127,255},
|
||||||
|
{204, 0,204},
|
||||||
|
{204,102,204},
|
||||||
|
{153, 0,153},
|
||||||
|
{153, 76,153}, // 215
|
||||||
|
{127, 0,127},
|
||||||
|
{127, 63,127},
|
||||||
|
{ 76, 0, 76},
|
||||||
|
{ 76, 38, 76},
|
||||||
|
{255, 0,191}, // 220
|
||||||
|
{255,127,223},
|
||||||
|
{204, 0,153},
|
||||||
|
{204,102,178},
|
||||||
|
{153, 0,114},
|
||||||
|
{153, 76,133}, // 225
|
||||||
|
{127, 0, 95},
|
||||||
|
{127, 63, 11},
|
||||||
|
{ 76, 0, 57},
|
||||||
|
{ 76, 38, 66},
|
||||||
|
{255, 0,127}, // 230
|
||||||
|
{255,127,191},
|
||||||
|
{204, 0,102},
|
||||||
|
{204,102,153},
|
||||||
|
{153, 0, 76},
|
||||||
|
{153, 76,114}, // 235
|
||||||
|
{127, 0, 63},
|
||||||
|
{127, 63, 95},
|
||||||
|
{ 76, 0, 38},
|
||||||
|
{ 76, 38, 57},
|
||||||
|
{255, 0, 63}, // 240
|
||||||
|
{255,127,159},
|
||||||
|
{204, 0, 51},
|
||||||
|
{204,102,127},
|
||||||
|
{153, 0, 38},
|
||||||
|
{153, 76, 95}, // 245
|
||||||
|
{127, 0, 31},
|
||||||
|
{127, 63, 79},
|
||||||
|
{ 76, 0, 19},
|
||||||
|
{ 76, 38, 47},
|
||||||
|
{ 51, 51, 51}, // 250
|
||||||
|
{ 91, 91, 91},
|
||||||
|
{132,132,132},
|
||||||
|
{173,173,173},
|
||||||
|
{214,214,214},
|
||||||
|
{255,255,255} // 255
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// EOF
|
164
src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp
Normal file
164
src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
|
||||||
|
DRW_dbg *DRW_dbg::instance= NULL;
|
||||||
|
|
||||||
|
/*********private clases*************/
|
||||||
|
class print_none {
|
||||||
|
public:
|
||||||
|
virtual void printS(std::string s){(void)s;}
|
||||||
|
virtual void printI(long long int i){(void)i;}
|
||||||
|
virtual void printUI(long long unsigned int i){(void)i;}
|
||||||
|
virtual void printD(double d){(void)d;}
|
||||||
|
virtual void printH(long long int i){(void)i;}
|
||||||
|
virtual void printB(int i){(void)i;}
|
||||||
|
virtual void printHL(int c, int s, int h){(void)c;(void)s;(void)h;}
|
||||||
|
virtual void printPT(double x, double y, double z){(void)x;(void)y;(void)z;}
|
||||||
|
print_none(){}
|
||||||
|
virtual ~print_none(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
class print_debug : public print_none {
|
||||||
|
public:
|
||||||
|
virtual void printS(std::string s);
|
||||||
|
virtual void printI(long long int i);
|
||||||
|
virtual void printUI(long long unsigned int i);
|
||||||
|
virtual void printD(double d);
|
||||||
|
virtual void printH(long long int i);
|
||||||
|
virtual void printB(int i);
|
||||||
|
virtual void printHL(int c, int s, int h);
|
||||||
|
virtual void printPT(double x, double y, double z);
|
||||||
|
print_debug();
|
||||||
|
virtual ~print_debug(){}
|
||||||
|
private:
|
||||||
|
std::ios_base::fmtflags flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
/********* debug class *************/
|
||||||
|
DRW_dbg *DRW_dbg::getInstance(){
|
||||||
|
if (instance == NULL){
|
||||||
|
instance = new DRW_dbg;
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_dbg::DRW_dbg(){
|
||||||
|
level = NONE;
|
||||||
|
prClass = new print_none;
|
||||||
|
flags = std::cerr.flags();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::setLevel(LEVEL lvl){
|
||||||
|
level = lvl;
|
||||||
|
delete prClass;
|
||||||
|
switch (level){
|
||||||
|
case DEBUG:
|
||||||
|
prClass = new print_debug;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prClass = new print_none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DRW_dbg::LEVEL DRW_dbg::getLevel(){
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(std::string s){
|
||||||
|
prClass->printS(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(int i){
|
||||||
|
prClass->printI(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(unsigned int i){
|
||||||
|
prClass->printUI(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(long long int i){
|
||||||
|
prClass->printI(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(long unsigned int i){
|
||||||
|
prClass->printUI(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(long long unsigned int i){
|
||||||
|
prClass->printUI(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::print(double d){
|
||||||
|
prClass->printD(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::printH(long long int i){
|
||||||
|
prClass->printH(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::printB(int i){
|
||||||
|
prClass->printB(i);
|
||||||
|
}
|
||||||
|
void DRW_dbg::printHL(int c, int s, int h){
|
||||||
|
prClass->printHL(c, s, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_dbg::printPT(double x, double y, double z){
|
||||||
|
prClass->printPT(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_debug::print_debug(){
|
||||||
|
flags = std::cerr.flags();
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printS(std::string s){
|
||||||
|
std::cerr << s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printI(long long int i){
|
||||||
|
std::cerr << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printUI(long long unsigned int i){
|
||||||
|
std::cerr << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printD(double d){
|
||||||
|
std::cerr << std::fixed << d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printH(long long i){
|
||||||
|
std::cerr << "0x" << std::setw(2) << std::setfill('0');
|
||||||
|
std::cerr << std::hex << i;
|
||||||
|
std::cerr.flags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printB(int i){
|
||||||
|
std::cerr << std::setw(8) << std::setfill('0');
|
||||||
|
std::cerr << std::setbase(2) << i;
|
||||||
|
std::cerr.flags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printHL(int c, int s, int h){
|
||||||
|
std::cerr << c << '.' << s << '.';
|
||||||
|
std::cerr << "0x" << std::setw(2) << std::setfill('0');
|
||||||
|
std::cerr << std::hex << h;
|
||||||
|
std::cerr.flags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_debug::printPT(double x, double y, double z){
|
||||||
|
std::cerr << std::fixed << "x: " << x << ", y: " << y << ", z: "<< z;
|
||||||
|
}
|
61
src/libs/vdxf/libdxfrw/intern/drw_dbg.h
Normal file
61
src/libs/vdxf/libdxfrw/intern/drw_dbg.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRW_DBG_H
|
||||||
|
#define DRW_DBG_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
//#include <iomanip>
|
||||||
|
|
||||||
|
#define DRW_DBGSL(a) DRW_dbg::getInstance()->setLevel(a)
|
||||||
|
#define DRW_DBGGL DRW_dbg::getInstance()->getLevel()
|
||||||
|
#define DRW_DBG(a) DRW_dbg::getInstance()->print(a)
|
||||||
|
#define DRW_DBGH(a) DRW_dbg::getInstance()->printH(a)
|
||||||
|
#define DRW_DBGB(a) DRW_dbg::getInstance()->printB(a)
|
||||||
|
#define DRW_DBGHL(a, b, c) DRW_dbg::getInstance()->printHL(a, b ,c)
|
||||||
|
#define DRW_DBGPT(a, b, c) DRW_dbg::getInstance()->printPT(a, b, c)
|
||||||
|
|
||||||
|
|
||||||
|
class print_none;
|
||||||
|
|
||||||
|
class DRW_dbg {
|
||||||
|
public:
|
||||||
|
enum LEVEL {
|
||||||
|
NONE,
|
||||||
|
DEBUG
|
||||||
|
};
|
||||||
|
void setLevel(LEVEL lvl);
|
||||||
|
LEVEL getLevel();
|
||||||
|
static DRW_dbg *getInstance();
|
||||||
|
void print(std::string s);
|
||||||
|
void print(int i);
|
||||||
|
void print(unsigned int i);
|
||||||
|
void print(long long int i);
|
||||||
|
void print(long unsigned int i);
|
||||||
|
void print(long long unsigned int i);
|
||||||
|
void print(double d);
|
||||||
|
void printH(long long int i);
|
||||||
|
void printB(int i);
|
||||||
|
void printHL(int c, int s, int h);
|
||||||
|
void printPT(double x, double y, double z);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DRW_dbg();
|
||||||
|
static DRW_dbg *instance;
|
||||||
|
LEVEL level;
|
||||||
|
std::ios_base::fmtflags flags;
|
||||||
|
print_none* prClass;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DRW_DBG_H
|
165
src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp
Normal file
165
src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include "../drw_base.h"
|
||||||
|
|
||||||
|
DRW_TextCodec::DRW_TextCodec() {
|
||||||
|
version = DRW::AC1021;
|
||||||
|
conv = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_TextCodec::setVersion(int v, bool dxfFormat){
|
||||||
|
if (v == DRW::AC1009 || v == DRW::AC1006) {
|
||||||
|
version = DRW::AC1009;
|
||||||
|
cp = "ANSI_1252";
|
||||||
|
setCodePage(&cp, dxfFormat);
|
||||||
|
} else if (v == DRW::AC1012 || v == DRW::AC1014
|
||||||
|
|| v == DRW::AC1015 || v == DRW::AC1018) {
|
||||||
|
version = DRW::AC1015;
|
||||||
|
// if (cp.empty()) { //codepage not set, initialize
|
||||||
|
cp = "ANSI_1252";
|
||||||
|
setCodePage(&cp, dxfFormat);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
version = DRW::AC1021;
|
||||||
|
if (dxfFormat)
|
||||||
|
cp = "UTF-8";//RLZ: can be UCS2 or UTF-16 16bits per char
|
||||||
|
else
|
||||||
|
cp = "UTF-16";//RLZ: can be UCS2 or UTF-16 16bits per char
|
||||||
|
setCodePage(&cp, dxfFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_TextCodec::setVersion(std::string *v, bool dxfFormat){
|
||||||
|
std::string versionStr = *v;
|
||||||
|
if (versionStr == "AC1009" || versionStr == "AC1006") {
|
||||||
|
setVersion(DRW::AC1009, dxfFormat);
|
||||||
|
} else if (versionStr == "AC1012" || versionStr == "AC1014"
|
||||||
|
|| versionStr == "AC1015" || versionStr == "AC1018") {
|
||||||
|
setVersion(DRW::AC1015, dxfFormat);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setVersion(DRW::AC1021, dxfFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_TextCodec::setCodePage(std::string *c, bool dxfFormat){
|
||||||
|
cp = correctCodePage(*c);
|
||||||
|
if (version < DRW::AC1021)
|
||||||
|
{
|
||||||
|
if (cp == "UTF-8")
|
||||||
|
{ //DXF older than 2007 are write in win codepages
|
||||||
|
cp = "ANSI_1252";
|
||||||
|
}
|
||||||
|
conv = QTextCodec::codecForName(cp.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dxfFormat)
|
||||||
|
{
|
||||||
|
conv = QTextCodec::codecForName("UTF-8");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
conv = QTextCodec::codecForName("UTF-16");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DRW_TextCodec::toUtf8(std::string s) {
|
||||||
|
if (conv == nullptr)
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString encodedString = conv->toUnicode(s.c_str());
|
||||||
|
return encodedString.toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DRW_TextCodec::fromUtf8(std::string s) {
|
||||||
|
if (conv == nullptr)
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray encodedString = conv->fromUnicode(QString::fromStdString(s));
|
||||||
|
return std::string(encodedString.constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DRW_TextCodec::correctCodePage(const std::string& s) {
|
||||||
|
//stringstream cause crash in OS/X, bug#3597944
|
||||||
|
std::string cp=s;
|
||||||
|
transform(cp.begin(), cp.end(), cp.begin(), toupper);
|
||||||
|
//Latin/Thai
|
||||||
|
if (cp=="ANSI_874" || cp=="CP874" || cp=="ISO8859-11" || cp=="TIS-620") {
|
||||||
|
return "ANSI_874";
|
||||||
|
//Central Europe and Eastern Europe
|
||||||
|
} else if (cp=="ANSI_1250" || cp=="CP1250" || cp=="ISO8859-2") {
|
||||||
|
return "ANSI_1250";
|
||||||
|
//Cyrillic script
|
||||||
|
} else if (cp=="ANSI_1251" || cp=="CP1251" || cp=="ISO8859-5" || cp=="KOI8-R" ||
|
||||||
|
cp=="KOI8-U" || cp=="IBM 866") {
|
||||||
|
return "ANSI_1251";
|
||||||
|
//Western Europe
|
||||||
|
} else if (cp=="ANSI_1252" || cp=="CP1252" || cp=="LATIN1" || cp=="ISO-8859-1" ||
|
||||||
|
cp=="CP819" || cp=="CSISO" || cp=="IBM819" || cp=="ISO_8859-1" || cp=="APPLE ROMAN" ||
|
||||||
|
cp=="ISO8859-1" || cp=="ISO8859-15" || cp=="ISO-IR-100" || cp=="L1" || cp=="IBM 850") {
|
||||||
|
return "ANSI_1252";
|
||||||
|
//Greek
|
||||||
|
} else if (cp=="ANSI_1253" || cp=="CP1253" || cp=="iso8859-7") {
|
||||||
|
return "ANSI_1253";
|
||||||
|
//Turkish
|
||||||
|
} else if (cp=="ANSI_1254" || cp=="CP1254" || cp=="iso8859-9" || cp=="iso8859-3") {
|
||||||
|
return "ANSI_1254";
|
||||||
|
//Hebrew
|
||||||
|
} else if (cp=="ANSI_1255" || cp=="CP1255" || cp=="iso8859-8") {
|
||||||
|
return "ANSI_1255";
|
||||||
|
//Arabic
|
||||||
|
} else if (cp=="ANSI_1256" || cp=="CP1256" || cp=="ISO8859-6") {
|
||||||
|
return "ANSI_1256";
|
||||||
|
//Baltic
|
||||||
|
} else if (cp=="ANSI_1257" || cp=="CP1257" || cp=="ISO8859-4" || cp=="ISO8859-10" || cp=="ISO8859-13") {
|
||||||
|
return "ANSI_1257";
|
||||||
|
//Vietnamese
|
||||||
|
} else if (cp=="ANSI_1258" || cp=="CP1258") {
|
||||||
|
return "ANSI_1258";
|
||||||
|
|
||||||
|
//Japanese
|
||||||
|
} else if (cp=="ANSI_932" || cp=="SHIFT-JIS" || cp=="SHIFT_JIS" || cp=="CSSHIFTJIS" ||
|
||||||
|
cp=="CSWINDOWS31J" || cp=="MS_KANJI" || cp=="X-MS-CP932" || cp=="X-SJIS" ||
|
||||||
|
cp=="EUCJP" || cp=="EUC-JP" || cp=="CSEUCPKDFMTJAPANESE" || cp=="X-EUC" ||
|
||||||
|
cp=="X-EUC-JP" || cp=="JIS7") {
|
||||||
|
return "ANSI_932";
|
||||||
|
//Chinese PRC GBK (XGB) simplified
|
||||||
|
} else if (cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB" ||
|
||||||
|
cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280" ||
|
||||||
|
cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" ||
|
||||||
|
cp=="ISO-IR-58" || cp=="GB18030") {
|
||||||
|
return "ANSI_936";
|
||||||
|
//Korean
|
||||||
|
} else if (cp=="ANSI_949" || cp=="EUCKR") {
|
||||||
|
return "ANSI_949";
|
||||||
|
//Chinese Big5 (Taiwan, Hong Kong SAR)
|
||||||
|
} else if (cp=="ANSI_950" || cp=="BIG5" || cp=="CN-BIG5" || cp=="CSBIG5" ||
|
||||||
|
cp=="X-X-BIG5" || cp=="BIG5-HKSCS") {
|
||||||
|
return "ANSI_950";
|
||||||
|
|
||||||
|
//celtic
|
||||||
|
/* } else if (cp=="ISO8859-14") {
|
||||||
|
return "ISO8859-14";
|
||||||
|
} else if (cp=="TSCII") {
|
||||||
|
return "TSCII"; //tamil
|
||||||
|
}*/
|
||||||
|
|
||||||
|
} else if (cp=="UTF-8" || cp=="UTF8" || cp=="UTF8-BIT") {
|
||||||
|
return "UTF-8";
|
||||||
|
} else if (cp=="UTF-16" || cp=="UTF16" || cp=="UTF16-BIT") {
|
||||||
|
return "UTF-16";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "ANSI_1252";
|
||||||
|
}
|
30
src/libs/vdxf/libdxfrw/intern/drw_textcodec.h
Normal file
30
src/libs/vdxf/libdxfrw/intern/drw_textcodec.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef DRW_TEXTCODEC_H
|
||||||
|
#define DRW_TEXTCODEC_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class QTextCodec;
|
||||||
|
|
||||||
|
class DRW_TextCodec
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DRW_TextCodec();
|
||||||
|
std::string fromUtf8(std::string s);
|
||||||
|
std::string toUtf8(std::string s);
|
||||||
|
int getVersion(){return version;}
|
||||||
|
void setVersion(std::string *v, bool dxfFormat);
|
||||||
|
void setVersion(int v, bool dxfFormat);
|
||||||
|
void setCodePage(std::string *c, bool dxfFormat);
|
||||||
|
void setCodePage(std::string c, bool dxfFormat){setCodePage(&c, dxfFormat);}
|
||||||
|
std::string getCodePage(){return cp;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string correctCodePage(const std::string& s);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int version;
|
||||||
|
std::string cp;
|
||||||
|
QTextCodec *conv;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DRW_TEXTCODEC_H
|
923
src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp
Normal file
923
src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp
Normal file
|
@ -0,0 +1,923 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
//#include <bitset>
|
||||||
|
/*#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
|
#include "dwgreader.h"*/
|
||||||
|
//#include "dxfwriter.h"
|
||||||
|
|
||||||
|
|
||||||
|
//#define FIRSTHANDLE 48
|
||||||
|
|
||||||
|
/*enum sections {
|
||||||
|
secUnknown,
|
||||||
|
secHeader,
|
||||||
|
secTables,
|
||||||
|
secBlocks,
|
||||||
|
secEntities,
|
||||||
|
secObjects
|
||||||
|
};*/
|
||||||
|
|
||||||
|
static unsigned int crctable[256]= {
|
||||||
|
0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,
|
||||||
|
0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,
|
||||||
|
0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,
|
||||||
|
0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,
|
||||||
|
0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,
|
||||||
|
0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,
|
||||||
|
0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,
|
||||||
|
0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,
|
||||||
|
0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,
|
||||||
|
0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,
|
||||||
|
0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,
|
||||||
|
0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,
|
||||||
|
0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
|
||||||
|
0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,
|
||||||
|
0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,
|
||||||
|
0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,
|
||||||
|
0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,
|
||||||
|
0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,
|
||||||
|
0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,
|
||||||
|
0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,
|
||||||
|
0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,
|
||||||
|
0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,
|
||||||
|
0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,
|
||||||
|
0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,
|
||||||
|
0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,
|
||||||
|
0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
|
||||||
|
0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,
|
||||||
|
0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,
|
||||||
|
0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,
|
||||||
|
0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,
|
||||||
|
0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,
|
||||||
|
0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040 };
|
||||||
|
|
||||||
|
static unsigned int crc32Table[256] ={
|
||||||
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||||
|
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||||
|
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||||
|
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
||||||
|
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||||
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||||
|
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||||
|
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
||||||
|
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||||
|
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||||
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
||||||
|
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||||
|
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||||
|
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||||
|
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||||
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
||||||
|
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
||||||
|
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||||
|
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
||||||
|
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||||
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||||
|
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
||||||
|
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
||||||
|
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||||
|
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||||
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
||||||
|
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||||
|
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||||
|
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
||||||
|
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||||
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||||
|
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
|
||||||
|
|
||||||
|
union typeCast {
|
||||||
|
char buf[8];
|
||||||
|
duint16 i16;
|
||||||
|
duint32 i32;
|
||||||
|
duint64 i64;
|
||||||
|
ddouble64 d64;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool dwgFileStream::setPos(duint64 p){
|
||||||
|
if (p >= sz)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
stream->seekg(p);
|
||||||
|
return stream->good();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgFileStream::read(duint8* s, duint64 n){
|
||||||
|
stream->read (reinterpret_cast<char*>(s),n);
|
||||||
|
return stream->good();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgCharStream::setPos(duint64 p){
|
||||||
|
if (p > size()) {
|
||||||
|
isOk = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = p;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgCharStream::read(duint8* s, duint64 n){
|
||||||
|
if ( n > (sz - pos) ) {
|
||||||
|
isOk = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (duint64 i=0; i<n; i++){
|
||||||
|
s[i]= stream[pos++];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer::dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc){
|
||||||
|
filestr = new dwgCharStream(buf, size);
|
||||||
|
decoder = dc;
|
||||||
|
maxSize = size;
|
||||||
|
bitPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer::dwgBuffer(std::istream *stream, DRW_TextCodec *dc){
|
||||||
|
filestr = new dwgFileStream(stream);
|
||||||
|
decoder = dc;
|
||||||
|
maxSize = filestr->size();
|
||||||
|
bitPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer::dwgBuffer( const dwgBuffer& org ){
|
||||||
|
filestr = org.filestr->clone();
|
||||||
|
decoder = org.decoder;
|
||||||
|
maxSize = filestr->size();
|
||||||
|
currByte = org.currByte;
|
||||||
|
bitPos = org.bitPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer& dwgBuffer::operator=( const dwgBuffer& org ){
|
||||||
|
filestr = org.filestr->clone();
|
||||||
|
decoder = org.decoder;
|
||||||
|
maxSize = filestr->size();
|
||||||
|
currByte = org.currByte;
|
||||||
|
bitPos = org.bitPos;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer::~dwgBuffer(){
|
||||||
|
delete filestr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Gets the current byte position in buffer **/
|
||||||
|
duint64 dwgBuffer::getPosition(){
|
||||||
|
if (bitPos != 0)
|
||||||
|
return filestr->getPos() -1;
|
||||||
|
return filestr->getPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Sets the buffer position in pos byte, reset the bit position **/
|
||||||
|
bool dwgBuffer::setPosition(duint64 pos){
|
||||||
|
bitPos = 0;
|
||||||
|
/* if (pos>=maxSize)
|
||||||
|
return false;*/
|
||||||
|
return filestr->setPos(pos);
|
||||||
|
// return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//RLZ: Fails if ... ???
|
||||||
|
void dwgBuffer::setBitPos(duint8 pos){
|
||||||
|
if (pos>7)
|
||||||
|
return;
|
||||||
|
if (pos != 0 && bitPos == 0){
|
||||||
|
duint8 buffer;
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
}
|
||||||
|
if (pos == 0 && bitPos != 0){//reset current byte
|
||||||
|
filestr->setPos(filestr->getPos()-1);
|
||||||
|
}
|
||||||
|
bitPos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgBuffer::moveBitPos(dint32 size){
|
||||||
|
if (size == 0) return true;
|
||||||
|
|
||||||
|
dint32 b= size + bitPos;
|
||||||
|
filestr->setPos(getPosition() + (b >> 3) );
|
||||||
|
bitPos = b & 7;
|
||||||
|
|
||||||
|
if (bitPos != 0){
|
||||||
|
filestr->read (&currByte,1);
|
||||||
|
}
|
||||||
|
return filestr->good();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads one Bit returns a char with value 0/1 (B) **/
|
||||||
|
duint8 dwgBuffer::getBit(){
|
||||||
|
duint8 buffer;
|
||||||
|
duint8 ret = 0;
|
||||||
|
if (bitPos == 0){
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (currByte >> (7 - bitPos) & 1);
|
||||||
|
bitPos +=1;
|
||||||
|
if (bitPos == 8)
|
||||||
|
bitPos = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads one Bit returns a bool value 0==false 1==true (B) **/
|
||||||
|
bool dwgBuffer::getBoolBit(){
|
||||||
|
return (getBit() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads two Bits returns a char (BB) **/
|
||||||
|
duint8 dwgBuffer::get2Bits(){
|
||||||
|
duint8 buffer;
|
||||||
|
duint8 ret = 0;
|
||||||
|
if (bitPos == 0){
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bitPos +=2;
|
||||||
|
if (bitPos < 9)
|
||||||
|
ret = currByte >>(8 - bitPos);
|
||||||
|
else {//read one bit per byte
|
||||||
|
ret = currByte << 1;
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
bitPos = 1;
|
||||||
|
ret = ret | currByte >> 7;
|
||||||
|
}
|
||||||
|
if (bitPos == 8)
|
||||||
|
bitPos = 0;
|
||||||
|
ret = ret & 3;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads thee Bits returns a char (3B) **/
|
||||||
|
//RLZ: todo verify this
|
||||||
|
duint8 dwgBuffer::get3Bits(){
|
||||||
|
duint8 buffer;
|
||||||
|
duint8 ret = 0;
|
||||||
|
if (bitPos == 0){
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bitPos +=3;
|
||||||
|
if (bitPos < 9)
|
||||||
|
ret = currByte >>(8 - bitPos);
|
||||||
|
else {//read one bit per byte
|
||||||
|
ret = currByte << 1;
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
currByte = buffer;
|
||||||
|
bitPos = 1;
|
||||||
|
ret = ret | currByte >> 7;
|
||||||
|
}
|
||||||
|
if (bitPos == 8)
|
||||||
|
bitPos = 0;
|
||||||
|
ret = ret & 7;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads tree Bits returns a char (3B) for R24 **/
|
||||||
|
//to be written
|
||||||
|
|
||||||
|
/**Reads compresed Short (max. 16 + 2 bits) little-endian order, returns a UNsigned 16 bits (BS) **/
|
||||||
|
duint16 dwgBuffer::getBitShort(){
|
||||||
|
duint8 b = get2Bits();
|
||||||
|
if (b == 0)
|
||||||
|
return getRawShort16();
|
||||||
|
else if (b== 1)
|
||||||
|
return getRawChar8();
|
||||||
|
else if (b == 2)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
/**Reads compresed Short (max. 16 + 2 bits) little-endian order, returns a signed 16 bits (BS) **/
|
||||||
|
dint16 dwgBuffer::getSBitShort(){
|
||||||
|
duint8 b = get2Bits();
|
||||||
|
if (b == 0)
|
||||||
|
return (dint16)getRawShort16();
|
||||||
|
else if (b== 1)
|
||||||
|
return (dint16)getRawChar8();
|
||||||
|
else if (b == 2)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads compresed 32 bits Int (max. 32 + 2 bits) little-endian order, returns a signed 32 bits (BL) **/
|
||||||
|
//to be written
|
||||||
|
dint32 dwgBuffer::getBitLong(){
|
||||||
|
dint8 b = get2Bits();
|
||||||
|
if (b == 0)
|
||||||
|
return getRawLong32();
|
||||||
|
else if (b== 1)
|
||||||
|
return getRawChar8();
|
||||||
|
else //if (b == 2)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads compresed 64 bits Int (max. 56 + 3 bits) little-endian order, returns a unsigned 64 bits (BLL) **/
|
||||||
|
duint64 dwgBuffer::getBitLongLong(){
|
||||||
|
dint8 b = get3Bits();
|
||||||
|
duint64 ret=0;
|
||||||
|
for (duint8 i=0; i<b; i++){
|
||||||
|
ret = ret << 8;
|
||||||
|
ret |= getRawChar8();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads compresed Double (max. 64 + 2 bits) returns a floating point double of 64 bits (BD) **/
|
||||||
|
double dwgBuffer::getBitDouble(){
|
||||||
|
dint8 b = get2Bits();
|
||||||
|
if (b == 1)
|
||||||
|
return 1.0;
|
||||||
|
else if (b == 0){
|
||||||
|
duint8 buffer[8];
|
||||||
|
if (bitPos != 0) {
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
buffer[i] = getRawChar8();
|
||||||
|
} else {
|
||||||
|
filestr->read (buffer,8);
|
||||||
|
}
|
||||||
|
double* ret = reinterpret_cast<double*>( buffer );
|
||||||
|
return *ret;
|
||||||
|
}
|
||||||
|
// if (b == 2)
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads 3 compresed Double (max. 64 + 2 bits) returns a DRW_Coord of floating point double of 64 bits (3BD) **/
|
||||||
|
DRW_Coord dwgBuffer::get3BitDouble(){
|
||||||
|
DRW_Coord crd;
|
||||||
|
crd.x = getBitDouble();
|
||||||
|
crd.y = getBitDouble();
|
||||||
|
crd.z = getBitDouble();
|
||||||
|
return crd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads raw char 8 bits returns a unsigned char (RC) **/
|
||||||
|
duint8 dwgBuffer::getRawChar8(){
|
||||||
|
duint8 ret;
|
||||||
|
duint8 buffer;
|
||||||
|
filestr->read (&buffer,1);
|
||||||
|
if (bitPos == 0)
|
||||||
|
return buffer;
|
||||||
|
else {
|
||||||
|
ret = currByte << bitPos;
|
||||||
|
currByte = buffer;
|
||||||
|
ret = ret | (currByte >>(8 - bitPos));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads raw short 16 bits little-endian order, returns a unsigned short (RS) **/
|
||||||
|
duint16 dwgBuffer::getRawShort16(){
|
||||||
|
duint8 buffer[2];
|
||||||
|
duint16 ret;
|
||||||
|
|
||||||
|
filestr->read (buffer,2);
|
||||||
|
if (bitPos == 0) {
|
||||||
|
/* no offset directly swap bytes for little-endian */
|
||||||
|
ret = (buffer[1] << 8) | (buffer[0] & 0x00FF);
|
||||||
|
} else {
|
||||||
|
ret = (buffer[0] << 8) | (buffer[1] & 0x00FF);
|
||||||
|
/* apply offset */
|
||||||
|
ret = ret >> (8 - bitPos);
|
||||||
|
ret = ret | (currByte << (8 + bitPos));
|
||||||
|
currByte = buffer[1];
|
||||||
|
/* swap bytes for little-endian */
|
||||||
|
ret = (ret << 8) | (ret >> 8);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads raw double IEEE standard 64 bits returns a double (RD) **/
|
||||||
|
double dwgBuffer::getRawDouble(){
|
||||||
|
duint8 buffer[8];
|
||||||
|
if (bitPos == 0)
|
||||||
|
filestr->read (buffer,8);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
buffer[i] = getRawChar8();
|
||||||
|
}
|
||||||
|
double* nOffset = reinterpret_cast<double*>( buffer );
|
||||||
|
return *nOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads 2 raw double IEEE standard 64 bits returns a DRW_Coord of floating point double 64 bits (2RD) **/
|
||||||
|
DRW_Coord dwgBuffer::get2RawDouble(){
|
||||||
|
DRW_Coord crd;
|
||||||
|
crd.x = getRawDouble();
|
||||||
|
crd.y = getRawDouble();
|
||||||
|
return crd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**Reads raw int 32 bits little-endian order, returns a unsigned int (RL) **/
|
||||||
|
duint32 dwgBuffer::getRawLong32(){
|
||||||
|
duint16 tmp1 = getRawShort16();
|
||||||
|
duint16 tmp2 = getRawShort16();
|
||||||
|
duint32 ret = (tmp2 << 16) | (tmp1 & 0x0000FFFF);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads raw int 64 bits little-endian order, returns a unsigned long long (RLL) **/
|
||||||
|
duint64 dwgBuffer::getRawLong64(){
|
||||||
|
duint32 tmp1 = getRawLong32();
|
||||||
|
duint64 tmp2 = getRawLong32();
|
||||||
|
duint64 ret = (tmp2 << 32) | (tmp1 & 0x00000000FFFFFFFF);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads modular unsigner int, char based, compresed form, little-endian order, returns a unsigned int (U-MC) **/
|
||||||
|
duint32 dwgBuffer::getUModularChar(){
|
||||||
|
std::vector<duint8> buffer;
|
||||||
|
duint32 result =0;
|
||||||
|
for (int i=0; i<4;i++){
|
||||||
|
duint8 b= getRawChar8();
|
||||||
|
buffer.push_back(b & 0x7F);
|
||||||
|
if (! (b & 0x80))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int offset = 0;
|
||||||
|
for (unsigned int i=0; i<buffer.size();i++){
|
||||||
|
result += buffer[i] << offset;
|
||||||
|
offset +=7;
|
||||||
|
}
|
||||||
|
//RLZ: WARNING!!! needed to verify on read handles
|
||||||
|
//result = result & 0x7F;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads modular int, char based, compresed form, little-endian order, returns a signed int (MC) **/
|
||||||
|
dint32 dwgBuffer::getModularChar(){
|
||||||
|
bool negative = false;
|
||||||
|
std::vector<dint8> buffer;
|
||||||
|
dint32 result =0;
|
||||||
|
for (int i=0; i<4;i++){
|
||||||
|
duint8 b= getRawChar8();
|
||||||
|
buffer.push_back(b & 0x7F);
|
||||||
|
if (! (b & 0x80))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dint8 b= buffer.back();
|
||||||
|
if (b & 0x40) {
|
||||||
|
negative = true;
|
||||||
|
buffer.pop_back();
|
||||||
|
buffer.push_back(b & 0x3F);
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
for (unsigned int i=0; i<buffer.size();i++){
|
||||||
|
result += buffer[i] << offset;
|
||||||
|
offset +=7;
|
||||||
|
}
|
||||||
|
if (negative)
|
||||||
|
result = -result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads modular int, short based, compresed form, little-endian order, returns a unsigned int (MC) **/
|
||||||
|
dint32 dwgBuffer::getModularShort(){
|
||||||
|
// bool negative = false;
|
||||||
|
std::vector<dint16> buffer;
|
||||||
|
dint32 result =0;
|
||||||
|
for (int i=0; i<2;i++){
|
||||||
|
duint16 b= getRawShort16();
|
||||||
|
buffer.push_back(b & 0x7FFF);
|
||||||
|
if (! (b & 0x8000))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//only positive ?
|
||||||
|
/* dint8 b= buffer.back();
|
||||||
|
if (! (b & 0x40)) {
|
||||||
|
negative = true;
|
||||||
|
buffer.pop_back();
|
||||||
|
buffer.push_back(b & 0x3F);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
for (unsigned int i=0; i<buffer.size();i++){
|
||||||
|
result += buffer[i] << offset;
|
||||||
|
offset +=15;
|
||||||
|
}
|
||||||
|
/* if (negative)
|
||||||
|
result = -result;*/
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgHandle dwgBuffer::getHandle(){ //H
|
||||||
|
dwgHandle hl;
|
||||||
|
duint8 data = getRawChar8();
|
||||||
|
hl.code = (data >> 4) & 0x0F;
|
||||||
|
hl.size = data & 0x0F;
|
||||||
|
hl.ref=0;
|
||||||
|
for (int i=0; i< hl.size;i++){
|
||||||
|
hl.ref = (hl.ref << 8) | getRawChar8();
|
||||||
|
}
|
||||||
|
return hl;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgHandle dwgBuffer::getOffsetHandle(duint32 href){ //H
|
||||||
|
dwgHandle hl = getHandle();
|
||||||
|
|
||||||
|
if (hl.code > 5){
|
||||||
|
if (hl.code == 0x0C)
|
||||||
|
hl.ref = href - hl.ref;
|
||||||
|
else if (hl.code == 0x0A)
|
||||||
|
hl.ref = href + hl.ref;
|
||||||
|
else if (hl.code == 0x08)
|
||||||
|
hl.ref = href - 1;
|
||||||
|
else if (hl.code == 0x06)
|
||||||
|
hl.ref = href + 1;
|
||||||
|
//all are soft pointer reference change to 7 (without offset)
|
||||||
|
hl.code = 7;
|
||||||
|
}
|
||||||
|
return hl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//internal until 2004
|
||||||
|
std::string dwgBuffer::get8bitStr(){
|
||||||
|
duint16 textSize = getBitShort();
|
||||||
|
if (textSize == 0)
|
||||||
|
return std::string();
|
||||||
|
duint8 *tmpBuffer = new duint8[textSize];
|
||||||
|
bool good = getBytes(tmpBuffer, textSize);
|
||||||
|
if (!good)
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
/* filestr->read (buffer,textSize);
|
||||||
|
if (!filestr->good())
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
duint8 tmp;
|
||||||
|
if (bitPos != 0){
|
||||||
|
for (int i=0; i<textSize;i++){
|
||||||
|
tmp = buffer[i];
|
||||||
|
buffer[i] = (currByte << bitPos) | (tmp >> (8 - bitPos));
|
||||||
|
currByte = tmp;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
std::string str(reinterpret_cast<char*>(tmpBuffer), textSize);
|
||||||
|
delete[]tmpBuffer;
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//internal since 2007 //pending: are 2 bytes null terminated??
|
||||||
|
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||||
|
std::string dwgBuffer::get16bitStr(duint16 textSize, bool nullTerm){
|
||||||
|
if (textSize == 0)
|
||||||
|
return std::string();
|
||||||
|
textSize *=2;
|
||||||
|
duint16 ts = textSize;
|
||||||
|
if (nullTerm)
|
||||||
|
ts += 2;
|
||||||
|
duint8 *tmpBuffer = new duint8[textSize + 2];
|
||||||
|
bool good = getBytes(tmpBuffer, ts);
|
||||||
|
if (!good)
|
||||||
|
return std::string();
|
||||||
|
if (!nullTerm) {
|
||||||
|
tmpBuffer[textSize] = '\0';
|
||||||
|
tmpBuffer[textSize + 1] = '\0';
|
||||||
|
}
|
||||||
|
std::string str(reinterpret_cast<char*>(tmpBuffer), ts);
|
||||||
|
delete[]tmpBuffer;
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//T 8 bit text converted from codepage to utf8
|
||||||
|
std::string dwgBuffer::getCP8Text(){
|
||||||
|
std::string strData;
|
||||||
|
strData = get8bitStr();//RLZ correct these function
|
||||||
|
if (decoder == NULL)
|
||||||
|
return strData;
|
||||||
|
|
||||||
|
return decoder->toUtf8(strData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TU unicode 16 bit (UCS) text converted to utf8
|
||||||
|
/**Reads 2-bytes char (UCS2, NULL terminated) and convert to std::string (only for Latin-1)
|
||||||
|
ts= total input size in bytes.
|
||||||
|
**/
|
||||||
|
std::string dwgBuffer::getUCSStr(duint16 ts){
|
||||||
|
std::string strData;
|
||||||
|
if (ts<4) //at least 1 char
|
||||||
|
return std::string();
|
||||||
|
strData = get16bitStr(ts/2, false);
|
||||||
|
if (decoder == NULL)
|
||||||
|
return strData;
|
||||||
|
|
||||||
|
return decoder->toUtf8(strData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TU unicode 16 bit (UCS) text converted to utf8
|
||||||
|
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||||
|
std::string dwgBuffer::getUCSText(bool nullTerm){
|
||||||
|
std::string strData;
|
||||||
|
duint16 ts = getBitShort();
|
||||||
|
if (ts == 0)
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
strData = get16bitStr(ts, nullTerm);
|
||||||
|
if (decoder == NULL)
|
||||||
|
return strData;
|
||||||
|
|
||||||
|
return decoder->toUtf8(strData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//RLZ: read a T or TU if version is 2007+
|
||||||
|
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||||
|
std::string dwgBuffer::getVariableText(DRW::Version v, bool nullTerm){//TV
|
||||||
|
if (v > DRW::AC1018)
|
||||||
|
return getUCSText(nullTerm);
|
||||||
|
return getCP8Text();
|
||||||
|
}
|
||||||
|
duint16 dwgBuffer::getObjType(DRW::Version v){//OT
|
||||||
|
if (v > DRW::AC1021) {
|
||||||
|
duint8 b = get2Bits();
|
||||||
|
if (b == 0)
|
||||||
|
return getRawChar8();
|
||||||
|
else if (b== 1){
|
||||||
|
return (getRawChar8() + 0x01F0);
|
||||||
|
} else //b == 2
|
||||||
|
return getRawShort16();
|
||||||
|
}
|
||||||
|
return getBitShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bit Extrusion
|
||||||
|
* For R2000+, this is a single bit, If the single bit is 1,
|
||||||
|
* the extrusion value is assumed to be 0,0,1 and no explicit
|
||||||
|
* extrusion is stored. If the single bit is 0, then it will
|
||||||
|
* be followed by 3BD.
|
||||||
|
* For R13-R14 this is 3BD.
|
||||||
|
*/
|
||||||
|
DRW_Coord dwgBuffer::getExtrusion(bool b_R2000_style) {
|
||||||
|
DRW_Coord ext(0.0,0.0,1.0);
|
||||||
|
if ( b_R2000_style )
|
||||||
|
/* If the bit is one, the extrusion value is assumed to be 0,0,1*/
|
||||||
|
if ( getBit() == 1 )
|
||||||
|
return ext;
|
||||||
|
/*R13-R14 or bit == 0*/
|
||||||
|
ext.x = getBitDouble();
|
||||||
|
ext.y = getBitDouble();
|
||||||
|
ext.z = getBitDouble();
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Reads compresed Double with default (max. 64 + 2 bits) returns a floating point double of 64 bits (DD) **/
|
||||||
|
double dwgBuffer::getDefaultDouble(double d){
|
||||||
|
dint8 b = get2Bits();
|
||||||
|
if (b == 0)
|
||||||
|
return d;
|
||||||
|
else if (b == 1){
|
||||||
|
duint8 buffer[4];
|
||||||
|
char *tmp;
|
||||||
|
if (bitPos != 0) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
buffer[i] = getRawChar8();
|
||||||
|
} else {
|
||||||
|
filestr->read (buffer,4);
|
||||||
|
}
|
||||||
|
tmp = reinterpret_cast<char*>(&d);
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
tmp[i] = buffer[i];
|
||||||
|
double ret = *reinterpret_cast<double*>( tmp );
|
||||||
|
return ret;
|
||||||
|
} else if (b == 2){
|
||||||
|
duint8 buffer[6];
|
||||||
|
char *tmp;
|
||||||
|
if (bitPos != 0) {
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
buffer[i] = getRawChar8();
|
||||||
|
} else {
|
||||||
|
filestr->read (buffer,6);
|
||||||
|
}
|
||||||
|
tmp = reinterpret_cast<char*>(&d);
|
||||||
|
for (int i = 2; i < 6; i++)
|
||||||
|
tmp[i-2] = buffer[i];
|
||||||
|
tmp[4] = buffer[0];
|
||||||
|
tmp[5] = buffer[1];
|
||||||
|
double ret = *reinterpret_cast<double*>( tmp );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// if (b == 3) return a full raw double
|
||||||
|
return getRawDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* BitThickness
|
||||||
|
* For R13-R14, this is a BD.
|
||||||
|
* For R2000+, this is a single bit, If the bit is one,
|
||||||
|
* the thickness value is assumed to be 0.0, if not a BD follow
|
||||||
|
*/
|
||||||
|
double dwgBuffer::getThickness(bool b_R2000_style) {
|
||||||
|
if ( b_R2000_style )
|
||||||
|
/* If the bit is one, the thickness value is assumed to be 0.0.*/
|
||||||
|
if ( getBit() == 1 )
|
||||||
|
return 0.0;
|
||||||
|
/*R13-R14 or bit == 0*/
|
||||||
|
return getBitDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CmColor (CMC)
|
||||||
|
* For R15 and earlier call directly BS as ACIS color.
|
||||||
|
* For R2004+, can be CMC or ENC
|
||||||
|
* RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS
|
||||||
|
*/
|
||||||
|
duint32 dwgBuffer::getCmColor(DRW::Version v) {
|
||||||
|
if (v < DRW::AC1018) //2000-
|
||||||
|
return getSBitShort();
|
||||||
|
duint16 idx = getBitShort();
|
||||||
|
duint32 rgb = getBitLong();
|
||||||
|
duint8 cb = getRawChar8();
|
||||||
|
duint8 type = rgb >> 24;
|
||||||
|
DRW_DBG("\ntype COLOR: "); DRW_DBGH(type);
|
||||||
|
DRW_DBG("\nindex COLOR: "); DRW_DBGH(idx);
|
||||||
|
DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||||
|
DRW_DBG("\nbyte COLOR: "); DRW_DBGH(cb);
|
||||||
|
if (cb&1){
|
||||||
|
std::string colorName = getVariableText(v, false);
|
||||||
|
DRW_DBG("\ncolorName: "); DRW_DBG(colorName);
|
||||||
|
}
|
||||||
|
if (cb&2){
|
||||||
|
std::string bookName = getVariableText(v, false);
|
||||||
|
DRW_DBG("\nbookName: "); DRW_DBG(bookName);
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
|
case 0xC0:
|
||||||
|
return 256;//ByLayer
|
||||||
|
break;
|
||||||
|
case 0xC1:
|
||||||
|
return 0;//ByBlock
|
||||||
|
break;
|
||||||
|
case 0xC2:
|
||||||
|
return 256;//RGB RLZ TODO
|
||||||
|
break;
|
||||||
|
case 0xC3:
|
||||||
|
return rgb&0xFF;//ACIS
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//check cb if strings follows RLZ TODO
|
||||||
|
return 256; //default return ByLayer
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EnColor (ENC)
|
||||||
|
* For R15 and earlier call directly BS as ACIS color.
|
||||||
|
* For R2004+, can be CMC or ENC
|
||||||
|
* RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS
|
||||||
|
*/
|
||||||
|
duint32 dwgBuffer::getEnColor(DRW::Version v) {
|
||||||
|
if (v < DRW::AC1018) //2000-
|
||||||
|
return getSBitShort();
|
||||||
|
duint32 rgb = 0;
|
||||||
|
duint32 cb = 0;
|
||||||
|
duint16 idx = getBitShort();
|
||||||
|
DRW_DBG("idx reads COLOR: "); DRW_DBGH(idx);
|
||||||
|
duint16 flags = idx>>8;
|
||||||
|
idx = idx & 0x1FF; //RLZ: warning this is correct?
|
||||||
|
DRW_DBG("\nflag COLOR: "); DRW_DBGH(flags);
|
||||||
|
DRW_DBG(", index COLOR: "); DRW_DBGH(idx);
|
||||||
|
// if (flags & 0x80) {
|
||||||
|
// rgb = getBitLong();
|
||||||
|
// DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||||
|
// }
|
||||||
|
if (flags & 0x20) {
|
||||||
|
cb = getBitLong();
|
||||||
|
DRW_DBG("\nTransparency COLOR: "); DRW_DBGH(cb);
|
||||||
|
}
|
||||||
|
if (flags & 0x40)
|
||||||
|
DRW_DBG("\nacdbColor COLOR are present");
|
||||||
|
else {
|
||||||
|
if (flags & 0x80) {
|
||||||
|
rgb = getBitLong();
|
||||||
|
DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if (flags & 0x80)
|
||||||
|
return getBitLong();*/
|
||||||
|
|
||||||
|
return idx; //default return ByLayer
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**Reads raw short 16 bits big-endian order, returns a unsigned short crc & size **/
|
||||||
|
duint16 dwgBuffer::getBERawShort16(){
|
||||||
|
char buffer[2];
|
||||||
|
buffer[0] = getRawChar8();
|
||||||
|
buffer[1] = getRawChar8();
|
||||||
|
duint16 size = (buffer[0] << 8) | (buffer[1] & 0xFF);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reads "size" bytes and stores in "buf" return false if fail */
|
||||||
|
bool dwgBuffer::getBytes(unsigned char *buf, int size){
|
||||||
|
duint8 tmp;
|
||||||
|
filestr->read (buf,size);
|
||||||
|
if (!filestr->good())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (bitPos != 0){
|
||||||
|
for (int i=0; i<size;i++){
|
||||||
|
tmp = buf[i];
|
||||||
|
buf[i] = (currByte << bitPos) | (tmp >> (8 - bitPos));
|
||||||
|
currByte = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint16 dwgBuffer::crc8(duint16 dx,dint32 start,dint32 end){
|
||||||
|
int pos = filestr->getPos();
|
||||||
|
filestr->setPos(start);
|
||||||
|
int n = end-start;
|
||||||
|
duint8 *tmpBuf = new duint8[n];
|
||||||
|
duint8 *p = tmpBuf;
|
||||||
|
filestr->read (tmpBuf,n);
|
||||||
|
filestr->setPos(pos);
|
||||||
|
if (!filestr->good())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
duint8 al;
|
||||||
|
|
||||||
|
while (n-- > 0) {
|
||||||
|
al = (duint8)((*p) ^ ((dint8)(dx & 0xFF)));
|
||||||
|
dx = (dx>>8) & 0xFF;
|
||||||
|
dx = dx ^ crctable[al & 0xFF];
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
delete[]tmpBuf;
|
||||||
|
return(dx);
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgBuffer::crc32(duint32 seed,dint32 start,dint32 end){
|
||||||
|
int pos = filestr->getPos();
|
||||||
|
filestr->setPos(start);
|
||||||
|
int n = end-start;
|
||||||
|
duint8 *tmpBuf = new duint8[n];
|
||||||
|
duint8 *p = tmpBuf;
|
||||||
|
filestr->read (tmpBuf,n);
|
||||||
|
filestr->setPos(pos);
|
||||||
|
if (!filestr->good())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
duint32 invertedCrc = ~seed;
|
||||||
|
while (n-- > 0) {
|
||||||
|
duint8 data = *p++;
|
||||||
|
invertedCrc = (invertedCrc >> 8) ^ crc32Table[(invertedCrc ^ data) & 0xff];
|
||||||
|
}
|
||||||
|
delete[]tmpBuf;
|
||||||
|
return ~invertedCrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*std::string dwgBuffer::getBytes(int size){
|
||||||
|
char buffer[size];
|
||||||
|
char tmp;
|
||||||
|
filestr->read (buffer,size);
|
||||||
|
if (!filestr->good())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (bitPos != 0){
|
||||||
|
for (int i=0; i<=size;i++){
|
||||||
|
tmp = buffer[i];
|
||||||
|
buffer[i] = (currByte << bitPos) | (tmp >> (8 - bitPos));
|
||||||
|
currByte = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string st;
|
||||||
|
for (int i=0; i<size;i++) {
|
||||||
|
st.push_back(buffer[i]);
|
||||||
|
}
|
||||||
|
return st;
|
||||||
|
// return std::string(buffer);
|
||||||
|
}*/
|
155
src/libs/vdxf/libdxfrw/intern/dwgbuffer.h
Normal file
155
src/libs/vdxf/libdxfrw/intern/dwgbuffer.h
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGBUFFER_H
|
||||||
|
#define DWGBUFFER_H
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include "../drw_base.h"
|
||||||
|
|
||||||
|
class DRW_Coord;
|
||||||
|
class DRW_TextCodec;
|
||||||
|
|
||||||
|
class dwgBasicStream{
|
||||||
|
protected:
|
||||||
|
dwgBasicStream(){}
|
||||||
|
public:
|
||||||
|
virtual ~dwgBasicStream(){}
|
||||||
|
virtual bool read(duint8* s, duint64 n) = 0;
|
||||||
|
virtual duint64 size() = 0;
|
||||||
|
virtual duint64 getPos() = 0;
|
||||||
|
virtual bool setPos(duint64 p) = 0;
|
||||||
|
virtual bool good() = 0;
|
||||||
|
virtual dwgBasicStream* clone() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class dwgFileStream: public dwgBasicStream{
|
||||||
|
public:
|
||||||
|
dwgFileStream(std::istream *s){
|
||||||
|
stream =s;
|
||||||
|
stream->seekg (0, std::ios::end);
|
||||||
|
sz = stream->tellg();
|
||||||
|
stream->seekg(0, std::ios_base::beg);
|
||||||
|
}
|
||||||
|
virtual ~dwgFileStream(){}
|
||||||
|
virtual bool read(duint8* s, duint64 n);
|
||||||
|
virtual duint64 size(){return sz;}
|
||||||
|
virtual duint64 getPos(){return stream->tellg();}
|
||||||
|
virtual bool setPos(duint64 p);
|
||||||
|
virtual bool good(){return stream->good();}
|
||||||
|
virtual dwgBasicStream* clone(){return new dwgFileStream(stream);}
|
||||||
|
private:
|
||||||
|
std::istream *stream;
|
||||||
|
duint64 sz;
|
||||||
|
};
|
||||||
|
|
||||||
|
class dwgCharStream: public dwgBasicStream{
|
||||||
|
public:
|
||||||
|
dwgCharStream(duint8 *buf, int s){
|
||||||
|
stream =buf;
|
||||||
|
sz = s;
|
||||||
|
pos = 0;
|
||||||
|
isOk = true;
|
||||||
|
}
|
||||||
|
virtual ~dwgCharStream(){}
|
||||||
|
virtual bool read(duint8* s, duint64 n);
|
||||||
|
virtual duint64 size(){return sz;}
|
||||||
|
virtual duint64 getPos(){return pos;}
|
||||||
|
virtual bool setPos(duint64 p);
|
||||||
|
virtual bool good(){return isOk;}
|
||||||
|
virtual dwgBasicStream* clone(){return new dwgCharStream(stream, sz);}
|
||||||
|
private:
|
||||||
|
duint8 *stream;
|
||||||
|
duint64 sz;
|
||||||
|
duint64 pos;
|
||||||
|
bool isOk;
|
||||||
|
};
|
||||||
|
|
||||||
|
class dwgBuffer {
|
||||||
|
public:
|
||||||
|
dwgBuffer(std::istream *stream, DRW_TextCodec *decoder = NULL);
|
||||||
|
dwgBuffer(duint8 *buf, int size, DRW_TextCodec *decoder= NULL);
|
||||||
|
dwgBuffer( const dwgBuffer& org );
|
||||||
|
dwgBuffer& operator=( const dwgBuffer& org );
|
||||||
|
~dwgBuffer();
|
||||||
|
duint64 size(){return filestr->size();}
|
||||||
|
bool setPosition(duint64 pos);
|
||||||
|
duint64 getPosition();
|
||||||
|
void resetPosition(){setPosition(0); setBitPos(0);}
|
||||||
|
void setBitPos(duint8 pos);
|
||||||
|
duint8 getBitPos(){return bitPos;}
|
||||||
|
bool moveBitPos(dint32 size);
|
||||||
|
|
||||||
|
duint8 getBit(); //B
|
||||||
|
bool getBoolBit(); //B as bool
|
||||||
|
duint8 get2Bits(); //BB
|
||||||
|
duint8 get3Bits(); //3B
|
||||||
|
duint16 getBitShort(); //BS
|
||||||
|
dint16 getSBitShort(); //BS
|
||||||
|
dint32 getBitLong(); //BL
|
||||||
|
duint64 getBitLongLong(); //BLL (R24)
|
||||||
|
double getBitDouble(); //BD
|
||||||
|
//2BD => call BD 2 times
|
||||||
|
DRW_Coord get3BitDouble(); //3BD
|
||||||
|
duint8 getRawChar8(); //RC
|
||||||
|
duint16 getRawShort16(); //RS
|
||||||
|
double getRawDouble(); //RD
|
||||||
|
duint32 getRawLong32(); //RL
|
||||||
|
duint64 getRawLong64(); //RLL
|
||||||
|
DRW_Coord get2RawDouble(); //2RD
|
||||||
|
//3RD => call RD 3 times
|
||||||
|
duint32 getUModularChar(); //UMC, unsigned for offsets in 1015
|
||||||
|
dint32 getModularChar(); //MC
|
||||||
|
dint32 getModularShort(); //MS
|
||||||
|
dwgHandle getHandle(); //H
|
||||||
|
dwgHandle getOffsetHandle(duint32 href); //H converted to hard
|
||||||
|
UTF8STRING getVariableText(DRW::Version v, bool nullTerm = true); //TV => call TU for 2007+ or T for previous versions
|
||||||
|
UTF8STRING getCP8Text(); //T 8 bit text converted from codepage to utf8
|
||||||
|
UTF8STRING getUCSText(bool nullTerm = true); //TU unicode 16 bit (UCS) text converted to utf8
|
||||||
|
UTF8STRING getUCSStr(duint16 ts);
|
||||||
|
|
||||||
|
duint16 getObjType(DRW::Version v); //OT
|
||||||
|
|
||||||
|
//X, U, SN,
|
||||||
|
|
||||||
|
DRW_Coord getExtrusion(bool b_R2000_style); //BE
|
||||||
|
double getDefaultDouble(double d); //DD
|
||||||
|
double getThickness(bool b_R2000_style);//BT
|
||||||
|
//3DD
|
||||||
|
duint32 getCmColor(DRW::Version v); //CMC
|
||||||
|
duint32 getEnColor(DRW::Version v); //ENC
|
||||||
|
//TC
|
||||||
|
|
||||||
|
duint16 getBERawShort16(); //RS big-endian order
|
||||||
|
|
||||||
|
bool isGood(){return filestr->good();}
|
||||||
|
bool getBytes(duint8 *buf, int size);
|
||||||
|
int numRemainingBytes(){return (maxSize- filestr->getPos());}
|
||||||
|
|
||||||
|
duint16 crc8(duint16 dx,dint32 start,dint32 end);
|
||||||
|
duint32 crc32(duint32 seed,dint32 start,dint32 end);
|
||||||
|
|
||||||
|
// duint8 getCurrByte(){return currByte;}
|
||||||
|
DRW_TextCodec *decoder;
|
||||||
|
|
||||||
|
private:
|
||||||
|
dwgBasicStream *filestr;
|
||||||
|
int maxSize;
|
||||||
|
duint8 currByte;
|
||||||
|
duint8 bitPos;
|
||||||
|
|
||||||
|
UTF8STRING get8bitStr();
|
||||||
|
UTF8STRING get16bitStr(duint16 textSize, bool nullTerm = true);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGBUFFER_H
|
1294
src/libs/vdxf/libdxfrw/intern/dwgreader.cpp
Normal file
1294
src/libs/vdxf/libdxfrw/intern/dwgreader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
203
src/libs/vdxf/libdxfrw/intern/dwgreader.h
Normal file
203
src/libs/vdxf/libdxfrw/intern/dwgreader.h
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER_H
|
||||||
|
#define DWGREADER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "dwgutil.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
class objHandle{
|
||||||
|
public:
|
||||||
|
objHandle(){ handle = type = loc = 0; }
|
||||||
|
objHandle(duint32 t, duint32 h, duint32 l){
|
||||||
|
type = t;
|
||||||
|
handle = h;
|
||||||
|
loc = l;
|
||||||
|
}
|
||||||
|
duint32 type;
|
||||||
|
duint32 handle;
|
||||||
|
duint32 loc;
|
||||||
|
};
|
||||||
|
|
||||||
|
//until 2000 = 2000-
|
||||||
|
//since 2004 except 2007 = 2004+
|
||||||
|
// 2007 = 2007
|
||||||
|
// pages of section
|
||||||
|
/* 2000-: No pages, only sections
|
||||||
|
* 2004+: Id, page number (index)
|
||||||
|
* size, size of page in file stream
|
||||||
|
* address, address in file stream
|
||||||
|
* dataSize, data size for this page
|
||||||
|
* startOffset, start offset for this page
|
||||||
|
* cSize, compresed size of data
|
||||||
|
* uSize, uncompresed size of data
|
||||||
|
* 2007: page Id, pageCount & pages
|
||||||
|
* size, size in file
|
||||||
|
* dataSize
|
||||||
|
* startOffset, start position in decompresed data stream
|
||||||
|
* cSize, compresed size of data
|
||||||
|
* uSize, uncompresed size of data
|
||||||
|
* address, address in file stream
|
||||||
|
* */
|
||||||
|
class dwgPageInfo {
|
||||||
|
public:
|
||||||
|
dwgPageInfo(){}
|
||||||
|
dwgPageInfo(duint64 i, duint64 ad, duint32 sz){
|
||||||
|
Id=i; address=ad; size=sz;
|
||||||
|
}
|
||||||
|
~dwgPageInfo(){}
|
||||||
|
duint64 Id;
|
||||||
|
duint64 address; //in file stream, for rd18, rd21
|
||||||
|
duint64 size; //in file stream, for rd18, rd21
|
||||||
|
duint64 dataSize; //for rd18, rd21
|
||||||
|
duint32 startOffset; //for rd18, rd21
|
||||||
|
duint64 cSize; //compresed page size, for rd21
|
||||||
|
duint64 uSize; //uncompresed page size, for rd21
|
||||||
|
};
|
||||||
|
|
||||||
|
// sections of file
|
||||||
|
/* 2000-: No pages, only section Id, size & address in file
|
||||||
|
* 2004+: Id, Section Id
|
||||||
|
* size, total size of uncompresed data
|
||||||
|
* pageCount & pages, number of pages in section
|
||||||
|
* maxSize, max decompressed Size per page
|
||||||
|
* compresed, (1 = no, 2 = yes, normally 2)
|
||||||
|
* encrypted, (0 = no, 1 = yes, 2 = unknown)
|
||||||
|
* name, read & stored but not used
|
||||||
|
* 2007: same as 2004+ except encoding, saved in compresed field
|
||||||
|
* */
|
||||||
|
class dwgSectionInfo {
|
||||||
|
public:
|
||||||
|
dwgSectionInfo(){
|
||||||
|
compresed = 1;//1=no, 2=yes
|
||||||
|
encrypted = 0;//???
|
||||||
|
pageCount = 0;
|
||||||
|
Id=-1;
|
||||||
|
}
|
||||||
|
~dwgSectionInfo(){}
|
||||||
|
dint32 Id; //section Id, 2000- rd15 rd18
|
||||||
|
std::string name; //section name rd18
|
||||||
|
duint32 compresed;//is compresed? 1=no, 2=yes rd18, rd21(encoding)
|
||||||
|
duint32 encrypted;//encrypted (doc: 0=no, 1=yes, 2=unkn) on read: objects 0 and encrypted yes rd18
|
||||||
|
std::map<duint32, dwgPageInfo >pages;//index, size, offset
|
||||||
|
duint64 size;//size of section, 2000- rd15, rd18, rd21 (data size)
|
||||||
|
duint64 pageCount; //number of pages (dwgPageInfo) in section rd18, rd21
|
||||||
|
duint64 maxSize; //max decompressed size (needed??) rd18 rd21
|
||||||
|
duint64 address; //address (seek) , 2000-
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Class to handle dwg obj control entries
|
||||||
|
/*!
|
||||||
|
* Class to handle dwg obj control entries
|
||||||
|
* @author Rallaz
|
||||||
|
*/
|
||||||
|
class DRW_ObjControl : public DRW_TableEntry {
|
||||||
|
public:
|
||||||
|
DRW_ObjControl() { reset();}
|
||||||
|
|
||||||
|
void reset(){
|
||||||
|
}
|
||||||
|
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||||
|
std::list<duint32>hadlesList;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class dwgReader {
|
||||||
|
friend class dwgR;
|
||||||
|
public:
|
||||||
|
dwgReader(std::istream *stream, dwgR *p){
|
||||||
|
fileBuf = new dwgBuffer(stream);
|
||||||
|
parent = p;
|
||||||
|
decoder.setVersion(DRW::AC1021, false);//default 2007 in utf8(no convert)
|
||||||
|
decoder.setCodePage("UTF-16", false);
|
||||||
|
// blockCtrl=0; //RLZ: temporary
|
||||||
|
// blockCtrl=layerCtrl=styleCtrl=linetypeCtrl=viewCtrl=0;
|
||||||
|
// ucsCtrl=vportCtrl=appidCtrl=dimstyleCtrl=vpEntHeaderCtrl=0;
|
||||||
|
nextEntLink = prevEntLink = 0;
|
||||||
|
maintenanceVersion=0;
|
||||||
|
}
|
||||||
|
virtual ~dwgReader();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool readMetaData() = 0;
|
||||||
|
virtual bool readPreview(){return false;}
|
||||||
|
virtual bool readFileHeader() = 0;
|
||||||
|
virtual bool readDwgHeader(DRW_Header& hdr)=0;
|
||||||
|
virtual bool readDwgClasses() = 0;
|
||||||
|
virtual bool readDwgHandles() = 0;
|
||||||
|
virtual bool readDwgTables(DRW_Header& hdr)=0;
|
||||||
|
virtual bool readDwgBlocks(DRW_Interface& intfa) = 0;
|
||||||
|
virtual bool readDwgEntities(DRW_Interface& intfa) = 0;
|
||||||
|
virtual bool readDwgObjects(DRW_Interface& intfa) = 0;
|
||||||
|
|
||||||
|
virtual bool readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa);
|
||||||
|
bool readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa);
|
||||||
|
void parseAttribs(DRW_Entity* e);
|
||||||
|
std::string findTableName(DRW::TTYPE table, dint32 handle);
|
||||||
|
|
||||||
|
void setCodePage(std::string *c){decoder.setCodePage(c, false);}
|
||||||
|
std::string getCodePage(){ return decoder.getCodePage();}
|
||||||
|
bool readDwgHeader(DRW_Header& hdr, dwgBuffer *buf, dwgBuffer *hBuf);
|
||||||
|
bool readDwgHandles(dwgBuffer *dbuf, duint32 offset, duint32 size);
|
||||||
|
bool readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf);
|
||||||
|
bool checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start);
|
||||||
|
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||||
|
bool readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||||
|
bool readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||||
|
bool readPlineVertex(DRW_Polyline& pline, dwgBuffer *dbuf);
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::map<duint32, objHandle>ObjectMap;
|
||||||
|
std::map<duint32, objHandle>objObjectMap; //stores the ojects & entities not read in readDwgEntities
|
||||||
|
std::map<duint32, objHandle>remainingMap; //stores the ojects & entities not read in all proces, for debug only
|
||||||
|
std::map<duint32, DRW_LType*> ltypemap;
|
||||||
|
std::map<duint32, DRW_Layer*> layermap;
|
||||||
|
std::map<duint32, DRW_Block*> blockmap;
|
||||||
|
std::map<duint32, DRW_Textstyle*> stylemap;
|
||||||
|
std::map<duint32, DRW_Dimstyle*> dimstylemap;
|
||||||
|
std::map<duint32, DRW_Vport*> vportmap;
|
||||||
|
std::map<duint32, DRW_Block_Record*> blockRecordmap;
|
||||||
|
std::map<duint32, DRW_AppId*> appIdmap;
|
||||||
|
// duint32 currBlock;
|
||||||
|
duint8 maintenanceVersion;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
dwgBuffer *fileBuf;
|
||||||
|
dwgR *parent;
|
||||||
|
DRW::Version version;
|
||||||
|
|
||||||
|
//seeker (position) for the beginning sentinel of the image data (R13 to R15)
|
||||||
|
duint32 previewImagePos;
|
||||||
|
|
||||||
|
//sections map
|
||||||
|
std::map<enum secEnum::DWGSection, dwgSectionInfo >sections;
|
||||||
|
std::map<duint32, DRW_Class*> classesmap;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DRW_TextCodec decoder;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// duint32 blockCtrl;
|
||||||
|
duint32 nextEntLink;
|
||||||
|
duint32 prevEntLink;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DWGREADER_H
|
198
src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp
Normal file
198
src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgreader15.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
bool dwgReader15::readMetaData() {
|
||||||
|
version = parent->getVersion();
|
||||||
|
decoder.setVersion(version, false);
|
||||||
|
DRW_DBG("dwgReader15::readMetaData\n");
|
||||||
|
if (! fileBuf->setPosition(13))
|
||||||
|
return false;
|
||||||
|
previewImagePos = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("previewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||||
|
/* MEASUREMENT system variable 2 bytes*/
|
||||||
|
duint16 meas = fileBuf->getRawShort16();
|
||||||
|
DRW_DBG("\nMEASUREMENT (0 = English, 1 = Metric)= "); DRW_DBG(meas);
|
||||||
|
duint16 cp = fileBuf->getRawShort16();
|
||||||
|
DRW_DBG("\ncodepage= "); DRW_DBG(cp); DRW_DBG("\n");
|
||||||
|
if (cp == 29) //TODO RLZ: locate wath code page and correct this
|
||||||
|
decoder.setCodePage("ANSI_1252", false);
|
||||||
|
if (cp == 30)
|
||||||
|
decoder.setCodePage("ANSI_1252", false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader15::readFileHeader() {
|
||||||
|
bool ret = true;
|
||||||
|
DRW_DBG("dwgReader15::readFileHeader\n");
|
||||||
|
if (! fileBuf->setPosition(21))
|
||||||
|
return false;
|
||||||
|
duint32 count = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("count records= "); DRW_DBG(count); DRW_DBG("\n");
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < count; i++) {
|
||||||
|
duint8 rec = fileBuf->getRawChar8();
|
||||||
|
duint32 address = fileBuf->getRawLong32();
|
||||||
|
duint32 size = fileBuf->getRawLong32();
|
||||||
|
dwgSectionInfo si;
|
||||||
|
si.Id = rec;
|
||||||
|
si.size = size;
|
||||||
|
si.address = address;
|
||||||
|
if (rec == 0) {
|
||||||
|
DRW_DBG("\nSection HEADERS address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::HEADER] = si;
|
||||||
|
} else if (rec == 1) {
|
||||||
|
DRW_DBG("\nSection CLASSES address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::CLASSES] = si;
|
||||||
|
} else if (rec == 2) {
|
||||||
|
DRW_DBG("\nSection OBJECTS (handles) address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::HANDLES] = si;
|
||||||
|
} else if (rec == 3) {
|
||||||
|
DRW_DBG("\nSection UNKNOWN address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::UNKNOWNS] = si;
|
||||||
|
} else if (rec == 4) {
|
||||||
|
DRW_DBG("\nSection R14DATA (AcDb:Template) address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::TEMPLATE] = si;
|
||||||
|
} else if (rec == 5) {
|
||||||
|
DRW_DBG("\nSection R14REC5 (AcDb:AuxHeader) address= ");
|
||||||
|
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||||
|
sections[secEnum::AUXHEADER] = si;
|
||||||
|
} else {
|
||||||
|
std::cerr << "\nUnsupported section number\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! fileBuf->isGood())
|
||||||
|
return false;
|
||||||
|
DRW_DBG("\nposition after read section locator records= "); DRW_DBG(fileBuf->getPosition());
|
||||||
|
DRW_DBG(", bit are= "); DRW_DBG(fileBuf->getBitPos());
|
||||||
|
duint32 ckcrc = fileBuf->crc8(0,0,fileBuf->getPosition());
|
||||||
|
DRW_DBG("\nfile header crc8 0 result= "); DRW_DBG(ckcrc);
|
||||||
|
switch (count){
|
||||||
|
case 3:
|
||||||
|
ckcrc = ckcrc ^ 0xA598;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
ckcrc = ckcrc ^ 0x8101;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ckcrc = ckcrc ^ 0x3CC4;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
ckcrc = ckcrc ^ 0x8461;
|
||||||
|
}
|
||||||
|
DRW_DBG("\nfile header crc8 xor result= "); DRW_DBG(ckcrc);
|
||||||
|
DRW_DBG("\nfile header CRC= "); DRW_DBG(fileBuf->getRawShort16());
|
||||||
|
DRW_DBG("\nfile header sentinel= ");
|
||||||
|
checkSentinel(fileBuf, secEnum::FILEHEADER, false);
|
||||||
|
|
||||||
|
DRW_DBG("\nposition after read file header sentinel= "); DRW_DBG(fileBuf->getPosition());
|
||||||
|
DRW_DBG(", bit are= "); DRW_DBG(fileBuf->getBitPos());
|
||||||
|
|
||||||
|
DRW_DBG("\ndwgReader15::readFileHeader END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader15::readDwgHeader(DRW_Header& hdr){
|
||||||
|
DRW_DBG("dwgReader15::readDwgHeader\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
if (!fileBuf->setPosition(si.address))
|
||||||
|
return false;
|
||||||
|
duint8 *tmpByteStr = new duint8[si.size];
|
||||||
|
fileBuf->getBytes(tmpByteStr, si.size);
|
||||||
|
dwgBuffer buff(tmpByteStr, si.size, &decoder);
|
||||||
|
DRW_DBG("Header section sentinel= ");
|
||||||
|
checkSentinel(&buff, secEnum::HEADER, true);
|
||||||
|
bool ret = dwgReader::readDwgHeader(hdr, &buff, &buff);
|
||||||
|
delete[]tmpByteStr;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader15::readDwgClasses(){
|
||||||
|
DRW_DBG("\ndwgReader15::readDwgClasses\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
if (!fileBuf->setPosition(si.address))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DRW_DBG("classes section sentinel= ");
|
||||||
|
checkSentinel(fileBuf, secEnum::CLASSES, true);
|
||||||
|
|
||||||
|
duint32 size = fileBuf->getRawLong32();
|
||||||
|
if (size != (si.size - 38)) {
|
||||||
|
DRW_DBG("\nWARNING dwgReader15::readDwgClasses size are "); DRW_DBG(size);
|
||||||
|
DRW_DBG(" and secSize - 38 are "); DRW_DBG(si.size - 38); DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
duint8 *tmpByteStr = new duint8[size];
|
||||||
|
fileBuf->getBytes(tmpByteStr, size);
|
||||||
|
dwgBuffer buff(tmpByteStr, size, &decoder);
|
||||||
|
size--; //reduce 1 byte instead of check pos + bitPos
|
||||||
|
while (size > buff.getPosition()) {
|
||||||
|
DRW_Class *cl = new DRW_Class();
|
||||||
|
cl->parseDwg(version, &buff, &buff);
|
||||||
|
classesmap[cl->classNum] = cl;
|
||||||
|
}
|
||||||
|
DRW_DBG("\nCRC: "); DRW_DBGH(fileBuf->getRawShort16());
|
||||||
|
DRW_DBG("\nclasses section end sentinel= ");
|
||||||
|
checkSentinel(fileBuf, secEnum::CLASSES, false);
|
||||||
|
bool ret = buff.isGood();
|
||||||
|
delete[]tmpByteStr;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader15::readDwgHandles() {
|
||||||
|
DRW_DBG("\ndwgReader15::readDwgHandles\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool ret = dwgReader::readDwgHandles(fileBuf, si.address, si.size);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** objects ************************/
|
||||||
|
/**
|
||||||
|
* Reads all the object referenced in the object map section of the DWG file
|
||||||
|
* (using their object file offsets)
|
||||||
|
*/
|
||||||
|
bool dwgReader15::readDwgTables(DRW_Header& hdr) {
|
||||||
|
bool ret = dwgReader::readDwgTables(hdr, fileBuf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads all the object referenced in the object map section of the DWG file
|
||||||
|
* (using their object file offsets)
|
||||||
|
*/
|
||||||
|
bool dwgReader15::readDwgBlocks(DRW_Interface& intfa) {
|
||||||
|
bool ret = true;
|
||||||
|
ret = dwgReader::readDwgBlocks(intfa, fileBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
47
src/libs/vdxf/libdxfrw/intern/dwgreader15.h
Normal file
47
src/libs/vdxf/libdxfrw/intern/dwgreader15.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER15_H
|
||||||
|
#define DWGREADER15_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "dwgreader.h"
|
||||||
|
|
||||||
|
class dwgReader15 : public dwgReader {
|
||||||
|
public:
|
||||||
|
dwgReader15(std::istream *stream, dwgR *p):dwgReader(stream, p){ }
|
||||||
|
virtual ~dwgReader15() {}
|
||||||
|
bool readMetaData();
|
||||||
|
bool readFileHeader();
|
||||||
|
bool readDwgHeader(DRW_Header& hdr);
|
||||||
|
bool readDwgClasses();
|
||||||
|
bool readDwgHandles();
|
||||||
|
bool readDwgTables(DRW_Header& hdr);
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa);
|
||||||
|
bool readDwgEntities(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
ret = dwgReader::readDwgEntities(intfa, fileBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool readDwgObjects(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
ret = dwgReader::readDwgObjects(intfa, fileBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DWGREADER15_H
|
594
src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp
Normal file
594
src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp
Normal file
|
@ -0,0 +1,594 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgreader18.h"
|
||||||
|
#include "dwgutil.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
void dwgReader18::genMagicNumber(){
|
||||||
|
int size =0x114;
|
||||||
|
duint8 *tmpMagicStr = new duint8[size];
|
||||||
|
duint8 *p = tmpMagicStr;
|
||||||
|
int rSeed =1;
|
||||||
|
while (size--) {
|
||||||
|
rSeed *= 0x343fd;
|
||||||
|
rSeed += 0x269ec3;
|
||||||
|
*p++ = static_cast<duint8>(rSeed >> 0x10);
|
||||||
|
}
|
||||||
|
int j = 0;
|
||||||
|
size =0x114;
|
||||||
|
for (int i=0; i< size;i++) {
|
||||||
|
DRW_DBGH(tmpMagicStr[i]);
|
||||||
|
if (j == 15) {
|
||||||
|
DRW_DBG("\n");
|
||||||
|
j = 0;
|
||||||
|
} else {
|
||||||
|
DRW_DBG(", ");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[]tmpMagicStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgReader18::checksum(duint32 seed, duint8* data, duint32 sz){
|
||||||
|
duint32 size = sz;
|
||||||
|
duint32 sum1 = seed & 0xffff;
|
||||||
|
duint32 sum2 = seed >> 0x10;
|
||||||
|
while (size != 0) {
|
||||||
|
// duint32 chunkSize = min(0x15b0, size);
|
||||||
|
duint32 chunkSize = 0x15b0 < size? 0x15b0:size;
|
||||||
|
size -= chunkSize;
|
||||||
|
for (duint32 i = 0; i < chunkSize; i++) {
|
||||||
|
sum1 += *data++;
|
||||||
|
sum2 += sum1;
|
||||||
|
}
|
||||||
|
sum1 %= 0xFFF1;
|
||||||
|
sum2 %= 0xFFF1;
|
||||||
|
}
|
||||||
|
return (sum2 << 0x10) | (sum1 & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
//called: Section page map: 0x41630e3b
|
||||||
|
void dwgReader18::parseSysPage(duint8 *decompSec, duint32 decompSize){
|
||||||
|
DRW_DBG("\nparseSysPage:\n ");
|
||||||
|
duint32 compSize = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("Compressed size= "); DRW_DBG(compSize); DRW_DBG(", "); DRW_DBGH(compSize);
|
||||||
|
DRW_DBG("\nCompression type= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
DRW_DBG("\nSection page checksum= "); DRW_DBGH(fileBuf->getRawLong32()); DRW_DBG("\n");
|
||||||
|
|
||||||
|
duint8 hdrData[20];
|
||||||
|
fileBuf->moveBitPos(-160);
|
||||||
|
fileBuf->getBytes(hdrData, 20);
|
||||||
|
for (duint8 i= 16; i<20; ++i)
|
||||||
|
hdrData[i]=0;
|
||||||
|
duint32 calcsH = checksum(0, hdrData, 20);
|
||||||
|
DRW_DBG("Calc hdr checksum= "); DRW_DBGH(calcsH);
|
||||||
|
duint8 *tmpCompSec = new duint8[compSize];
|
||||||
|
fileBuf->getBytes(tmpCompSec, compSize);
|
||||||
|
duint32 calcsD = checksum(calcsH, tmpCompSec, compSize);
|
||||||
|
DRW_DBG("\nCalc data checksum= "); DRW_DBGH(calcsD); DRW_DBG("\n");
|
||||||
|
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
for (unsigned int i=0, j=0; i< compSize;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)compSec[i]);
|
||||||
|
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||||
|
} else { DRW_DBG(", "); j++; }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
DRW_DBG("decompresing "); DRW_DBG(compSize); DRW_DBG(" bytes in "); DRW_DBG(decompSize); DRW_DBG(" bytes\n");
|
||||||
|
dwgCompressor comp;
|
||||||
|
comp.decompress18(tmpCompSec, decompSec, compSize, decompSize);
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
for (unsigned int i=0, j=0; i< decompSize;i++) {
|
||||||
|
DRW_DBGH( decompSec[i]);
|
||||||
|
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||||
|
} else { DRW_DBG(", "); j++; }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
delete[]tmpCompSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
//called ???: Section map: 0x4163003b
|
||||||
|
bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){
|
||||||
|
DRW_DBG("\nparseDataPage\n ");
|
||||||
|
objData = new duint8 [si.pageCount * si.maxSize];
|
||||||
|
|
||||||
|
for (std::map<duint32, dwgPageInfo>::iterator it=si.pages.begin(); it!=si.pages.end(); ++it){
|
||||||
|
dwgPageInfo pi = it->second;
|
||||||
|
if (!fileBuf->setPosition(pi.address))
|
||||||
|
return false;
|
||||||
|
//decript section header
|
||||||
|
duint8 hdrData[32];
|
||||||
|
fileBuf->getBytes(hdrData, 32);
|
||||||
|
dwgCompressor::decrypt18Hdr(hdrData, 32, pi.address);
|
||||||
|
DRW_DBG("Section "); DRW_DBG(si.name); DRW_DBG(" page header=\n");
|
||||||
|
for (unsigned int i=0, j=0; i< 32;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)hdrData[i]);
|
||||||
|
if (j == 7) {
|
||||||
|
DRW_DBG("\n");
|
||||||
|
j = 0;
|
||||||
|
} else {
|
||||||
|
DRW_DBG(", ");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
|
||||||
|
DRW_DBG("\n Page number= "); DRW_DBGH(pi.Id);
|
||||||
|
DRW_DBG("\n size in file= "); DRW_DBGH(pi.size);
|
||||||
|
DRW_DBG("\n address in file= "); DRW_DBGH(pi.address);
|
||||||
|
DRW_DBG("\n Data size= "); DRW_DBGH(pi.dataSize);
|
||||||
|
DRW_DBG("\n Start offset= "); DRW_DBGH(pi.startOffset); DRW_DBG("\n");
|
||||||
|
dwgBuffer bufHdr(hdrData, 32, &decoder);
|
||||||
|
DRW_DBG(" section page type= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||||
|
DRW_DBG("\n section number= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||||
|
pi.cSize = bufHdr.getRawLong32();
|
||||||
|
DRW_DBG("\n data size (compressed)= "); DRW_DBGH(pi.cSize); DRW_DBG(" dec "); DRW_DBG(pi.cSize);
|
||||||
|
pi.uSize = bufHdr.getRawLong32();
|
||||||
|
DRW_DBG("\n page size (decompressed)= "); DRW_DBGH(pi.uSize); DRW_DBG(" dec "); DRW_DBG(pi.uSize);
|
||||||
|
DRW_DBG("\n start offset (in decompressed buffer)= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||||
|
DRW_DBG("\n unknown= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||||
|
DRW_DBG("\n header checksum= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||||
|
DRW_DBG("\n data checksum= "); DRW_DBGH(bufHdr.getRawLong32()); DRW_DBG("\n");
|
||||||
|
|
||||||
|
//get compresed data
|
||||||
|
duint8 *cData = new duint8[pi.cSize];
|
||||||
|
if (!fileBuf->setPosition(pi.address+32))
|
||||||
|
return false;
|
||||||
|
fileBuf->getBytes(cData, pi.cSize);
|
||||||
|
|
||||||
|
//calculate checksum
|
||||||
|
duint32 calcsD = checksum(0, cData, pi.cSize);
|
||||||
|
for (duint8 i= 24; i<28; ++i)
|
||||||
|
hdrData[i]=0;
|
||||||
|
duint32 calcsH = checksum(calcsD, hdrData, 32);
|
||||||
|
DRW_DBG("Calc header checksum= "); DRW_DBGH(calcsH);
|
||||||
|
DRW_DBG("\nCalc data checksum= "); DRW_DBGH(calcsD); DRW_DBG("\n");
|
||||||
|
|
||||||
|
duint8* oData = objData + pi.startOffset;
|
||||||
|
pi.uSize = si.maxSize;
|
||||||
|
DRW_DBG("decompresing "); DRW_DBG(pi.cSize); DRW_DBG(" bytes in "); DRW_DBG(pi.uSize); DRW_DBG(" bytes\n");
|
||||||
|
dwgCompressor comp;
|
||||||
|
comp.decompress18(cData, oData, pi.cSize, pi.uSize);
|
||||||
|
delete[]cData;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader18::readMetaData() {
|
||||||
|
version = parent->getVersion();
|
||||||
|
decoder.setVersion(version, false);
|
||||||
|
DRW_DBG("dwgReader18::readMetaData\n");
|
||||||
|
if (! fileBuf->setPosition(11))
|
||||||
|
return false;
|
||||||
|
maintenanceVersion = fileBuf->getRawChar8();
|
||||||
|
DRW_DBG("maintenance verion= "); DRW_DBGH(maintenanceVersion);
|
||||||
|
DRW_DBG("\nbyte at 0x0C= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||||
|
previewImagePos = fileBuf->getRawLong32(); //+ page header size (0x20).
|
||||||
|
DRW_DBG("\npreviewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||||
|
DRW_DBG("\napp Dwg version= "); DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", ");
|
||||||
|
DRW_DBG("\napp maintenance version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||||
|
duint16 cp = fileBuf->getRawShort16();
|
||||||
|
DRW_DBG("\ncodepage= "); DRW_DBG(cp);
|
||||||
|
if (cp == 30)
|
||||||
|
decoder.setCodePage("ANSI_1252", false);
|
||||||
|
DRW_DBG("\n3 0x00 bytes(seems 0x00, appDwgV & appMaintV) = "); DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", ");
|
||||||
|
DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", "); DRW_DBGH(fileBuf->getRawChar8());
|
||||||
|
securityFlags = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nsecurity flags= "); DRW_DBG(securityFlags);
|
||||||
|
// UNKNOWN SECTION 4 bytes
|
||||||
|
duint32 uk = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nUNKNOWN SECTION ( 4 bytes) = "); DRW_DBG(uk);
|
||||||
|
duint32 sumInfoAddr = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nsummary Info Address= "); DRW_DBG(sumInfoAddr);
|
||||||
|
duint32 vbaAdd = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nVBA address= "); DRW_DBGH(vbaAdd);
|
||||||
|
DRW_DBG("\npos 0x28 are 0x00000080= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
DRW_DBG("\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader18::readFileHeader() {
|
||||||
|
|
||||||
|
if (! fileBuf->setPosition(0x80))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// genMagicNumber(); DBG("\n"); DBG("\n");
|
||||||
|
DRW_DBG("Encripted Header Data=\n");
|
||||||
|
duint8 byteStr[0x6C];
|
||||||
|
int size =0x6C;
|
||||||
|
for (int i=0, j=0; i< 0x6C;i++) {
|
||||||
|
duint8 ch = fileBuf->getRawChar8();
|
||||||
|
DRW_DBGH(ch);
|
||||||
|
if (j == 15) {
|
||||||
|
DRW_DBG("\n");
|
||||||
|
j = 0;
|
||||||
|
} else {
|
||||||
|
DRW_DBG(", ");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
byteStr[i] = DRW_magicNum18[i] ^ ch;
|
||||||
|
}
|
||||||
|
DRW_DBG("\n");
|
||||||
|
|
||||||
|
// size =0x6C;
|
||||||
|
DRW_DBG("Decripted Header Data=\n");
|
||||||
|
for (int i=0, j = 0; i< size;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)byteStr[i]);
|
||||||
|
if (j == 15) {
|
||||||
|
DRW_DBG("\n");
|
||||||
|
j = 0;
|
||||||
|
} else {
|
||||||
|
DRW_DBG(", ");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dwgBuffer buff(byteStr, 0x6C, &decoder);
|
||||||
|
std::string name = reinterpret_cast<char*>(byteStr);
|
||||||
|
DRW_DBG("\nFile ID string (AcFssFcAJMB)= "); DRW_DBG(name.c_str());
|
||||||
|
//ID string + NULL = 12
|
||||||
|
buff.setPosition(12);
|
||||||
|
DRW_DBG("\n0x00 long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\n0x6c long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\n0x04 long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nRoot tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nLowermost left tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nLowermost right tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nUnknown long (1)= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nLast section page Id= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nLast section page end address 64b= "); DRW_DBGH(buff.getRawLong64());
|
||||||
|
DRW_DBG("\nStart of second header data address 64b= "); DRW_DBGH(buff.getRawLong64());
|
||||||
|
DRW_DBG("\nGap amount= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nSection page amount= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\n0x20 long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\n0x80 long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\n0x40 long= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
dint32 secPageMapId = buff.getRawLong32();
|
||||||
|
DRW_DBG("\nSection Page Map Id= "); DRW_DBGH(secPageMapId);
|
||||||
|
duint64 secPageMapAddr = buff.getRawLong64()+0x100;
|
||||||
|
DRW_DBG("\nSection Page Map address 64b= "); DRW_DBGH(secPageMapAddr);
|
||||||
|
DRW_DBG("\nSection Page Map address 64b dec= "); DRW_DBG(secPageMapAddr);
|
||||||
|
duint32 secMapId = buff.getRawLong32();
|
||||||
|
DRW_DBG("\nSection Map Id= "); DRW_DBGH(secMapId);
|
||||||
|
DRW_DBG("\nSection page array size= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
DRW_DBG("\nGap array size= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
//TODO: verify CRC
|
||||||
|
DRW_DBG("\nCRC32= "); DRW_DBGH(buff.getRawLong32());
|
||||||
|
for (duint8 i = 0x68; i < 0x6c; ++i)
|
||||||
|
byteStr[i] = '\0';
|
||||||
|
// byteStr[i] = '\0';
|
||||||
|
duint32 crcCalc = buff.crc32(0x00,0,0x6C);
|
||||||
|
DRW_DBG("\nCRC32 calculated= "); DRW_DBGH(crcCalc);
|
||||||
|
|
||||||
|
DRW_DBG("\nEnd Encrypted Data. Reads 0x14 bytes, equal to magic number:\n");
|
||||||
|
for (int i=0, j=0; i< 0x14;i++) {
|
||||||
|
DRW_DBG("magic num: "); DRW_DBGH( (unsigned char)DRW_magicNumEnd18[i]);
|
||||||
|
DRW_DBG(",read "); DRW_DBGH( (unsigned char)fileBuf->getRawChar8());
|
||||||
|
if (j == 3) {
|
||||||
|
DRW_DBG("\n");
|
||||||
|
j = 0;
|
||||||
|
} else {
|
||||||
|
DRW_DBG(", ");
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// At this point are parsed the first 256 bytes
|
||||||
|
DRW_DBG("\nJump to Section Page Map address: "); DRW_DBGH(secPageMapAddr);
|
||||||
|
|
||||||
|
if (! fileBuf->setPosition(secPageMapAddr))
|
||||||
|
return false;
|
||||||
|
duint32 pageType = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nSection page type= "); DRW_DBGH(pageType);
|
||||||
|
duint32 decompSize = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nDecompressed size= "); DRW_DBG(decompSize); DRW_DBG(", "); DRW_DBGH(decompSize);
|
||||||
|
if (pageType != 0x41630e3b){
|
||||||
|
//bad page type, ends
|
||||||
|
DRW_DBG("Warning, bad page type, was expected 0x41630e3b instead of"); DRW_DBGH(pageType); DRW_DBG("\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
duint8 *tmpDecompSec = new duint8[decompSize];
|
||||||
|
parseSysPage(tmpDecompSec, decompSize);
|
||||||
|
|
||||||
|
//parses "Section page map" decompresed data
|
||||||
|
dwgBuffer buff2(tmpDecompSec, decompSize, &decoder);
|
||||||
|
duint32 address = 0x100;
|
||||||
|
//stores temporaly info of all pages:
|
||||||
|
std::map<duint32, dwgPageInfo >sectionPageMapTmp;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < decompSize;) {
|
||||||
|
dint32 id = buff2.getRawLong32();//RLZ bad can be +/-
|
||||||
|
duint32 size = buff2.getRawLong32();
|
||||||
|
i += 8;
|
||||||
|
DRW_DBG("Page num= "); DRW_DBG(id); DRW_DBG(" size= "); DRW_DBGH(size);
|
||||||
|
DRW_DBG(" address= "); DRW_DBGH(address); DRW_DBG("\n");
|
||||||
|
//TODO num can be negative indicating gap
|
||||||
|
// duint64 ind = id > 0 ? id : -id;
|
||||||
|
if (id < 0){
|
||||||
|
DRW_DBG("Parent= "); DRW_DBG(buff2.getRawLong32());
|
||||||
|
DRW_DBG("\nLeft= "); DRW_DBG(buff2.getRawLong32());
|
||||||
|
DRW_DBG(", Right= "); DRW_DBG(buff2.getRawLong32());
|
||||||
|
DRW_DBG(", 0x00= ");DRW_DBGH(buff2.getRawLong32()); DRW_DBG("\n");
|
||||||
|
i += 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
sectionPageMapTmp[id] = dwgPageInfo(id, address, size);
|
||||||
|
address += size;
|
||||||
|
}
|
||||||
|
delete[]tmpDecompSec;
|
||||||
|
|
||||||
|
DRW_DBG("\n*** dwgReader18: Processing Data Section Map ***\n");
|
||||||
|
dwgPageInfo sectionMap = sectionPageMapTmp[secMapId];
|
||||||
|
if (!fileBuf->setPosition(sectionMap.address))
|
||||||
|
return false;
|
||||||
|
pageType = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nSection page type= "); DRW_DBGH(pageType);
|
||||||
|
decompSize = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nDecompressed size= "); DRW_DBG(decompSize); DRW_DBG(", "); DRW_DBGH(decompSize);
|
||||||
|
if (pageType != 0x4163003b){
|
||||||
|
//bad page type, ends
|
||||||
|
DRW_DBG("Warning, bad page type, was expected 0x4163003b instead of"); DRW_DBGH(pageType); DRW_DBG("\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tmpDecompSec = new duint8[decompSize];
|
||||||
|
parseSysPage(tmpDecompSec, decompSize);
|
||||||
|
|
||||||
|
//reads sections:
|
||||||
|
DRW_DBG("\n*** dwgReader18: reads sections:");
|
||||||
|
dwgBuffer buff3(tmpDecompSec, decompSize, &decoder);
|
||||||
|
duint32 numDescriptions = buff3.getRawLong32();
|
||||||
|
DRW_DBG("\nnumDescriptions (sections)= "); DRW_DBG(numDescriptions);
|
||||||
|
DRW_DBG("\n0x02 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||||
|
DRW_DBG("\n0x00007400 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||||
|
DRW_DBG("\n0x00 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||||
|
DRW_DBG("\nunknown long (numDescriptions?)= "); DRW_DBG(buff3.getRawLong32()); DRW_DBG("\n");
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < numDescriptions; i++) {
|
||||||
|
dwgSectionInfo secInfo;
|
||||||
|
secInfo.size = buff3.getRawLong64();
|
||||||
|
DRW_DBG("\nSize of section= "); DRW_DBGH(secInfo.size);
|
||||||
|
secInfo.pageCount = buff3.getRawLong32();
|
||||||
|
DRW_DBG("\nPage count= "); DRW_DBGH(secInfo.pageCount);
|
||||||
|
secInfo.maxSize = buff3.getRawLong32();
|
||||||
|
DRW_DBG("\nMax Decompressed Size= "); DRW_DBGH(secInfo.maxSize);
|
||||||
|
DRW_DBG("\nunknown long= "); DRW_DBGH(buff3.getRawLong32());
|
||||||
|
secInfo.compresed = buff3.getRawLong32();
|
||||||
|
DRW_DBG("\nis Compressed? 1:no, 2:yes= "); DRW_DBGH(secInfo.compresed);
|
||||||
|
secInfo.Id = buff3.getRawLong32();
|
||||||
|
DRW_DBG("\nSection Id= "); DRW_DBGH(secInfo.Id);
|
||||||
|
secInfo.encrypted = buff3.getRawLong32();
|
||||||
|
//encrypted (doc: 0 no, 1 yes, 2 unkn) on read: objects 0 and encrypted yes
|
||||||
|
DRW_DBG("\nEncrypted= "); DRW_DBGH(secInfo.encrypted);
|
||||||
|
duint8 nameCStr[64];
|
||||||
|
buff3.getBytes(nameCStr, 64);
|
||||||
|
secInfo.name = reinterpret_cast<char*>(nameCStr);
|
||||||
|
DRW_DBG("\nSection std::Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||||
|
for (unsigned int i = 0; i < secInfo.pageCount; i++){
|
||||||
|
duint32 pn = buff3.getRawLong32();
|
||||||
|
dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy
|
||||||
|
DRW_DBG(" reading pag num = "); DRW_DBGH(pn);
|
||||||
|
pi.dataSize = buff3.getRawLong32();
|
||||||
|
pi.startOffset = buff3.getRawLong64();
|
||||||
|
secInfo.pages[pn]= pi;//complete copy in secInfo
|
||||||
|
DRW_DBG("\n Page number= "); DRW_DBGH(secInfo.pages[pn].Id);
|
||||||
|
DRW_DBG("\n size in file= "); DRW_DBGH(secInfo.pages[pn].size);
|
||||||
|
DRW_DBG("\n address in file= "); DRW_DBGH(secInfo.pages[pn].address);
|
||||||
|
DRW_DBG("\n Data size= "); DRW_DBGH(secInfo.pages[pn].dataSize);
|
||||||
|
DRW_DBG("\n Start offset= "); DRW_DBGH(secInfo.pages[pn].startOffset); DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
//do not save empty section
|
||||||
|
if (!secInfo.name.empty()) {
|
||||||
|
DRW_DBG("Saved section Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||||
|
sections[secEnum::getEnum(secInfo.name)] = secInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[]tmpDecompSec;
|
||||||
|
|
||||||
|
if (! fileBuf->isGood())
|
||||||
|
return false;
|
||||||
|
DRW_DBG("\ndwgReader18::readFileHeader END\n\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader18::readDwgHeader(DRW_Header& hdr){
|
||||||
|
DRW_DBG("dwgReader18::readDwgHeader\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
bool ret = parseDataPage(si/*, objData*/);
|
||||||
|
//global store for uncompressed data of all pages
|
||||||
|
uncompSize=si.size;
|
||||||
|
if (ret) {
|
||||||
|
dwgBuffer dataBuf(objData, si.size, &decoder);
|
||||||
|
DRW_DBG("Header section sentinel= ");
|
||||||
|
checkSentinel(&dataBuf, secEnum::HEADER, true);
|
||||||
|
if (version == DRW::AC1018){
|
||||||
|
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &dataBuf);
|
||||||
|
} else {
|
||||||
|
dwgBuffer handleBuf(objData, si.size, &decoder);
|
||||||
|
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Cleanup: global store for uncompressed data of all pages
|
||||||
|
if (objData != NULL){
|
||||||
|
delete[] objData;
|
||||||
|
objData = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader18::readDwgClasses(){
|
||||||
|
DRW_DBG("\ndwgReader18::readDwgClasses\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
bool ret = parseDataPage(si/*, objData*/);
|
||||||
|
//global store for uncompressed data of all pages
|
||||||
|
uncompSize=si.size;
|
||||||
|
if (ret) {
|
||||||
|
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
|
||||||
|
DRW_DBG("classes section sentinel= ");
|
||||||
|
checkSentinel(&dataBuf, secEnum::CLASSES, true);
|
||||||
|
|
||||||
|
duint32 size = dataBuf.getRawLong32();
|
||||||
|
DRW_DBG("\ndata size in bytes "); DRW_DBG(size);
|
||||||
|
if (version > DRW::AC1021 && maintenanceVersion > 3) { //2010+
|
||||||
|
duint32 hSize = dataBuf.getRawLong32();
|
||||||
|
DRW_DBG("\n2010+ & MV> 3, higth 32b: "); DRW_DBG(hSize);
|
||||||
|
}
|
||||||
|
duint32 bitSize = 0;
|
||||||
|
if (version > DRW::AC1021) {//2007+
|
||||||
|
bitSize = dataBuf.getRawLong32();
|
||||||
|
DRW_DBG("\ntotal size in bits "); DRW_DBG(bitSize);
|
||||||
|
}
|
||||||
|
duint32 maxClassNum = dataBuf.getBitShort();
|
||||||
|
DRW_DBG("\nMaximum class number "); DRW_DBG(maxClassNum);
|
||||||
|
DRW_DBG("\nRc 1 "); DRW_DBG(dataBuf.getRawChar8());
|
||||||
|
DRW_DBG("\nRc 2 "); DRW_DBG(dataBuf.getRawChar8());
|
||||||
|
DRW_DBG("\nBit "); DRW_DBG(dataBuf.getBit());
|
||||||
|
|
||||||
|
/*******************************/
|
||||||
|
dwgBuffer *strBuf = &dataBuf;
|
||||||
|
dwgBuffer strBuff(objData, uncompSize, &decoder);
|
||||||
|
//prepare string stream for 2007+
|
||||||
|
if (version > DRW::AC1021) {//2007+
|
||||||
|
strBuf = &strBuff;
|
||||||
|
duint32 strStartPos = bitSize+191;//size in bits + 24 bytes (sn+size+hSize) - 1 bit (endbit)
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
DRW_DBG("\nendBit "); DRW_DBG(strBuff.getBit());
|
||||||
|
strStartPos -= 16;//decrement 16 bits
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
duint32 strDataSize = strBuff.getRawShort16();
|
||||||
|
DRW_DBG("\nstrDataSize: "); DRW_DBG(strDataSize);
|
||||||
|
if (strDataSize & 0x8000) {
|
||||||
|
strStartPos -= 16;//decrement 16 bits
|
||||||
|
strDataSize &= 0x7FFF; //strip 0x8000;
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
duint32 hiSize = strBuff.getRawShort16();
|
||||||
|
strDataSize |= (hiSize << 15);
|
||||||
|
}
|
||||||
|
strStartPos -= strDataSize;
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************/
|
||||||
|
|
||||||
|
duint32 endDataPos = maxClassNum-499;
|
||||||
|
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||||
|
for (duint32 i= 0; i<endDataPos;i++) {
|
||||||
|
DRW_Class *cl = new DRW_Class();
|
||||||
|
cl->parseDwg(version, &dataBuf, strBuf);
|
||||||
|
classesmap[cl->classNum] = cl;
|
||||||
|
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||||
|
}
|
||||||
|
DRW_DBG("\nend classes data buff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||||
|
DRW_DBG("\nend classes data buff.getBitPos: "); DRW_DBG(dataBuf.getBitPos());
|
||||||
|
DRW_DBG("\nend classes strings buff.getPosition: "); DRW_DBG(strBuf->getPosition());
|
||||||
|
DRW_DBG("\nend classes strings buff.getBitPos: "); DRW_DBG(strBuf->getBitPos());
|
||||||
|
|
||||||
|
/***************/
|
||||||
|
|
||||||
|
strBuf->setPosition(strBuf->getPosition()+1);//skip remaining bits
|
||||||
|
DRW_DBG("\nCRC: "); DRW_DBGH(strBuf->getRawShort16());
|
||||||
|
if (version > DRW::AC1018){
|
||||||
|
DRW_DBG("\nunknown CRC: "); DRW_DBGH(strBuf->getRawShort16());
|
||||||
|
}
|
||||||
|
DRW_DBG("\nclasses section end sentinel= ");
|
||||||
|
checkSentinel(strBuf, secEnum::CLASSES, false);
|
||||||
|
|
||||||
|
ret = strBuf->isGood();
|
||||||
|
}
|
||||||
|
//Cleanup: global store for uncompressed data of all pages
|
||||||
|
if (objData != NULL){
|
||||||
|
delete[] objData;
|
||||||
|
objData = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********** objects map ************************/
|
||||||
|
/** Note: object map are split in sections with max size 2035?
|
||||||
|
* heach section are 2 bytes size + data bytes + 2 bytes crc
|
||||||
|
* size value are data bytes + 2 and to calculate crc are used
|
||||||
|
* 2 bytes size + data bytes
|
||||||
|
* last section are 2 bytes size + 2 bytes crc (size value always 2)
|
||||||
|
**/
|
||||||
|
bool dwgReader18::readDwgHandles() {
|
||||||
|
DRW_DBG("\ndwgReader18::readDwgHandles\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
bool ret = parseDataPage(si);
|
||||||
|
//global store for uncompressed data of all pages
|
||||||
|
uncompSize=si.size;
|
||||||
|
if (ret) {
|
||||||
|
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
|
||||||
|
ret = dwgReader::readDwgHandles(&dataBuf, 0, si.size);
|
||||||
|
}
|
||||||
|
//Cleanup: global store for uncompressed data of all pages
|
||||||
|
if (objData != NULL){
|
||||||
|
delete[] objData;
|
||||||
|
objData = NULL;
|
||||||
|
uncompSize = 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********** objects ************************/
|
||||||
|
/**
|
||||||
|
* Reads all the object referenced in the object map section of the DWG file
|
||||||
|
* (using their object file offsets)
|
||||||
|
*/
|
||||||
|
bool dwgReader18::readDwgTables(DRW_Header& hdr) {
|
||||||
|
DRW_DBG("\ndwgReader18::readDwgTables\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::OBJECTS];
|
||||||
|
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
bool ret = parseDataPage(si/*, objData*/);
|
||||||
|
//global store for uncompressed data of all pages
|
||||||
|
uncompSize=si.size;
|
||||||
|
if (ret) {
|
||||||
|
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
|
||||||
|
ret = dwgReader::readDwgTables(hdr, &dataBuf);
|
||||||
|
|
||||||
|
}
|
||||||
|
//Do not delete objData in this point, needed in the remaining code
|
||||||
|
return ret;
|
||||||
|
}
|
99
src/libs/vdxf/libdxfrw/intern/dwgreader18.h
Normal file
99
src/libs/vdxf/libdxfrw/intern/dwgreader18.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER18_H
|
||||||
|
#define DWGREADER18_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "dwgreader.h"
|
||||||
|
//#include "../drw_textcodec.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
|
||||||
|
static const int DRW_magicNum18[] = {
|
||||||
|
0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae,
|
||||||
|
0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb,
|
||||||
|
0xb3, 0xa6, 0xdb, 0x3c, 0x87, 0x0c, 0x3e, 0x99,
|
||||||
|
0x24, 0x5e, 0x0d, 0x1c, 0x06, 0xb7, 0x47, 0xde,
|
||||||
|
0xb3, 0x12, 0x4d, 0xc8, 0x43, 0xbb, 0x8b, 0xa6,
|
||||||
|
0x1f, 0x03, 0x5a, 0x7d, 0x09, 0x38, 0x25, 0x1f,
|
||||||
|
0x5d, 0xd4, 0xcb, 0xfc, 0x96, 0xf5, 0x45, 0x3b,
|
||||||
|
0x13, 0x0d, 0x89, 0x0a, 0x1c, 0xdb, 0xae, 0x32,
|
||||||
|
0x20, 0x9a, 0x50, 0xee, 0x40, 0x78, 0x36, 0xfd,
|
||||||
|
0x12, 0x49, 0x32, 0xf6, 0x9e, 0x7d, 0x49, 0xdc,
|
||||||
|
0xad, 0x4f, 0x14, 0xf2, 0x44, 0x40, 0x66, 0xd0,
|
||||||
|
0x6b, 0xc4, 0x30, 0xb7, 0x32, 0x3b, 0xa1, 0x22,
|
||||||
|
0xf6, 0x22, 0x91, 0x9d, 0xe1, 0x8b, 0x1f, 0xda,
|
||||||
|
0xb0, 0xca, 0x99, 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int DRW_magicNumEnd18[] = {
|
||||||
|
0xf8, 0x46, 0x6a, 0x04, 0x96, 0x73, 0x0e, 0xd9,
|
||||||
|
0x16, 0x2f, 0x67, 0x68, 0xd4, 0xf7, 0x4a, 0x4a,
|
||||||
|
0xd0, 0x57, 0x68, 0x76};
|
||||||
|
|
||||||
|
class dwgReader18 : public dwgReader {
|
||||||
|
public:
|
||||||
|
dwgReader18(std::istream *stream, dwgR *p):dwgReader(stream, p){
|
||||||
|
objData = NULL;
|
||||||
|
}
|
||||||
|
virtual ~dwgReader18(){
|
||||||
|
if (objData != NULL)
|
||||||
|
delete[] objData;
|
||||||
|
}
|
||||||
|
bool readMetaData();
|
||||||
|
bool readFileHeader();
|
||||||
|
bool readDwgHeader(DRW_Header& hdr);
|
||||||
|
bool readDwgClasses();
|
||||||
|
bool readDwgHandles();
|
||||||
|
bool readDwgTables(DRW_Header& hdr);
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||||
|
// bool ret = true;
|
||||||
|
// return ret;
|
||||||
|
// }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
duint8 *objData;
|
||||||
|
duint64 uncompSize;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void genMagicNumber();
|
||||||
|
// dwgBuffer* bufObj;
|
||||||
|
void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b
|
||||||
|
bool parseDataPage(dwgSectionInfo si/*, duint8 *dData*/); //called ???: Section map: 0x4163003b
|
||||||
|
duint32 checksum(duint32 seed, duint8* data, duint32 sz);
|
||||||
|
|
||||||
|
private:
|
||||||
|
duint32 securityFlags;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGREADER18_H
|
487
src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp
Normal file
487
src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp
Normal file
|
@ -0,0 +1,487 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgreader21.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
bool dwgReader21::readMetaData() {
|
||||||
|
version = parent->getVersion();
|
||||||
|
decoder.setVersion(version, false);
|
||||||
|
DRW_DBG("dwgReader21::readFileHeader()\n");
|
||||||
|
DRW_DBG("dwgReader21::parsing metadata\n");
|
||||||
|
if (! fileBuf->setPosition(11))
|
||||||
|
return false;
|
||||||
|
maintenanceVersion = fileBuf->getRawChar8();
|
||||||
|
DRW_DBG("maintenance verion= "); DRW_DBGH(maintenanceVersion);
|
||||||
|
DRW_DBG("\nbyte at 0x0C= "); DRW_DBG(fileBuf->getRawChar8());
|
||||||
|
previewImagePos = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("previewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||||
|
DRW_DBG("\n\napp writer version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||||
|
DRW_DBG("\napp writer maintenance version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||||
|
duint16 cp = fileBuf->getRawShort16();
|
||||||
|
DRW_DBG("\ncodepage= "); DRW_DBG(cp);
|
||||||
|
if (cp == 30)
|
||||||
|
decoder.setCodePage("ANSI_1252", false);
|
||||||
|
/* UNKNOUWN SECTION 2 bytes*/
|
||||||
|
DRW_DBG("\nUNKNOWN SECTION= "); DRW_DBG(fileBuf->getRawShort16());
|
||||||
|
DRW_DBG("\nUNKNOUWN SECTION 3b= "); DRW_DBG(fileBuf->getRawChar8());
|
||||||
|
duint32 secType = fileBuf->getRawLong32();
|
||||||
|
DRW_DBG("\nsecurity type flag= "); DRW_DBGH(secType);
|
||||||
|
/* UNKNOWN2 SECTION 4 bytes*/
|
||||||
|
DRW_DBG("\nUNKNOWN SECTION 4bytes= "); DRW_DBG(fileBuf->getRawLong32());
|
||||||
|
|
||||||
|
DRW_DBG("\nSummary info address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
DRW_DBG("\nVBA project address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
DRW_DBG("\n0x00000080 32b= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
DRW_DBG("\nApp info address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
//current position are 0x30 from here to 0x80 are undocumented
|
||||||
|
DRW_DBG("\nAnother address? = "); DRW_DBGH(fileBuf->getRawLong32());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader21::parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, duint8 *decompData){
|
||||||
|
//round to 8
|
||||||
|
duint64 alsize = (sizeCompressed + 7) &(-8);
|
||||||
|
//minimum RS chunk:
|
||||||
|
duint32 chunks = (((alsize * correctionFactor)+238)/239);
|
||||||
|
duint64 fpsize = chunks * 255;
|
||||||
|
|
||||||
|
if (! fileBuf->setPosition(offset))
|
||||||
|
return false;
|
||||||
|
duint8 *tmpDataRaw = new duint8[fpsize];
|
||||||
|
fileBuf->getBytes(tmpDataRaw, fpsize);
|
||||||
|
duint8 *tmpDataRS = new duint8[fpsize];
|
||||||
|
dwgRSCodec::decode239I(tmpDataRaw, tmpDataRS, fpsize/255);
|
||||||
|
dwgCompressor::decompress21(tmpDataRS, decompData, sizeCompressed, sizeUncompressed);
|
||||||
|
delete[]tmpDataRaw;
|
||||||
|
delete[]tmpDataRS;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader21::parseDataPage(dwgSectionInfo si, duint8 *dData){
|
||||||
|
DRW_DBG("parseDataPage, section size: "); DRW_DBG(si.size);
|
||||||
|
for (std::map<duint32, dwgPageInfo>::iterator it=si.pages.begin(); it!=si.pages.end(); ++it){
|
||||||
|
dwgPageInfo pi = it->second;
|
||||||
|
if (!fileBuf->setPosition(pi.address))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
duint8 *tmpPageRaw = new duint8[pi.size];
|
||||||
|
fileBuf->getBytes(tmpPageRaw, pi.size);
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
DRW_DBG("\nSection OBJECTS raw data=\n");
|
||||||
|
for (unsigned int i=0, j=0; i< pi.size;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)tmpPageRaw[i]);
|
||||||
|
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||||
|
} else { DRW_DBG(", "); j++; }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
duint8 *tmpPageRS = new duint8[pi.size];
|
||||||
|
duint8 chunks =pi.size / 255;
|
||||||
|
dwgRSCodec::decode251I(tmpPageRaw, tmpPageRS, chunks);
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
DRW_DBG("\nSection OBJECTS RS data=\n");
|
||||||
|
for (unsigned int i=0, j=0; i< pi.size;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)tmpPageRS[i]);
|
||||||
|
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||||
|
} else { DRW_DBG(", "); j++; }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DRW_DBG("\npage uncomp size: "); DRW_DBG(pi.uSize); DRW_DBG(" comp size: "); DRW_DBG(pi.cSize);
|
||||||
|
DRW_DBG("\noffset: "); DRW_DBG(pi.startOffset);
|
||||||
|
duint8 *pageData = dData + pi.startOffset;
|
||||||
|
dwgCompressor::decompress21(tmpPageRS, pageData, pi.cSize, pi.uSize);
|
||||||
|
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
DRW_DBG("\n\nSection OBJECTS decompresed data=\n");
|
||||||
|
for (unsigned int i=0, j=0; i< pi.uSize;i++) {
|
||||||
|
DRW_DBGH( (unsigned char)pageData[i]);
|
||||||
|
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||||
|
} else { DRW_DBG(", "); j++; }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delete[]tmpPageRaw;
|
||||||
|
delete[]tmpPageRS;
|
||||||
|
}
|
||||||
|
DRW_DBG("\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader21::readFileHeader() {
|
||||||
|
|
||||||
|
DRW_DBG("\n\ndwgReader21::parsing file header\n");
|
||||||
|
if (! fileBuf->setPosition(0x80))
|
||||||
|
return false;
|
||||||
|
duint8 fileHdrRaw[0x2FD];//0x3D8
|
||||||
|
fileBuf->getBytes(fileHdrRaw, 0x2FD);
|
||||||
|
duint8 fileHdrdRS[0x2CD];
|
||||||
|
dwgRSCodec::decode239I(fileHdrRaw, fileHdrdRS, 3);
|
||||||
|
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
DRW_DBG("\ndwgReader21::parsed Reed Solomon decode:\n");
|
||||||
|
int j = 0;
|
||||||
|
for (int i=0, j=0; i<0x2CD; i++){
|
||||||
|
DRW_DBGH( (unsigned char)fileHdrdRS[i]);
|
||||||
|
if (j== 15){ j=0; DRW_DBG("\n");
|
||||||
|
} else{ j++; DRW_DBG(", "); }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dwgBuffer fileHdrBuf(fileHdrdRS, 0x2CD, &decoder);
|
||||||
|
DRW_DBG("\nCRC 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nunknown key 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||||
|
DRW_DBG("\ncomp data CRC 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||||
|
dint32 fileHdrCompLength = fileHdrBuf.getRawLong32();
|
||||||
|
DRW_DBG("\ncompr len 4bytes= "); DRW_DBG(fileHdrCompLength);
|
||||||
|
dint32 fileHdrCompLength2 = fileHdrBuf.getRawLong32();
|
||||||
|
DRW_DBG("\nlength2 4bytes= "); DRW_DBG(fileHdrCompLength2);
|
||||||
|
|
||||||
|
int fileHdrDataLength = 0x110;
|
||||||
|
duint8 *fileHdrData;
|
||||||
|
if (fileHdrCompLength < 0) {
|
||||||
|
fileHdrDataLength = fileHdrCompLength * -1;
|
||||||
|
fileHdrData = new duint8[fileHdrDataLength];
|
||||||
|
fileHdrBuf.getBytes(fileHdrData, fileHdrDataLength);
|
||||||
|
}else {
|
||||||
|
DRW_DBG("\ndwgReader21:: file header are compresed:\n");
|
||||||
|
duint8 *compByteStr = new duint8[fileHdrCompLength];
|
||||||
|
fileHdrBuf.getBytes(compByteStr, fileHdrCompLength);
|
||||||
|
fileHdrData = new duint8[fileHdrDataLength];
|
||||||
|
dwgCompressor::decompress21(compByteStr, fileHdrData, fileHdrCompLength, fileHdrDataLength);
|
||||||
|
delete[] compByteStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DRW_DBG_DUMP
|
||||||
|
DRW_DBG("\ndwgReader21::parsed file header:\n");
|
||||||
|
for (int i=0, j=0; i<fileHdrDataLength; i++){
|
||||||
|
DRW_DBGH( (unsigned char)fileHdrData[i]);
|
||||||
|
if (j== 15){ j=0; DRW_DBG("\n");
|
||||||
|
} else{ j++; DRW_DBG(", "); }
|
||||||
|
} DRW_DBG("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dwgBuffer fileHdrDataBuf(fileHdrData, fileHdrDataLength, &decoder);
|
||||||
|
DRW_DBG("\nHeader size = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nFile size = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nPagesMapCrcCompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 PagesMapCorrectionFactor = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPagesMapCorrectionFactor = "); DRW_DBG(PagesMapCorrectionFactor);
|
||||||
|
DRW_DBG("\nPagesMapCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nPages map2offset = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); //relative to data page map 1, add 0x480 to get stream position
|
||||||
|
DRW_DBG("\nPages map2Id = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 PagesMapOffset = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPagesMapOffset = "); DRW_DBGH(PagesMapOffset); //relative to data page map 1, add 0x480 to get stream position
|
||||||
|
DRW_DBG("\nPagesMapId = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nHeader2offset = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); //relative to data page map 1, add 0x480 to get stream position
|
||||||
|
duint64 PagesMapSizeCompressed = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPagesMapSizeCompressed = "); DRW_DBG(PagesMapSizeCompressed);
|
||||||
|
duint64 PagesMapSizeUncompressed = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPagesMapSizeUncompressed = "); DRW_DBG(PagesMapSizeUncompressed);
|
||||||
|
DRW_DBG("\nPagesAmount = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 PagesMaxId = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPagesMaxId = "); DRW_DBG(PagesMaxId);
|
||||||
|
DRW_DBG("\nUnknown (normally 0x20) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nUnknown (normally 0x40) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nPagesMapCrcUncompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nUnknown (normally 0xf800) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nUnknown (normally 4) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nUnknown (normally 1) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nSectionsAmount (number of sections + 1) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nSectionsMapCrcUncompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 SectionsMapSizeCompressed = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSectionsMapSizeCompressed = "); DRW_DBGH(SectionsMapSizeCompressed);
|
||||||
|
DRW_DBG("\nSectionsMap2Id = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 SectionsMapId = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSectionsMapId = "); DRW_DBG(SectionsMapId);
|
||||||
|
duint64 SectionsMapSizeUncompressed = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSectionsMapSizeUncompressed = "); DRW_DBGH(SectionsMapSizeUncompressed);
|
||||||
|
DRW_DBG("\nSectionsMapCrcCompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
duint64 SectionsMapCorrectionFactor = fileHdrDataBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSectionsMapCorrectionFactor = "); DRW_DBG(SectionsMapCorrectionFactor);
|
||||||
|
DRW_DBG("\nSectionsMapCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nStreamVersion (normally 0x60100) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nCrcSeedEncoded = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nRandomSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||||
|
DRW_DBG("\nHeader CRC64 = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); DRW_DBG("\n");
|
||||||
|
|
||||||
|
delete[] fileHdrData;
|
||||||
|
|
||||||
|
DRW_DBG("\ndwgReader21::parse page map:\n");
|
||||||
|
duint8 *PagesMapData = new duint8[PagesMapSizeUncompressed];
|
||||||
|
|
||||||
|
bool ret = parseSysPage(PagesMapSizeCompressed, PagesMapSizeUncompressed, PagesMapCorrectionFactor, 0x480+PagesMapOffset, PagesMapData);
|
||||||
|
if (!ret) {
|
||||||
|
delete[]PagesMapData;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint64 address = 0x480;
|
||||||
|
duint64 i = 0;
|
||||||
|
dwgBuffer PagesMapBuf(PagesMapData, PagesMapSizeUncompressed, &decoder);
|
||||||
|
//stores temporaly info of all pages:
|
||||||
|
std::map<duint32, dwgPageInfo >sectionPageMapTmp;
|
||||||
|
|
||||||
|
// dwgPageInfo *m_pages= new dwgPageInfo[PagesMaxId+1];
|
||||||
|
while (PagesMapSizeUncompressed > i ) {
|
||||||
|
duint64 size = PagesMapBuf.getRawLong64();
|
||||||
|
dint64 id = PagesMapBuf.getRawLong64();
|
||||||
|
duint64 ind = id > 0 ? id : -id;
|
||||||
|
i += 16;
|
||||||
|
|
||||||
|
DRW_DBG("Page gap= "); DRW_DBG(id); DRW_DBG(" Page num= "); DRW_DBG(ind); DRW_DBG(" size= "); DRW_DBGH(size);
|
||||||
|
DRW_DBG(" address= "); DRW_DBGH(address); DRW_DBG("\n");
|
||||||
|
sectionPageMapTmp[ind] = dwgPageInfo(ind, address,size);
|
||||||
|
address += size;
|
||||||
|
//TODO num can be negative indicating gap
|
||||||
|
// seek += offset;
|
||||||
|
}
|
||||||
|
delete[]PagesMapData;
|
||||||
|
|
||||||
|
DRW_DBG("\n*** dwgReader21: Processing Section Map ***\n");
|
||||||
|
duint8 *SectionsMapData = new duint8[SectionsMapSizeUncompressed];
|
||||||
|
dwgPageInfo sectionMap = sectionPageMapTmp[SectionsMapId];
|
||||||
|
ret = parseSysPage(SectionsMapSizeCompressed, SectionsMapSizeUncompressed, SectionsMapCorrectionFactor, sectionMap.address, SectionsMapData);
|
||||||
|
if (!ret)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//reads sections:
|
||||||
|
//Note: compressed value are not stored in file then, commpresed field are use to store
|
||||||
|
// encoding value
|
||||||
|
dwgBuffer SectionsMapBuf(SectionsMapData, SectionsMapSizeUncompressed, &decoder);
|
||||||
|
duint8 nextId =1;
|
||||||
|
while(SectionsMapBuf.getPosition() < SectionsMapBuf.size()){
|
||||||
|
dwgSectionInfo secInfo;
|
||||||
|
secInfo.size = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSize of section (data size)= "); DRW_DBGH(secInfo.size);
|
||||||
|
secInfo.maxSize = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nMax Decompressed Size= "); DRW_DBGH(secInfo.maxSize);
|
||||||
|
secInfo.encrypted = SectionsMapBuf.getRawLong64();
|
||||||
|
//encrypted (doc: 0 no, 1 yes, 2 unkn) on read: objects 0 and encrypted yes
|
||||||
|
DRW_DBG("\nencription= "); DRW_DBGH(secInfo.encrypted);
|
||||||
|
DRW_DBG("\nHashCode = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||||
|
duint64 SectionNameLength = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nSectionNameLength = "); DRW_DBG(SectionNameLength);
|
||||||
|
DRW_DBG("\nUnknown = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||||
|
secInfo.compresed = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nEncoding (compresed) = "); DRW_DBGH(secInfo.compresed);
|
||||||
|
secInfo.pageCount = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG("\nPage count= "); DRW_DBGH(secInfo.pageCount);
|
||||||
|
secInfo.name = SectionsMapBuf.getUCSStr(SectionNameLength);
|
||||||
|
DRW_DBG("\nSection name = "); DRW_DBG(secInfo.name); DRW_DBG("\n");
|
||||||
|
|
||||||
|
for (unsigned int i=0; i< secInfo.pageCount; i++){
|
||||||
|
duint64 po = SectionsMapBuf.getRawLong64();
|
||||||
|
duint32 ds = SectionsMapBuf.getRawLong64();
|
||||||
|
duint32 pn = SectionsMapBuf.getRawLong64();
|
||||||
|
DRW_DBG(" pag Id = "); DRW_DBGH(pn); DRW_DBG(" data size = "); DRW_DBGH(ds);
|
||||||
|
dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy
|
||||||
|
pi.dataSize = ds;
|
||||||
|
pi.startOffset = po;
|
||||||
|
pi.uSize = SectionsMapBuf.getRawLong64();
|
||||||
|
pi.cSize = SectionsMapBuf.getRawLong64();
|
||||||
|
secInfo.pages[pn]= pi;//complete copy in secInfo
|
||||||
|
DRW_DBG("\n Page number= "); DRW_DBGH(secInfo.pages[pn].Id);
|
||||||
|
DRW_DBG("\n address in file= "); DRW_DBGH(secInfo.pages[pn].address);
|
||||||
|
DRW_DBG("\n size in file= "); DRW_DBGH(secInfo.pages[pn].size);
|
||||||
|
DRW_DBG("\n Data size= "); DRW_DBGH(secInfo.pages[pn].dataSize);
|
||||||
|
DRW_DBG("\n Start offset= "); DRW_DBGH(secInfo.pages[pn].startOffset);
|
||||||
|
DRW_DBG("\n Page uncompressed size = "); DRW_DBGH(secInfo.pages[pn].uSize);
|
||||||
|
DRW_DBG("\n Page compressed size = "); DRW_DBGH(secInfo.pages[pn].cSize);
|
||||||
|
|
||||||
|
DRW_DBG("\n Page checksum = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||||
|
DRW_DBG("\n Page CRC = "); DRW_DBGH(SectionsMapBuf.getRawLong64()); DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secInfo.name.empty()) {
|
||||||
|
secInfo.Id = nextId++;
|
||||||
|
DRW_DBG("Saved section Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||||
|
sections[secEnum::getEnum(secInfo.name)] = secInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[]SectionsMapData;
|
||||||
|
|
||||||
|
if (! fileBuf->isGood())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DRW_DBG("\ndwgReader21::readFileHeader END\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader21::readDwgHeader(DRW_Header& hdr){
|
||||||
|
DRW_DBG("\ndwgReader21::readDwgHeader\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||||
|
duint8 *tmpHeaderData = new duint8[si.size];
|
||||||
|
bool ret = dwgReader21::parseDataPage(si, tmpHeaderData);
|
||||||
|
if (!ret) {
|
||||||
|
delete[]tmpHeaderData;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgBuffer dataBuf(tmpHeaderData, si.size, &decoder);
|
||||||
|
dwgBuffer handleBuf(tmpHeaderData, si.size, &decoder);
|
||||||
|
DRW_DBG("Header section sentinel= ");
|
||||||
|
checkSentinel(&dataBuf, secEnum::HEADER, true);
|
||||||
|
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf);
|
||||||
|
delete[]tmpHeaderData;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader21::readDwgClasses(){
|
||||||
|
DRW_DBG("\ndwgReader21::readDwgClasses");
|
||||||
|
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||||
|
duint8 *tmpClassesData = new duint8[si.size];
|
||||||
|
bool ret = dwgReader21::parseDataPage(si, tmpClassesData);
|
||||||
|
if (!ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dwgBuffer buff(tmpClassesData, si.size, &decoder);
|
||||||
|
DRW_DBG("classes section sentinel= ");
|
||||||
|
checkSentinel(&buff, secEnum::CLASSES, true);
|
||||||
|
|
||||||
|
duint32 size = buff.getRawLong32();
|
||||||
|
DRW_DBG("\ndata size in bytes "); DRW_DBG(size);
|
||||||
|
|
||||||
|
duint32 bitSize = buff.getRawLong32();
|
||||||
|
DRW_DBG("\ntotal size in bits "); DRW_DBG(bitSize);
|
||||||
|
|
||||||
|
duint32 maxClassNum = buff.getBitShort();
|
||||||
|
DRW_DBG("\nMaximum class number "); DRW_DBG(maxClassNum);
|
||||||
|
DRW_DBG("\nRc 1 "); DRW_DBG(buff.getRawChar8());
|
||||||
|
DRW_DBG("\nRc 2 "); DRW_DBG(buff.getRawChar8());
|
||||||
|
DRW_DBG("\nBit "); DRW_DBG(buff.getBit());
|
||||||
|
|
||||||
|
/*******************************/
|
||||||
|
//prepare string stream
|
||||||
|
dwgBuffer strBuff(tmpClassesData, si.size, &decoder);
|
||||||
|
duint32 strStartPos = bitSize + 159;//size in bits + 20 bytes (sn+size) - 1 bit (endbit)
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
DRW_DBG("\nendBit "); DRW_DBG(strBuff.getBit());
|
||||||
|
strStartPos -= 16;//decrement 16 bits
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
duint32 strDataSize = strBuff.getRawShort16();
|
||||||
|
DRW_DBG("\nstrDataSize: "); DRW_DBG(strDataSize);
|
||||||
|
if (strDataSize & 0x8000) {
|
||||||
|
strStartPos -= 16;//decrement 16 bits
|
||||||
|
strDataSize &= 0x7FFF; //strip 0x8000;
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
duint32 hiSize = strBuff.getRawShort16();
|
||||||
|
strDataSize |= (hiSize << 15);
|
||||||
|
}
|
||||||
|
strStartPos -= strDataSize;
|
||||||
|
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||||
|
strBuff.setPosition(strStartPos >> 3);
|
||||||
|
strBuff.setBitPos(strStartPos & 7);
|
||||||
|
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||||
|
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************/
|
||||||
|
|
||||||
|
duint32 endDataPos = maxClassNum-499;
|
||||||
|
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||||
|
for (duint32 i= 0; i<endDataPos;i++) {
|
||||||
|
DRW_Class *cl = new DRW_Class();
|
||||||
|
cl->parseDwg(version, &buff, &strBuff);
|
||||||
|
classesmap[cl->classNum] = cl;
|
||||||
|
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||||
|
}
|
||||||
|
DRW_DBG("\nend classes data buff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||||
|
DRW_DBG("\nend classes data buff.getBitPos: "); DRW_DBG(buff.getBitPos());
|
||||||
|
|
||||||
|
buff.setPosition(size+20);//sizeVal+sn+32bSize
|
||||||
|
DRW_DBG("\nCRC: "); DRW_DBGH(buff.getRawShort16());
|
||||||
|
DRW_DBG("\nclasses section end sentinel= ");
|
||||||
|
checkSentinel(&buff, secEnum::CLASSES, true);
|
||||||
|
delete[]tmpClassesData;
|
||||||
|
return buff.isGood();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader21::readDwgHandles(){
|
||||||
|
DRW_DBG("\ndwgReader21::readDwgHandles");
|
||||||
|
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||||
|
duint8 *tmpHandlesData = new duint8[si.size];
|
||||||
|
bool ret = dwgReader21::parseDataPage(si, tmpHandlesData);
|
||||||
|
if (!ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dwgBuffer dataBuf(tmpHandlesData, si.size, &decoder);
|
||||||
|
|
||||||
|
ret = dwgReader::readDwgHandles(&dataBuf, 0, si.size);
|
||||||
|
delete[]tmpHandlesData;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** objects ************************/
|
||||||
|
/**
|
||||||
|
* Reads all the object referenced in the object map section of the DWG file
|
||||||
|
* (using their object file offsets)
|
||||||
|
*/
|
||||||
|
bool dwgReader21::readDwgTables(DRW_Header& hdr) {
|
||||||
|
DRW_DBG("\ndwgReader21::readDwgTables\n");
|
||||||
|
dwgSectionInfo si = sections[secEnum::OBJECTS];
|
||||||
|
if (si.Id<0)//not found, ends
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||||
|
dataSize = si.size;
|
||||||
|
objData = new duint8 [dataSize];
|
||||||
|
bool ret = dwgReader21::parseDataPage(si, objData);
|
||||||
|
if (!ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
DRW_DBG("readDwgTables total data size= "); DRW_DBG(dataSize); DRW_DBG("\n");
|
||||||
|
dwgBuffer dataBuf(objData, dataSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgTables(hdr, &dataBuf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader21::readDwgBlocks(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, dataSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
65
src/libs/vdxf/libdxfrw/intern/dwgreader21.h
Normal file
65
src/libs/vdxf/libdxfrw/intern/dwgreader21.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER21_H
|
||||||
|
#define DWGREADER21_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "dwgreader.h"
|
||||||
|
|
||||||
|
//reader for AC1021 aka v2007, chapter 5
|
||||||
|
class dwgReader21 : public dwgReader {
|
||||||
|
public:
|
||||||
|
dwgReader21(std::istream *stream, dwgR *p):dwgReader(stream, p){
|
||||||
|
objData = NULL;
|
||||||
|
dataSize = 0;
|
||||||
|
}
|
||||||
|
virtual ~dwgReader21(){
|
||||||
|
if (objData != NULL)
|
||||||
|
delete[] objData;
|
||||||
|
}
|
||||||
|
bool readMetaData();
|
||||||
|
bool readFileHeader();
|
||||||
|
bool readDwgHeader(DRW_Header& hdr);
|
||||||
|
bool readDwgClasses();
|
||||||
|
bool readDwgHandles();
|
||||||
|
bool readDwgTables(DRW_Header& hdr);
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa);
|
||||||
|
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, dataSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, dataSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
//bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, duint8 *decompData);
|
||||||
|
bool parseDataPage(dwgSectionInfo si, duint8 *dData);
|
||||||
|
|
||||||
|
duint8 *objData;
|
||||||
|
duint64 dataSize;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGREADER21_H
|
43
src/libs/vdxf/libdxfrw/intern/dwgreader24.cpp
Normal file
43
src/libs/vdxf/libdxfrw/intern/dwgreader24.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgreader24.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader24::readFileHeader() {
|
||||||
|
DRW_DBG("dwgReader24::readFileHeader\n");
|
||||||
|
bool ret = dwgReader18::readFileHeader();
|
||||||
|
DRW_DBG("dwgReader24::readFileHeader END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader24::readDwgHeader(DRW_Header& hdr){
|
||||||
|
DRW_DBG("dwgReader24::readDwgHeader\n");
|
||||||
|
bool ret = dwgReader18::readDwgHeader(hdr);
|
||||||
|
DRW_DBG("dwgReader24::readDwgHeader END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader24::readDwgClasses(){
|
||||||
|
DRW_DBG("\ndwgReader24::readDwgClasses");
|
||||||
|
bool ret = dwgReader18::readDwgClasses();
|
||||||
|
DRW_DBG("\ndwgReader24::readDwgClasses END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
56
src/libs/vdxf/libdxfrw/intern/dwgreader24.h
Normal file
56
src/libs/vdxf/libdxfrw/intern/dwgreader24.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER24_H
|
||||||
|
#define DWGREADER24_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "dwgreader18.h"
|
||||||
|
|
||||||
|
class dwgReader24 : public dwgReader18 {
|
||||||
|
public:
|
||||||
|
dwgReader24(std::istream *stream, dwgR *p):dwgReader18(stream, p){ }
|
||||||
|
virtual ~dwgReader24(){}
|
||||||
|
bool readFileHeader();
|
||||||
|
bool readDwgHeader(DRW_Header& hdr);
|
||||||
|
bool readDwgClasses();
|
||||||
|
// bool readDwgHandles(){return false;}
|
||||||
|
// bool readDwgTables(){return false;}
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||||
|
// DRW_UNUSED(obj);
|
||||||
|
// DRW_UNUSED(intfa);
|
||||||
|
// return false;}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGREADER24_H
|
43
src/libs/vdxf/libdxfrw/intern/dwgreader27.cpp
Normal file
43
src/libs/vdxf/libdxfrw/intern/dwgreader27.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgreader27.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool dwgReader27::readFileHeader() {
|
||||||
|
DRW_DBG("dwgReader27::readFileHeader\n");
|
||||||
|
bool ret = dwgReader18::readFileHeader();
|
||||||
|
DRW_DBG("dwgReader27::readFileHeader END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader27::readDwgHeader(DRW_Header& hdr){
|
||||||
|
DRW_DBG("dwgReader27::readDwgHeader\n");
|
||||||
|
bool ret = dwgReader18::readDwgHeader(hdr);
|
||||||
|
DRW_DBG("dwgReader27::readDwgHeader END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgReader27::readDwgClasses(){
|
||||||
|
DRW_DBG("dwgReader27::readDwgClasses");
|
||||||
|
bool ret = dwgReader18::readDwgClasses();
|
||||||
|
DRW_DBG("\ndwgReader27::readDwgClasses END\n");
|
||||||
|
return ret;
|
||||||
|
}
|
55
src/libs/vdxf/libdxfrw/intern/dwgreader27.h
Normal file
55
src/libs/vdxf/libdxfrw/intern/dwgreader27.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGREADER27_H
|
||||||
|
#define DWGREADER27_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "dwgbuffer.h"
|
||||||
|
#include "dwgreader18.h"
|
||||||
|
|
||||||
|
class dwgReader27 : public dwgReader18 {
|
||||||
|
public:
|
||||||
|
dwgReader27(std::istream *stream, dwgR *p):dwgReader18(stream, p){ }
|
||||||
|
virtual ~dwgReader27(){}
|
||||||
|
bool readFileHeader();
|
||||||
|
bool readDwgHeader(DRW_Header& hdr);
|
||||||
|
bool readDwgClasses();
|
||||||
|
// bool readDwgHandles(){return false;}
|
||||||
|
// bool readDwgTables(){return false;}
|
||||||
|
bool readDwgBlocks(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||||
|
bool ret = true;
|
||||||
|
dwgBuffer dataBuf(objData, uncompSize, &decoder);
|
||||||
|
ret = dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||||
|
// DRW_UNUSED(obj);
|
||||||
|
// DRW_UNUSED(intfa);
|
||||||
|
// return false;}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGREADER21_H
|
694
src/libs/vdxf/libdxfrw/intern/dwgutil.cpp
Normal file
694
src/libs/vdxf/libdxfrw/intern/dwgutil.cpp
Normal file
|
@ -0,0 +1,694 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
#include "dwgutil.h"
|
||||||
|
#include "rscodec.h"
|
||||||
|
#include "../libdwgr.h"
|
||||||
|
|
||||||
|
/** utility function
|
||||||
|
* convert a int to string in hex
|
||||||
|
**/
|
||||||
|
namespace DRW {
|
||||||
|
std::string toHexStr(int n){
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
char buffer[9]= {'\0'};
|
||||||
|
snprintf(buffer,9, "%X", n);
|
||||||
|
return std::string(buffer);
|
||||||
|
#else
|
||||||
|
std::ostringstream Convert;
|
||||||
|
Convert << std::uppercase << std::hex << n;
|
||||||
|
return Convert.str();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief dwgRSCodec::decode239I
|
||||||
|
* @param in : input data (at least 255*blk bytes)
|
||||||
|
* @param out : output data (at least 239*blk bytes)
|
||||||
|
* @param blk number of codewords ( 1 cw == 255 bytes)
|
||||||
|
*/
|
||||||
|
void dwgRSCodec::decode239I(unsigned char *in, unsigned char *out, duint32 blk){
|
||||||
|
int k=0;
|
||||||
|
unsigned char data[255];
|
||||||
|
RScodec rsc(0x96, 8, 8); //(255, 239)
|
||||||
|
for (duint32 i=0; i<blk; i++){
|
||||||
|
k = i;
|
||||||
|
for (int j=0; j<255; j++) {
|
||||||
|
data[j] = in[k];
|
||||||
|
k +=blk;
|
||||||
|
}
|
||||||
|
int r = rsc.decode(data);
|
||||||
|
if (r<0)
|
||||||
|
DRW_DBG("\nWARNING: dwgRSCodec::decode239I, can't correct all errors");
|
||||||
|
k = i*239;
|
||||||
|
for (int j=0; j<239; j++) {
|
||||||
|
out[k++] = data[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief dwgRSCodec::decode251I
|
||||||
|
* @param in : input data (at least 255*blk bytes)
|
||||||
|
* @param out : output data (at least 251*blk bytes)
|
||||||
|
* @param blk number of codewords ( 1 cw == 255 bytes)
|
||||||
|
*/
|
||||||
|
void dwgRSCodec::decode251I(unsigned char *in, unsigned char *out, duint32 blk){
|
||||||
|
int k=0;
|
||||||
|
unsigned char data[255];
|
||||||
|
RScodec rsc(0xB8, 8, 2); //(255, 251)
|
||||||
|
for (duint32 i=0; i<blk; i++){
|
||||||
|
k = i;
|
||||||
|
for (int j=0; j<255; j++) {
|
||||||
|
data[j] = in[k];
|
||||||
|
k +=blk;
|
||||||
|
}
|
||||||
|
int r = rsc.decode(data);
|
||||||
|
if (r<0)
|
||||||
|
DRW_DBG("\nWARNING: dwgRSCodec::decode251I, can't correct all errors");
|
||||||
|
k = i*251;
|
||||||
|
for (int j=0; j<251; j++) {
|
||||||
|
out[k++] = data[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgCompressor::twoByteOffset(duint32 *ll){
|
||||||
|
duint32 cont = 0;
|
||||||
|
duint8 fb = bufC[pos++];
|
||||||
|
cont = (fb >> 2) | (bufC[pos++] << 6);
|
||||||
|
*ll = (fb & 0x03);
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgCompressor::longCompressionOffset(){
|
||||||
|
duint32 cont = 0;
|
||||||
|
duint8 ll = bufC[pos++];
|
||||||
|
while (ll == 0x00){
|
||||||
|
cont += 0xFF;
|
||||||
|
ll = bufC[pos++];
|
||||||
|
}
|
||||||
|
cont += ll;
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgCompressor::long20CompressionOffset(){
|
||||||
|
// duint32 cont = 0;
|
||||||
|
duint32 cont = 0x0F;
|
||||||
|
duint8 ll = bufC[pos++];
|
||||||
|
while (ll == 0x00){
|
||||||
|
// cont += 0xFF;
|
||||||
|
ll = bufC[pos++];
|
||||||
|
}
|
||||||
|
cont += ll;
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
duint32 dwgCompressor::litLength18(){
|
||||||
|
duint32 cont=0;
|
||||||
|
duint8 ll = bufC[pos++];
|
||||||
|
//no literal length, this byte is next opCode
|
||||||
|
if (ll > 0x0F) {
|
||||||
|
pos--;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ll == 0x00) {
|
||||||
|
cont = 0x0F;
|
||||||
|
ll = bufC[pos++];
|
||||||
|
while (ll == 0x00){//repeat until ll != 0x00
|
||||||
|
cont +=0xFF;
|
||||||
|
ll = bufC[pos++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cont +=ll;
|
||||||
|
cont +=3; //already sum 3
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dwgCompressor::decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize){
|
||||||
|
bufC = cbuf;
|
||||||
|
bufD = dbuf;
|
||||||
|
sizeC = csize -2;
|
||||||
|
sizeD = dsize;
|
||||||
|
DRW_DBG("dwgCompressor::decompress, last 2 bytes: ");
|
||||||
|
DRW_DBGH(bufC[sizeC]);DRW_DBGH(bufC[sizeC+1]);DRW_DBG("\n");
|
||||||
|
sizeC = csize;
|
||||||
|
|
||||||
|
duint32 compBytes;
|
||||||
|
duint32 compOffset;
|
||||||
|
duint32 litCount;
|
||||||
|
|
||||||
|
pos=0; //current position in compresed buffer
|
||||||
|
rpos=0; //current position in resulting decompresed buffer
|
||||||
|
litCount = litLength18();
|
||||||
|
//copy first lileral lenght
|
||||||
|
for (duint32 i=0; i < litCount; ++i) {
|
||||||
|
bufD[rpos++] = bufC[pos++];
|
||||||
|
}
|
||||||
|
|
||||||
|
while (pos < csize && (rpos < dsize+1)){//rpos < dsize to prevent crash more robust are needed
|
||||||
|
duint8 oc = bufC[pos++]; //next opcode
|
||||||
|
if (oc == 0x10){
|
||||||
|
compBytes = longCompressionOffset()+ 9;
|
||||||
|
compOffset = twoByteOffset(&litCount) + 0x3FFF;
|
||||||
|
if (litCount == 0)
|
||||||
|
litCount= litLength18();
|
||||||
|
} else if (oc > 0x11 && oc< 0x20){
|
||||||
|
compBytes = (oc & 0x0F) + 2;
|
||||||
|
compOffset = twoByteOffset(&litCount) + 0x3FFF;
|
||||||
|
if (litCount == 0)
|
||||||
|
litCount= litLength18();
|
||||||
|
} else if (oc == 0x20){
|
||||||
|
compBytes = longCompressionOffset() + 0x21;
|
||||||
|
compOffset = twoByteOffset(&litCount);
|
||||||
|
if (litCount == 0)
|
||||||
|
litCount= litLength18();
|
||||||
|
else
|
||||||
|
oc = 0x00;
|
||||||
|
} else if (oc > 0x20 && oc< 0x40){
|
||||||
|
compBytes = oc - 0x1E;
|
||||||
|
compOffset = twoByteOffset(&litCount);
|
||||||
|
if (litCount == 0)
|
||||||
|
litCount= litLength18();
|
||||||
|
} else if ( oc > 0x3F){
|
||||||
|
compBytes = ((oc & 0xF0) >> 4) - 1;
|
||||||
|
duint8 ll2 = bufC[pos++];
|
||||||
|
compOffset = (ll2 << 2) | ((oc & 0x0C) >> 2);
|
||||||
|
litCount = oc & 0x03;
|
||||||
|
if (litCount < 1){
|
||||||
|
litCount= litLength18();}
|
||||||
|
} else if (oc == 0x11){
|
||||||
|
DRW_DBG("dwgCompressor::decompress, end of input stream, Cpos: ");
|
||||||
|
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||||
|
return; //end of input stream
|
||||||
|
} else { //ll < 0x10
|
||||||
|
DRW_DBG("WARNING dwgCompressor::decompress, failed, illegal char, Cpos: ");
|
||||||
|
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||||
|
return; //fails, not valid
|
||||||
|
}
|
||||||
|
//copy "compresed data", TODO Needed verify out of bounds
|
||||||
|
duint32 remaining = sizeD - (litCount+rpos);
|
||||||
|
if (remaining < compBytes){
|
||||||
|
compBytes = remaining;
|
||||||
|
DRW_DBG("WARNING dwgCompressor::decompress, bad compBytes size, Cpos: ");
|
||||||
|
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
for (duint32 i=0, j= rpos - compOffset -1; i < compBytes; i++) {
|
||||||
|
bufD[rpos++] = bufD[j++];
|
||||||
|
}
|
||||||
|
//copy "uncompresed data", TODO Needed verify out of bounds
|
||||||
|
for (duint32 i=0; i < litCount; i++) {
|
||||||
|
bufD[rpos++] = bufC[pos++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DRW_DBG("WARNING dwgCompressor::decompress, bad out, Cpos: ");DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dwgCompressor::decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset){
|
||||||
|
duint8 max = size / 4;
|
||||||
|
duint32 secMask = 0x4164536b ^ offset;
|
||||||
|
duint32* pHdr = (duint32*)buf;
|
||||||
|
for (duint8 j = 0; j < max; j++)
|
||||||
|
*pHdr++ ^= secMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void dwgCompressor::decrypt18Data(duint8 *buf, duint32 size, duint32 offset){
|
||||||
|
duint8 max = size / 4;
|
||||||
|
duint32 secMask = 0x4164536b ^ offset;
|
||||||
|
duint32* pHdr = (duint32*)buf;
|
||||||
|
for (duint8 j = 0; j < max; j++)
|
||||||
|
*pHdr++ ^= secMask;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
duint32 dwgCompressor::litLength21(duint8 *cbuf, duint8 oc, duint32 *si){
|
||||||
|
|
||||||
|
duint32 srcIndex=*si;
|
||||||
|
|
||||||
|
duint32 length = oc + 8;
|
||||||
|
if (length == 0x17) {
|
||||||
|
duint32 n = cbuf[srcIndex++];
|
||||||
|
length += n;
|
||||||
|
if (n == 0xff) {
|
||||||
|
do {
|
||||||
|
n = cbuf[srcIndex++];
|
||||||
|
n |= (duint32)(cbuf[srcIndex++] << 8);
|
||||||
|
length += n;
|
||||||
|
} while (n == 0xffff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*si = srcIndex;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dwgCompressor::decompress21(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize){
|
||||||
|
duint32 srcIndex=0;
|
||||||
|
duint32 dstIndex=0;
|
||||||
|
duint32 length=0;
|
||||||
|
duint32 sourceOffset;
|
||||||
|
duint8 opCode;
|
||||||
|
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
if ((opCode >> 4) == 2){
|
||||||
|
srcIndex = srcIndex +2;
|
||||||
|
length = cbuf[srcIndex++] & 0x07;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (srcIndex < csize && (dstIndex < dsize+1)){//dstIndex < dsize to prevent crash more robust are needed
|
||||||
|
if (length == 0)
|
||||||
|
length = litLength21(cbuf, opCode, &srcIndex);
|
||||||
|
copyCompBytes21(cbuf, dbuf, length, srcIndex, dstIndex);
|
||||||
|
srcIndex += length;
|
||||||
|
dstIndex += length;
|
||||||
|
if (dstIndex >=dsize) break; //check if last chunk are compresed & terminate
|
||||||
|
|
||||||
|
length = 0;
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
readInstructions21(cbuf, &srcIndex, &opCode, &sourceOffset, &length);
|
||||||
|
while (true) {
|
||||||
|
//prevent crash with corrupted data
|
||||||
|
if (sourceOffset > dstIndex){
|
||||||
|
DRW_DBG("\nWARNING dwgCompressor::decompress21 => sourceOffset> dstIndex.\n");
|
||||||
|
DRW_DBG("csize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||||
|
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);
|
||||||
|
sourceOffset = dstIndex;
|
||||||
|
}
|
||||||
|
//prevent crash with corrupted data
|
||||||
|
if (length > dsize - dstIndex){
|
||||||
|
DRW_DBG("\nWARNING dwgCompressor::decompress21 => length > dsize - dstIndex.\n");
|
||||||
|
DRW_DBG("csize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||||
|
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);
|
||||||
|
length = dsize - dstIndex;
|
||||||
|
srcIndex = csize;//force exit
|
||||||
|
}
|
||||||
|
sourceOffset = dstIndex-sourceOffset;
|
||||||
|
for (duint32 i=0; i< length; i++)
|
||||||
|
dbuf[dstIndex++] = dbuf[sourceOffset+i];
|
||||||
|
|
||||||
|
length = opCode & 7;
|
||||||
|
if ((length != 0) || (srcIndex >= csize)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
if ((opCode >> 4) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((opCode >> 4) == 15) {
|
||||||
|
opCode &= 15;
|
||||||
|
}
|
||||||
|
readInstructions21(cbuf, &srcIndex, &opCode, &sourceOffset, &length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DRW_DBG("\ncsize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||||
|
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);DRW_DBG("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void dwgCompressor::readInstructions21(duint8 *cbuf, duint32 *si, duint8 *oc, duint32 *so, duint32 *l){
|
||||||
|
duint32 length;
|
||||||
|
duint32 srcIndex = *si;
|
||||||
|
duint32 sourceOffset;
|
||||||
|
unsigned char opCode = *oc;
|
||||||
|
switch ((opCode >> 4)) {
|
||||||
|
case 0:
|
||||||
|
length = (opCode & 0xf) + 0x13;
|
||||||
|
sourceOffset = cbuf[srcIndex++];
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
length = ((opCode >> 3) & 0x10) + length;
|
||||||
|
sourceOffset = ((opCode & 0x78) << 5) + 1 + sourceOffset;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
length = (opCode & 0xf) + 3;
|
||||||
|
sourceOffset = cbuf[srcIndex++];
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
sourceOffset = ((opCode & 0xf8) << 5) + 1 + sourceOffset;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sourceOffset = cbuf[srcIndex++];
|
||||||
|
sourceOffset = ((cbuf[srcIndex++] << 8) & 0xff00) | sourceOffset;
|
||||||
|
length = opCode & 7;
|
||||||
|
if ((opCode & 8) == 0) {
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
length = (opCode & 0xf8) + length;
|
||||||
|
} else {
|
||||||
|
sourceOffset++;
|
||||||
|
length = (cbuf[srcIndex++] << 3) + length;
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
length = (((opCode & 0xf8) << 8) + length) + 0x100;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
length = opCode >> 4;
|
||||||
|
sourceOffset = opCode & 15;
|
||||||
|
opCode = cbuf[srcIndex++];
|
||||||
|
sourceOffset = (((opCode & 0xf8) << 1) + sourceOffset) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*oc = opCode;
|
||||||
|
*si = srcIndex;
|
||||||
|
*so = sourceOffset;
|
||||||
|
*l = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dwgCompressor::copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint32 si, duint32 di){
|
||||||
|
duint32 length =l;
|
||||||
|
duint32 dix = di;
|
||||||
|
duint32 six = si;
|
||||||
|
|
||||||
|
while (length > 31){
|
||||||
|
//in doc: 16-31, 0-15
|
||||||
|
for (duint32 i = six+24; i<six+32; i++)
|
||||||
|
dbuf[dix++] = cbuf[i];
|
||||||
|
for (duint32 i = six+16; i<six+24; i++)
|
||||||
|
dbuf[dix++] = cbuf[i];
|
||||||
|
for (duint32 i = six+8; i<six+16; i++)
|
||||||
|
dbuf[dix++] = cbuf[i];
|
||||||
|
for (duint32 i = six; i<six+8; i++)
|
||||||
|
dbuf[dix++] = cbuf[i];
|
||||||
|
six = six + 32;
|
||||||
|
length = length -32;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (length) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1: //Ok
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 2: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+1];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 3: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+2];
|
||||||
|
dbuf[dix++] = cbuf[six+1];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 4: //Ok
|
||||||
|
for (int i = 0; i<4;i++) //RLZ is OK, or are inverse?, OK
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 5: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+4];
|
||||||
|
for (int i = 0; i<4;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 6: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+5];
|
||||||
|
for (int i = 1; i<5;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
//in doc: six+5, six+6, 1-5, six+0
|
||||||
|
dbuf[dix++] = cbuf[six+6];
|
||||||
|
dbuf[dix++] = cbuf[six+5];
|
||||||
|
for (int i = 1; i<5;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
case 8: //Ok
|
||||||
|
for (int i = 0; i<8;i++) //RLZ 4[0],4[4] or 4[4],4[0]
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 9: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+8];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 10: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+9];
|
||||||
|
for (int i = 1; i<9;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
//in doc: six+9, six+10, 1-9, six+0
|
||||||
|
dbuf[dix++] = cbuf[six+10];
|
||||||
|
dbuf[dix++] = cbuf[six+9];
|
||||||
|
for (int i = 1; i<9;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 12: //Ok
|
||||||
|
for (int i = 8; i<12;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 13: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+12];
|
||||||
|
for (int i = 8; i<12;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 14: //Ok
|
||||||
|
dbuf[dix++] = cbuf[six+13];
|
||||||
|
for (int i = 9; i<13; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 1; i<9; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
//in doc: six+13, six+14, 9-12, 1-8, six+0
|
||||||
|
dbuf[dix++] = cbuf[six+14];
|
||||||
|
dbuf[dix++] = cbuf[six+13];
|
||||||
|
for (int i = 9; i<13; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 1; i<9; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 16: //Ok
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 17: //Seems Ok
|
||||||
|
for (int i = 9; i<17;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix++] = cbuf[six+8];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
//in doc: six+17, 1-16, six+0
|
||||||
|
dbuf[dix++] = cbuf[six+17];
|
||||||
|
for (int i = 9; i<17;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 1; i<9;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
//in doc: 16-18, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+18];
|
||||||
|
dbuf[dix++] = cbuf[six+17];
|
||||||
|
dbuf[dix++] = cbuf[six+16];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
//in doc: 16-19, 0-15
|
||||||
|
for (int i = 16; i<20;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
//in doc: six+20, 16-19, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+20];
|
||||||
|
for (int i = 16; i<20;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
//in doc: six+20, six+21, 16-19, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+21];
|
||||||
|
dbuf[dix++] = cbuf[six+20];
|
||||||
|
for (int i = 16; i<20;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
//in doc: six+20, six+21, six+22, 16-19, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+22];
|
||||||
|
dbuf[dix++] = cbuf[six+21];
|
||||||
|
dbuf[dix++] = cbuf[six+20];
|
||||||
|
for (int i = 16; i<20;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
//in doc: 16-23, 0-15
|
||||||
|
for (int i = 16; i<24;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 25:
|
||||||
|
//in doc: 17-24, six+16, 0-15
|
||||||
|
for (int i = 17; i<25;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix++] = cbuf[six+16];
|
||||||
|
for (int i = 8; i<16; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 26:
|
||||||
|
//in doc: six+25, 17-24, six+16, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+25];
|
||||||
|
for (int i = 17; i<25;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix++] = cbuf[six+16];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 27:
|
||||||
|
//in doc: six+25, six+26, 17-24, six+16, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+26];
|
||||||
|
dbuf[dix++] = cbuf[six+25];
|
||||||
|
for (int i = 17; i<25;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix++] = cbuf[six+16];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 28:
|
||||||
|
//in doc: 24-27, 16-23, 0-15
|
||||||
|
for (int i = 24; i<28; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 16; i<24;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 29:
|
||||||
|
//in doc: six+28, 24-27, 16-23, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+28];
|
||||||
|
for (int i = 24; i<28; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 16; i<24;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 30:
|
||||||
|
//in doc: six+28, six+29, 24-27, 16-23, 0-15
|
||||||
|
dbuf[dix++] = cbuf[six+29];
|
||||||
|
dbuf[dix++] = cbuf[six+28];
|
||||||
|
for (int i = 24; i<28; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 16; i<24;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 8; i<16;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
dbuf[dix++] = cbuf[six++];
|
||||||
|
break;
|
||||||
|
case 31:
|
||||||
|
//in doc: six+30, 26-29, 18-25, 2-17, 0-1
|
||||||
|
dbuf[dix++] = cbuf[six+30];
|
||||||
|
for (int i = 26; i<30;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 18; i<26;i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
/* for (int i = 2; i<18; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];*/
|
||||||
|
for (int i = 10; i<18; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
for (int i = 2; i<10; i++)
|
||||||
|
dbuf[dix++] = cbuf[six+i];
|
||||||
|
dbuf[dix++] = cbuf[six+1];
|
||||||
|
dbuf[dix] = cbuf[six];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DRW_DBG("WARNING dwgCompressor::copyCompBytes21, bad output.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
secEnum::DWGSection secEnum::getEnum(std::string nameSec){
|
||||||
|
//TODO: complete it
|
||||||
|
if (nameSec=="AcDb:Header"){
|
||||||
|
return HEADER;
|
||||||
|
} else if (nameSec=="AcDb:Classes"){
|
||||||
|
return CLASSES;
|
||||||
|
} else if (nameSec=="AcDb:SummaryInfo"){
|
||||||
|
return SUMARYINFO;
|
||||||
|
} else if (nameSec=="AcDb:Preview"){
|
||||||
|
return PREVIEW;
|
||||||
|
} else if (nameSec=="AcDb:VBAProject"){
|
||||||
|
return VBAPROY;
|
||||||
|
} else if (nameSec=="AcDb:AppInfo"){
|
||||||
|
return APPINFO;
|
||||||
|
} else if (nameSec=="AcDb:FileDepList"){
|
||||||
|
return FILEDEP;
|
||||||
|
} else if (nameSec=="AcDb:RevHistory"){
|
||||||
|
return REVHISTORY;
|
||||||
|
} else if (nameSec=="AcDb:Security"){
|
||||||
|
return SECURITY;
|
||||||
|
} else if (nameSec=="AcDb:AcDbObjects"){
|
||||||
|
return OBJECTS;
|
||||||
|
} else if (nameSec=="AcDb:ObjFreeSpace"){
|
||||||
|
return OBJFREESPACE;
|
||||||
|
} else if (nameSec=="AcDb:Template"){
|
||||||
|
return TEMPLATE;
|
||||||
|
} else if (nameSec=="AcDb:Handles"){
|
||||||
|
return HANDLES;
|
||||||
|
} else if (nameSec=="AcDb:AcDsPrototype_1b"){
|
||||||
|
return PROTOTYPE;
|
||||||
|
} else if (nameSec=="AcDb:AuxHeader"){
|
||||||
|
return AUXHEADER;
|
||||||
|
} else if (nameSec=="AcDb:Signature"){
|
||||||
|
return SIGNATURE;
|
||||||
|
} else if (nameSec=="AcDb:AppInfoHistory"){ //in ac1021
|
||||||
|
return APPINFOHISTORY;
|
||||||
|
// } else if (nameSec=="AcDb:Extended Entity Data"){
|
||||||
|
// return EXTEDATA;
|
||||||
|
// } else if (nameSec=="AcDb:PROXY ENTITY GRAPHICS"){
|
||||||
|
// return PROXYGRAPHICS;
|
||||||
|
}
|
||||||
|
return UNKNOWNS;
|
||||||
|
}
|
91
src/libs/vdxf/libdxfrw/intern/dwgutil.h
Normal file
91
src/libs/vdxf/libdxfrw/intern/dwgutil.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DWGUTIL_H
|
||||||
|
#define DWGUTIL_H
|
||||||
|
|
||||||
|
#include "../drw_base.h"
|
||||||
|
|
||||||
|
namespace DRW {
|
||||||
|
std::string toHexStr(int n);
|
||||||
|
}
|
||||||
|
|
||||||
|
class dwgRSCodec {
|
||||||
|
public:
|
||||||
|
dwgRSCodec(){}
|
||||||
|
~dwgRSCodec(){}
|
||||||
|
static void decode239I(duint8 *in, duint8 *out, duint32 blk);
|
||||||
|
static void decode251I(duint8 *in, duint8 *out, duint32 blk);
|
||||||
|
};
|
||||||
|
|
||||||
|
class dwgCompressor {
|
||||||
|
public:
|
||||||
|
dwgCompressor(){}
|
||||||
|
~dwgCompressor(){}
|
||||||
|
|
||||||
|
void decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize);
|
||||||
|
static void decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset);
|
||||||
|
// static void decrypt18Data(duint8 *buf, duint32 size, duint32 offset);
|
||||||
|
static void decompress21(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize);
|
||||||
|
|
||||||
|
private:
|
||||||
|
duint32 litLength18();
|
||||||
|
static duint32 litLength21(duint8 *cbuf, duint8 oc, duint32 *si);
|
||||||
|
static void copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint32 si, duint32 di);
|
||||||
|
static void readInstructions21(duint8 *cbuf, duint32 *si, duint8 *oc, duint32 *so, duint32 *l);
|
||||||
|
|
||||||
|
duint32 longCompressionOffset();
|
||||||
|
duint32 long20CompressionOffset();
|
||||||
|
duint32 twoByteOffset(duint32 *ll);
|
||||||
|
|
||||||
|
duint8 *bufC;
|
||||||
|
duint8 *bufD;
|
||||||
|
duint32 sizeC;
|
||||||
|
duint32 sizeD;
|
||||||
|
duint32 pos;
|
||||||
|
duint32 rpos;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class secEnum {
|
||||||
|
public:
|
||||||
|
enum DWGSection {
|
||||||
|
UNKNOWNS, /*!< UNKNOWN section. */
|
||||||
|
FILEHEADER, /*!< File Header (in R3-R15*/
|
||||||
|
HEADER, /*!< AcDb:Header */
|
||||||
|
CLASSES, /*!< AcDb:Classes */
|
||||||
|
SUMARYINFO, /*!< AcDb:SummaryInfo */
|
||||||
|
PREVIEW, /*!< AcDb:Preview */
|
||||||
|
VBAPROY, /*!< AcDb:VBAProject */
|
||||||
|
APPINFO, /*!< AcDb:AppInfo */
|
||||||
|
FILEDEP, /*!< AcDb:FileDepList */
|
||||||
|
REVHISTORY, /*!< AcDb:RevHistory */
|
||||||
|
SECURITY, /*!< AcDb:Security */
|
||||||
|
OBJECTS, /*!< AcDb:AcDbObjects */
|
||||||
|
OBJFREESPACE, /*!< AcDb:ObjFreeSpace */
|
||||||
|
TEMPLATE, /*!< AcDb:Template */
|
||||||
|
HANDLES, /*!< AcDb:Handles */
|
||||||
|
PROTOTYPE, /*!< AcDb:AcDsPrototype_1b */
|
||||||
|
AUXHEADER, /*!< AcDb:AuxHeader, in (R13-R15) second file header */
|
||||||
|
SIGNATURE, /*!< AcDb:Signature */
|
||||||
|
APPINFOHISTORY, /*!< AcDb:AppInfoHistory (in ac1021 may be a renamed section?*/
|
||||||
|
EXTEDATA, /*!< Extended Entity Data */
|
||||||
|
PROXYGRAPHICS /*!< PROXY ENTITY GRAPHICS */
|
||||||
|
};
|
||||||
|
|
||||||
|
secEnum(){}
|
||||||
|
~secEnum(){}
|
||||||
|
|
||||||
|
static DWGSection getEnum(std::string nameSec);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DWGUTIL_H
|
263
src/libs/vdxf/libdxfrw/intern/dxfreader.cpp
Normal file
263
src/libs/vdxf/libdxfrw/intern/dxfreader.cpp
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include "dxfreader.h"
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
#include "drw_dbg.h"
|
||||||
|
|
||||||
|
bool dxfReader::readRec(int *codeData) {
|
||||||
|
// std::string text;
|
||||||
|
int code;
|
||||||
|
|
||||||
|
if (!readCode(&code))
|
||||||
|
return false;
|
||||||
|
*codeData = code;
|
||||||
|
|
||||||
|
if (code < 10)
|
||||||
|
readString();
|
||||||
|
else if (code < 60)
|
||||||
|
readDouble();
|
||||||
|
else if (code < 80)
|
||||||
|
readInt16();
|
||||||
|
else if (code > 89 && code < 100) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code == 100 || code == 102 || code == 105)
|
||||||
|
readString();
|
||||||
|
else if (code > 109 && code < 150) //skip not used at the v2012
|
||||||
|
readDouble();
|
||||||
|
else if (code > 159 && code < 170) //skip not used at the v2012
|
||||||
|
readInt64();
|
||||||
|
else if (code < 180)
|
||||||
|
readInt16();
|
||||||
|
else if (code > 209 && code < 240) //skip not used at the v2012
|
||||||
|
readDouble();
|
||||||
|
else if (code > 269 && code < 290) //skip not used at the v2012
|
||||||
|
readInt16();
|
||||||
|
else if (code < 300) //TODO this is a boolean indicator, int in Binary?
|
||||||
|
readBool();
|
||||||
|
else if (code < 370)
|
||||||
|
readString();
|
||||||
|
else if (code < 390)
|
||||||
|
readInt16();
|
||||||
|
else if (code < 400)
|
||||||
|
readString();
|
||||||
|
else if (code < 410)
|
||||||
|
readInt16();
|
||||||
|
else if (code < 420)
|
||||||
|
readString();
|
||||||
|
else if (code < 430) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code < 440)
|
||||||
|
readString();
|
||||||
|
else if (code < 450) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code < 460) //TODO this is long??
|
||||||
|
readInt32();
|
||||||
|
else if (code < 470) //TODO this is a floating point double precision??
|
||||||
|
readDouble();
|
||||||
|
else if (code < 481)
|
||||||
|
readString();
|
||||||
|
else if (code > 998 && code < 1009) //skip not used at the v2012
|
||||||
|
readString();
|
||||||
|
else if (code < 1060) //TODO this is a floating point double precision??
|
||||||
|
readDouble();
|
||||||
|
else if (code < 1071)
|
||||||
|
readInt16();
|
||||||
|
else if (code == 1071) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (skip)
|
||||||
|
//skip safely this dxf entry ( ok for ascii dxf)
|
||||||
|
readString();
|
||||||
|
else
|
||||||
|
//break in binary files because the conduct is unpredictable
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
int dxfReader::getHandleString(){
|
||||||
|
int res;
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
int Succeeded = sscanf ( strData.c_str(), "%x", &res );
|
||||||
|
if ( !Succeeded || Succeeded == EOF )
|
||||||
|
res = 0;
|
||||||
|
#else
|
||||||
|
std::istringstream Convert(strData);
|
||||||
|
if ( !(Convert >> std::hex >>res) )
|
||||||
|
res = 0;
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readCode(int *code) {
|
||||||
|
unsigned short *int16p;
|
||||||
|
char buffer[2];
|
||||||
|
filestr->read(buffer,2);
|
||||||
|
int16p = (unsigned short *) buffer;
|
||||||
|
//exist a 32bits int (code 90) with 2 bytes???
|
||||||
|
if ((*code == 90) && (*int16p>2000)){
|
||||||
|
DRW_DBG(*code); DRW_DBG(" de 16bits\n");
|
||||||
|
filestr->seekg(-4, std::ios_base::cur);
|
||||||
|
filestr->read(buffer,2);
|
||||||
|
int16p = (unsigned short *) buffer;
|
||||||
|
}
|
||||||
|
*code = *int16p;
|
||||||
|
DRW_DBG(*code); DRW_DBG("\n");
|
||||||
|
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readString() {
|
||||||
|
type = STRING;
|
||||||
|
std::getline(*filestr, strData, '\0');
|
||||||
|
DRW_DBG(strData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readString(std::string *text) {
|
||||||
|
type = STRING;
|
||||||
|
std::getline(*filestr, *text, '\0');
|
||||||
|
DRW_DBG(*text); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readInt16() {
|
||||||
|
type = INT32;
|
||||||
|
char buffer[2];
|
||||||
|
filestr->read(buffer,2);
|
||||||
|
intData = (int)((buffer[1] << 8) | buffer[0]);
|
||||||
|
DRW_DBG(intData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readInt32() {
|
||||||
|
type = INT32;
|
||||||
|
unsigned int *int32p;
|
||||||
|
char buffer[4];
|
||||||
|
filestr->read(buffer,4);
|
||||||
|
int32p = (unsigned int *) buffer;
|
||||||
|
intData = *int32p;
|
||||||
|
DRW_DBG(intData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readInt64() {
|
||||||
|
type = INT64;
|
||||||
|
unsigned long long int *int64p; //64 bits integer pointer
|
||||||
|
char buffer[8];
|
||||||
|
filestr->read(buffer,8);
|
||||||
|
int64p = (unsigned long long int *) buffer;
|
||||||
|
int64 = *int64p;
|
||||||
|
DRW_DBG(int64); DRW_DBG(" int64\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderBinary::readDouble() {
|
||||||
|
type = DOUBLE;
|
||||||
|
double *result;
|
||||||
|
char buffer[8];
|
||||||
|
filestr->read(buffer,8);
|
||||||
|
result = (double *) buffer;
|
||||||
|
doubleData = *result;
|
||||||
|
DRW_DBG(doubleData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
//saved as int or add a bool member??
|
||||||
|
bool dxfReaderBinary::readBool() {
|
||||||
|
char buffer[1];
|
||||||
|
filestr->read(buffer,1);
|
||||||
|
intData = (int)(buffer[0]);
|
||||||
|
DRW_DBG(intData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readCode(int *code) {
|
||||||
|
std::string text;
|
||||||
|
std::getline(*filestr, text);
|
||||||
|
*code = atoi(text.c_str());
|
||||||
|
DRW_DBG(*code); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
bool dxfReaderAscii::readString(std::string *text) {
|
||||||
|
type = STRING;
|
||||||
|
std::getline(*filestr, *text);
|
||||||
|
if (!text->empty() && text->at(text->size()-1) == '\r')
|
||||||
|
text->erase(text->size()-1);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readString() {
|
||||||
|
type = STRING;
|
||||||
|
std::getline(*filestr, strData);
|
||||||
|
if (!strData.empty() && strData.at(strData.size()-1) == '\r')
|
||||||
|
strData.erase(strData.size()-1);
|
||||||
|
DRW_DBG(strData); DRW_DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readInt16() {
|
||||||
|
type = INT32;
|
||||||
|
std::string text;
|
||||||
|
if (readString(&text)){
|
||||||
|
intData = atoi(text.c_str());
|
||||||
|
DRW_DBG(intData); DRW_DBG("\n");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readInt32() {
|
||||||
|
type = INT32;
|
||||||
|
return readInt16();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readInt64() {
|
||||||
|
type = INT64;
|
||||||
|
return readInt16();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfReaderAscii::readDouble() {
|
||||||
|
type = DOUBLE;
|
||||||
|
std::string text;
|
||||||
|
if (readString(&text)){
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
int succeeded=sscanf( & (text[0]), "%lg", &doubleData);
|
||||||
|
if(succeeded != 1) {
|
||||||
|
DRW_DBG("dxfReaderAscii::readDouble(): reading double error: ");
|
||||||
|
DRW_DBG(text);
|
||||||
|
DRW_DBG('\n');
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::istringstream sd(text);
|
||||||
|
sd >> doubleData;
|
||||||
|
DRW_DBG(doubleData); DRW_DBG('\n');
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//saved as int or add a bool member??
|
||||||
|
bool dxfReaderAscii::readBool() {
|
||||||
|
type = BOOL;
|
||||||
|
std::string text;
|
||||||
|
if (readString(&text)){
|
||||||
|
intData = atoi(text.c_str());
|
||||||
|
DRW_DBG(intData); DRW_DBG("\n");
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
99
src/libs/vdxf/libdxfrw/intern/dxfreader.h
Normal file
99
src/libs/vdxf/libdxfrw/intern/dxfreader.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DXFREADER_H
|
||||||
|
#define DXFREADER_H
|
||||||
|
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
|
||||||
|
class dxfReader {
|
||||||
|
public:
|
||||||
|
enum TYPE {
|
||||||
|
STRING,
|
||||||
|
INT32,
|
||||||
|
INT64,
|
||||||
|
DOUBLE,
|
||||||
|
BOOL,
|
||||||
|
INVALID
|
||||||
|
};
|
||||||
|
enum TYPE type;
|
||||||
|
public:
|
||||||
|
dxfReader(std::istream *stream){
|
||||||
|
filestr = stream;
|
||||||
|
type = INVALID;
|
||||||
|
}
|
||||||
|
virtual ~dxfReader(){}
|
||||||
|
bool readRec(int *code);
|
||||||
|
|
||||||
|
std::string getString() {return strData;}
|
||||||
|
int getHandleString();//Convert hex string to int
|
||||||
|
std::string toUtf8String(std::string t) {return decoder.toUtf8(t);}
|
||||||
|
std::string getUtf8String() {return decoder.toUtf8(strData);}
|
||||||
|
double getDouble() {return doubleData;}
|
||||||
|
int getInt32() {return intData;}
|
||||||
|
unsigned long long int getInt64() {return int64;}
|
||||||
|
bool getBool() { return (intData==0) ? false : true;}
|
||||||
|
int getVersion(){return decoder.getVersion();}
|
||||||
|
void setVersion(std::string *v, bool dxfFormat){decoder.setVersion(v, dxfFormat);}
|
||||||
|
void setCodePage(std::string *c){decoder.setCodePage(c, true);}
|
||||||
|
std::string getCodePage(){ return decoder.getCodePage();}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF)
|
||||||
|
virtual bool readString(std::string *text) = 0;
|
||||||
|
virtual bool readString() = 0;
|
||||||
|
virtual bool readInt16() = 0;
|
||||||
|
virtual bool readInt32() = 0;
|
||||||
|
virtual bool readInt64() = 0;
|
||||||
|
virtual bool readDouble() = 0;
|
||||||
|
virtual bool readBool() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::istream *filestr;
|
||||||
|
std::string strData;
|
||||||
|
double doubleData;
|
||||||
|
signed int intData; //32 bits integer
|
||||||
|
unsigned long long int int64; //64 bits integer
|
||||||
|
bool skip; //set to true for ascii dxf, false for binary
|
||||||
|
private:
|
||||||
|
DRW_TextCodec decoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
class dxfReaderBinary : public dxfReader {
|
||||||
|
public:
|
||||||
|
dxfReaderBinary(std::istream *stream):dxfReader(stream){skip = false; }
|
||||||
|
virtual ~dxfReaderBinary() {}
|
||||||
|
virtual bool readCode(int *code);
|
||||||
|
virtual bool readString(std::string *text);
|
||||||
|
virtual bool readString();
|
||||||
|
virtual bool readInt16();
|
||||||
|
virtual bool readInt32();
|
||||||
|
virtual bool readInt64();
|
||||||
|
virtual bool readDouble();
|
||||||
|
virtual bool readBool();
|
||||||
|
};
|
||||||
|
|
||||||
|
class dxfReaderAscii : public dxfReader {
|
||||||
|
public:
|
||||||
|
dxfReaderAscii(std::istream *stream):dxfReader(stream){skip = true; }
|
||||||
|
virtual ~dxfReaderAscii(){}
|
||||||
|
virtual bool readCode(int *code);
|
||||||
|
virtual bool readString(std::string *text);
|
||||||
|
virtual bool readString();
|
||||||
|
virtual bool readInt16();
|
||||||
|
virtual bool readDouble();
|
||||||
|
virtual bool readInt32();
|
||||||
|
virtual bool readInt64();
|
||||||
|
virtual bool readBool();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DXFREADER_H
|
270
src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp
Normal file
270
src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp
Normal file
|
@ -0,0 +1,270 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "dxfwriter.h"
|
||||||
|
|
||||||
|
//RLZ TODO change std::endl to x0D x0A (13 10)
|
||||||
|
/*bool dxfWriter::readRec(int *codeData, bool skip) {
|
||||||
|
// std::string text;
|
||||||
|
int code;
|
||||||
|
|
||||||
|
#ifdef DRW_DBG
|
||||||
|
count = count+2; //DBG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!readCode(&code))
|
||||||
|
return false;
|
||||||
|
*codeData = code;
|
||||||
|
|
||||||
|
if (code < 10)
|
||||||
|
readString();
|
||||||
|
else if (code < 60)
|
||||||
|
readDouble();
|
||||||
|
else if (code < 80)
|
||||||
|
readInt();
|
||||||
|
else if (code > 89 && code < 100) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code == 100 || code == 102 || code == 105)
|
||||||
|
readString();
|
||||||
|
else if (code > 109 && code < 150) //skip not used at the v2012
|
||||||
|
readDouble();
|
||||||
|
else if (code > 159 && code < 170) //skip not used at the v2012
|
||||||
|
readInt64();
|
||||||
|
else if (code < 180)
|
||||||
|
readInt();
|
||||||
|
else if (code > 209 && code < 240) //skip not used at the v2012
|
||||||
|
readDouble();
|
||||||
|
else if (code > 269 && code < 290) //skip not used at the v2012
|
||||||
|
readInt();
|
||||||
|
else if (code < 300) //TODO this is a boolean indicator, int in Binary?
|
||||||
|
readBool();
|
||||||
|
else if (code < 370)
|
||||||
|
readString();
|
||||||
|
else if (code < 390)
|
||||||
|
readInt();
|
||||||
|
else if (code < 400)
|
||||||
|
readString();
|
||||||
|
else if (code < 410)
|
||||||
|
readInt();
|
||||||
|
else if (code < 420)
|
||||||
|
readString();
|
||||||
|
else if (code < 430) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code < 440)
|
||||||
|
readString();
|
||||||
|
else if (code < 450) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (code < 460) //TODO this is long??
|
||||||
|
readInt();
|
||||||
|
else if (code < 470) //TODO this is a floating point double precision??
|
||||||
|
readDouble();
|
||||||
|
else if (code < 481)
|
||||||
|
readString();
|
||||||
|
else if (code > 998 && code < 1009) //skip not used at the v2012
|
||||||
|
readString();
|
||||||
|
else if (code < 1060) //TODO this is a floating point double precision??
|
||||||
|
readDouble();
|
||||||
|
else if (code < 1071)
|
||||||
|
readInt();
|
||||||
|
else if (code == 1071) //TODO this is an int 32b
|
||||||
|
readInt32();
|
||||||
|
else if (skip)
|
||||||
|
//skip safely this dxf entry ( ok for ascii dxf)
|
||||||
|
readString();
|
||||||
|
else
|
||||||
|
//break in binary files because the conduct is unpredictable
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (filestr->good());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
bool dxfWriter::writeUtf8String(int code, std::string text) {
|
||||||
|
std::string t = encoder.fromUtf8(text);
|
||||||
|
return writeString(code, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriter::writeUtf8Caps(int code, std::string text) {
|
||||||
|
std::string strname = text;
|
||||||
|
std::transform(strname.begin(), strname.end(), strname.begin(),::toupper);
|
||||||
|
std::string t = encoder.fromUtf8(strname);
|
||||||
|
return writeString(code, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterBinary::writeString(int code, std::string text) {
|
||||||
|
char bufcode[2];
|
||||||
|
bufcode[0] =code & 0xFF;
|
||||||
|
bufcode[1] =code >> 8;
|
||||||
|
filestr->write(bufcode, 2);
|
||||||
|
*filestr << text << '\0';
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*bool dxfWriterBinary::readCode(int *code) {
|
||||||
|
unsigned short *int16p;
|
||||||
|
char buffer[2];
|
||||||
|
filestr->read(buffer,2);
|
||||||
|
int16p = (unsigned short *) buffer;
|
||||||
|
//exist a 32bits int (code 90) with 2 bytes???
|
||||||
|
if ((*code == 90) && (*int16p>2000)){
|
||||||
|
DBG(*code); DBG(" de 16bits\n");
|
||||||
|
filestr->seekg(-4, std::ios_base::cur);
|
||||||
|
filestr->read(buffer,2);
|
||||||
|
int16p = (unsigned short *) buffer;
|
||||||
|
}
|
||||||
|
*code = *int16p;
|
||||||
|
DBG(*code); DBG("\n");
|
||||||
|
|
||||||
|
return (filestr->good());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*bool dxfWriterBinary::readString() {
|
||||||
|
std::getline(*filestr, strData, '\0');
|
||||||
|
DBG(strData); DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*bool dxfWriterBinary::readString(std::string *text) {
|
||||||
|
std::getline(*filestr, *text, '\0');
|
||||||
|
DBG(*text); DBG("\n");
|
||||||
|
return (filestr->good());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
bool dxfWriterBinary::writeInt16(int code, int data) {
|
||||||
|
char bufcode[2];
|
||||||
|
char buffer[2];
|
||||||
|
bufcode[0] =code & 0xFF;
|
||||||
|
bufcode[1] =code >> 8;
|
||||||
|
buffer[0] =data & 0xFF;
|
||||||
|
buffer[1] =data >> 8;
|
||||||
|
filestr->write(bufcode, 2);
|
||||||
|
filestr->write(buffer, 2);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterBinary::writeInt32(int code, int data) {
|
||||||
|
char buffer[4];
|
||||||
|
buffer[0] =code & 0xFF;
|
||||||
|
buffer[1] =code >> 8;
|
||||||
|
filestr->write(buffer, 2);
|
||||||
|
|
||||||
|
buffer[0] =data & 0xFF;
|
||||||
|
buffer[1] =data >> 8;
|
||||||
|
buffer[2] =data >> 16;
|
||||||
|
buffer[3] =data >> 24;
|
||||||
|
filestr->write(buffer, 4);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterBinary::writeInt64(int code, unsigned long long int data) {
|
||||||
|
char buffer[8];
|
||||||
|
buffer[0] =code & 0xFF;
|
||||||
|
buffer[1] =code >> 8;
|
||||||
|
filestr->write(buffer, 2);
|
||||||
|
|
||||||
|
buffer[0] =data & 0xFF;
|
||||||
|
buffer[1] =data >> 8;
|
||||||
|
buffer[2] =data >> 16;
|
||||||
|
buffer[3] =data >> 24;
|
||||||
|
buffer[4] =data >> 32;
|
||||||
|
buffer[5] =data >> 40;
|
||||||
|
buffer[6] =data >> 48;
|
||||||
|
buffer[7] =data >> 56;
|
||||||
|
filestr->write(buffer, 8);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterBinary::writeDouble(int code, double data) {
|
||||||
|
char bufcode[2];
|
||||||
|
char buffer[8];
|
||||||
|
bufcode[0] =code & 0xFF;
|
||||||
|
bufcode[1] =code >> 8;
|
||||||
|
filestr->write(bufcode, 2);
|
||||||
|
|
||||||
|
unsigned char *val;
|
||||||
|
val = (unsigned char *) &data;
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
buffer[i] =val[i];
|
||||||
|
}
|
||||||
|
filestr->write(buffer, 8);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
//saved as int or add a bool member??
|
||||||
|
bool dxfWriterBinary::writeBool(int code, bool data) {
|
||||||
|
char buffer[1];
|
||||||
|
char bufcode[2];
|
||||||
|
bufcode[0] =code & 0xFF;
|
||||||
|
bufcode[1] =code >> 8;
|
||||||
|
filestr->write(bufcode, 2);
|
||||||
|
buffer[0] = data;
|
||||||
|
filestr->write(buffer, 1);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
dxfWriterAscii::dxfWriterAscii(std::ofstream *stream):dxfWriter(stream){
|
||||||
|
filestr->precision(16);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterAscii::writeString(int code, std::string text) {
|
||||||
|
// *filestr << code << std::endl << text << std::endl ;
|
||||||
|
filestr->width(3);
|
||||||
|
*filestr << std::right << code << std::endl;
|
||||||
|
filestr->width(0);
|
||||||
|
*filestr << std::left << text << std::endl;
|
||||||
|
/* std::getline(*filestr, strData, '\0');
|
||||||
|
DBG(strData); DBG("\n");*/
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterAscii::writeInt16(int code, int data) {
|
||||||
|
// *filestr << std::right << code << std::endl << data << std::endl;
|
||||||
|
filestr->width(3);
|
||||||
|
*filestr << std::right << code << std::endl;
|
||||||
|
filestr->width(5);
|
||||||
|
*filestr << data << std::endl;
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterAscii::writeInt32(int code, int data) {
|
||||||
|
return writeInt16(code, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterAscii::writeInt64(int code, unsigned long long int data) {
|
||||||
|
// *filestr << code << std::endl << data << std::endl;
|
||||||
|
filestr->width(3);
|
||||||
|
*filestr << std::right << code << std::endl;
|
||||||
|
filestr->width(5);
|
||||||
|
*filestr << data << std::endl;
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dxfWriterAscii::writeDouble(int code, double data) {
|
||||||
|
// std::streamsize prec = filestr->precision();
|
||||||
|
// filestr->precision(12);
|
||||||
|
// *filestr << code << std::endl << data << std::endl;
|
||||||
|
filestr->width(3);
|
||||||
|
*filestr << std::right << code << std::endl;
|
||||||
|
*filestr << data << std::endl;
|
||||||
|
// filestr->precision(prec);
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
||||||
|
//saved as int or add a bool member??
|
||||||
|
bool dxfWriterAscii::writeBool(int code, bool data) {
|
||||||
|
*filestr << code << std::endl << data << std::endl;
|
||||||
|
return (filestr->good());
|
||||||
|
}
|
||||||
|
|
64
src/libs/vdxf/libdxfrw/intern/dxfwriter.h
Normal file
64
src/libs/vdxf/libdxfrw/intern/dxfwriter.h
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DXFWRITER_H
|
||||||
|
#define DXFWRITER_H
|
||||||
|
|
||||||
|
#include "drw_textcodec.h"
|
||||||
|
|
||||||
|
class dxfWriter {
|
||||||
|
public:
|
||||||
|
dxfWriter(std::ofstream *stream){filestr = stream; /*count =0;*/}
|
||||||
|
virtual ~dxfWriter(){}
|
||||||
|
virtual bool writeString(int code, std::string text) = 0;
|
||||||
|
bool writeUtf8String(int code, std::string text);
|
||||||
|
bool writeUtf8Caps(int code, std::string text);
|
||||||
|
std::string fromUtf8String(std::string t) {return encoder.fromUtf8(t);}
|
||||||
|
virtual bool writeInt16(int code, int data) = 0;
|
||||||
|
virtual bool writeInt32(int code, int data) = 0;
|
||||||
|
virtual bool writeInt64(int code, unsigned long long int data) = 0;
|
||||||
|
virtual bool writeDouble(int code, double data) = 0;
|
||||||
|
virtual bool writeBool(int code, bool data) = 0;
|
||||||
|
void setVersion(std::string *v, bool dxfFormat){encoder.setVersion(v, dxfFormat);}
|
||||||
|
void setCodePage(std::string *c){encoder.setCodePage(c, true);}
|
||||||
|
std::string getCodePage(){return encoder.getCodePage();}
|
||||||
|
protected:
|
||||||
|
std::ofstream *filestr;
|
||||||
|
private:
|
||||||
|
DRW_TextCodec encoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
class dxfWriterBinary : public dxfWriter {
|
||||||
|
public:
|
||||||
|
dxfWriterBinary(std::ofstream *stream):dxfWriter(stream){}
|
||||||
|
virtual ~dxfWriterBinary() {}
|
||||||
|
virtual bool writeString(int code, std::string text);
|
||||||
|
virtual bool writeInt16(int code, int data);
|
||||||
|
virtual bool writeInt32(int code, int data);
|
||||||
|
virtual bool writeInt64(int code, unsigned long long int data);
|
||||||
|
virtual bool writeDouble(int code, double data);
|
||||||
|
virtual bool writeBool(int code, bool data);
|
||||||
|
};
|
||||||
|
|
||||||
|
class dxfWriterAscii : public dxfWriter {
|
||||||
|
public:
|
||||||
|
dxfWriterAscii(std::ofstream *stream);
|
||||||
|
virtual ~dxfWriterAscii(){}
|
||||||
|
virtual bool writeString(int code, std::string text);
|
||||||
|
virtual bool writeInt16(int code, int data);
|
||||||
|
virtual bool writeInt32(int code, int data);
|
||||||
|
virtual bool writeInt64(int code, unsigned long long int data);
|
||||||
|
virtual bool writeDouble(int code, double data);
|
||||||
|
virtual bool writeBool(int code, bool data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DXFWRITER_H
|
401
src/libs/vdxf/libdxfrw/intern/rscodec.cpp
Normal file
401
src/libs/vdxf/libdxfrw/intern/rscodec.cpp
Normal file
|
@ -0,0 +1,401 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reed-Solomon codec
|
||||||
|
* Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff
|
||||||
|
*
|
||||||
|
* Original code:
|
||||||
|
* This program may be freely modified and/or given to whoever wants it.
|
||||||
|
* A condition of such distribution is that the author's contribution be
|
||||||
|
* acknowledged by his name being left in the comments heading the program,
|
||||||
|
* however no responsibility is accepted for any financial or other loss which
|
||||||
|
* may result from some unforseen errors or malfunctioning of the program
|
||||||
|
* during use.
|
||||||
|
* Simon Rockliff, 26th June 1991
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "rscodec.h"
|
||||||
|
#include <new> // std::nothrow
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
RScodec::RScodec(unsigned int pp, int mm, int tt) {
|
||||||
|
this->mm = mm;
|
||||||
|
this->tt = tt;
|
||||||
|
nn = (1<<mm) -1; //mm==8 nn=255
|
||||||
|
kk = nn -(tt*2);
|
||||||
|
isOk = true;
|
||||||
|
|
||||||
|
alpha_to = new (std::nothrow) int[nn+1];
|
||||||
|
index_of = new (std::nothrow) unsigned int[nn+1];
|
||||||
|
gg = new (std::nothrow) int[nn-kk+1];
|
||||||
|
|
||||||
|
RSgenerate_gf(pp) ;
|
||||||
|
/* compute the generator polynomial for this RS code */
|
||||||
|
RSgen_poly() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
RScodec::~RScodec() {
|
||||||
|
delete[] alpha_to;
|
||||||
|
delete[] index_of;
|
||||||
|
delete[] gg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* generate GF(2^mm) from the irreducible polynomial p(X) in pp[0]..pp[mm]
|
||||||
|
lookup tables: index->polynomial form alpha_to[] contains j=alpha**i;
|
||||||
|
polynomial form -> index form index_of[j=alpha**i] = i
|
||||||
|
alpha=2 is the primitive element of GF(2^mm)
|
||||||
|
*/
|
||||||
|
void RScodec::RSgenerate_gf(unsigned int pp) {
|
||||||
|
int i, mask ;
|
||||||
|
int pb;
|
||||||
|
|
||||||
|
mask = 1 ;
|
||||||
|
alpha_to[mm] = 0 ;
|
||||||
|
for (i=0; i<mm; i++) {
|
||||||
|
alpha_to[i] = mask ;
|
||||||
|
index_of[alpha_to[i]] = i ;
|
||||||
|
pb = (pp >>(mm-1-i)) & 1;
|
||||||
|
if (pb!=0) {
|
||||||
|
alpha_to[mm] ^= mask;
|
||||||
|
}
|
||||||
|
mask <<= 1 ;
|
||||||
|
}
|
||||||
|
index_of[alpha_to[mm]] = mm ;
|
||||||
|
mask >>= 1 ;
|
||||||
|
for (i=mm+1; i<nn; i++) {
|
||||||
|
if (alpha_to[i-1] >= mask) {
|
||||||
|
alpha_to[i] = alpha_to[mm] ^ ((alpha_to[i-1]^mask)<<1) ;
|
||||||
|
} else alpha_to[i] = alpha_to[i-1]<<1 ;
|
||||||
|
index_of[alpha_to[i]] = i ;
|
||||||
|
}
|
||||||
|
index_of[0] = -1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Obtain the generator polynomial of the tt-error correcting, length
|
||||||
|
nn=(2^mm -1) Reed Solomon code from the product of (X+alpha**i), i=1..2*tt
|
||||||
|
*/
|
||||||
|
void RScodec::RSgen_poly() {
|
||||||
|
int i,j ;
|
||||||
|
int tmp;
|
||||||
|
int bb = nn-kk;; //nn-kk length of parity data
|
||||||
|
|
||||||
|
gg[0] = 2 ; /* primitive element alpha = 2 for GF(2**mm) */
|
||||||
|
gg[1] = 1 ; /* g(x) = (X+alpha) initially */
|
||||||
|
for (i=2; i<=bb; i++) {
|
||||||
|
gg[i] = 1 ;
|
||||||
|
for (j=i-1; j>0; j--)
|
||||||
|
if (gg[j] != 0) {
|
||||||
|
if (gg[j]<0) { isOk=false; return; }
|
||||||
|
tmp = (index_of[gg[j]]+i)%nn;
|
||||||
|
if (tmp<0) { isOk=false; return; }
|
||||||
|
gg[j] = gg[j-1]^ alpha_to[tmp] ;
|
||||||
|
} else {
|
||||||
|
gg[j] = gg[j-1] ;
|
||||||
|
}
|
||||||
|
gg[0] = alpha_to[(index_of[gg[0]]+i)%nn] ; /* gg[0] can never be zero */
|
||||||
|
}
|
||||||
|
/* convert gg[] to index form for quicker encoding */
|
||||||
|
for (i=0; i<=bb; i++) gg[i] = index_of[gg[i]] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RScodec::calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb)
|
||||||
|
{
|
||||||
|
if (!isOk) return -1;
|
||||||
|
int count = 0;
|
||||||
|
int syn_error = 0;
|
||||||
|
int i, j, u, q;
|
||||||
|
|
||||||
|
// for (int i=0; i<nn; i++)
|
||||||
|
// recd[i] = index_of[recd[i]] ; /* put recd[i] into index form */
|
||||||
|
for (int i = 0, j = bb; i<kk; i++, j++)
|
||||||
|
recd[j] = index_of[data[j]]; /* put data in recd[i] into index form */
|
||||||
|
for (int i = kk, j = 0; i<nn; i++, j++)
|
||||||
|
recd[j] = index_of[data[j]]; /* put data in recd[i] into index form */
|
||||||
|
|
||||||
|
/* first form the syndromes */
|
||||||
|
for (i = 1; i <= bb; i++) {
|
||||||
|
s[i] = 0;
|
||||||
|
for (j = 0; j<nn; j++) {
|
||||||
|
if (recd[j] != -1) {
|
||||||
|
s[i] ^= alpha_to[(recd[j] + i*j) % nn]; /* recd[j] in index form */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* convert syndrome from polynomial form to index form */
|
||||||
|
if (s[i] != 0) syn_error = 1; /* set flag if non-zero syndrome => error */
|
||||||
|
s[i] = index_of[s[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!syn_error) { /* if no errors, ends */
|
||||||
|
/* no non-zero syndromes => no errors: output is received codeword */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* errors are present, try and correct */
|
||||||
|
/* compute the error location polynomial via the Berlekamp iterative algorithm,
|
||||||
|
following the terminology of Lin and Costello : d[u] is the 'mu'th
|
||||||
|
discrepancy, where u='mu'+1 and 'mu' (the Greek letter!) is the step number
|
||||||
|
ranging from -1 to 2*tt (see L&C), l[u] is the
|
||||||
|
degree of the elp at that step, and u_l[u] is the difference between the
|
||||||
|
step number and the degree of the elp.
|
||||||
|
*/
|
||||||
|
/* initialise table entries */
|
||||||
|
d[0] = 0; /* index form */
|
||||||
|
d[1] = s[1]; /* index form */
|
||||||
|
elp[0][0] = 0; /* index form */
|
||||||
|
elp[1][0] = 1; /* polynomial form */
|
||||||
|
for (i = 1; i<bb; i++) {
|
||||||
|
elp[0][i] = -1; /* index form */
|
||||||
|
elp[1][i] = 0; /* polynomial form */
|
||||||
|
}
|
||||||
|
l[0] = 0;
|
||||||
|
l[1] = 0;
|
||||||
|
u_lu[0] = -1;
|
||||||
|
u_lu[1] = 0;
|
||||||
|
u = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
u++;
|
||||||
|
if (d[u] == -1) {
|
||||||
|
l[u + 1] = l[u];
|
||||||
|
for (i = 0; i <= l[u]; i++) {
|
||||||
|
elp[u + 1][i] = elp[u][i];
|
||||||
|
elp[u][i] = index_of[elp[u][i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* search for words with greatest u_lu[q] for which d[q]!=0 */
|
||||||
|
q = u - 1;
|
||||||
|
while ((d[q] == -1) && (q>0)) q--;
|
||||||
|
/* have found first non-zero d[q] */
|
||||||
|
if (q>0) {
|
||||||
|
j = q;
|
||||||
|
do {
|
||||||
|
j--;
|
||||||
|
if ((d[j] != -1) && (u_lu[q]<u_lu[j]))
|
||||||
|
q = j;
|
||||||
|
} while (j>0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* have now found q such that d[u]!=0 and u_lu[q] is maximum */
|
||||||
|
/* store degree of new elp polynomial */
|
||||||
|
if (l[u]>l[q] + u - q) {
|
||||||
|
l[u + 1] = l[u];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
l[u + 1] = l[q] + u - q;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* form new elp(x) */
|
||||||
|
for (i = 0; i<bb; i++) elp[u + 1][i] = 0;
|
||||||
|
for (i = 0; i <= l[q]; i++){
|
||||||
|
if (elp[q][i] != -1) {
|
||||||
|
elp[u + 1][i + u - q] = alpha_to[(d[u] + nn - d[q] + elp[q][i]) % nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i <= l[u]; i++) {
|
||||||
|
elp[u + 1][i] ^= elp[u][i];
|
||||||
|
elp[u][i] = index_of[elp[u][i]]; /*convert old elp value to index*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u_lu[u + 1] = u - l[u + 1];
|
||||||
|
|
||||||
|
/* form (u+1)th discrepancy */
|
||||||
|
if (u<bb){ /* no discrepancy computed on last iteration */
|
||||||
|
if (s[u + 1] != -1) {
|
||||||
|
d[u + 1] = alpha_to[s[u + 1]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
d[u + 1] = 0;
|
||||||
|
}
|
||||||
|
for (i = 1; i <= l[u + 1]; i++){
|
||||||
|
if ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0)) {
|
||||||
|
d[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d[u + 1] = index_of[d[u + 1]]; /* put d[u+1] into index form */
|
||||||
|
}
|
||||||
|
} while ((u<bb) && (l[u + 1] <= tt));
|
||||||
|
|
||||||
|
u++;
|
||||||
|
if (l[u]>tt) { /* elp has degree has degree >tt hence cannot solve */
|
||||||
|
return -1; /* just output is received codeword as is */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* can correct error */
|
||||||
|
/* put elp into index form */
|
||||||
|
for (i = 0; i <= l[u]; i++) elp[u][i] = index_of[elp[u][i]];
|
||||||
|
|
||||||
|
/* find roots of the error location polynomial */
|
||||||
|
for (i = 1; i <= l[u]; i++) {
|
||||||
|
reg[i] = elp[u][i];
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
for (i = 1; i <= nn; i++) {
|
||||||
|
q = 1;
|
||||||
|
for (j = 1; j <= l[u]; j++) {
|
||||||
|
if (reg[j] != -1) {
|
||||||
|
reg[j] = (reg[j] + j) % nn;
|
||||||
|
q ^= alpha_to[reg[j]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!q) { /* store root and error location number indices */
|
||||||
|
root[count] = i;
|
||||||
|
loc[count] = nn - i;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count != l[u]) { /* no. roots != degree of elp => >tt errors and cannot solve */
|
||||||
|
return -1; /* just output is received codeword as is */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no. roots = degree of elp hence <= tt errors */
|
||||||
|
/* form polynomial z(x) */
|
||||||
|
for (i = 1; i <= l[u]; i++) { /* Z[0] = 1 always - do not need */
|
||||||
|
if ((s[i] != -1) && (elp[u][i] != -1)) {
|
||||||
|
z[i] = alpha_to[s[i]] ^ alpha_to[elp[u][i]];
|
||||||
|
}
|
||||||
|
else if ((s[i] != -1) && (elp[u][i] == -1)) {
|
||||||
|
z[i] = alpha_to[s[i]];
|
||||||
|
}
|
||||||
|
else if ((s[i] == -1) && (elp[u][i] != -1)) {
|
||||||
|
z[i] = alpha_to[elp[u][i]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
z[i] = 0;
|
||||||
|
}
|
||||||
|
for (j = 1; j<i; j++) {
|
||||||
|
if ((s[j] != -1) && (elp[u][i - j] != -1)) {
|
||||||
|
z[i] ^= alpha_to[(elp[u][i - j] + s[j]) % nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
z[i] = index_of[z[i]]; /* put into index form */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* evaluate errors at locations given by error location numbers loc[i] */
|
||||||
|
for (i = 0; i<nn; i++) err[i] = 0;
|
||||||
|
for (i = 0; i<l[u]; i++) { /* compute numerator of error term first */
|
||||||
|
err[loc[i]] = 1; /* accounts for z[0] */
|
||||||
|
for (j = 1; j <= l[u]; j++) {
|
||||||
|
if (z[j] != -1) {
|
||||||
|
err[loc[i]] ^= alpha_to[(z[j] + j*root[i]) % nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err[loc[i]] != 0) {
|
||||||
|
err[loc[i]] = index_of[err[loc[i]]];
|
||||||
|
q = 0; /* form denominator of error term */
|
||||||
|
for (j = 0; j<l[u]; j++) {
|
||||||
|
if (j != i) {
|
||||||
|
q += index_of[1 ^ alpha_to[(loc[j] + root[i]) % nn]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
q = q % nn;
|
||||||
|
err[loc[i]] = alpha_to[(err[loc[i]] - q + nn) % nn];
|
||||||
|
data[loc[i]] ^= err[loc[i]]; /*change errors by correct data, in polynomial form */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** take the string of symbols in data[i], i=0..(k-1) and encode systematically
|
||||||
|
to produce 2*tt parity symbols in bd[0]..bd[2*tt-1]
|
||||||
|
data[] is input and bd[] is output in polynomial form.
|
||||||
|
Encoding is done by using a feedback shift register with appropriate
|
||||||
|
connections specified by the elements of gg[], which was generated above.
|
||||||
|
Codeword is c(X) = data(X)*X**(nn-kk)+ b(X) */
|
||||||
|
bool RScodec::encode(unsigned char *data, unsigned char *parity) {
|
||||||
|
if (!isOk) return false;
|
||||||
|
int i,j ;
|
||||||
|
int feedback ;
|
||||||
|
unsigned char *idata = data;
|
||||||
|
unsigned char *bd = parity;
|
||||||
|
int bb = nn-kk;; //nn-kk length of parity data
|
||||||
|
|
||||||
|
for (i=0; i<bb; i++) bd[i] = 0 ;
|
||||||
|
for (i=kk-1; i>=0; i--) {
|
||||||
|
feedback = index_of[idata[i]^bd[bb-1]] ;
|
||||||
|
if (feedback != -1) {
|
||||||
|
for (j=bb-1; j>0; j--)
|
||||||
|
if (gg[j] != -1)
|
||||||
|
bd[j] = bd[j-1]^alpha_to[(gg[j]+feedback)%nn] ;
|
||||||
|
else
|
||||||
|
bd[j] = bd[j-1] ;
|
||||||
|
bd[0] = alpha_to[(gg[0]+feedback)%nn] ;
|
||||||
|
} else {
|
||||||
|
for (j=bb-1; j>0; j--)
|
||||||
|
bd[j] = bd[j-1] ;
|
||||||
|
bd[0] = 0 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* assume we have received bits grouped into mm-bit symbols in recd[i],
|
||||||
|
i=0..(nn-1), and recd[i] is index form (ie as powers of alpha).
|
||||||
|
We first compute the 2*tt syndromes by substituting alpha**i into rec(X) and
|
||||||
|
evaluating, storing the syndromes in s[i], i=1..2tt (leave s[0] zero) .
|
||||||
|
Then we use the Berlekamp iteration to find the error location polynomial
|
||||||
|
elp[i]. If the degree of the elp is >tt, we cannot correct all the errors
|
||||||
|
and hence just put out the information symbols uncorrected. If the degree of
|
||||||
|
elp is <=tt, we substitute alpha**i , i=1..n into the elp to get the roots,
|
||||||
|
hence the inverse roots, the error location numbers. If the number of errors
|
||||||
|
located does not equal the degree of the elp, we have more than tt errors
|
||||||
|
and cannot correct them. Otherwise, we then solve for the error value at
|
||||||
|
the error location and correct the error. The procedure is that found in
|
||||||
|
Lin and Costello. For the cases where the number of errors is known to be too
|
||||||
|
large to correct, the information symbols as received are output (the
|
||||||
|
advantage of systematic encoding is that hopefully some of the information
|
||||||
|
symbols will be okay and that if we are in luck, the errors are in the
|
||||||
|
parity part of the transmitted codeword). Of course, these insoluble cases
|
||||||
|
can be returned as error flags to the calling routine if desired. */
|
||||||
|
/** return value: number of corrected errors or -1 if can't correct it */
|
||||||
|
int RScodec::decode(unsigned char *data) {
|
||||||
|
if (!isOk) return -1;
|
||||||
|
int bb = nn-kk;; //nn-kk length of parity data
|
||||||
|
|
||||||
|
int *recd = new (std::nothrow) int[nn];
|
||||||
|
int **elp = new int*[bb + 2];
|
||||||
|
for (int i = 0; i < bb + 2; ++i)
|
||||||
|
elp[i] = new int[bb];
|
||||||
|
int *d = new int[bb + 2];
|
||||||
|
int *l = new int[bb + 2];
|
||||||
|
int *u_lu = new int[bb + 2];
|
||||||
|
int *s = new int[bb + 1];
|
||||||
|
int *root = new int[tt];
|
||||||
|
int *loc = new int[tt];
|
||||||
|
int *z = new int[tt+1];
|
||||||
|
int *err = new int[nn];
|
||||||
|
int *reg = new int[tt + 1];
|
||||||
|
|
||||||
|
int res = calcDecode(data, recd, elp ,d ,l, u_lu, s, root, loc ,z, err, reg, bb);
|
||||||
|
|
||||||
|
delete[] recd;
|
||||||
|
for (int i = 0; i < bb + 2; ++i)
|
||||||
|
delete[] elp[i];
|
||||||
|
delete[] elp;
|
||||||
|
delete[] d;
|
||||||
|
delete[] l;
|
||||||
|
delete[] u_lu;
|
||||||
|
delete[] s;
|
||||||
|
delete[] root;
|
||||||
|
delete[] loc;
|
||||||
|
delete[] z;
|
||||||
|
delete[] err;
|
||||||
|
delete[] reg;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
69
src/libs/vdxf/libdxfrw/intern/rscodec.h
Normal file
69
src/libs/vdxf/libdxfrw/intern/rscodec.h
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reed-Solomon codec
|
||||||
|
* Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff
|
||||||
|
*
|
||||||
|
* Original code:
|
||||||
|
* This program may be freely modified and/or given to whoever wants it.
|
||||||
|
* A condition of such distribution is that the author's contribution be
|
||||||
|
* acknowledged by his name being left in the comments heading the program,
|
||||||
|
* however no responsibility is accepted for any financial or other loss which
|
||||||
|
* may result from some unforseen errors or malfunctioning of the program
|
||||||
|
* during use.
|
||||||
|
* Simon Rockliff, 26th June 1991
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RSCODEC_H
|
||||||
|
#define RSCODEC_H
|
||||||
|
/**
|
||||||
|
mm: RS code over GF(2^4)
|
||||||
|
nn: nn= (2^mm) - 1 length of codeword
|
||||||
|
tt: number of errors that can be corrected
|
||||||
|
kk: kk = nn-2*tt
|
||||||
|
pp: irreducible polynomial coeffts, pp [mm] send as int
|
||||||
|
*/
|
||||||
|
class RScodec {
|
||||||
|
public:
|
||||||
|
RScodec(unsigned int pp, int mm, int tt);
|
||||||
|
|
||||||
|
~RScodec();
|
||||||
|
// bool encode(int *data, int *parity);
|
||||||
|
// int decode(int *recd);
|
||||||
|
bool encode(unsigned char *data, unsigned char *parity);
|
||||||
|
int decode(unsigned char *data);
|
||||||
|
bool isOkey(){return isOk;}
|
||||||
|
const unsigned int* indexOf() {return index_of;}
|
||||||
|
const int* alphaTo() {return alpha_to;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RSgenerate_gf(unsigned int pp);
|
||||||
|
void RSgen_poly();
|
||||||
|
int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mm; //RS code over GF(2^4)
|
||||||
|
int tt; //number of errors that can be corrected
|
||||||
|
int nn; //(2^mm) - 1 length of codeword
|
||||||
|
int kk; //nn-2*tt length of original data
|
||||||
|
|
||||||
|
int *gg;
|
||||||
|
bool isOk;
|
||||||
|
unsigned int *index_of;
|
||||||
|
int *alpha_to;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RSCODEC_H
|
237
src/libs/vdxf/libdxfrw/libdwgr.cpp
Normal file
237
src/libs/vdxf/libdxfrw/libdwgr.cpp
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "libdwgr.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
|
#include "intern/drw_dbg.h"
|
||||||
|
#include "intern/drw_textcodec.h"
|
||||||
|
#include "intern/dwgreader.h"
|
||||||
|
#include "intern/dwgreader15.h"
|
||||||
|
#include "intern/dwgreader18.h"
|
||||||
|
#include "intern/dwgreader21.h"
|
||||||
|
#include "intern/dwgreader24.h"
|
||||||
|
#include "intern/dwgreader27.h"
|
||||||
|
|
||||||
|
#define FIRSTHANDLE 48
|
||||||
|
|
||||||
|
/*enum sections {
|
||||||
|
secUnknown,
|
||||||
|
secHeader,
|
||||||
|
secTables,
|
||||||
|
secBlocks,
|
||||||
|
secEntities,
|
||||||
|
secObjects
|
||||||
|
};*/
|
||||||
|
|
||||||
|
dwgR::dwgR(){
|
||||||
|
DRW_DBGSL(DRW_dbg::NONE);
|
||||||
|
reader = NULL;
|
||||||
|
// writer = NULL;
|
||||||
|
applyExt = false;
|
||||||
|
version = DRW::UNKNOWNV;
|
||||||
|
error = DRW::BAD_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwgR::~dwgR(){
|
||||||
|
if (reader != NULL)
|
||||||
|
delete reader;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void dwgR::setDebug(DRW::DBG_LEVEL lvl){
|
||||||
|
switch (lvl){
|
||||||
|
case DRW::DEBUG:
|
||||||
|
DRW_DBGSL(DRW_dbg::DEBUG);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DRW_DBGSL(DRW_dbg::NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*reads metadata and loads image preview*/
|
||||||
|
bool dwgR::getPreview(std::istream &stream){
|
||||||
|
bool isOk = false;
|
||||||
|
|
||||||
|
isOk = open(&stream);
|
||||||
|
if (!isOk)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
isOk = reader->readMetaData();
|
||||||
|
if (isOk) {
|
||||||
|
isOk = reader->readPreview();
|
||||||
|
} else
|
||||||
|
error = DRW::BAD_READ_METADATA;
|
||||||
|
|
||||||
|
if (reader != NULL) {
|
||||||
|
delete reader;
|
||||||
|
reader = NULL;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgR::read(std::istream &stream, DRW_Interface *interface_, bool ext){
|
||||||
|
applyExt = ext;
|
||||||
|
iface = interface_;
|
||||||
|
|
||||||
|
bool isOk = false;
|
||||||
|
|
||||||
|
isOk = open(&stream);
|
||||||
|
if (!isOk)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
isOk = reader->readMetaData();
|
||||||
|
if (isOk) {
|
||||||
|
isOk = reader->readFileHeader();
|
||||||
|
if (isOk) {
|
||||||
|
isOk = processDwg();
|
||||||
|
} else
|
||||||
|
error = DRW::BAD_READ_FILE_HEADER;
|
||||||
|
} else
|
||||||
|
error = DRW::BAD_READ_METADATA;
|
||||||
|
|
||||||
|
if (reader != NULL) {
|
||||||
|
delete reader;
|
||||||
|
reader = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dwgR::open(std::istream *stream){
|
||||||
|
char line[7];
|
||||||
|
stream->read (line, 6);
|
||||||
|
line[6]='\0';
|
||||||
|
DRW_DBG("dwgR::read 2\n");
|
||||||
|
DRW_DBG("dwgR::read line version: ");
|
||||||
|
DRW_DBG(line);
|
||||||
|
DRW_DBG("\n");
|
||||||
|
|
||||||
|
if (strcmp(line, "AC1006") == 0)
|
||||||
|
version = DRW::AC1006;
|
||||||
|
else if (strcmp(line, "AC1009") == 0) {
|
||||||
|
version = DRW::AC1009;
|
||||||
|
// reader = new dwgReader09(&filestr, this);
|
||||||
|
}else if (strcmp(line, "AC1012") == 0){
|
||||||
|
version = DRW::AC1012;
|
||||||
|
reader = new dwgReader15(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1014") == 0) {
|
||||||
|
version = DRW::AC1014;
|
||||||
|
reader = new dwgReader15(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1015") == 0) {
|
||||||
|
version = DRW::AC1015;
|
||||||
|
reader = new dwgReader15(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1018") == 0){
|
||||||
|
version = DRW::AC1018;
|
||||||
|
reader = new dwgReader18(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1021") == 0) {
|
||||||
|
version = DRW::AC1021;
|
||||||
|
reader = new dwgReader21(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1024") == 0) {
|
||||||
|
version = DRW::AC1024;
|
||||||
|
reader = new dwgReader24(stream, this);
|
||||||
|
} else if (strcmp(line, "AC1027") == 0) {
|
||||||
|
version = DRW::AC1027;
|
||||||
|
reader = new dwgReader27(stream, this);
|
||||||
|
} else
|
||||||
|
version = DRW::UNKNOWNV;
|
||||||
|
|
||||||
|
if (reader == NULL) {
|
||||||
|
error = DRW::BAD_VERSION;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********* Reader Process *********/
|
||||||
|
|
||||||
|
bool dwgR::processDwg() {
|
||||||
|
DRW_DBG("dwgR::processDwg() start processing dwg\n");
|
||||||
|
bool ret;
|
||||||
|
bool ret2;
|
||||||
|
DRW_Header hdr;
|
||||||
|
ret = reader->readDwgHeader(hdr);
|
||||||
|
if (!ret) {
|
||||||
|
error = DRW::BAD_READ_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgClasses();
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_CLASSES;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgHandles();
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_HANDLES;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgTables(hdr);
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_TABLES;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
iface->addHeader(&hdr);
|
||||||
|
|
||||||
|
for (std::map<duint32, DRW_LType*>::iterator it=reader->ltypemap.begin(); it!=reader->ltypemap.end(); ++it) {
|
||||||
|
DRW_LType *lt = it->second;
|
||||||
|
iface->addLType(const_cast<DRW_LType&>(*lt) );
|
||||||
|
}
|
||||||
|
for (std::map<duint32, DRW_Layer*>::iterator it=reader->layermap.begin(); it!=reader->layermap.end(); ++it) {
|
||||||
|
DRW_Layer *ly = it->second;
|
||||||
|
iface->addLayer(const_cast<DRW_Layer&>(*ly));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::map<duint32, DRW_Textstyle*>::iterator it=reader->stylemap.begin(); it!=reader->stylemap.end(); ++it) {
|
||||||
|
DRW_Textstyle *ly = it->second;
|
||||||
|
iface->addTextStyle(const_cast<DRW_Textstyle&>(*ly));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::map<duint32, DRW_Dimstyle*>::iterator it=reader->dimstylemap.begin(); it!=reader->dimstylemap.end(); ++it) {
|
||||||
|
DRW_Dimstyle *ly = it->second;
|
||||||
|
iface->addDimStyle(const_cast<DRW_Dimstyle&>(*ly));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::map<duint32, DRW_Vport*>::iterator it=reader->vportmap.begin(); it!=reader->vportmap.end(); ++it) {
|
||||||
|
DRW_Vport *ly = it->second;
|
||||||
|
iface->addVport(const_cast<DRW_Vport&>(*ly));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::map<duint32, DRW_AppId*>::iterator it=reader->appIdmap.begin(); it!=reader->appIdmap.end(); ++it) {
|
||||||
|
DRW_AppId *ly = it->second;
|
||||||
|
iface->addAppId(const_cast<DRW_AppId&>(*ly));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgBlocks(*iface);
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_BLOCKS;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgEntities(*iface);
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_ENTITIES;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret2 = reader->readDwgObjects(*iface);
|
||||||
|
if (ret && !ret2) {
|
||||||
|
error = DRW::BAD_READ_OBJECTS;
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
50
src/libs/vdxf/libdxfrw/libdwgr.h
Normal file
50
src/libs/vdxf/libdxfrw/libdwgr.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LIBDWGR_H
|
||||||
|
#define LIBDWGR_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
//#include <deque>
|
||||||
|
#include "drw_entities.h"
|
||||||
|
#include "drw_objects.h"
|
||||||
|
#include "drw_classes.h"
|
||||||
|
#include "drw_interface.h"
|
||||||
|
|
||||||
|
class dwgReader;
|
||||||
|
|
||||||
|
class dwgR {
|
||||||
|
public:
|
||||||
|
dwgR();
|
||||||
|
~dwgR();
|
||||||
|
//read: return true if all ok
|
||||||
|
bool read(std::istream &stream, DRW_Interface *interface_, bool ext);
|
||||||
|
bool getPreview(std::istream &stream);
|
||||||
|
DRW::Version getVersion(){return version;}
|
||||||
|
DRW::error getError(){return error;}
|
||||||
|
void setDebug(DRW::DBG_LEVEL lvl);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool open(std::istream *stream);
|
||||||
|
bool processDwg();
|
||||||
|
private:
|
||||||
|
DRW::Version version;
|
||||||
|
DRW::error error;
|
||||||
|
std::string fileName;
|
||||||
|
bool applyExt; /*apply extrusion in entities to conv in 2D?*/
|
||||||
|
std::string codePage;
|
||||||
|
DRW_Interface *iface;
|
||||||
|
dwgReader *reader;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIBDWGR_H
|
2797
src/libs/vdxf/libdxfrw/libdxfrw.cpp
Normal file
2797
src/libs/vdxf/libdxfrw/libdxfrw.cpp
Normal file
File diff suppressed because it is too large
Load Diff
148
src/libs/vdxf/libdxfrw/libdxfrw.h
Normal file
148
src/libs/vdxf/libdxfrw/libdxfrw.h
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
/******************************************************************************
|
||||||
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||||
|
** **
|
||||||
|
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||||
|
** **
|
||||||
|
** This library is free software, licensed under the terms of the GNU **
|
||||||
|
** General Public License as published by the Free Software Foundation, **
|
||||||
|
** either version 2 of the License, or (at your option) any later version. **
|
||||||
|
** You should have received a copy of the GNU General Public License **
|
||||||
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LIBDXFRW_H
|
||||||
|
#define LIBDXFRW_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "drw_entities.h"
|
||||||
|
#include "drw_objects.h"
|
||||||
|
#include "drw_header.h"
|
||||||
|
#include "drw_interface.h"
|
||||||
|
|
||||||
|
|
||||||
|
class dxfReader;
|
||||||
|
class dxfWriter;
|
||||||
|
|
||||||
|
class dxfRW {
|
||||||
|
public:
|
||||||
|
dxfRW(const char* name);
|
||||||
|
~dxfRW();
|
||||||
|
void setDebug(DRW::DBG_LEVEL lvl);
|
||||||
|
/// reads the file specified in constructor
|
||||||
|
/*!
|
||||||
|
* An interface must be provided. It is used by the class to signal various
|
||||||
|
* components being added.
|
||||||
|
* @param interface_ the interface to use
|
||||||
|
* @param ext should the extrusion be applied to convert in 2D?
|
||||||
|
* @return true for success
|
||||||
|
*/
|
||||||
|
bool read(DRW_Interface *interface_, bool ext);
|
||||||
|
void setBinary(bool b) {binFile = b;}
|
||||||
|
|
||||||
|
bool write(DRW_Interface *interface_, DRW::Version ver, bool bin);
|
||||||
|
bool writeLineType(DRW_LType *ent);
|
||||||
|
bool writeLayer(DRW_Layer *ent);
|
||||||
|
bool writeDimstyle(DRW_Dimstyle *ent);
|
||||||
|
bool writeTextstyle(DRW_Textstyle *ent);
|
||||||
|
bool writeVport(DRW_Vport *ent);
|
||||||
|
bool writeAppId(DRW_AppId *ent);
|
||||||
|
bool writePoint(DRW_Point *ent);
|
||||||
|
bool writeLine(DRW_Line *ent);
|
||||||
|
bool writeRay(DRW_Ray *ent);
|
||||||
|
bool writeXline(DRW_Xline *ent);
|
||||||
|
bool writeCircle(DRW_Circle *ent);
|
||||||
|
bool writeArc(DRW_Arc *ent);
|
||||||
|
bool writeEllipse(DRW_Ellipse *ent);
|
||||||
|
bool writeTrace(DRW_Trace *ent);
|
||||||
|
bool writeSolid(DRW_Solid *ent);
|
||||||
|
bool write3dface(DRW_3Dface *ent);
|
||||||
|
bool writeLWPolyline(DRW_LWPolyline *ent);
|
||||||
|
bool writePolyline(DRW_Polyline *ent);
|
||||||
|
bool writeSpline(DRW_Spline *ent);
|
||||||
|
bool writeBlockRecord(std::string name);
|
||||||
|
bool writeBlock(DRW_Block *ent);
|
||||||
|
bool writeInsert(DRW_Insert *ent);
|
||||||
|
bool writeMText(DRW_MText *ent);
|
||||||
|
bool writeText(DRW_Text *ent);
|
||||||
|
bool writeHatch(DRW_Hatch *ent);
|
||||||
|
bool writeViewport(DRW_Viewport *ent);
|
||||||
|
DRW_ImageDef *writeImage(DRW_Image *ent, std::string name);
|
||||||
|
bool writeLeader(DRW_Leader *ent);
|
||||||
|
bool writeDimension(DRW_Dimension *ent);
|
||||||
|
void setEllipseParts(int parts){elParts = parts;} /*!< set parts munber when convert ellipse to polyline */
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// used by read() to parse the content of the file
|
||||||
|
bool processDxf();
|
||||||
|
bool processHeader();
|
||||||
|
bool processTables();
|
||||||
|
bool processBlocks();
|
||||||
|
bool processBlock();
|
||||||
|
bool processEntities(bool isblock);
|
||||||
|
bool processObjects();
|
||||||
|
|
||||||
|
bool processLType();
|
||||||
|
bool processLayer();
|
||||||
|
bool processDimStyle();
|
||||||
|
bool processTextStyle();
|
||||||
|
bool processVports();
|
||||||
|
bool processAppId();
|
||||||
|
|
||||||
|
bool processPoint();
|
||||||
|
bool processLine();
|
||||||
|
bool processRay();
|
||||||
|
bool processXline();
|
||||||
|
bool processCircle();
|
||||||
|
bool processArc();
|
||||||
|
bool processEllipse();
|
||||||
|
bool processTrace();
|
||||||
|
bool processSolid();
|
||||||
|
bool processInsert();
|
||||||
|
bool processLWPolyline();
|
||||||
|
bool processPolyline();
|
||||||
|
bool processVertex(DRW_Polyline* pl);
|
||||||
|
bool processText();
|
||||||
|
bool processMText();
|
||||||
|
bool processHatch();
|
||||||
|
bool processSpline();
|
||||||
|
bool process3dface();
|
||||||
|
bool processViewport();
|
||||||
|
bool processImage();
|
||||||
|
bool processImageDef();
|
||||||
|
bool processDimension();
|
||||||
|
bool processLeader();
|
||||||
|
|
||||||
|
// bool writeHeader();
|
||||||
|
bool writeEntity(DRW_Entity *ent);
|
||||||
|
bool writeTables();
|
||||||
|
bool writeBlocks();
|
||||||
|
bool writeObjects();
|
||||||
|
bool writeExtData(const std::vector<DRW_Variant*> &ed);
|
||||||
|
/*use version from dwgutil.h*/
|
||||||
|
std::string toHexStr(int n);//RLZ removeme
|
||||||
|
|
||||||
|
private:
|
||||||
|
DRW::Version version;
|
||||||
|
std::string fileName;
|
||||||
|
std::string codePage;
|
||||||
|
bool binFile;
|
||||||
|
dxfReader *reader;
|
||||||
|
dxfWriter *writer;
|
||||||
|
DRW_Interface *iface;
|
||||||
|
DRW_Header header;
|
||||||
|
// int section;
|
||||||
|
std::string nextentity;
|
||||||
|
int entCount;
|
||||||
|
bool wlayer0;
|
||||||
|
bool dimstyleStd;
|
||||||
|
bool applyExt;
|
||||||
|
bool writingBlock;
|
||||||
|
int elParts; /*!< parts munber when convert ellipse to polyline */
|
||||||
|
std::map<std::string,int> blockMap;
|
||||||
|
std::vector<DRW_ImageDef*> imageDef; /*!< imageDef list */
|
||||||
|
|
||||||
|
int currHandle;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIBDXFRW_H
|
14
src/libs/vdxf/libdxfrw/main_doc.h
Normal file
14
src/libs/vdxf/libdxfrw/main_doc.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mainpage
|
||||||
|
*
|
||||||
|
* This manual documents the use of <b>libdxfrw</b>.
|
||||||
|
*
|
||||||
|
* With libdxfrw you can read and write several parts of a dxf files.<p>
|
||||||
|
* Dxf files can be written in assci and binary form, both are supported.<p>
|
||||||
|
* Dwg support (only read) are work in progress.<p>
|
||||||
|
*
|
||||||
|
* the complete documentation and examples are pending to free time,
|
||||||
|
* but to start see DRW_Interface, dxfRW & dwgR, clases
|
||||||
|
*/
|
||||||
|
|
|
@ -2,27 +2,57 @@
|
||||||
# This need for corect working file translations.pro
|
# This need for corect working file translations.pro
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/dxflib/dl_dxf.cpp \
|
|
||||||
$$PWD/dxflib/dl_writer_ascii.cpp \
|
|
||||||
$$PWD/vdxfengine.cpp \
|
$$PWD/vdxfengine.cpp \
|
||||||
$$PWD/vdxfpaintdevice.cpp \
|
$$PWD/vdxfpaintdevice.cpp \
|
||||||
$$PWD/dxflib/dl_writer.cpp
|
$$PWD/libdxfrw/intern/drw_dbg.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/drw_textcodec.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgbuffer.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader15.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader18.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader21.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader24.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader27.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dwgutil.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dxfreader.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/dxfwriter.cpp \
|
||||||
|
$$PWD/libdxfrw/intern/rscodec.cpp \
|
||||||
|
$$PWD/libdxfrw/drw_classes.cpp \
|
||||||
|
$$PWD/libdxfrw/drw_entities.cpp \
|
||||||
|
$$PWD/libdxfrw/drw_header.cpp \
|
||||||
|
$$PWD/libdxfrw/drw_objects.cpp \
|
||||||
|
$$PWD/libdxfrw/libdwgr.cpp \
|
||||||
|
$$PWD/libdxfrw/libdxfrw.cpp \
|
||||||
|
$$PWD/dxiface.cpp \
|
||||||
|
$$PWD/dxfdef.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
$$PWD/dxflib/dl_attributes.h \
|
|
||||||
$$PWD/dxflib/dl_codes.h \
|
|
||||||
$$PWD/dxflib/dl_creationadapter.h \
|
|
||||||
$$PWD/dxflib/dl_creationinterface.h \
|
|
||||||
$$PWD/dxflib/dl_dxf.h \
|
|
||||||
$$PWD/dxflib/dl_entities.h \
|
|
||||||
$$PWD/dxflib/dl_extrusion.h \
|
|
||||||
$$PWD/dxflib/dl_global.h \
|
|
||||||
$$PWD/dxflib/dl_writer.h \
|
|
||||||
$$PWD/dxflib/dl_writer_ascii.h \
|
|
||||||
$$PWD/vdxfengine.h \
|
$$PWD/vdxfengine.h \
|
||||||
$$PWD/vdxfpaintdevice.h \
|
$$PWD/vdxfpaintdevice.h \
|
||||||
$$PWD/dxfdef.h \
|
$$PWD/dxfdef.h \
|
||||||
$$PWD/dxflib/strlcpy.h
|
$$PWD/libdxfrw/intern/drw_dbg.h \
|
||||||
|
$$PWD/libdxfrw/intern/drw_textcodec.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgbuffer.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader15.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader18.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader21.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader24.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgreader27.h \
|
||||||
|
$$PWD/libdxfrw/intern/dwgutil.h \
|
||||||
|
$$PWD/libdxfrw/intern/dxfreader.h \
|
||||||
|
$$PWD/libdxfrw/intern/dxfwriter.h \
|
||||||
|
$$PWD/libdxfrw/intern/rscodec.h \
|
||||||
|
$$PWD/libdxfrw/drw_base.h \
|
||||||
|
$$PWD/libdxfrw/drw_classes.h \
|
||||||
|
$$PWD/libdxfrw/drw_entities.h \
|
||||||
|
$$PWD/libdxfrw/drw_header.h \
|
||||||
|
$$PWD/libdxfrw/drw_interface.h \
|
||||||
|
$$PWD/libdxfrw/drw_objects.h \
|
||||||
|
$$PWD/libdxfrw/libdwgr.h \
|
||||||
|
$$PWD/libdxfrw/libdxfrw.h \
|
||||||
|
$$PWD/libdxfrw/main_doc.h \
|
||||||
|
$$PWD/dxiface.h
|
||||||
|
|
|
@ -48,11 +48,7 @@
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
#include "dxflib/dl_attributes.h"
|
#include "dxiface.h"
|
||||||
#include "dxflib/dl_codes.h"
|
|
||||||
#include "dxflib/dl_dxf.h"
|
|
||||||
#include "dxflib/dl_entities.h"
|
|
||||||
#include "dxflib/dl_writer_ascii.h"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
|
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
|
||||||
|
@ -77,17 +73,20 @@ VDxfEngine::VDxfEngine()
|
||||||
size(),
|
size(),
|
||||||
resolution(static_cast<int>(PrintDPI)),
|
resolution(static_cast<int>(PrintDPI)),
|
||||||
fileName(),
|
fileName(),
|
||||||
|
m_version(DRW::AC1014),
|
||||||
|
m_binary(false),
|
||||||
matrix(),
|
matrix(),
|
||||||
dxf(nullptr),
|
input(),
|
||||||
dw(nullptr),
|
|
||||||
varMeasurement(VarMeasurement::Metric),
|
varMeasurement(VarMeasurement::Metric),
|
||||||
varInsunits(VarInsunits::Centimeters)
|
varInsunits(VarInsunits::Centimeters),
|
||||||
|
textBuffer(new DRW_Text())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VDxfEngine::~VDxfEngine()
|
VDxfEngine::~VDxfEngine()
|
||||||
{
|
{
|
||||||
|
delete textBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -100,143 +99,15 @@ bool VDxfEngine::begin(QPaintDevice *pdev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf = new DL_Dxf();
|
input = QSharedPointer<dx_iface>(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits));
|
||||||
DL_Codes::version exportVersion = DL_Codes::AC1015;
|
|
||||||
QByteArray fileNameArray = getFileName().toLocal8Bit();
|
|
||||||
dw = dxf->out(fileNameArray.data(), exportVersion);
|
|
||||||
|
|
||||||
if (dw==nullptr)
|
|
||||||
{
|
|
||||||
qWarning("VDxfEngine::begin(), can't open file");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dxf->writeHeader(*dw);
|
|
||||||
|
|
||||||
dxf->writeComment(*dw, "Valentina DXF File");
|
|
||||||
|
|
||||||
dw->dxfString(9, "$ANGDIR"); // 1 = Clockwise angles, 0 = Counterclockwise
|
|
||||||
dw->dxfInt(70, 0); // Qt use counterclockwise
|
|
||||||
|
|
||||||
dw->dxfString(9, "$MEASUREMENT"); // Sets drawing units: 0 = English; 1 = Metric
|
|
||||||
dw->dxfInt(70, static_cast<int>(varMeasurement));
|
|
||||||
|
|
||||||
dw->dxfString(9, "$INSUNITS");
|
|
||||||
dw->dxfInt(70, static_cast<int>(varInsunits));
|
|
||||||
|
|
||||||
dw->dxfString(9, "$DIMSCALE");
|
|
||||||
dw->dxfReal(40, 1.0);
|
|
||||||
|
|
||||||
// Official documentation says that initial value is 1.0, however LibreCAD has trouble if not set this value
|
|
||||||
// explicitly.
|
|
||||||
dw->dxfString(9, "$DIMLFAC");
|
|
||||||
dw->dxfReal(40, 1.0);
|
|
||||||
|
|
||||||
QString dateTime = QDateTime::currentDateTime().toString("yyyyMMdd.HHmmsszzz");
|
|
||||||
dateTime.chop(1);// we need hundredths of a second
|
|
||||||
dw->dxfString(9, "$TDCREATE");
|
|
||||||
dw->dxfString(40, dateTime.toUtf8().constData());
|
|
||||||
|
|
||||||
dw->sectionEnd();
|
|
||||||
|
|
||||||
dw->sectionTables();
|
|
||||||
dxf->writeVPort(*dw);
|
|
||||||
|
|
||||||
dw->tableLinetypes(25);
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("BYBLOCK", "BYBLOCK", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("BYLAYER", "BYLAYER", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("CONTINUOUS", "Continuous", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("ACAD_ISO02W100", "ACAD_ISO02W100", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("ACAD_ISO03W100", "ACAD_ISO03W100", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("ACAD_ISO04W100", "ACAD_ISO04W100", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("ACAD_ISO05W100", "ACAD_ISO05W100", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("BORDER", "BORDER", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("BORDER2", "BORDER2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("BORDERX2", "BORDERX2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("CENTER", "CENTER", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("CENTER2", "CENTER2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("CENTERX2", "CENTERX2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHDOT", "DASHDOT", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHDOT2", "DASHDOT2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHDOTX2", "DASHDOTX2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHED", "DASHED", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHED2", "DASHED2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DASHEDX2", "DASHEDX2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DIVIDE", "DIVIDE", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DIVIDE2", "DIVIDE2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DIVIDEX2", "DIVIDEX2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DOT", "DOT", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DOT2", "DOT2", 0, 0, 0.0));
|
|
||||||
dxf->writeLinetype(*dw, DL_LinetypeData("DOTX2", "DOTX2", 0, 0, 0.0));
|
|
||||||
dw->tableEnd();
|
|
||||||
|
|
||||||
int numberOfLayers = 1;
|
|
||||||
dw->tableLayers(numberOfLayers);
|
|
||||||
dxf->writeLayer(*dw,
|
|
||||||
DL_LayerData("0", 0),
|
|
||||||
DL_Attributes(
|
|
||||||
std::string(""), // leave empty
|
|
||||||
DL_Codes::black, // default color
|
|
||||||
100, // default width
|
|
||||||
"CONTINUOUS", // default line style
|
|
||||||
1.0)); // default line type scale
|
|
||||||
|
|
||||||
dw->tableEnd();
|
|
||||||
|
|
||||||
dw->tableStyle(1);
|
|
||||||
DL_StyleData style("Standard", 0, 0.0, 1.0, 0.0, 0, 2.5, "txt", "");
|
|
||||||
style.bold = false;
|
|
||||||
style.italic = false;
|
|
||||||
dxf->writeStyle(*dw, style);
|
|
||||||
dw->tableEnd();
|
|
||||||
|
|
||||||
dxf->writeView(*dw);
|
|
||||||
dxf->writeUcs(*dw);
|
|
||||||
dw->tableAppid(1);
|
|
||||||
dw->tableAppidEntry(0x12);
|
|
||||||
dw->dxfString(2, "ACAD");
|
|
||||||
dw->dxfInt(70, 0);
|
|
||||||
dw->tableEnd();
|
|
||||||
|
|
||||||
dxf->writeDimStyle(*dw, 1, 1, 1, 1, 1);
|
|
||||||
|
|
||||||
dxf->writeBlockRecord(*dw);
|
|
||||||
dxf->writeBlockRecord(*dw, "layout");
|
|
||||||
dw->tableEnd();
|
|
||||||
|
|
||||||
dw->sectionEnd();
|
|
||||||
|
|
||||||
dw->sectionBlocks();
|
|
||||||
dxf->writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0));
|
|
||||||
dxf->writeEndBlock(*dw, "*Model_Space");
|
|
||||||
dxf->writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0));
|
|
||||||
dxf->writeEndBlock(*dw, "*Paper_Space");
|
|
||||||
dxf->writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0));
|
|
||||||
dxf->writeEndBlock(*dw, "*Paper_Space0");
|
|
||||||
|
|
||||||
dxf->writeBlock(*dw, DL_BlockData("layout", 0, 0.0, 0.0, 0.0));
|
|
||||||
// ...
|
|
||||||
// write block entities e.g. with dxf->writeLine(), ..
|
|
||||||
// ...
|
|
||||||
dxf->writeEndBlock(*dw, "layout");
|
|
||||||
|
|
||||||
dw->sectionEnd();
|
|
||||||
|
|
||||||
dw->sectionEntities();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VDxfEngine::end()
|
bool VDxfEngine::end()
|
||||||
{
|
{
|
||||||
dw->sectionEnd();
|
const bool res = input->fileExport(m_binary);
|
||||||
dxf->writeObjects(*dw);
|
return res;
|
||||||
dxf->writeObjectsEnd(*dw);
|
|
||||||
dw->dxfEOF();
|
|
||||||
dw->close();
|
|
||||||
delete dw;
|
|
||||||
delete dxf;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -265,21 +136,54 @@ void VDxfEngine::drawPath(const QPainterPath &path)
|
||||||
const QPolygonF polygon = subpaths.at(j);
|
const QPolygonF polygon = subpaths.at(j);
|
||||||
if (polygon.isEmpty())
|
if (polygon.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf->writePolyline(*dw,
|
if (m_version > DRW::AC1009)
|
||||||
DL_PolylineData(polygon.size(), 0, 0, 0),
|
{ // Use lwpolyline
|
||||||
DL_Attributes("0", getPenColor(), -1, getPenStyle(), 1.0));
|
DRW_LWPolyline *poly = new DRW_LWPolyline();
|
||||||
|
poly->layer = "0";
|
||||||
|
poly->color = getPenColor();
|
||||||
|
poly->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
poly->lineType = getPenStyle();
|
||||||
|
|
||||||
|
if (polygon.size() > 1 && polygon.first() == polygon.last())
|
||||||
|
{
|
||||||
|
poly->flags |= 0x1; // closed
|
||||||
|
}
|
||||||
|
|
||||||
|
poly->flags |= 0x80; // plinegen
|
||||||
|
|
||||||
for (int i=0; i < polygon.count(); ++i)
|
for (int i=0; i < polygon.count(); ++i)
|
||||||
{
|
{
|
||||||
dxf->writeVertex(*dw,
|
poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits),
|
||||||
DL_VertexData(FromPixel(polygon.at(i).x(), varInsunits),
|
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
input->AddEntity(poly);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Use polyline
|
||||||
|
DRW_Polyline *poly = new DRW_Polyline();
|
||||||
|
poly->layer = "0";
|
||||||
|
poly->color = getPenColor();
|
||||||
|
poly->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
poly->lineType = getPenStyle();
|
||||||
|
if (polygon.size() > 1 && polygon.first() == polygon.last())
|
||||||
|
{
|
||||||
|
poly->flags |= 0x1; // closed
|
||||||
|
}
|
||||||
|
|
||||||
|
poly->flags |= 0x80; // plinegen
|
||||||
|
|
||||||
|
for (int i=0; i < polygon.count(); ++i)
|
||||||
|
{
|
||||||
|
poly->addVertex(DRW_Vertex(FromPixel(polygon.at(i).x(), varInsunits),
|
||||||
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0, 0));
|
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf->writePolylineEnd(*dw);
|
input->AddEntity(poly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,14 +195,17 @@ void VDxfEngine::drawLines(const QLineF * lines, int lineCount)
|
||||||
const QPointF p1 = matrix.map(lines[i].p1());
|
const QPointF p1 = matrix.map(lines[i].p1());
|
||||||
const QPointF p2 = matrix.map(lines[i].p2());
|
const QPointF p2 = matrix.map(lines[i].p2());
|
||||||
|
|
||||||
dxf->writeLine(*dw,
|
DRW_Line *line = new DRW_Line();
|
||||||
DL_LineData(FromPixel(p1.x(), varInsunits), // start point
|
line->basePoint = DRW_Coord(FromPixel(p1.x(), varInsunits),
|
||||||
FromPixel(getSize().height() - p1.y(), varInsunits),
|
FromPixel(getSize().height() - p1.y(), varInsunits), 0);
|
||||||
FromPixel(0.0, varInsunits),
|
line->secPoint = DRW_Coord(FromPixel(p2.x(), varInsunits),
|
||||||
FromPixel(p2.x(), varInsunits), // end point
|
FromPixel(getSize().height() - p2.y(), varInsunits), 0);
|
||||||
FromPixel(getSize().height() - p2.y(), varInsunits),
|
line->layer = "0";
|
||||||
FromPixel(0.0, varInsunits)),
|
line->color = getPenColor();
|
||||||
DL_Attributes("0", getPenColor(), -1, getPenStyle(), 1.0));
|
line->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
line->lineType = getPenStyle();
|
||||||
|
|
||||||
|
input->AddEntity(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,19 +225,54 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf->writePolyline(*dw,
|
if (m_version > DRW::AC1009)
|
||||||
DL_PolylineData(pointCount, 0, 0, 0),
|
{ // Use lwpolyline
|
||||||
DL_Attributes("0", getPenColor(), -1, getPenStyle(), 1.0));
|
DRW_LWPolyline *poly = new DRW_LWPolyline();
|
||||||
|
poly->layer = "0";
|
||||||
|
poly->color = getPenColor();
|
||||||
|
poly->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
poly->lineType = getPenStyle();
|
||||||
|
|
||||||
|
if (pointCount > 1 && points[0] == points[pointCount])
|
||||||
|
{
|
||||||
|
poly->flags |= 0x1; // closed
|
||||||
|
}
|
||||||
|
|
||||||
|
poly->flags |= 0x80; // plinegen
|
||||||
|
|
||||||
for (int i = 0; i < pointCount; ++i)
|
for (int i = 0; i < pointCount; ++i)
|
||||||
{
|
{
|
||||||
const QPointF p = matrix.map(points[i]);
|
const QPointF p = matrix.map(points[i]);
|
||||||
dxf->writeVertex(*dw,
|
poly->addVertex(DRW_Vertex2D(FromPixel(p.x(), varInsunits),
|
||||||
DL_VertexData(FromPixel(p.x(), varInsunits),
|
FromPixel(getSize().height() - p.y(), varInsunits), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
input->AddEntity(poly);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Use polyline
|
||||||
|
DRW_Polyline *poly = new DRW_Polyline();
|
||||||
|
poly->layer = "0";
|
||||||
|
poly->color = getPenColor();
|
||||||
|
poly->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
poly->lineType = getPenStyle();
|
||||||
|
|
||||||
|
if (pointCount > 1 && points[0] == points[pointCount])
|
||||||
|
{
|
||||||
|
poly->flags |= 0x1; // closed
|
||||||
|
}
|
||||||
|
|
||||||
|
poly->flags |= 0x80; // plinegen
|
||||||
|
|
||||||
|
for (int i = 0; i < pointCount; ++i)
|
||||||
|
{
|
||||||
|
const QPointF p = matrix.map(points[i]);
|
||||||
|
poly->addVertex(DRW_Vertex(FromPixel(p.x(), varInsunits),
|
||||||
FromPixel(getSize().height() - p.y(), varInsunits), 0, 0));
|
FromPixel(getSize().height() - p.y(), varInsunits), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf->writePolylineEnd(*dw);
|
input->AddEntity(poly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -364,17 +306,20 @@ void VDxfEngine::drawEllipse(const QRectF & rect)
|
||||||
ratio = rect.height()/rect.width();
|
ratio = rect.height()/rect.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
dxf->writeEllipse(*dw,
|
DRW_Ellipse *ellipse = new DRW_Ellipse();
|
||||||
DL_EllipseData(FromPixel(newRect.center().x(), varInsunits), // center X
|
ellipse->basePoint = DRW_Coord(FromPixel(newRect.center().x(), varInsunits),
|
||||||
FromPixel(getSize().height() - newRect.center().y(), varInsunits), // center Y
|
FromPixel(getSize().height() - newRect.center().y(), varInsunits), 0);
|
||||||
FromPixel(0, varInsunits), // center Z
|
ellipse->secPoint = DRW_Coord(FromPixel(majorX, varInsunits), FromPixel(majorY, varInsunits), 0);
|
||||||
FromPixel(majorX, varInsunits),
|
ellipse->ratio = ratio;
|
||||||
FromPixel(majorY, varInsunits),
|
ellipse->staparam = 0;
|
||||||
FromPixel(0, varInsunits),
|
ellipse->endparam = 2*M_PI;
|
||||||
FromPixel(ratio, varInsunits),
|
|
||||||
0, 6.28 // startangle and endangle of ellipse in rad
|
ellipse->layer = "0";
|
||||||
),
|
ellipse->color = getPenColor();
|
||||||
DL_Attributes("0", getPenColor(), -1, getPenStyle(), 1.0));
|
ellipse->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
|
ellipse->lineType = getPenStyle();
|
||||||
|
|
||||||
|
input->AddEntity(ellipse);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -385,29 +330,47 @@ void VDxfEngine::drawEllipse(const QRect & rect)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
|
void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
|
||||||
|
{
|
||||||
|
if (textBuffer->text.size() == 0)
|
||||||
{
|
{
|
||||||
const QPointF startPoint = matrix.map(p);
|
const QPointF startPoint = matrix.map(p);
|
||||||
const double rotationAngle = atan(matrix.m12()/matrix.m11());
|
const double rotationAngle = qRadiansToDegrees(qAtan2(matrix.m12(), matrix.m11()));
|
||||||
|
|
||||||
const QFont f = textItem.font();
|
const QFont f = textItem.font();
|
||||||
const int textSize = f.pixelSize() == -1 ? f.pointSize() : f.pixelSize();
|
const UTF8STRING fontStyle = input->AddFont(f);
|
||||||
dxf->writeText(*dw,
|
|
||||||
DL_TextData(FromPixel(startPoint.x(), varInsunits),
|
textBuffer->basePoint = DRW_Coord(FromPixel(startPoint.x(), varInsunits),
|
||||||
FromPixel(getSize().height() - startPoint.y(), varInsunits),
|
FromPixel(getSize().height() - startPoint.y(), varInsunits), 0);
|
||||||
FromPixel(0, varInsunits),
|
textBuffer->secPoint = DRW_Coord(FromPixel(startPoint.x(), varInsunits),
|
||||||
FromPixel(startPoint.x(), varInsunits),
|
FromPixel(getSize().height() - startPoint.y(), varInsunits), 0);
|
||||||
FromPixel(getSize().height() - startPoint.y(), varInsunits),
|
textBuffer->height = FromPixel(QFontMetrics(f).height(), varInsunits);
|
||||||
FromPixel(0, varInsunits),
|
|
||||||
textSize * matrix.m11(),
|
textBuffer->style = fontStyle;
|
||||||
1, // relative X scale factor
|
textBuffer->angle = -rotationAngle;
|
||||||
0, // flag (0 = default, 2 = Backwards, 4 = Upside down)
|
|
||||||
0, // Horizontal justification (0 = Left (default), 1 = Center, 2 = Right,)
|
textBuffer->layer = "0";
|
||||||
0, // Vertical justification (0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top)
|
textBuffer->color = getPenColor();
|
||||||
textItem.text().toUtf8().constData(), // text data
|
textBuffer->lWeight = DRW_LW_Conv::widthByLayer;
|
||||||
f.family().toUtf8().constData(), // font
|
textBuffer->lineType = getPenStyle();
|
||||||
-rotationAngle
|
}
|
||||||
),
|
|
||||||
DL_Attributes("0", getPenColor(), -1, getPenStyle(), 1.0));
|
/* Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding
|
||||||
|
* special placholder. */
|
||||||
|
QString t = textItem.text();
|
||||||
|
const bool foundEndOfString = t.contains(endStringPlaceholder);
|
||||||
|
|
||||||
|
if (foundEndOfString)
|
||||||
|
{
|
||||||
|
t.replace(endStringPlaceholder, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
textBuffer->text += t.toStdString();
|
||||||
|
|
||||||
|
if (foundEndOfString)
|
||||||
|
{
|
||||||
|
input->AddEntity(textBuffer);
|
||||||
|
textBuffer = new DRW_Text();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -464,6 +427,31 @@ void VDxfEngine::setFileName(const QString &value)
|
||||||
fileName = value;
|
fileName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DRW::Version VDxfEngine::GetVersion() const
|
||||||
|
{
|
||||||
|
return m_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDxfEngine::SetVersion(DRW::Version version)
|
||||||
|
{
|
||||||
|
Q_ASSERT(not isActive());
|
||||||
|
m_version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDxfEngine::SetBinaryFormat(bool binary)
|
||||||
|
{
|
||||||
|
m_binary = binary;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VDxfEngine::IsBinaryFormat() const
|
||||||
|
{
|
||||||
|
return m_binary;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
std::string VDxfEngine::getPenStyle()
|
std::string VDxfEngine::getPenStyle()
|
||||||
{
|
{
|
||||||
|
@ -474,9 +462,9 @@ std::string VDxfEngine::getPenStyle()
|
||||||
case Qt::DotLine:
|
case Qt::DotLine:
|
||||||
return "DOT";
|
return "DOT";
|
||||||
case Qt::DashDotLine:
|
case Qt::DashDotLine:
|
||||||
return "DASHDOT";
|
return "DASHDOT2";
|
||||||
case Qt::DashDotDotLine:
|
case Qt::DashDotDotLine:
|
||||||
return "DIVIDE";
|
return "DIVIDE2";
|
||||||
case Qt::SolidLine:
|
case Qt::SolidLine:
|
||||||
default:
|
default:
|
||||||
return "BYLAYER";
|
return "BYLAYER";
|
||||||
|
@ -490,67 +478,67 @@ int VDxfEngine::getPenColor()
|
||||||
|
|
||||||
if(color == Qt::black)
|
if(color == Qt::black)
|
||||||
{
|
{
|
||||||
return DL_Codes::black;
|
return DRW::black;
|
||||||
}
|
}
|
||||||
else if(color == Qt::white)
|
else if(color == Qt::white)
|
||||||
{
|
{
|
||||||
return DL_Codes::white;
|
return DRW::white;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkGray)
|
else if(color == Qt::darkGray)
|
||||||
{
|
{
|
||||||
return DL_Codes::gray;
|
return DRW::gray;
|
||||||
}
|
}
|
||||||
else if(color == Qt::gray)
|
else if(color == Qt::gray)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_gray;
|
return DRW::l_gray;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkMagenta)
|
else if(color == Qt::darkMagenta)
|
||||||
{
|
{
|
||||||
return DL_Codes::magenta;
|
return DRW::magenta;
|
||||||
}
|
}
|
||||||
else if(color == Qt::magenta)
|
else if(color == Qt::magenta)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_magenta;
|
return DRW::l_magenta;
|
||||||
}
|
}
|
||||||
else if(color == Qt::cyan)
|
else if(color == Qt::cyan)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_cyan;
|
return DRW::l_cyan;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkCyan)
|
else if(color == Qt::darkCyan)
|
||||||
{
|
{
|
||||||
return DL_Codes::cyan;
|
return DRW::cyan;
|
||||||
}
|
}
|
||||||
else if(color == Qt::blue)
|
else if(color == Qt::blue)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_blue;
|
return DRW::l_blue;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkBlue)
|
else if(color == Qt::darkBlue)
|
||||||
{
|
{
|
||||||
return DL_Codes::blue;
|
return DRW::blue;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkGreen)
|
else if(color == Qt::darkGreen)
|
||||||
{
|
{
|
||||||
return DL_Codes::green;
|
return DRW::green;
|
||||||
}
|
}
|
||||||
else if(color == Qt::green)
|
else if(color == Qt::green)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_green;
|
return DRW::l_green;
|
||||||
}
|
}
|
||||||
else if(color == Qt::darkRed)
|
else if(color == Qt::darkRed)
|
||||||
{
|
{
|
||||||
return DL_Codes::red;
|
return DRW::red;
|
||||||
}
|
}
|
||||||
else if(color == Qt::red)
|
else if(color == Qt::red)
|
||||||
{
|
{
|
||||||
return DL_Codes::l_red;
|
return DRW::l_red;
|
||||||
}
|
}
|
||||||
else if(color == Qt::yellow)
|
else if(color == Qt::yellow)
|
||||||
{
|
{
|
||||||
return DL_Codes::yellow;
|
return DRW::yellow;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return DL_Codes::bylayer;
|
return DRW::ColorByLayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,17 @@
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "dxfdef.h"
|
#include "dxfdef.h"
|
||||||
#include "dxflib/dl_dxf.h"
|
#include "libdxfrw/drw_base.h"
|
||||||
|
|
||||||
class QTextStream;
|
class QTextStream;
|
||||||
|
class dx_iface;
|
||||||
|
class DRW_Text;
|
||||||
|
|
||||||
class VDxfEngine : public QPaintEngine
|
class VDxfEngine : public QPaintEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VDxfEngine();
|
VDxfEngine();
|
||||||
virtual ~VDxfEngine() Q_DECL_OVERRIDE;
|
virtual ~VDxfEngine();
|
||||||
|
|
||||||
virtual bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE;
|
virtual bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE;
|
||||||
virtual bool end() Q_DECL_OVERRIDE;
|
virtual bool end() Q_DECL_OVERRIDE;
|
||||||
|
@ -74,6 +76,12 @@ public:
|
||||||
QString getFileName() const;
|
QString getFileName() const;
|
||||||
void setFileName(const QString &value);
|
void setFileName(const QString &value);
|
||||||
|
|
||||||
|
DRW::Version GetVersion() const;
|
||||||
|
void SetVersion(DRW::Version version);
|
||||||
|
|
||||||
|
void SetBinaryFormat(bool binary);
|
||||||
|
bool IsBinaryFormat() const;
|
||||||
|
|
||||||
std::string getPenStyle();
|
std::string getPenStyle();
|
||||||
int getPenColor();
|
int getPenColor();
|
||||||
|
|
||||||
|
@ -85,11 +93,13 @@ private:
|
||||||
QSize size;
|
QSize size;
|
||||||
double resolution;
|
double resolution;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
DRW::Version m_version;
|
||||||
|
bool m_binary;
|
||||||
QMatrix matrix;
|
QMatrix matrix;
|
||||||
DL_Dxf* dxf;
|
QSharedPointer<dx_iface> input;
|
||||||
DL_WriterA* dw;
|
|
||||||
VarMeasurement varMeasurement;
|
VarMeasurement varMeasurement;
|
||||||
VarInsunits varInsunits;
|
VarInsunits varInsunits;
|
||||||
|
DRW_Text *textBuffer;
|
||||||
|
|
||||||
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
|
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,18 +98,67 @@ double VDxfPaintDevice::getResolution() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDxfPaintDevice::setResolution(double dpi)
|
void VDxfPaintDevice::setResolution(double dpi)
|
||||||
{
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VDxfPaintDevice::setResolution(), cannot set dpi while Dxf is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
engine->setResolution(dpi);
|
engine->setResolution(dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DRW::Version VDxfPaintDevice::GetVersion() const
|
||||||
|
{
|
||||||
|
return engine->GetVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDxfPaintDevice::SetVersion(DRW::Version version)
|
||||||
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VDxfPaintDevice::SetVersion(), cannot set version while Dxf is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
engine->SetVersion(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDxfPaintDevice::SetBinaryFormat(bool binary)
|
||||||
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VDxfPaintDevice::SetBinaryFormat(), cannot set binary format while Dxf is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
engine->SetBinaryFormat(binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VDxfPaintDevice::IsBinaryFromat() const
|
||||||
|
{
|
||||||
|
return engine->IsBinaryFormat();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDxfPaintDevice::setMeasurement(const VarMeasurement &var)
|
void VDxfPaintDevice::setMeasurement(const VarMeasurement &var)
|
||||||
{
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VDxfPaintDevice::setMeasurement(), cannot set measurements while Dxf is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
engine->setMeasurement(var);
|
engine->setMeasurement(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDxfPaintDevice::setInsunits(const VarInsunits &var)
|
void VDxfPaintDevice::setInsunits(const VarInsunits &var)
|
||||||
{
|
{
|
||||||
|
if (engine->isActive())
|
||||||
|
{
|
||||||
|
qWarning("VDxfPaintDevice::setInsunits(), cannot set units while Dxf is being generated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
engine->setInsunits(var);
|
engine->setInsunits(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "dxfdef.h"
|
#include "dxfdef.h"
|
||||||
#include "dxflib/../dxfdef.h"
|
#include "libdxfrw/drw_base.h"
|
||||||
|
|
||||||
class VDxfEngine;
|
class VDxfEngine;
|
||||||
|
|
||||||
|
@ -56,6 +56,12 @@ public:
|
||||||
double getResolution() const;
|
double getResolution() const;
|
||||||
void setResolution(double dpi);
|
void setResolution(double dpi);
|
||||||
|
|
||||||
|
DRW::Version GetVersion() const;
|
||||||
|
void SetVersion(DRW::Version version);
|
||||||
|
|
||||||
|
void SetBinaryFormat(bool binary);
|
||||||
|
bool IsBinaryFromat() const;
|
||||||
|
|
||||||
void setMeasurement(const VarMeasurement &var);
|
void setMeasurement(const VarMeasurement &var);
|
||||||
void setInsunits(const VarInsunits &var);
|
void setInsunits(const VarInsunits &var);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,17 @@ unix {
|
||||||
QMAKE_CXXFLAGS += -Werror
|
QMAKE_CXXFLAGS += -Werror
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -isystem key works only for headers. In some cases it's not enough. But we can't delete these warnings and
|
||||||
|
# want them in the global list. Compromise decision is to delete them from the local list.
|
||||||
|
QMAKE_CXXFLAGS -= \
|
||||||
|
-Weffc++ \
|
||||||
|
-Wconversion \
|
||||||
|
-Wold-style-cast \
|
||||||
|
-Wstack-protector \
|
||||||
|
-Wswitch-default \
|
||||||
|
-Wimplicit-fallthrough \
|
||||||
|
-Wfloat-equal
|
||||||
|
|
||||||
noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer
|
noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer
|
||||||
# do nothing
|
# do nothing
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,8 @@ VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
||||||
unitePages(false),
|
unitePages(false),
|
||||||
stripOptimizationEnabled(false),
|
stripOptimizationEnabled(false),
|
||||||
multiplier(1),
|
multiplier(1),
|
||||||
stripOptimization(false)
|
stripOptimization(false),
|
||||||
|
textAsPaths(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -209,7 +210,7 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
|
||||||
QList<QGraphicsItem *> list;
|
QList<QGraphicsItem *> list;
|
||||||
for (int i=0; i < papers.count(); ++i)
|
for (int i=0; i < papers.count(); ++i)
|
||||||
{
|
{
|
||||||
list.append(papers.at(i).GetPaperItem(autoCrop));
|
list.append(papers.at(i).GetPaperItem(autoCrop, IsTestAsPaths()));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +221,7 @@ QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetails() const
|
||||||
QList<QList<QGraphicsItem *> > list;
|
QList<QList<QGraphicsItem *> > list;
|
||||||
for (int i=0; i < papers.count(); ++i)
|
for (int i=0; i < papers.count(); ++i)
|
||||||
{
|
{
|
||||||
list.append(papers.at(i).GetItemDetails());
|
list.append(papers.at(i).GetItemDetails(IsTestAsPaths()));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -245,6 +246,18 @@ void VLayoutGenerator::SetStripOptimization(bool value)
|
||||||
stripOptimization = value;
|
stripOptimization = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VLayoutGenerator::IsTestAsPaths() const
|
||||||
|
{
|
||||||
|
return textAsPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutGenerator::SetTestAsPaths(bool value)
|
||||||
|
{
|
||||||
|
textAsPaths = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint8 VLayoutGenerator::GetMultiplier() const
|
quint8 VLayoutGenerator::GetMultiplier() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,9 @@ public:
|
||||||
bool IsStripOptimization() const;
|
bool IsStripOptimization() const;
|
||||||
void SetStripOptimization(bool value);
|
void SetStripOptimization(bool value);
|
||||||
|
|
||||||
|
bool IsTestAsPaths() const;
|
||||||
|
void SetTestAsPaths(bool value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Start();
|
void Start();
|
||||||
void Arranged(int count);
|
void Arranged(int count);
|
||||||
|
@ -134,6 +137,7 @@ private:
|
||||||
bool stripOptimizationEnabled;
|
bool stripOptimizationEnabled;
|
||||||
quint8 multiplier;
|
quint8 multiplier;
|
||||||
bool stripOptimization;
|
bool stripOptimization;
|
||||||
|
bool textAsPaths;
|
||||||
|
|
||||||
int PageHeight() const;
|
int PageHeight() const;
|
||||||
int PageWidth() const;
|
int PageWidth() const;
|
||||||
|
|
|
@ -315,13 +315,13 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const
|
QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) const
|
||||||
{
|
{
|
||||||
QGraphicsRectItem *paper;
|
QGraphicsRectItem *paper;
|
||||||
if (autoCrop)
|
if (autoCrop)
|
||||||
{
|
{
|
||||||
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
|
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
|
||||||
QList<QGraphicsItem *> list = GetItemDetails();
|
QList<QGraphicsItem *> list = GetItemDetails(textAsPaths);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
scene->addItem(list.at(i));
|
scene->addItem(list.at(i));
|
||||||
|
@ -346,12 +346,12 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QList<QGraphicsItem *> VLayoutPaper::GetItemDetails() const
|
QList<QGraphicsItem *> VLayoutPaper::GetItemDetails(bool textAsPaths) const
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> list;
|
QList<QGraphicsItem *> list;
|
||||||
for (int i=0; i < d->details.count(); ++i)
|
for (int i=0; i < d->details.count(); ++i)
|
||||||
{
|
{
|
||||||
list.append(d->details.at(i).GetItem());
|
list.append(d->details.at(i).GetItem(textAsPaths));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,8 @@ public:
|
||||||
|
|
||||||
bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop);
|
bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop);
|
||||||
int Count() const;
|
int Count() const;
|
||||||
Q_REQUIRED_RESULT QGraphicsRectItem *GetPaperItem(bool autoCrop) const;
|
Q_REQUIRED_RESULT QGraphicsRectItem *GetPaperItem(bool autoCrop, bool textAsPaths) const;
|
||||||
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetItemDetails() const;
|
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetItemDetails(bool textAsPaths) const;
|
||||||
|
|
||||||
QVector<VLayoutPiece> GetDetails() const;
|
QVector<VLayoutPiece> GetDetails() const;
|
||||||
void SetDetails(const QList<VLayoutPiece>& details);
|
void SetDetails(const QList<VLayoutPiece>& details);
|
||||||
|
|
|
@ -336,19 +336,6 @@ QPointF RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
|
||||||
|
|
||||||
return ptDest + ptCenter;
|
return ptDest + ptCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void CreateLabel(QGraphicsItem *parent, const QPainterPath &path)
|
|
||||||
{
|
|
||||||
SCASSERT(parent != nullptr)
|
|
||||||
|
|
||||||
if (not path.isEmpty())
|
|
||||||
{
|
|
||||||
QGraphicsPathItem* item = new QGraphicsPathItem(parent);
|
|
||||||
item->setPath(path);
|
|
||||||
item->setBrush(QBrush(Qt::black));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -398,14 +385,15 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
|
||||||
const VPieceLabelData& data = piece.GetPatternPieceData();
|
const VPieceLabelData& data = piece.GetPatternPieceData();
|
||||||
if (data.IsVisible() == true)
|
if (data.IsVisible() == true)
|
||||||
{
|
{
|
||||||
det.SetDetail(piece.GetName(), data, QApplication::font(), pattern);
|
det.SetDetail(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
const VPatternLabelData& geom = piece.GetPatternInfo();
|
const VPatternLabelData& geom = piece.GetPatternInfo();
|
||||||
if (geom.IsVisible() == true)
|
if (geom.IsVisible() == true)
|
||||||
{
|
{
|
||||||
VAbstractPattern* pDoc = qApp->getCurrentDocument();
|
VAbstractPattern* pDoc = qApp->getCurrentDocument();
|
||||||
det.SetPatternInfo(pDoc, geom, QApplication::font(), VContainer::size(), VContainer::height(), pattern);
|
det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), VContainer::size(), VContainer::height(),
|
||||||
|
pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry();
|
const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry();
|
||||||
|
@ -489,8 +477,9 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
|
||||||
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
||||||
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
||||||
|
|
||||||
const qreal dAng = qDegreesToRadians(labelAngle);
|
const qreal dAng = qDegreesToRadians(-labelAngle);
|
||||||
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
||||||
|
|
||||||
for (int i = 0; i < v.count(); ++i)
|
for (int i = 0; i < v.count(); ++i)
|
||||||
{
|
{
|
||||||
v[i] = RotatePoint(ptCenter, v.at(i), dAng);
|
v[i] = RotatePoint(ptCenter, v.at(i), dAng);
|
||||||
|
@ -530,7 +519,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
|
||||||
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
||||||
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
||||||
|
|
||||||
const qreal dAng = qDegreesToRadians(labelAngle);
|
const qreal dAng = qDegreesToRadians(-labelAngle);
|
||||||
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
||||||
for (int i = 0; i < v.count(); ++i)
|
for (int i = 0; i < v.count(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -934,7 +923,7 @@ QPainterPath VLayoutPiece::LayoutAllowancePath() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsItem *VLayoutPiece::GetItem() const
|
QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
|
||||||
{
|
{
|
||||||
QGraphicsPathItem *item = GetMainItem();
|
QGraphicsPathItem *item = GetMainItem();
|
||||||
|
|
||||||
|
@ -943,13 +932,108 @@ QGraphicsItem *VLayoutPiece::GetItem() const
|
||||||
CreateInternalPathItem(i, item);
|
CreateInternalPathItem(i, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateLabel(item, CreateLabelText(d->detailLabel, d->m_tmDetail));
|
CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths);
|
||||||
CreateLabel(item, CreateLabelText(d->patternInfo, d->m_tmPattern));
|
CreateLabelStrings(item, d->patternInfo, d->m_tmPattern, textAsPaths);
|
||||||
CreateGrainlineItem(item);
|
CreateGrainlineItem(item);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape,
|
||||||
|
const VTextManager &tm, bool textAsPaths) const
|
||||||
|
{
|
||||||
|
SCASSERT(parent != nullptr)
|
||||||
|
|
||||||
|
if (labelShape.count() > 2)
|
||||||
|
{
|
||||||
|
const qreal dW = QLineF(labelShape.at(0), labelShape.at(1)).length();
|
||||||
|
const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length();
|
||||||
|
const qreal angle = - QLineF(labelShape.at(0), labelShape.at(1)).angle();
|
||||||
|
qreal dY = 0;
|
||||||
|
qreal dX = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
|
||||||
|
{
|
||||||
|
const TextLine& tl = tm.GetSourceLine(i);
|
||||||
|
QFont fnt = tm.GetFont();
|
||||||
|
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
|
||||||
|
fnt.setWeight(tl.m_eFontWeight);
|
||||||
|
fnt.setStyle(tl.m_eStyle);
|
||||||
|
|
||||||
|
QFontMetrics fm(fnt);
|
||||||
|
|
||||||
|
if (textAsPaths)
|
||||||
|
{
|
||||||
|
dY += fm.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dY > dH)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString qsText = tl.m_qsText;
|
||||||
|
if (fm.width(qsText) > dW)
|
||||||
|
{
|
||||||
|
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
||||||
|
}
|
||||||
|
if ((tl.m_eAlign & Qt::AlignLeft) > 0)
|
||||||
|
{
|
||||||
|
dX = 0;
|
||||||
|
}
|
||||||
|
else if ((tl.m_eAlign & Qt::AlignHCenter) > 0)
|
||||||
|
{
|
||||||
|
dX = (dW - fm.width(qsText))/2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dX = dW - fm.width(qsText);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up the rotation around top-left corner matrix
|
||||||
|
QTransform labelMatrix;
|
||||||
|
labelMatrix.translate(labelShape.at(0).x(), labelShape.at(0).y());
|
||||||
|
if (d->mirror)
|
||||||
|
{
|
||||||
|
labelMatrix.scale(-1, 1);
|
||||||
|
labelMatrix.rotate(angle);
|
||||||
|
labelMatrix.translate(-dW, 0);
|
||||||
|
labelMatrix.translate(dX, dY); // Each string has own position
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
labelMatrix.rotate(angle);
|
||||||
|
labelMatrix.translate(dX, dY); // Each string has own position
|
||||||
|
}
|
||||||
|
|
||||||
|
labelMatrix *= d->matrix;
|
||||||
|
|
||||||
|
if (textAsPaths)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addText(0, - static_cast<qreal>(fm.ascent())/6., fnt, qsText);
|
||||||
|
|
||||||
|
QGraphicsPathItem* item = new QGraphicsPathItem(parent);
|
||||||
|
item->setPath(path);
|
||||||
|
item->setBrush(QBrush(Qt::black));
|
||||||
|
item->setTransform(labelMatrix);
|
||||||
|
|
||||||
|
dY += tm.GetSpacing();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem(parent);
|
||||||
|
item->setFont(fnt);
|
||||||
|
item->setText(qsText);
|
||||||
|
item->setTransform(labelMatrix);
|
||||||
|
|
||||||
|
dY += (fm.height() + tm.GetSpacing());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
||||||
{
|
{
|
||||||
|
@ -1062,74 +1146,3 @@ int VLayoutPiece::EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) c
|
||||||
}
|
}
|
||||||
return 0; // Did not find edge
|
return 0; // Did not find edge
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QPainterPath VLayoutPiece::CreateLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm) const
|
|
||||||
{
|
|
||||||
QPainterPath textpath;
|
|
||||||
if (labelShape.count() > 2)
|
|
||||||
{
|
|
||||||
const qreal dW = QLineF(labelShape.at(0), labelShape.at(1)).length();
|
|
||||||
const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length();
|
|
||||||
const qreal angle = QLineF(labelShape.at(0), labelShape.at(1)).angle();
|
|
||||||
qreal dY = 0;
|
|
||||||
qreal dX;
|
|
||||||
|
|
||||||
// set up the rotation around top-left corner matrix
|
|
||||||
QTransform mat;
|
|
||||||
mat.translate(labelShape.at(0).x(), labelShape.at(0).y());
|
|
||||||
if (d->mirror)
|
|
||||||
{
|
|
||||||
mat.scale(-1, 1);
|
|
||||||
mat.rotate(angle);
|
|
||||||
mat.translate(-dW, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mat.rotate(angle);
|
|
||||||
}
|
|
||||||
|
|
||||||
mat *= d->matrix;
|
|
||||||
|
|
||||||
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
|
|
||||||
{
|
|
||||||
const TextLine& tl = tm.GetSourceLine(i);
|
|
||||||
QFont fnt = tm.GetFont();
|
|
||||||
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
|
|
||||||
fnt.setWeight(tl.m_eFontWeight);
|
|
||||||
fnt.setStyle(tl.m_eStyle);
|
|
||||||
|
|
||||||
QFontMetrics fm(fnt);
|
|
||||||
|
|
||||||
dY += fm.height();
|
|
||||||
if (dY > dH)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString qsText = tl.m_qsText;
|
|
||||||
if (fm.width(qsText) > dW)
|
|
||||||
{
|
|
||||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
|
||||||
}
|
|
||||||
if ((tl.m_eAlign & Qt::AlignLeft) > 0)
|
|
||||||
{
|
|
||||||
dX = 0;
|
|
||||||
}
|
|
||||||
else if ((tl.m_eAlign & Qt::AlignHCenter) > 0)
|
|
||||||
{
|
|
||||||
dX = (dW - fm.width(qsText))/2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dX = dW - fm.width(qsText);
|
|
||||||
}
|
|
||||||
QPainterPath path;
|
|
||||||
path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, qsText);
|
|
||||||
textpath.addPath(mat.map(path));
|
|
||||||
dY += tm.GetSpacing();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return textpath;
|
|
||||||
}
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ public:
|
||||||
QPainterPath ContourPath() const;
|
QPainterPath ContourPath() const;
|
||||||
|
|
||||||
QPainterPath LayoutAllowancePath() const;
|
QPainterPath LayoutAllowancePath() const;
|
||||||
Q_REQUIRED_RESULT QGraphicsItem *GetItem() const;
|
Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VLayoutPieceData> d;
|
QSharedDataPointer<VLayoutPieceData> d;
|
||||||
|
@ -135,9 +135,9 @@ private:
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QGraphicsPathItem *GetMainItem() const;
|
Q_REQUIRED_RESULT QGraphicsPathItem *GetMainItem() const;
|
||||||
|
|
||||||
QPainterPath CreateLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm) const;
|
|
||||||
|
|
||||||
void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
|
void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
|
||||||
|
void CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape, const VTextManager &tm,
|
||||||
|
bool textAsPaths) const;
|
||||||
void CreateGrainlineItem(QGraphicsItem *parent) const;
|
void CreateGrainlineItem(QGraphicsItem *parent) const;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -11,11 +11,6 @@ unix {
|
||||||
QMAKE_CXXFLAGS += -Werror
|
QMAKE_CXXFLAGS += -Werror
|
||||||
}
|
}
|
||||||
|
|
||||||
# -isystem key works only for headers. In some cases it's not enough. But we can't delete these warnings and
|
|
||||||
# want them in the global list. Compromise decision is to delete them from the local list.
|
|
||||||
QMAKE_CXXFLAGS -= \
|
|
||||||
-Wlong-long \
|
|
||||||
|
|
||||||
noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer
|
noAddressSanitizer{ # For enable run qmake with CONFIG+=noAddressSanitizer
|
||||||
# do nothing
|
# do nothing
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,6 +49,9 @@ const QString SINGLE_OPTION_PAGETEMPLATE = QStringLiteral("p");
|
||||||
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format");
|
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format");
|
||||||
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f");
|
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f");
|
||||||
|
|
||||||
|
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf");
|
||||||
|
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
|
||||||
|
|
||||||
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
|
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
|
||||||
const QString SINGLE_OPTION_ROTATE = QStringLiteral("r");
|
const QString SINGLE_OPTION_ROTATE = QStringLiteral("r");
|
||||||
|
|
||||||
|
@ -115,6 +118,7 @@ QStringList AllKeys()
|
||||||
<< LONG_OPTION_MEASUREFILE << SINGLE_OPTION_MEASUREFILE
|
<< LONG_OPTION_MEASUREFILE << SINGLE_OPTION_MEASUREFILE
|
||||||
<< LONG_OPTION_PAGETEMPLATE << SINGLE_OPTION_PAGETEMPLATE
|
<< LONG_OPTION_PAGETEMPLATE << SINGLE_OPTION_PAGETEMPLATE
|
||||||
<< LONG_OPTION_EXP2FORMAT << SINGLE_OPTION_EXP2FORMAT
|
<< LONG_OPTION_EXP2FORMAT << SINGLE_OPTION_EXP2FORMAT
|
||||||
|
<< LONG_OPTION_BINARYDXF
|
||||||
<< LONG_OPTION_ROTATE << SINGLE_OPTION_ROTATE
|
<< LONG_OPTION_ROTATE << SINGLE_OPTION_ROTATE
|
||||||
<< LONG_OPTION_CROP << SINGLE_OPTION_CROP
|
<< LONG_OPTION_CROP << SINGLE_OPTION_CROP
|
||||||
<< LONG_OPTION_UNITE << SINGLE_OPTION_UNITE
|
<< LONG_OPTION_UNITE << SINGLE_OPTION_UNITE
|
||||||
|
|
|
@ -46,6 +46,9 @@ extern const QString SINGLE_OPTION_PAGETEMPLATE;
|
||||||
extern const QString LONG_OPTION_EXP2FORMAT;
|
extern const QString LONG_OPTION_EXP2FORMAT;
|
||||||
extern const QString SINGLE_OPTION_EXP2FORMAT;
|
extern const QString SINGLE_OPTION_EXP2FORMAT;
|
||||||
|
|
||||||
|
extern const QString LONG_OPTION_BINARYDXF;
|
||||||
|
extern const QString LONG_OPTION_TEXT2PATHS;
|
||||||
|
|
||||||
extern const QString LONG_OPTION_ROTATE;
|
extern const QString LONG_OPTION_ROTATE;
|
||||||
extern const QString SINGLE_OPTION_ROTATE;
|
extern const QString SINGLE_OPTION_ROTATE;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
@ -65,6 +66,7 @@ const QString settingPatternForbidFlipping = QStringLiteral("pattern/fo
|
||||||
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
|
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
|
||||||
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
|
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
|
||||||
const QString settingPatternDefaultSeamAllowance = QStringLiteral("pattern/defaultSeamAllowance");
|
const QString settingPatternDefaultSeamAllowance = QStringLiteral("pattern/defaultSeamAllowance");
|
||||||
|
const QString settingLabelFont = QStringLiteral("pattern/labelFont");
|
||||||
|
|
||||||
const QString settingGeneralRecentFileList = QStringLiteral("recentFileList");
|
const QString settingGeneralRecentFileList = QStringLiteral("recentFileList");
|
||||||
const QString settingGeneralRestoreFileList = QStringLiteral("restoreFileList");
|
const QString settingGeneralRestoreFileList = QStringLiteral("restoreFileList");
|
||||||
|
@ -810,4 +812,14 @@ double VCommonSettings::GetDefaultSeamAllowance()
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QFont VCommonSettings::GetLabelFont() const
|
||||||
|
{
|
||||||
|
return qvariant_cast<QFont>(value(settingLabelFont, QApplication::font()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCommonSettings::SetLabelFont(const QFont &f)
|
||||||
|
{
|
||||||
|
setValue(settingLabelFont, f);
|
||||||
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ public:
|
||||||
void SetDefaultSeamAllowance(double value);
|
void SetDefaultSeamAllowance(double value);
|
||||||
double GetDefaultSeamAllowance();
|
double GetDefaultSeamAllowance();
|
||||||
|
|
||||||
|
QFont GetLabelFont() const;
|
||||||
|
void SetLabelFont(const QFont &f);
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
static const QString unixStandardSharePath;
|
static const QString unixStandardSharePath;
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QMarginsF)
|
Q_DECLARE_METATYPE(QMarginsF)
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const QString settingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
|
const QString settingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
|
||||||
|
|
||||||
const QString settingPathsPattern = QStringLiteral("paths/pattern");
|
const QString settingPathsPattern = QStringLiteral("paths/pattern");
|
||||||
|
@ -76,6 +78,8 @@ const QString settingFields = QStringLiteral("layout/fields");
|
||||||
const QString settingIgnoreFields = QStringLiteral("layout/ignoreFields");
|
const QString settingIgnoreFields = QStringLiteral("layout/ignoreFields");
|
||||||
const QString settingStripOptimization = QStringLiteral("layout/stripOptimization");
|
const QString settingStripOptimization = QStringLiteral("layout/stripOptimization");
|
||||||
const QString settingMultiplier = QStringLiteral("layout/multiplier");
|
const QString settingMultiplier = QStringLiteral("layout/multiplier");
|
||||||
|
const QString settingTextAsPaths = QStringLiteral("layout/textAsPaths");
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
||||||
|
@ -584,3 +588,21 @@ void VSettings::SetMultiplier(quint8 value)
|
||||||
setValue(settingMultiplier, value);
|
setValue(settingMultiplier, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VSettings::GetTextAsPaths() const
|
||||||
|
{
|
||||||
|
return value(settingTextAsPaths, GetDefTextAsPaths()).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VSettings::GetDefTextAsPaths()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSettings::SetTextAsPaths(bool value)
|
||||||
|
{
|
||||||
|
setValue(settingTextAsPaths, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,10 @@ public:
|
||||||
static quint8 GetDefMultiplier();
|
static quint8 GetDefMultiplier();
|
||||||
void SetMultiplier(quint8 value);
|
void SetMultiplier(quint8 value);
|
||||||
|
|
||||||
|
bool GetTextAsPaths() const;
|
||||||
|
static bool GetDefTextAsPaths();
|
||||||
|
void SetTextAsPaths(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VSettings)
|
Q_DISABLE_COPY(VSettings)
|
||||||
};
|
};
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user