1
/***************************************************************************
2
* Copyright (c) 2007 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"
25
# include <QButtonGroup>
26
# include <QRegularExpression>
27
# include <QRegularExpressionValidator>
28
# include <QVBoxLayout>
29
# include <Interface_Static.hxx>
32
#include <Mod/Part/App/Interface.h>
33
#include <Mod/Part/App/IGES/ImportExportSettings.h>
34
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
35
#include <Mod/Part/App/STEP/ImportExportSettings.h>
37
#include "DlgSettingsGeneral.h"
38
#include "ui_DlgSettingsGeneral.h"
39
#include "ui_DlgImportExportIges.h"
40
#include "DlgExportStep.h"
41
#include "DlgImportStep.h"
44
using namespace PartGui;
46
DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent)
47
: PreferencePage(parent), ui(new Ui_DlgSettingsGeneral)
53
* Destroys the object and frees any allocated resources
55
DlgSettingsGeneral::~DlgSettingsGeneral() = default;
57
void DlgSettingsGeneral::saveSettings()
59
ui->checkBooleanCheck->onSave();
60
ui->checkBooleanRefine->onSave();
61
ui->checkSketchBaseRefine->onSave();
62
ui->checkObjectNaming->onSave();
63
ui->checkAllowCompoundBody->onSave();
66
void DlgSettingsGeneral::loadSettings()
68
ui->checkBooleanCheck->onRestore();
69
ui->checkBooleanRefine->onRestore();
70
ui->checkSketchBaseRefine->onRestore();
71
ui->checkObjectNaming->onRestore();
72
ui->checkAllowCompoundBody->onRestore();
76
* Sets the strings of the subwidgets using the current language.
78
void DlgSettingsGeneral::changeEvent(QEvent *e)
80
if (e->type() == QEvent::LanguageChange) {
81
ui->retranslateUi(this);
84
QWidget::changeEvent(e);
88
// ----------------------------------------------------------------------------
90
DlgImportExportIges::DlgImportExportIges(QWidget* parent)
91
: PreferencePage(parent), ui(new Ui_DlgImportExportIges)
94
ui->lineEditProduct->setReadOnly(true);
96
bg = new QButtonGroup(this);
97
bg->addButton(ui->radioButtonBRepOff, 0);
98
bg->addButton(ui->radioButtonBRepOn, 1);
100
QRegularExpression rx;
101
rx.setPattern(QString::fromLatin1("[\\x00-\\x7F]+"));
102
QRegularExpressionValidator* companyValidator = new QRegularExpressionValidator(ui->lineEditCompany);
103
companyValidator->setRegularExpression(rx);
104
ui->lineEditCompany->setValidator(companyValidator);
105
QRegularExpressionValidator* authorValidator = new QRegularExpressionValidator(ui->lineEditAuthor);
106
authorValidator->setRegularExpression(rx);
107
ui->lineEditAuthor->setValidator(authorValidator);
111
* Destroys the object and frees any allocated resources
113
DlgImportExportIges::~DlgImportExportIges() = default;
115
void DlgImportExportIges::saveSettings()
117
Part::IGES::ImportExportSettings settings;
119
int unit = ui->comboBoxUnits->currentIndex();
120
settings.setUnit(static_cast<Part::Interface::Unit>(unit));
121
settings.setBRepMode(bg->checkedId() == 1);
124
settings.setSkipBlankEntities(ui->checkSkipBlank->isChecked());
127
settings.setCompany(ui->lineEditCompany->text().toLatin1());
128
settings.setAuthor(ui->lineEditAuthor->text().toLatin1());
131
void DlgImportExportIges::loadSettings()
133
Part::IGES::ImportExportSettings settings;
135
ui->comboBoxUnits->setCurrentIndex(static_cast<int>(settings.getUnit()));
137
bool brep = settings.getBRepMode();
139
ui->radioButtonBRepOn->setChecked(true);
141
ui->radioButtonBRepOff->setChecked(true);
144
ui->checkSkipBlank->setChecked(settings.getSkipBlankEntities());
147
ui->lineEditCompany->setText(QString::fromStdString(settings.getCompany()));
148
ui->lineEditAuthor->setText(QString::fromStdString(settings.getAuthor()));
149
ui->lineEditProduct->setText(QString::fromStdString(settings.getProductName()));
153
* Sets the strings of the subwidgets using the current language.
155
void DlgImportExportIges::changeEvent(QEvent *e)
157
if (e->type() == QEvent::LanguageChange) {
158
ui->retranslateUi(this);
161
QWidget::changeEvent(e);
165
// ----------------------------------------------------------------------------
167
DlgImportExportStep::DlgImportExportStep(QWidget* parent)
168
: PreferencePage(parent)
169
, exportStep(new DlgExportStep(this))
170
, importStep(new DlgImportStep(this))
171
, headerStep(new DlgExportHeaderStep(this))
173
setWindowTitle(QLatin1String("STEP"));
174
QVBoxLayout* layout = new QVBoxLayout(this);
175
layout->setSpacing(0);
176
layout->setContentsMargins(0, 0, 0, 0);
179
layout->addWidget(exportStep);
180
layout->addWidget(importStep);
181
layout->addWidget(headerStep);
183
QSpacerItem* verticalSpacer = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding);
184
layout->addItem(verticalSpacer);
188
* Destroys the object and frees any allocated resources
190
DlgImportExportStep::~DlgImportExportStep() = default;
192
void DlgImportExportStep::saveSettings()
194
exportStep->saveSettings();
195
importStep->saveSettings();
196
headerStep->saveSettings();
199
void DlgImportExportStep::loadSettings()
201
exportStep->loadSettings();
202
importStep->loadSettings();
203
headerStep->loadSettings();
206
void DlgImportExportStep::changeEvent(QEvent *)
212
#include "moc_DlgSettingsGeneral.cpp"