1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid 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. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "guiedgelengthsourcesphere.h"
24 GuiEdgeLengthSourceSphere::GuiEdgeLengthSourceSphere()
26 m_Centre
= vec3_t(0,0,0);
32 QString
GuiEdgeLengthSourceSphere::write()
34 QString txt
= "sphere: " + name() + "; ";
36 num
.setNum(m_Centre
[0]); txt
+= num
+ "; ";
37 num
.setNum(m_Centre
[1]); txt
+= num
+ "; ";
38 num
.setNum(m_Centre
[2]); txt
+= num
+ "; ";
39 num
.setNum(m_Radius
); txt
+= num
+ "; ";
40 num
.setNum(m_Length1
); txt
+= num
+ "; ";
41 num
.setNum(m_Length2
); txt
+= num
+ "; ";
45 bool GuiEdgeLengthSourceSphere::read(QString txt
)
47 QStringList parts
= txt
.split(":");
48 if (parts
.size() != 2) {
51 if (parts
[0].trimmed() == "sphere") {
52 QStringList words
= parts
[1].split(";");
53 if (words
.size() < 7) {
56 m_Name
= words
[0].trimmed();
57 m_Centre
= vec3_t(words
[1].toDouble(), words
[2].toDouble(), words
[3].toDouble());
58 m_Radius
= words
[4].toDouble();
59 m_Length1
= words
[5].toDouble();
60 m_Length2
= words
[6].toDouble();
67 void GuiEdgeLengthSourceSphere::setDlgFields()
69 ui().lineEditName
->setText(name());
71 num
.setNum(m_Centre
[0]); ui().lineEditX
->setText(num
);
72 num
.setNum(m_Centre
[1]); ui().lineEditY
->setText(num
);
73 num
.setNum(m_Centre
[2]); ui().lineEditZ
->setText(num
);
74 num
.setNum(m_Radius
); ui().lineEditR
->setText(num
);
75 num
.setNum(m_Length1
); ui().lineEditEL1
->setText(num
);
76 num
.setNum(m_Length2
); ui().lineEditEL2
->setText(num
);
79 void GuiEdgeLengthSourceSphere::readDlgFields()
81 setName(ui().lineEditName
->text());
82 m_Centre
[0] = ui().lineEditX
->text().toDouble();
83 m_Centre
[1] = ui().lineEditY
->text().toDouble();
84 m_Centre
[2] = ui().lineEditZ
->text().toDouble();
85 m_Radius
= ui().lineEditR
->text().toDouble();
86 m_Length1
= ui().lineEditEL1
->text().toDouble();
87 m_Length2
= ui().lineEditEL2
->text().toDouble();
90 double GuiEdgeLengthSourceSphere::edgeLength(vec3_t x
)
92 double r
= (x
- m_Centre
).abs();
96 return m_Length1
+ r
/m_Radius
*(m_Length2
- m_Length1
);