34 #include <QMouseEvent> 35 #include <QTextStream> 52 CoordinatePickerPlugin::CoordinatePickerPlugin()
53 : config_widget_(new QWidget()),
59 QObject::connect(
ui_.selectframe, SIGNAL(clicked()),
61 QObject::connect(
ui_.frame, SIGNAL(editingFinished()),
63 QObject::connect(
ui_.copyCheckBox, SIGNAL(stateChanged(
int)),
65 QObject::connect(
ui_.clearListButton, SIGNAL(clicked()),
97 switch (event->type())
99 case QEvent::MouseButtonPress:
101 case QEvent::MouseButtonRelease:
103 case QEvent::MouseMove:
112 QPointF point =
event->localPos();
113 ROS_DEBUG(
"Map point: %f %f", point.x(), point.y());
116 std::string frame =
ui_.frame->text().toStdString();
129 ROS_DEBUG(
"Transforming from fixed frame '%s' to (plugin) target frame '%s'",
133 ROS_DEBUG(
"Point in fixed frame: %f %f", transformed.x(), transformed.y());
134 tf::Vector3 position(transformed.x(), transformed.y(), 0.0);
135 position = transform * position;
136 point.setX(position.x());
137 point.setY(position.y());
144 QTextStream(&warning) <<
"No available transform from '" << QString::fromStdString(
target_frame_) <<
"' to '" << QString::fromStdString(frame) <<
"'";
149 ROS_DEBUG(
"Transformed point in frame '%s': %f %f", frame.c_str(), point.x(), point.y());
151 QTextStream stream(&new_point);
152 stream.setRealNumberPrecision(9);
153 stream << point.x() <<
"," << point.y();
157 QClipboard* clipboard = QGuiApplication::clipboard();
158 clipboard->setText(new_point);
161 stream <<
" (" << QString::fromStdString(frame) <<
")\n";
163 ui_.coordTextEdit->setPlainText(
ui_.coordTextEdit->toPlainText().prepend(new_point));
186 ui_.frame->setText(QString::fromStdString(frame));
193 ROS_INFO(
"Setting target frame to %s",
ui_.frame->text().toStdString().c_str());
203 case Qt::PartiallyChecked:
213 ui_.coordTextEdit->setPlainText(QString());
225 node[
"frame"] >> frame;
226 ui_.frame->setText(QString::fromStdString(frame));
232 node[
"copy"] >> copy;
235 ui_.copyCheckBox->setCheckState(Qt::Checked);
239 ui_.copyCheckBox->setCheckState(Qt::Unchecked);
246 std::string frame =
ui_.frame->text().toStdString();
247 emitter << YAML::Key <<
"frame" << YAML::Value << frame;
249 bool copy_on_click =
ui_.copyCheckBox->isChecked();
250 emitter << YAML::Key <<
"copy" << YAML::Value << copy_on_click;
bool Initialize(QGLWidget *canvas)
bool handleMousePress(QMouseEvent *)
bool handleMouseRelease(QMouseEvent *)
QPointF MapGlCoordToFixedFrame(const QPointF &point)
QWidget * GetConfigWidget(QWidget *parent)
swri_transform_util::TransformManager tf_manager_
void transform(Route &route, const swri_transform_util::Transform &transform, const std::string &target_frame)
virtual ~CoordinatePickerPlugin()
void PrintInfo(const std::string &message)
static void PrintWarningHelper(QLabel *status_label, const std::string &message, double throttle=0.0)
static void PrintErrorHelper(QLabel *status_label, const std::string &message, double throttle=0.0)
std::string target_frame_
bool eventFilter(QObject *object, QEvent *event)
static void PrintInfoHelper(QLabel *status_label, const std::string &message, double throttle=0.0)
void PrintError(const std::string &message)
void PrintWarning(const std::string &message)
void Draw(double x, double y, double scale)
void LoadConfig(const YAML::Node &node, const std::string &path)
bool handleMouseMove(QMouseEvent *)
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
boost::shared_ptr< tf::TransformListener > tf_
void ToggleCopyOnClick(int state)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
Ui::coordinate_picker_config ui_
mapviz::MapCanvas * map_canvas_