Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/src/meshcontrol.cpp
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI meshcontrol *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
41
#include <QtGui>
42
#include <iostream>
43
#include "meshcontrol.h"
44
45
#include <stdio.h>
46
47
using namespace std;
48
49
MeshControl::MeshControl(QWidget *parent)
50
: QDialog(parent)
51
{
52
tetlibPresent = true;
53
nglibPresent = true;
54
55
ui.setupUi(this);
56
57
connect(ui.tetlibRadioButton, SIGNAL(clicked()), this, SLOT(tetlibClicked()));
58
connect(ui.nglibRadioButton, SIGNAL(clicked()), this, SLOT(nglibClicked()));
59
connect(ui.elmerGridRadioButton, SIGNAL(clicked()), this, SLOT(elmerGridClicked()));
60
61
connect(ui.tetlibStringEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineTetlibControlString(const QString&)));
62
63
connect(ui.nglibMaxHEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineNglibMaxH(const QString&)));
64
connect(ui.nglibFinenessEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineNglibFineness(const QString&)));
65
connect(ui.nglibBgmeshEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineNglibBackgroundmesh(const QString&)));
66
67
connect(ui.defaultsButton, SIGNAL(clicked()), this, SLOT(defaultControls()));
68
connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close()));
69
70
connect(ui.elmerGridStringEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineElmerGridControlString(const QString&)));
71
72
connect(ui.elmerGridStringEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineElmerGridControlString(const QString&)));
73
74
connect(ui.elementCodesStringEdit, SIGNAL(textChanged(const QString&)), this, SLOT(defineElementCodesString(const QString&)));
75
76
// defaultControls(); // Note - already called from mainwindow.cpp
77
78
this->setWindowIcon(QIcon::fromTheme("configure"));
79
ui.closeButton->setIcon(QIcon::fromTheme("dialog-accept"));
80
}
81
82
MeshControl::~MeshControl()
83
{
84
}
85
86
void MeshControl::tetlibClicked()
87
{
88
generatorType = GEN_TETLIB;
89
}
90
91
void MeshControl::nglibClicked()
92
{
93
generatorType = GEN_NGLIB;
94
}
95
96
void MeshControl::elmerGridClicked()
97
{
98
generatorType = GEN_ELMERGRID;
99
}
100
101
void MeshControl::defineElementCodesString(const QString &qs)
102
{
103
elementCodesString = qs;
104
}
105
106
void MeshControl::defineTetlibControlString(const QString &qs)
107
{
108
tetlibControlString = qs;
109
}
110
111
void MeshControl::defineNglibMaxH(const QString &qs)
112
{
113
nglibMaxH = qs;
114
}
115
116
void MeshControl::defineNglibFineness(const QString &qs)
117
{
118
nglibFineness = qs;
119
}
120
121
void MeshControl::defineNglibBackgroundmesh(const QString &qs)
122
{
123
nglibBackgroundmesh = qs;
124
}
125
126
void MeshControl::defineElmerGridControlString(const QString &qs)
127
{
128
elmerGridControlString = qs;
129
}
130
131
void MeshControl::defaultControls()
132
{
133
// generatorType = GEN_TETLIB;
134
// ui.tetlibRadioButton->setChecked(true);
135
136
generatorType = GEN_NGLIB;
137
ui.nglibRadioButton->setChecked(true);
138
139
// if(!tetlibPresent) {
140
// generatorType = GEN_NGLIB;
141
// ui.nglibRadioButton->setChecked(true);
142
// }
143
144
// if(!tetlibPresent && !nglibPresent) {
145
// generatorType = GEN_ELMERGRID;
146
// ui.elmerGridRadioButton->setChecked(true);
147
// }
148
149
// Check for valid tetgen quality in cmd line arguments:
150
//---------------------------
151
QStringList args = QCoreApplication::arguments();
152
int tq_ind = args.indexOf("-tq");
153
bool tq_isnum=0;
154
QString tetlib_options = "nnJApVq";
155
if (tq_ind > 0) args.at(tq_ind + 1).toFloat(&tq_isnum);
156
#if WITH_QT5 || WITH_QT6
157
if (tq_ind > 0 && !tq_isnum) cout << "Ignoring -tq option: " << args.at(tq_ind + 1).toLatin1().data() << endl;
158
#else
159
if (tq_ind > 0 && !tq_isnum) cout << "Ignoring -tq option: " << args.at(tq_ind + 1).toAscii().data() << endl;
160
#endif
161
if (tq_isnum) tetlib_options.append(args.at(tq_ind + 1));
162
else tetlib_options.append("1.414");
163
164
ui.tetlibStringEdit->setText(tetlib_options);
165
ui.nglibMaxHEdit->setText("1000000");
166
ui.nglibFinenessEdit->setText("0.5");
167
ui.nglibBgmeshEdit->setText("");
168
ui.elmerGridStringEdit->setText("-autoclean -relh 1.0");
169
ui.elementCodesStringEdit->setText("");
170
}
171
172
void MeshControl::appendToProject(QDomDocument *projectDoc, QDomElement *item)
173
{
174
projectIO.parentWidget = this;
175
projectIO.appendToProject(projectDoc, item);
176
}
177
178
void MeshControl::readFromProject(QDomDocument *projectDoc, QDomElement *item)
179
{
180
projectIO.parentWidget = this;
181
projectIO.readFromProject(projectDoc, item);
182
}
183
184