-
Notifications
You must be signed in to change notification settings - Fork 0
/
plane.cpp
106 lines (94 loc) · 3.2 KB
/
plane.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + +
// + This file is part of enVisu. +
// + +
// + Copyright 2013 O. Gloth, enGits GmbH +
// + +
// + enGrid is free software: you can redistribute it and/or modify +
// + it under the terms of the GNU General Public License as published by +
// + the Free Software Foundation, either version 3 of the License, or +
// + (at your option) any later version. +
// + +
// + enGrid is distributed in the hope that it will be useful, +
// + but WITHOUT ANY WARRANTY; without even the implied warranty of +
// + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
// + GNU General Public License for more details. +
// + +
// + You should have received a copy of the GNU General Public License +
// + along with enVisu. If not, see <http://www.gnu.org/licenses/>. +
// + +
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
#include "plane.h"
Plane::Plane(WorkSpace *ws) : GuiWsItem<Ui::PlaneConfig>(ws)
{
loadIcon("plane.png");
m_Ws->addItem(this);
setName("Plane");
vtk = vtkPlane::New();
connect(m_Dlg.ui.apply_pb,SIGNAL(clicked()),this,SLOT(apply()));
connect(m_Dlg.ui.n_slider,SIGNAL(valueChanged(int)),this,SLOT(autoApply()));
m_Dlg.ui.name_edit->setText(name());
m_HasOutput = true;
m_OutputTypes = "vtkImplicitFunction";
apply();
}
Plane::~Plane()
{
vtk->Delete();
}
void Plane::apply()
{
changeName(m_Dlg.ui.name_edit->text());
vec3_t x1 = getVector(m_Dlg.ui.x1);
vec3_t x2 = getVector(m_Dlg.ui.x2);
vec3_t n = x2 - x1;
double slider_value = double(m_Dlg.ui.n_slider->value());
double slider_max = double(m_Dlg.ui.n_slider->maxValue());
vec3_t x = x1 + (slider_value/slider_max)*n;
vtk->SetOrigin(x[0],x[1],x[2]);
vtk->SetNormal(n[0],n[1],n[2]);
setVector(x, m_Dlg.ui.m_CurrentX);
m_Ws->render();
}
void Plane::config()
{
if (m_Dlg.exec()) {
apply();
}
}
void Plane::autoApply()
{
if (m_Dlg.ui.auto_cb->isChecked()) apply();
}
void Plane::save(QTextStream &s)
{
GuiWsItem::save(s);
writeLineEdit(s, m_Dlg.ui.name_edit);
writeLineEdit(s, m_Dlg.ui.x1);
writeLineEdit(s, m_Dlg.ui.x2);
writeSlider(s,m_Dlg.ui.n_slider);
}
void Plane::load(QTextStream &s)
{
GuiWsItem::load(s);
readLineEdit(s, m_Dlg.ui.name_edit);
readLineEdit(s, m_Dlg.ui.x1);
readLineEdit(s, m_Dlg.ui.x2);
readSlider(s,m_Dlg.ui.n_slider);
apply();
}
vtkImplicitFunction* Plane::getImplicitFunction()
{
return vtk;
}
void Plane::setPolyData(int i, vtkPolyData *poly_data)
{
}
void Plane::setDataSet(int i, vtkDataSet *data_set)
{
}
void Plane::setImplicitFunction(int i, vtkImplicitFunction *function)
{
}