mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-04 03:20:53 +01:00
Add import dxf feature
Use dxf2elmt to import dxf. See https://github.com/antonioaja/dxf2elmt
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user