2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
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. +
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. +
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/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "guiedgelengthsourcesphere.h"
26 GuiEdgeLengthSourceSphere::GuiEdgeLengthSourceSphere()
28 m_Centre
= vec3_t(0,0,0);
34 QString
GuiEdgeLengthSourceSphere::write()
36 QString txt
= "sphere: " + name() + "; ";
38 num
.setNum(m_Centre
[0]); txt
+= num
+ "; ";
39 num
.setNum(m_Centre
[1]); txt
+= num
+ "; ";
40 num
.setNum(m_Centre
[2]); txt
+= num
+ "; ";
41 num
.setNum(m_Radius
); txt
+= num
+ "; ";
42 num
.setNum(m_Length1
); txt
+= num
+ "; ";
43 num
.setNum(m_Length2
); txt
+= num
+ "; ";
47 bool GuiEdgeLengthSourceSphere::read(QString txt
)
49 QStringList parts
= txt
.split(":");
50 if (parts
.size() != 2) {
53 if (parts
[0].trimmed() == "sphere") {
54 QStringList words
= parts
[1].split(";");
55 if (words
.size() < 7) {
58 m_Name
= words
[0].trimmed();
59 m_Centre
= vec3_t(words
[1].toDouble(), words
[2].toDouble(), words
[3].toDouble());
60 m_Radius
= words
[4].toDouble();
61 m_Length1
= words
[5].toDouble();
62 m_Length2
= words
[6].toDouble();
69 void GuiEdgeLengthSourceSphere::setDlgFields()
71 ui().lineEditName
->setText(name());
73 num
.setNum(m_Centre
[0]); ui().lineEditX
->setText(num
);
74 num
.setNum(m_Centre
[1]); ui().lineEditY
->setText(num
);
75 num
.setNum(m_Centre
[2]); ui().lineEditZ
->setText(num
);
76 num
.setNum(m_Radius
); ui().lineEditR
->setText(num
);
77 num
.setNum(m_Length1
); ui().lineEditEL1
->setText(num
);
78 num
.setNum(m_Length2
); ui().lineEditEL2
->setText(num
);
81 void GuiEdgeLengthSourceSphere::readDlgFields()
83 setName(ui().lineEditName
->text());
84 m_Centre
[0] = ui().lineEditX
->text().toDouble();
85 m_Centre
[1] = ui().lineEditY
->text().toDouble();
86 m_Centre
[2] = ui().lineEditZ
->text().toDouble();
87 m_Radius
= ui().lineEditR
->text().toDouble();
88 m_Length1
= ui().lineEditEL1
->text().toDouble();
89 m_Length2
= ui().lineEditEL2
->text().toDouble();
92 double GuiEdgeLengthSourceSphere::edgeLength(vec3_t x
)
94 double r
= (x
- m_Centre
).abs();
98 return m_Length1
+ r
/m_Radius
*(m_Length2
- m_Length1
);