1
/***************************************************************************
2
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
27
# include <QDialogButtonBox>
28
# include <QRegularExpression>
29
# include <QRegularExpressionValidator>
30
# include <QVBoxLayout>
31
# include <Interface_Static.hxx>
34
#include <App/Application.h>
35
#include <Base/Parameter.h>
36
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
37
#include <Mod/Part/App/STEP/ImportExportSettings.h>
39
#include "DlgExportStep.h"
40
#include "ui_DlgExportStep.h"
41
#include "ui_DlgExportHeaderStep.h"
44
using namespace PartGui;
46
DlgExportStep::DlgExportStep(QWidget* parent)
47
: PreferencePage(parent)
48
, ui(new Ui_DlgExportStep)
52
ui->comboBoxSchema->setItemData(0, QByteArray("AP203"));
53
ui->comboBoxSchema->setItemData(1, QByteArray("AP214CD"));
54
ui->comboBoxSchema->setItemData(2, QByteArray("AP214DIS"));
55
ui->comboBoxSchema->setItemData(3, QByteArray("AP214IS"));
56
ui->comboBoxSchema->setItemData(4, QByteArray("AP242DIS"));
58
// https://tracker.dev.opencascade.org/view.php?id=25654
59
ui->checkBoxPcurves->setToolTip(tr("This parameter indicates whether parametric curves (curves in parametric space of surface)\n"
60
"should be written into the STEP file. This parameter can be set to off in order to minimize\n"
61
"the size of the resulting STEP file."));
63
Part::OCAF::ImportExportSettings settings;
64
ui->checkBoxExportHiddenObj->setChecked(settings.getExportHiddenObject());
65
ui->checkBoxExportLegacy->setChecked(settings.getExportLegacy());
66
ui->checkBoxKeepPlacement->setChecked(settings.getExportKeepPlacement());
70
* Destroys the object and frees any allocated resources
72
DlgExportStep::~DlgExportStep() = default;
74
void DlgExportStep::saveSettings()
77
Part::STEP::ImportExportSettings settings;
78
settings.setWriteSurfaceCurveMode(ui->checkBoxPcurves->isChecked());
81
int unit = ui->comboBoxUnits->currentIndex();
82
settings.setUnit(static_cast<Part::Interface::Unit>(unit));
85
// possible values: AP203, AP214CD (1996), AP214DIS (1998), AP214IS (2002), AP242DIS
86
QByteArray schema = ui->comboBoxSchema->itemData(ui->comboBoxSchema->currentIndex()).toByteArray();
87
settings.setScheme(schema);
89
// (h)STEP of Import module
90
ui->checkBoxExportHiddenObj->onSave();
91
ui->checkBoxExportLegacy->onSave();
92
ui->checkBoxKeepPlacement->onSave();
95
void DlgExportStep::loadSettings()
98
Part::STEP::ImportExportSettings settings;
99
ui->checkBoxPcurves->setChecked(settings.getWriteSurfaceCurveMode());
102
ui->comboBoxUnits->setCurrentIndex(static_cast<int>(settings.getUnit()));
105
QByteArray ap(settings.getScheme().c_str());
106
int index = ui->comboBoxSchema->findData(QVariant(ap));
108
ui->comboBoxSchema->setCurrentIndex(index);
110
// (h)STEP of Import module
111
ui->checkBoxExportHiddenObj->onRestore();
112
ui->checkBoxExportLegacy->onRestore();
113
ui->checkBoxKeepPlacement->onRestore();
116
StepSettings DlgExportStep::getSettings() const
119
set.exportLegacy = ui->checkBoxExportLegacy->isChecked();
120
set.exportHidden = ui->checkBoxExportHiddenObj->isChecked();
121
set.keepPlacement = ui->checkBoxKeepPlacement->isChecked();
126
* Sets the strings of the subwidgets using the current language.
128
void DlgExportStep::changeEvent(QEvent *e)
130
if (e->type() == QEvent::LanguageChange) {
131
ui->retranslateUi(this);
134
QWidget::changeEvent(e);
138
// ----------------------------------------------------------------------------
140
DlgExportHeaderStep::DlgExportHeaderStep(QWidget* parent)
141
: PreferencePage(parent)
142
, ui(new Ui_DlgExportHeaderStep)
146
ui->lineEditProduct->setReadOnly(true);
148
QRegularExpression rx;
149
rx.setPattern(QString::fromLatin1("[\\x00-\\x7F]+"));
150
QRegularExpressionValidator* companyValidator = new QRegularExpressionValidator(ui->lineEditCompany);
151
companyValidator->setRegularExpression(rx);
152
ui->lineEditCompany->setValidator(companyValidator);
153
QRegularExpressionValidator* authorValidator = new QRegularExpressionValidator(ui->lineEditAuthor);
154
authorValidator->setRegularExpression(rx);
155
ui->lineEditAuthor->setValidator(authorValidator);
158
DlgExportHeaderStep::~DlgExportHeaderStep() = default;
160
void DlgExportHeaderStep::saveSettings()
162
Part::STEP::ImportExportSettings settings;
165
settings.setCompany(ui->lineEditCompany->text().toLatin1());
166
settings.setAuthor(ui->lineEditAuthor->text().toLatin1());
169
void DlgExportHeaderStep::loadSettings()
171
Part::STEP::ImportExportSettings settings;
174
ui->lineEditCompany->setText(QString::fromStdString(settings.getCompany()));
175
ui->lineEditAuthor->setText(QString::fromStdString(settings.getAuthor()));
176
ui->lineEditProduct->setText(QString::fromStdString(settings.getProductName()));
180
* Sets the strings of the subwidgets using the current language.
182
void DlgExportHeaderStep::changeEvent(QEvent *e)
184
if (e->type() == QEvent::LanguageChange) {
185
ui->retranslateUi(this);
188
QWidget::changeEvent(e);
192
// ----------------------------------------------------------------------------
194
TaskExportStep::TaskExportStep(QWidget* parent)
196
, ui(new DlgExportStep(this))
198
QApplication::setOverrideCursor(Qt::ArrowCursor);
201
setWindowTitle(ui->windowTitle());
203
QVBoxLayout* layout = new QVBoxLayout(this);
204
layout->addWidget(ui.get());
207
showThis = new QCheckBox(this);
208
showThis->setText(tr("Don't show this dialog again"));
209
layout->addWidget(showThis);
211
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
212
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
213
layout->addWidget(buttonBox);
215
connect(buttonBox, &QDialogButtonBox::accepted, this, &TaskExportStep::accept);
216
connect(buttonBox, &QDialogButtonBox::rejected, this, &TaskExportStep::reject);
219
TaskExportStep::~TaskExportStep()
221
QApplication::restoreOverrideCursor();
224
void TaskExportStep::accept()
229
Part::STEP::ImportExportSettings settings;
230
settings.setVisibleExportDialog(!showThis->isChecked());
233
bool TaskExportStep::showDialog() const
235
Part::STEP::ImportExportSettings settings;
236
return settings.isVisibleExportDialog();
239
StepSettings TaskExportStep::getSettings() const
241
return ui->getSettings();
245
#include "moc_DlgExportStep.cpp"