FreeCAD

Форк
0
/
DlgSettingsGeneral.cpp 
212 строк · 6.8 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <QButtonGroup>
26
# include <QRegularExpression>
27
# include <QRegularExpressionValidator>
28
# include <QVBoxLayout>
29
# include <Interface_Static.hxx>
30
#endif
31

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>
36

37
#include "DlgSettingsGeneral.h"
38
#include "ui_DlgSettingsGeneral.h"
39
#include "ui_DlgImportExportIges.h"
40
#include "DlgExportStep.h"
41
#include "DlgImportStep.h"
42

43

44
using namespace PartGui;
45

46
DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent)
47
  : PreferencePage(parent), ui(new Ui_DlgSettingsGeneral)
48
{
49
    ui->setupUi(this);
50
}
51

52
/**
53
 *  Destroys the object and frees any allocated resources
54
 */
55
DlgSettingsGeneral::~DlgSettingsGeneral() = default;
56

57
void DlgSettingsGeneral::saveSettings()
58
{
59
    ui->checkBooleanCheck->onSave();
60
    ui->checkBooleanRefine->onSave();
61
    ui->checkSketchBaseRefine->onSave();
62
    ui->checkObjectNaming->onSave();
63
    ui->checkAllowCompoundBody->onSave();
64
}
65

66
void DlgSettingsGeneral::loadSettings()
67
{
68
    ui->checkBooleanCheck->onRestore();
69
    ui->checkBooleanRefine->onRestore();
70
    ui->checkSketchBaseRefine->onRestore();
71
    ui->checkObjectNaming->onRestore();
72
    ui->checkAllowCompoundBody->onRestore();
73
}
74

75
/**
76
 * Sets the strings of the subwidgets using the current language.
77
 */
78
void DlgSettingsGeneral::changeEvent(QEvent *e)
79
{
80
    if (e->type() == QEvent::LanguageChange) {
81
        ui->retranslateUi(this);
82
    }
83
    else {
84
        QWidget::changeEvent(e);
85
    }
86
}
87

88
// ----------------------------------------------------------------------------
89

90
DlgImportExportIges::DlgImportExportIges(QWidget* parent)
91
  : PreferencePage(parent), ui(new Ui_DlgImportExportIges)
92
{
93
    ui->setupUi(this);
94
    ui->lineEditProduct->setReadOnly(true);
95

96
    bg = new QButtonGroup(this);
97
    bg->addButton(ui->radioButtonBRepOff, 0);
98
    bg->addButton(ui->radioButtonBRepOn, 1);
99

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);
108
}
109

110
/**
111
 *  Destroys the object and frees any allocated resources
112
 */
113
DlgImportExportIges::~DlgImportExportIges() = default;
114

115
void DlgImportExportIges::saveSettings()
116
{
117
    Part::IGES::ImportExportSettings settings;
118

119
    int unit = ui->comboBoxUnits->currentIndex();
120
    settings.setUnit(static_cast<Part::Interface::Unit>(unit));
121
    settings.setBRepMode(bg->checkedId() == 1);
122

123
    // Import
124
    settings.setSkipBlankEntities(ui->checkSkipBlank->isChecked());
125

126
    // header info
127
    settings.setCompany(ui->lineEditCompany->text().toLatin1());
128
    settings.setAuthor(ui->lineEditAuthor->text().toLatin1());
129
}
130

131
void DlgImportExportIges::loadSettings()
132
{
133
    Part::IGES::ImportExportSettings settings;
134

135
    ui->comboBoxUnits->setCurrentIndex(static_cast<int>(settings.getUnit()));
136

137
    bool brep = settings.getBRepMode();
138
    if (brep)
139
        ui->radioButtonBRepOn->setChecked(true);
140
    else
141
        ui->radioButtonBRepOff->setChecked(true);
142

143
    // Import
144
    ui->checkSkipBlank->setChecked(settings.getSkipBlankEntities());
145

146
    // header info
147
    ui->lineEditCompany->setText(QString::fromStdString(settings.getCompany()));
148
    ui->lineEditAuthor->setText(QString::fromStdString(settings.getAuthor()));
149
    ui->lineEditProduct->setText(QString::fromStdString(settings.getProductName()));
150
}
151

152
/**
153
 * Sets the strings of the subwidgets using the current language.
154
 */
155
void DlgImportExportIges::changeEvent(QEvent *e)
156
{
157
    if (e->type() == QEvent::LanguageChange) {
158
        ui->retranslateUi(this);
159
    }
160
    else {
161
        QWidget::changeEvent(e);
162
    }
163
}
164

165
// ----------------------------------------------------------------------------
166

167
DlgImportExportStep::DlgImportExportStep(QWidget* parent)
168
  : PreferencePage(parent)
169
  , exportStep(new DlgExportStep(this))
170
  , importStep(new DlgImportStep(this))
171
  , headerStep(new DlgExportHeaderStep(this))
172
{
173
    setWindowTitle(QLatin1String("STEP"));
174
    QVBoxLayout* layout = new QVBoxLayout(this);
175
    layout->setSpacing(0);
176
    layout->setContentsMargins(0, 0, 0, 0);
177
    setLayout(layout);
178

179
    layout->addWidget(exportStep);
180
    layout->addWidget(importStep);
181
    layout->addWidget(headerStep);
182

183
    QSpacerItem* verticalSpacer = new QSpacerItem(20, 82, QSizePolicy::Minimum, QSizePolicy::Expanding);
184
    layout->addItem(verticalSpacer);
185
}
186

187
/**
188
 *  Destroys the object and frees any allocated resources
189
 */
190
DlgImportExportStep::~DlgImportExportStep() = default;
191

192
void DlgImportExportStep::saveSettings()
193
{
194
    exportStep->saveSettings();
195
    importStep->saveSettings();
196
    headerStep->saveSettings();
197
}
198

199
void DlgImportExportStep::loadSettings()
200
{
201
    exportStep->loadSettings();
202
    importStep->loadSettings();
203
    headerStep->loadSettings();
204
}
205

206
void DlgImportExportStep::changeEvent(QEvent *)
207
{
208
    // do nothing
209
}
210

211

212
#include "moc_DlgSettingsGeneral.cpp"
213

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.