TransformWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016, Bielefeld University, CITEC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Author: Robert Haschke <rhaschke@techfak.uni-bielefeld.de>
30  */
31 
32 #include "TransformWidget.h"
33 #include "EulerWidget.h"
34 
35 #include "ui_transform.h"
36 
37 #include <QMetaType>
38 
40  QWidget(parent), ui_(new Ui::TransformWidget)
41 {
42  qRegisterMetaType<Eigen::Quaterniond>("Eigen::Vector3d");
43  qRegisterMetaType<Eigen::Quaterniond>("Eigen::Quaterniond");
44  pos_.setZero();
45 
46  ui_->setupUi(this);
47 
48  connect(ui_->pos_x, SIGNAL(valueChanged(double)), this, SLOT(changePos(double)));
49  connect(ui_->pos_y, SIGNAL(valueChanged(double)), this, SLOT(changePos(double)));
50  connect(ui_->pos_z, SIGNAL(valueChanged(double)), this, SLOT(changePos(double)));
51  connect(ui_->euler_widget_, SIGNAL(valueChanged(Eigen::Quaterniond)),
52  this, SIGNAL(quaternionChanged(Eigen::Quaterniond)));
53 }
54 
55 const Eigen::Vector3d &TransformWidget::position() const
56 {
57  return pos_;
58 }
59 
60 const Eigen::Quaterniond &TransformWidget::quaternion() const
61 {
62  return ui_->euler_widget_->value();
63 }
64 
65 void TransformWidget::setPosition(const Eigen::Vector3d &p)
66 {
67  if (pos_.isApprox(p)) return;
68  pos_ = p;
69 
70  // do not trigger posChanged() signals
71  ui_->pos_x->blockSignals(true);
72  ui_->pos_y->blockSignals(true);
73  ui_->pos_z->blockSignals(true);
74 
75  ui_->pos_x->setValue(p.x());
76  ui_->pos_y->setValue(p.y());
77  ui_->pos_z->setValue(p.z());
78 
79  ui_->pos_x->blockSignals(false);
80  ui_->pos_y->blockSignals(false);
81  ui_->pos_z->blockSignals(false);
82 
83  emit positionChanged(pos_);
84 }
85 
86 void TransformWidget::setQuaternion(const Eigen::Quaterniond &q)
87 {
88  ui_->euler_widget_->setValue(q);
89 }
90 
91 void TransformWidget::changePos(double value)
92 {
93  QDoubleSpinBox *s = qobject_cast<QDoubleSpinBox*>(sender());
94  if (s == ui_->pos_x) changePos(0, value);
95  if (s == ui_->pos_y) changePos(1, value);
96  if (s == ui_->pos_z) changePos(2, value);
97 }
98 
99 void TransformWidget::changePos(unsigned int i, double value)
100 {
101  if (Eigen::internal::isApprox(pos_[i], value)) return;
102  pos_[i] = value;
103  emit positionChanged(pos_);
104 }
const Eigen::Vector3d & position() const
const Eigen::Quaterniond & quaternion() const
Definition: EulerWidget.h:37
XmlRpcServer s
void quaternionChanged(const Eigen::Quaterniond &q)
void changePos(unsigned int i, double value)
TransformWidget(QWidget *parent=0)
void setPosition(const Eigen::Vector3d &p)
Ui::TransformWidget * ui_
void setQuaternion(const Eigen::Quaterniond &q)
void positionChanged(const Eigen::Vector3d &p)
Eigen::Vector3d pos_


agni_tf_tools
Author(s): Robert Haschke
autogenerated on Fri Jun 7 2019 22:04:59