FreeCAD

Форк
0
/
DlgImportStep.cpp 
186 строк · 6.4 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2022 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

25
#ifndef _PreComp_
26
# include <QDialogButtonBox>
27
#endif
28

29
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
30
#include <Mod/Part/App/STEP/ImportExportSettings.h>
31

32
#include "DlgImportStep.h"
33
#include "ui_DlgImportStep.h"
34
#include <Standard_Version.hxx>
35

36
using namespace PartGui;
37

38
DlgImportStep::DlgImportStep(QWidget* parent)
39
  : PreferencePage(parent)
40
  , ui(new Ui_DlgImportStep)
41
{
42
    ui->setupUi(this);
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));
56
    }
57
#else
58
    // hide options that not supported in this OCCT version (7.8.0)
59
    ui->label_6->hide();
60
    ui->comboBoxImportCodePage->hide();
61
#endif
62
}
63

64
/**
65
 *  Destroys the object and frees any allocated resources
66
 */
67
DlgImportStep::~DlgImportStep() = default;
68

69
void DlgImportStep::saveSettings()
70
{
71
    // (h)STEP of Import module
72
#if OCC_VERSION_HEX >= 0x070800
73
    ui->comboBoxImportCodePage->onSave();
74
#endif
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();
83
}
84

85
void DlgImportStep::loadSettings()
86
{
87
    // (h)STEP of Import module
88
#if OCC_VERSION_HEX >= 0x070800
89
    ui->comboBoxImportCodePage->onRestore();
90
#endif
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();
99
}
100

101
StepImportSettings DlgImportStep::getSettings() const
102
{
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);
116
#endif
117
    return set;
118
}
119

120
/**
121
 * Sets the strings of the subwidgets using the current language.
122
 */
123
void DlgImportStep::changeEvent(QEvent *e)
124
{
125
    if (e->type() == QEvent::LanguageChange) {
126
        ui->retranslateUi(this);
127
    }
128
    else {
129
        QWidget::changeEvent(e);
130
    }
131
}
132

133
// ----------------------------------------------------------------------------
134

135
TaskImportStep::TaskImportStep(QWidget* parent)
136
  : QDialog(parent)
137
  , ui(new DlgImportStep(this))
138
{
139
    QApplication::setOverrideCursor(Qt::ArrowCursor);
140

141
    ui->loadSettings();
142
    setWindowTitle(ui->windowTitle());
143

144
    QVBoxLayout* layout = new QVBoxLayout(this);
145
    layout->addWidget(ui.get());
146
    setLayout(layout);
147

148
    showThis = new QCheckBox(this);
149
    showThis->setText(tr("Don't show this dialog again"));
150
    layout->addWidget(showThis);
151

152
    QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
153
    buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
154
    layout->addWidget(buttonBox);
155

156
    connect(buttonBox, &QDialogButtonBox::accepted, this, &TaskImportStep::accept);
157
    connect(buttonBox, &QDialogButtonBox::rejected, this, &TaskImportStep::reject);
158
}
159

160
TaskImportStep::~TaskImportStep()
161
{
162
    QApplication::restoreOverrideCursor();
163
}
164

165
void TaskImportStep::accept()
166
{
167
    QDialog::accept();
168
    ui->saveSettings();
169

170
    Part::STEP::ImportExportSettings settings;
171
    settings.setVisibleImportDialog(!showThis->isChecked());
172
}
173

174
bool TaskImportStep::showDialog() const
175
{
176
    Part::STEP::ImportExportSettings settings;
177
    return settings.isVisibleImportDialog();
178
}
179

180
StepImportSettings TaskImportStep::getSettings() const
181
{
182
    return ui->getSettings();
183
}
184

185

186
#include "moc_DlgImportStep.cpp"
187

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

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

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

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