1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "STEPPlugin_ExportDlg.h"
22 #include <QApplication>
27 //=============================================================================
29 //=============================================================================
30 STEPPlugin_ExportDlg::STEPPlugin_ExportDlg(QWidget *parent)
31 : SUIT_FileDlg (parent, false, true, true),
34 QLabel* aUnitLabel = new QLabel(tr("STEP_LENGTH_UNITS"), this);
36 myUnitCB = new QComboBox(this);
37 myUnitCB->addItem(tr("STEP_UNITS_KILOMETER"), GEOM::LU_KILOMETER);
38 myUnitCB->addItem(tr("STEP_UNITS_METER"), GEOM::LU_METER);
39 myUnitCB->addItem(tr("STEP_UNITS_CENTIMETER"), GEOM::LU_CENTIMETER);
40 myUnitCB->addItem(tr("STEP_UNITS_MILLIMETER"), GEOM::LU_MILLIMETER);
41 myUnitCB->addItem(tr("STEP_UNITS_MICROMETER"), GEOM::LU_MICROMETER);
42 myUnitCB->addItem(tr("STEP_UNITS_MILE"), GEOM::LU_MILE);
43 myUnitCB->addItem(tr("STEP_UNITS_FOOT"), GEOM::LU_FOOT);
44 myUnitCB->addItem(tr("STEP_UNITS_INCH"), GEOM::LU_INCH);
45 myUnitCB->addItem(tr("STEP_UNITS_MILLIINCH"), GEOM::LU_MILLIINCH);
46 myUnitCB->addItem(tr("STEP_UNITS_MICROINCH"), GEOM::LU_MICROINCH);
49 myUnitCB->setCurrentIndex(1);
51 layout()->addWidget(aUnitLabel);
52 layout()->addWidget(myUnitCB);
55 //=============================================================================
57 //=============================================================================
58 STEPPlugin_ExportDlg::~STEPPlugin_ExportDlg()
62 //=============================================================================
64 //=============================================================================
65 GEOM::length_unit STEPPlugin_ExportDlg::getUnits() const
67 const GEOM::length_unit anUnit =
68 (GEOM::length_unit) myUnitCB->itemData(myUnitCB->currentIndex()).toInt();
73 //=============================================================================
75 //=============================================================================
76 QString STEPPlugin_ExportDlg::getFileName(const QString &theInitial,
77 const QString &theFilters,
78 const QString &theCaption,
80 GEOM::length_unit &theUnits)
82 QStringList aFls = theFilters.split(";;", QString::SkipEmptyParts);
83 QString aTmpFileName = theInitial;
85 aTmpFileName = aTmpFileName.simplified();
87 aTmpFileName.replace(QRegExp("\\*"), "").replace(QRegExp("\\?"), "");
89 STEPPlugin_ExportDlg aDlg(theParent);
91 aDlg.setFileMode(AnyFile);
92 aDlg.setNameFilters(aFls);
93 aDlg.setWindowTitle(theCaption);
95 if (!aTmpFileName.isEmpty()) {
96 aDlg.processPath(aTmpFileName);
101 if (aDlg.exec() == QDialog::Accepted) {
102 aFileName = aDlg.selectedFile();
103 theUnits = aDlg.getUnits();
106 QApplication::processEvents();