##

LaserView.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_GUI_VIEWERS_LASERVIEW_HH_
#define GAZEBO_GUI_VIEWERS_LASERVIEW_HH_
#include <string>
#include <vector>
#include <mutex>
#include "gazebo/common/Time.hh"
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/gui/qt.h"
#include "gazebo/gui/viewers/TopicView.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
class GZ_GUI_VISIBLE LaserView : public TopicView
{
Q_OBJECT
public: explicit LaserView(QWidget *_parent = NULL);
public: virtual ~LaserView();
// Documentation inherited
public: virtual void SetTopic(const std::string &_topicName);
// Documentation inherited
private: virtual void UpdateImpl();
protected: virtual void resizeEvent(QResizeEvent *_event);
private: void OnScan(ConstLaserScanStampedPtr &_msg);
private slots: void OnFitInView();
private slots: void OnDegree(bool _toggled);
private: class LaserItem : public QGraphicsItem
{
public: LaserItem();
public: void Clear();
public: unsigned int GetRangeCount();
public: void AddRange(double _range);
public: void SetRange(unsigned int _index, double _range);
public: QRectF GetBoundingRect() const;
public: double GetHoverRange() const;
public: double GetHoverAngle() const;
public: void Update(double _angleMin, double _angleMax,
double _angleStep, double _rangeMax,
double _rangeMin);
public: void UpdateGeometry();
private: virtual QRectF boundingRect() const;
private: virtual void paint(QPainter *_painter,
const QStyleOptionGraphicsItem *_option,
QWidget *_widget);
private: virtual void hoverEnterEvent(
QGraphicsSceneHoverEvent *_event);
private: virtual void hoverLeaveEvent(
QGraphicsSceneHoverEvent *_event);
private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
private: std::vector<QPointF> points;
private: std::vector<QPointF> noHitPoints;
private: std::vector<double> ranges;
private: double angleMin;
private: double angleMax;
private: double angleStep;
private: double rangeMax;
private: double rangeMin;
private: double indexAngle;
private: double scale;
public: bool radians;
private: mutable std::mutex mutex;
private: bool dirty = false;
};
private: class CustomView : public QGraphicsView
{
public: explicit CustomView(QWidget *_parent)
: QGraphicsView(_parent), viewZoomed(false) {}
private: void wheelEvent(QWheelEvent *_event)
{
this->viewZoomed = true;
_event->delta() > 0 ? this->scale(1.15, 1.15) :
this->scale(1.0 / 1.15, 1.0 / 1.15);
_event->accept();
}
public: bool viewZoomed;
};
private: LaserItem *laserItem;
private: CustomView *view;
private: bool firstMsg;
private: QLineEdit *rangeEdit;
private: QLineEdit *angleEdit;
private: QSpinBox *vertScanSpin;
};
}
}
#endif
Time.hh
gazebo::gui::LaserView
Definition: LaserView.hh:37
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
TopicView.hh
NULL
#define NULL
Definition: CommonTypes.hh:31
TransportTypes.hh
Forward declarations for transport.
gazebo::gui::LaserView::resizeEvent
virtual void resizeEvent(QResizeEvent *_event)
QT event, called when view is resized.
system.hh
msgs.hh
gazebo::gui::LaserView::SetTopic
virtual void SetTopic(const std::string &_topicName)
Set the name of the topic to get data from.
gazebo::gui::LaserView::LaserView
LaserView(QWidget *_parent=NULL)
Constructor.
gazebo::gui::LaserView::~LaserView
virtual ~LaserView()
Destructor.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::TopicView
Base class for widgets that display topic data.
Definition: TopicView.hh:78