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"
26
# include <QDialogButtonBox>
29
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
30
#include <Mod/Part/App/STEP/ImportExportSettings.h>
32
#include "DlgImportStep.h"
33
#include "ui_DlgImportStep.h"
34
#include <Standard_Version.hxx>
36
using namespace PartGui;
38
DlgImportStep::DlgImportStep(QWidget* parent)
39
: PreferencePage(parent)
40
, ui(new Ui_DlgImportStep)
43
Part::OCAF::ImportExportSettings settings;
44
ui->checkBoxMergeCompound->setChecked(settings.getReadShapeCompoundMode());
45
ui->checkBoxImportHiddenObj->setChecked(settings.getImportHiddenObject());
46
ui->checkBoxUseLinkGroup->setChecked(settings.getUseLinkGroup());
47
ui->checkBoxUseBaseName->setChecked(settings.getUseBaseName());
48
ui->checkBoxReduceObjects->setChecked(settings.getReduceObjects());
49
ui->checkBoxExpandCompound->setChecked(settings.getExpandCompound());
50
ui->checkBoxShowProgress->setChecked(settings.getShowProgress());
51
#if OCC_VERSION_HEX >= 0x070800
52
std::list<Part::OCAF::ImportExportSettings::CodePage> codepagelist;
53
codepagelist = settings.getCodePageList();
54
for (const auto& codePage : codepagelist) {
55
ui->comboBoxImportCodePage->addItem(QString::fromStdString(codePage.codePageName));
58
// hide options that not supported in this OCCT version (7.8.0)
60
ui->comboBoxImportCodePage->hide();
65
* Destroys the object and frees any allocated resources
67
DlgImportStep::~DlgImportStep() = default;
69
void DlgImportStep::saveSettings()
71
// (h)STEP of Import module
72
#if OCC_VERSION_HEX >= 0x070800
73
ui->comboBoxImportCodePage->onSave();
75
ui->checkBoxMergeCompound->onSave();
76
ui->checkBoxImportHiddenObj->onSave();
77
ui->checkBoxUseLinkGroup->onSave();
78
ui->checkBoxUseBaseName->onSave();
79
ui->checkBoxReduceObjects->onSave();
80
ui->checkBoxExpandCompound->onSave();
81
ui->checkBoxShowProgress->onSave();
82
ui->comboBoxImportMode->onSave();
85
void DlgImportStep::loadSettings()
87
// (h)STEP of Import module
88
#if OCC_VERSION_HEX >= 0x070800
89
ui->comboBoxImportCodePage->onRestore();
91
ui->checkBoxMergeCompound->onRestore();
92
ui->checkBoxImportHiddenObj->onRestore();
93
ui->checkBoxUseLinkGroup->onRestore();
94
ui->checkBoxUseBaseName->onRestore();
95
ui->checkBoxReduceObjects->onRestore();
96
ui->checkBoxExpandCompound->onRestore();
97
ui->checkBoxShowProgress->onRestore();
98
ui->comboBoxImportMode->onRestore();
101
StepImportSettings DlgImportStep::getSettings() const
103
StepImportSettings set;
104
Part::OCAF::ImportExportSettings settings;
105
set.merge = settings.getReadShapeCompoundMode();
106
set.useLinkGroup = settings.getUseLinkGroup();
107
set.useBaseName = settings.getUseBaseName();
108
set.importHidden = settings.getImportHiddenObject();
109
set.reduceObjects = settings.getReduceObjects();
110
set.showProgress = settings.getShowProgress();
111
set.expandCompound = settings.getExpandCompound();
112
set.mode = static_cast<int>(settings.getImportMode());
113
#if OCC_VERSION_HEX >= 0x070800
114
Resource_FormatType cp = settings.getImportCodePage();
115
set.codePage = static_cast<int>(cp);
121
* Sets the strings of the subwidgets using the current language.
123
void DlgImportStep::changeEvent(QEvent *e)
125
if (e->type() == QEvent::LanguageChange) {
126
ui->retranslateUi(this);
129
QWidget::changeEvent(e);
133
// ----------------------------------------------------------------------------
135
TaskImportStep::TaskImportStep(QWidget* parent)
137
, ui(new DlgImportStep(this))
139
QApplication::setOverrideCursor(Qt::ArrowCursor);
142
setWindowTitle(ui->windowTitle());
144
QVBoxLayout* layout = new QVBoxLayout(this);
145
layout->addWidget(ui.get());
148
showThis = new QCheckBox(this);
149
showThis->setText(tr("Don't show this dialog again"));
150
layout->addWidget(showThis);
152
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
153
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
154
layout->addWidget(buttonBox);
156
connect(buttonBox, &QDialogButtonBox::accepted, this, &TaskImportStep::accept);
157
connect(buttonBox, &QDialogButtonBox::rejected, this, &TaskImportStep::reject);
160
TaskImportStep::~TaskImportStep()
162
QApplication::restoreOverrideCursor();
165
void TaskImportStep::accept()
170
Part::STEP::ImportExportSettings settings;
171
settings.setVisibleImportDialog(!showThis->isChecked());
174
bool TaskImportStep::showDialog() const
176
Part::STEP::ImportExportSettings settings;
177
return settings.isVisibleImportDialog();
180
StepImportSettings TaskImportStep::getSettings() const
182
return ui->getSettings();
186
#include "moc_DlgImportStep.cpp"