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
lvr2::LVRTransformationDialog::m_pose_original
Pose m_pose_original
Definition: LVRTransformationDialog.hpp:84
lvr2::Pose::t
float t
Definition: LVRModelBridge.hpp:53
lvr2::LVRTransformationDialog::rotationXSlided
void rotationXSlided(int value)
Definition: LVRTransformationDialog.cpp:234
lvr2::LVRModelItem::setPose
void setPose(const Pose &pose)
Definition: LVRModelItem.cpp:100
lvr2::LVRTransformationDialog::save
void save()
Definition: LVRTransformationDialog.cpp:126
lvr2::LVRTransformationDialog::m_dialogUI
TransformationDialogUI * m_dialogUI
Definition: LVRTransformationDialog.hpp:85
lvr2::LVRTransformationDialog::restoreAndClose
void restoreAndClose()
Definition: LVRTransformationDialog.cpp:135
lvr2::LVRTransformationDialog::translationYEntered
void translationYEntered(double value)
Definition: LVRTransformationDialog.cpp:218
lvr2::LVRTransformationDialog::m_parent
LVRModelItem * m_parent
Definition: LVRTransformationDialog.hpp:86
lvr2::LVRTransformationDialog::LVRTransformationDialog
LVRTransformationDialog(LVRModelItem *parent, vtkRenderWindow *renderer)
Definition: LVRTransformationDialog.cpp:41
lvr2::LVRTransformationDialog::reset
void reset()
Definition: LVRTransformationDialog.cpp:141
lvr2::LVRTransformationDialog::rotationYEntered
void rotationYEntered(double value)
Definition: LVRTransformationDialog.cpp:188
lvr2::Pose::r
float r
Definition: LVRModelBridge.hpp:53
lvr2::LVRTransformationDialog::translationXEntered
void translationXEntered(double value)
Definition: LVRTransformationDialog.cpp:210
lvr2::LVRTransformationDialog::~LVRTransformationDialog
virtual ~LVRTransformationDialog()
Definition: LVRTransformationDialog.cpp:70
lvr2::LVRTransformationDialog::stepChanged
void stepChanged(double value)
Definition: LVRTransformationDialog.cpp:119
lvr2::LVRTransformationDialog::connectSignalsAndSlots
void connectSignalsAndSlots()
Definition: LVRTransformationDialog.cpp:75
lvr2::LVRTransformationDialog::rotationZEntered
void rotationZEntered(double value)
Definition: LVRTransformationDialog.cpp:199
scripts.normalize_multiple.filename
filename
Definition: normalize_multiple.py:60
lvr2::LVRTransformationDialog::transformGlobal
void transformGlobal()
Definition: LVRTransformationDialog.cpp:166
lvr2::LVRTransformationDialog::m_renderWindow
vtkRenderWindow * m_renderWindow
Definition: LVRTransformationDialog.hpp:87
LVRTransformationDialog.hpp
lvr2::LVRTransformationDialog::rotationXEntered
void rotationXEntered(double value)
Definition: LVRTransformationDialog.cpp:177
lvr2::LVRTransformationDialog::m_pose
Pose m_pose
Definition: LVRTransformationDialog.hpp:83
lvr2::LVRModelItem::getPose
Pose getPose()
Definition: LVRModelItem.cpp:95
lvr2::Pose::p
float p
Definition: LVRModelBridge.hpp:53
lvr2::LVRModelItem
Definition: LVRModelItem.hpp:47
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Pose::x
float x
Definition: LVRModelBridge.hpp:53
lvr2::Pose::y
float y
Definition: LVRModelBridge.hpp:53
lvr2::Pose::z
float z
Definition: LVRModelBridge.hpp:53
lvr2::LVRTransformationDialog::rotationZSlided
void rotationZSlided(int value)
Definition: LVRTransformationDialog.cpp:255
lvr2::LVRTransformationDialog::translationZEntered
void translationZEntered(double value)
Definition: LVRTransformationDialog.cpp:226
lvr2::LVRTransformationDialog::rotationYSlided
void rotationYSlided(int value)
Definition: LVRTransformationDialog.cpp:245
lvr2::LVRTransformationDialog::transformLocal
void transformLocal()
Definition: LVRTransformationDialog.cpp:171


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 Wed Mar 2 2022 00:37:24