LVRTransformationDialog.cpp
Go to the documentation of this file.
1 
35 #include <QFileDialog>
37 
38 namespace lvr2
39 {
40 
42  m_parent(parent), m_renderWindow(window)
43 {
44  // Setup DialogUI and events
45  QDialog* dialog = new QDialog(parent->treeWidget());
46  m_dialogUI = new TransformationDialogUI;
47  m_dialogUI->setupUi(dialog);
48 
49  m_pose = m_pose_original = parent->getPose();
50 
51  // Set slider to correct positions
52  m_dialogUI->sliderXRot->setValue(m_pose.r * 100000.0);
53  m_dialogUI->sliderYRot->setValue(m_pose.t * 100000.0);
54  m_dialogUI->sliderZRot->setValue(m_pose.p * 100000.0);
55  m_dialogUI->spinBoxXRot->setValue(m_pose.r);
56  m_dialogUI->spinBoxYRot->setValue(m_pose.t);
57  m_dialogUI->spinBoxZRot->setValue(m_pose.p);
58  m_dialogUI->spinBoxXTrans->setValue(m_pose.x);
59  m_dialogUI->spinBoxYTrans->setValue(m_pose.y);
60  m_dialogUI->spinBoxZTrans->setValue(m_pose.z);
62 
63  dialog->show();
64  dialog->raise();
65  dialog->activateWindow();
66 
67 
68 }
69 
71 {
72  // TODO Auto-generated destructor stub
73 }
74 
76 {
77  QObject::connect(m_dialogUI->buttonReset, SIGNAL(clicked()),
78  this, SLOT(reset()));
79 
80  // Slider and spin box for x rotation
81  QObject::connect(m_dialogUI->sliderXRot, SIGNAL(sliderMoved(int)),
82  this, SLOT(rotationXSlided(int)));
83 
84  QObject::connect(m_dialogUI->spinBoxXRot, SIGNAL(valueChanged(double)),
85  this, SLOT(rotationXEntered(double)));
86 
87  // Slider and spin box for y rotation
88  QObject::connect(m_dialogUI->sliderYRot, SIGNAL(sliderMoved(int)),
89  this, SLOT(rotationYSlided(int)));
90 
91  QObject::connect(m_dialogUI->spinBoxYRot, SIGNAL(valueChanged(double)),
92  this, SLOT(rotationYEntered(double)));
93 
94  // Slider and spin box for z rotation
95  QObject::connect(m_dialogUI->sliderZRot, SIGNAL(sliderMoved(int)),
96  this, SLOT(rotationZSlided(int)));
97 
98  QObject::connect(m_dialogUI->spinBoxZRot, SIGNAL(valueChanged(double)),
99  this, SLOT(rotationZEntered(double)));
100 
101  // Spin boxes for translation
102  QObject::connect(m_dialogUI->spinBoxXTrans, SIGNAL(valueChanged(double)),
103  this, SLOT(translationXEntered(double)));
104 
105  QObject::connect(m_dialogUI->spinBoxYTrans, SIGNAL(valueChanged(double)),
106  this, SLOT(translationYEntered(double)));
107 
108  QObject::connect(m_dialogUI->spinBoxZTrans, SIGNAL(valueChanged(double)),
109  this, SLOT(translationZEntered(double)));
110 
111  QObject::connect(m_dialogUI->spinBoxStep, SIGNAL(valueChanged(double)),
112  this, SLOT(stepChanged(double)));
113 
114  QObject::connect(m_dialogUI->buttonSave, SIGNAL(clicked()), this, SLOT(save()));
115 
116  QObject::connect(m_dialogUI->buttonBox, SIGNAL(rejected()), this, SLOT(restoreAndClose()));
117 }
118 
120 {
121  m_dialogUI->spinBoxXTrans->setSingleStep(value);
122  m_dialogUI->spinBoxYTrans->setSingleStep(value);
123  m_dialogUI->spinBoxZTrans->setSingleStep(value);
124 }
125 
127 {
128  QString filename = QFileDialog::getSaveFileName(m_parent->treeWidget(), "Save transformation to pose file", "", "*.pose");
129 
130  ofstream out(filename.toStdString().c_str());
131  out << m_pose.x << " " << m_pose.y << " " << m_pose.z << " " << m_pose.r << " " << m_pose.t << " " << m_pose.p;
132  out.close();
133 }
134 
136 {
138  m_renderWindow->Render();
139 }
140 
142 {
143  // Reset values
144  m_pose.p = 0.0;
145  m_pose.r = 0.0;
146  m_pose.t = 0.0;
147  m_pose.x = 0.0;
148  m_pose.y = 0.0;
149  m_pose.z = 0.0;
150 
151  // Reset sliders
152  m_dialogUI->sliderXRot->setValue(0);
153  m_dialogUI->sliderYRot->setValue(0);
154  m_dialogUI->sliderZRot->setValue(0);
155 
156  // Reset spin boxes
157  m_dialogUI->spinBoxXRot->setValue(0.0);
158  m_dialogUI->spinBoxYRot->setValue(0.0);
159  m_dialogUI->spinBoxZRot->setValue(0.0);
160 
161  m_dialogUI->spinBoxXTrans->setValue(0.0);
162  m_dialogUI->spinBoxYTrans->setValue(0.0);
163  m_dialogUI->spinBoxZTrans->setValue(0.0);
164 }
165 
167 {
168 
169 }
170 
172 {
174  m_renderWindow->Render();
175 }
176 
178 {
179  m_pose.r = value;
180 
181  // Update slider
182  m_dialogUI->sliderXRot->setValue((int)m_pose.r * 100000.0);
183 
184  // Transform selected object
185  transformLocal();
186 }
187 
189 {
190  m_pose.t = value;
191 
192  // Update slider
193  m_dialogUI->sliderYRot->setValue((int)m_pose.t * 100000.0);
194 
195  // Transform selected object
196  transformLocal();
197 }
198 
200 {
201  m_pose.p = value;
202 
203  // Update slider
204  m_dialogUI->sliderZRot->setValue((int)m_pose.p * 100000.0);
205 
206  // Transform selected object
207  transformLocal();
208 }
209 
211 {
212  m_pose.x = value;
213 
214  // Transform selected object
215  transformLocal();
216 }
217 
219 {
220  m_pose.y = value;
221 
222  // Transform selected object
223  transformLocal();
224 }
225 
227 {
228  m_pose.z = value;
229 
230  // Transform selected object
231  transformLocal();
232 }
233 
235 {
236  // Calc new value
237  double new_rot = (double)value / 100000.0;
238  m_pose.r = new_rot;
239 
240  // Update spin box
241  m_dialogUI->spinBoxXRot->setValue(m_pose.r);
242 
243 }
244 
246 {
247  // Calc new value
248  double new_rot = (double)value / 100000.0;
249  m_pose.t = new_rot;
250 
251  // Update spin box
252  m_dialogUI->spinBoxYRot->setValue(m_pose.t);
253 }
254 
256 {
257  // Calc new value
258  double new_rot = (double)value / 100000.0;
259  m_pose.p = new_rot;
260 
261  // Update spin box
262  m_dialogUI->spinBoxZRot->setValue(m_pose.p);
263 }
264 
265 
266 } // namespace lvr2
LVRTransformationDialog(LVRModelItem *parent, vtkRenderWindow *renderer)
void setPose(const Pose &pose)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08