added possibility to choose the reduction rate (vtkDecimate)
[engrid.git] / src / libengrid / guibrlcadimportdialogue.cpp
blob6696e9056dbe6f24128a74281bbb049f812c492f
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2012 enGits GmbH +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guibrlcadimportdialogue.h"
24 #include "ui_guibrlcadimportdialogue.h"
26 #include <QProcess>
27 #include <QFileInfo>
29 GuiBrlCadImportDialogue::GuiBrlCadImportDialogue(QWidget *parent) :
30 QDialog(parent),
31 ui(new Ui::GuiBrlCadImportDialogue)
33 ui->setupUi(this);
36 GuiBrlCadImportDialogue::~GuiBrlCadImportDialogue()
38 delete ui;
41 void GuiBrlCadImportDialogue::prepare(QString file_name)
43 QString program = "/usr/brlcad/bin/mged";
44 QStringList arguments;
45 QProcess proc(this);
46 arguments << "-c" << file_name<< "ls";
47 proc.start(program, arguments);
48 proc.waitForFinished();
49 QString output = proc.readAllStandardOutput() + proc.readAllStandardError();
50 QStringList objects = output.split(QRegExp("\\s+"));
51 ui->listWidget->clear();
52 foreach (QString obj, objects) {
53 ui->listWidget->addItem(obj);
55 m_StlFileName = file_name + ".stl";
56 if (QFileInfo(m_StlFileName).exists()) {
57 ui->checkBoxSTL->setEnabled(true);
58 ui->checkBoxSTL->setChecked(true);
62 bool GuiBrlCadImportDialogue::hasSelectedObject()
64 if (ui->listWidget->selectedItems().size() == 1) {
65 return true;
67 return false;
70 QString GuiBrlCadImportDialogue::selectedObject()
72 if (hasSelectedObject()) {
73 QString object_txt = ui->listWidget->selectedItems().first()->text();
74 QString object = object_txt.split("/").first();
75 return object;
76 } else {
77 EG_BUG;
81 double GuiBrlCadImportDialogue::scanMemory()
83 double mem = 1024.0;
84 mem *= mem*mem;
85 mem *= ui->doubleSpinBoxMemory->value();
86 return mem;
89 int GuiBrlCadImportDialogue::smoothingIterations()
91 return ui->spinBoxSmoothing->value();
94 int GuiBrlCadImportDialogue::preservationType()
96 if (ui->radioButtonNoPreservation->isChecked()) return 0;
97 if (ui->radioButtonSolidPreservation->isChecked()) return 1;
98 return 2;
101 double GuiBrlCadImportDialogue::smallestFeatureSize()
103 return ui->lineEditSmallestFeature->text().toDouble();
106 double GuiBrlCadImportDialogue::smallestResolution()
108 return ui->lineEditMinResolution->text().toDouble();
111 bool GuiBrlCadImportDialogue::useStlFile()
113 return ui->checkBoxSTL->isChecked();
116 QString GuiBrlCadImportDialogue::stlFileName()
118 return m_StlFileName;
121 double GuiBrlCadImportDialogue::reduction()
123 return 0.01*double(ui->horizontalSliderReduction->value());