Add import dxf feature

Use dxf2elmt to import dxf.
See https://github.com/antonioaja/dxf2elmt
This commit is contained in:
joshua
2022-07-23 21:54:23 +02:00
parent 2a7848e1ca
commit 6e81451b46
9 changed files with 373 additions and 2 deletions

View File

@@ -46,6 +46,7 @@
#include "dynamictextfieldeditor.h"
#include "../../newelementwizard.h"
#include "../editorcommands.h"
#include "../../dxf/dxftoelmt.h"
#include <QSettings>
#include <QActionGroup>
@@ -1490,3 +1491,31 @@ void QETElementEditor::on_m_donate_action_triggered() {
}
void QETElementEditor::on_m_about_qt_action_triggered() { qApp->aboutQt(); }
void QETElementEditor::on_m_import_dxf_triggered()
{
if (dxf2ElmtIsPresent(true, this))
{
QString file_path{QFileDialog::getOpenFileName(this,
QObject::tr("Importer un fichier dxf"),
"/home",
"DXF (*.dxf)")};
if (file_path.isEmpty()) {
return;
}
QMessageBox::information(this, tr("Avertissement"), tr("L'import d'un dxf volumineux peut prendre du temps \n"
"veuillez patienter durant l'import..."));
const QByteArray array_{dxfToElmt(file_path)};
if (array_.isEmpty()) {
return;
}
QDomDocument xml_;
xml_.setContent(array_);
m_elmt_scene->fromXml(xml_);
fillPartsList();
}
}

View File

@@ -110,6 +110,7 @@ class QETElementEditor : public QMainWindow
void on_m_youtube_action_triggered();
void on_m_donate_action_triggered();
void on_m_about_qt_action_triggered();
void on_m_import_dxf_triggered();
private:
bool canClose();

View File

@@ -35,6 +35,7 @@
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_open_from_file_action"/>
<addaction name="m_import_dxf"/>
<addaction name="m_open_dxf_action"/>
<addaction name="m_save_action"/>
<addaction name="m_save_as_action"/>
@@ -501,6 +502,15 @@
<string>Space</string>
</property>
</action>
<action name="m_import_dxf">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/run-dxf.png</normaloff>:/ico/16x16/run-dxf.png</iconset>
</property>
<property name="text">
<string>Importer un dxf</string>
</property>
</action>
</widget>
<resources>
<include location="../../../qelectrotech.qrc"/>