##

VariablePill.hh
Go to the documentation of this file.
/*
* Copyright (C) 2016 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_PLOT_VARIABLE_PILL_HH_
#define GAZEBO_GUI_PLOT_VARIABLE_PILL_HH_
#include <map>
#include <memory>
#include <string>
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
// Forward declare private data class
class VariablePillPrivate;
class VariablePillContainer;
class GZ_GUI_VISIBLE VariablePill : public QWidget
{
Q_OBJECT
public: explicit VariablePill(QWidget *_parent = nullptr);
public: virtual ~VariablePill();
public: unsigned int Id() const;
public: void SetName(const std::string &_name);
public: std::string Name() const;
public: void SetText(const std::string &_text);
public: std::string Text() const;
public: void SetParent(VariablePill *_parent);
public: VariablePill *Parent() const;
public: void SetContainer(VariablePillContainer *_container);
public: VariablePillContainer *Container() const;
public: void AddVariablePill(VariablePill *_variable);
public: void RemoveVariablePill(VariablePill *_variable);
public: VariablePill *VariablePillByName(const std::string &_name);
public: unsigned int VariablePillCount() const;
public: std::map<unsigned int, VariablePill *> &VariablePills() const;
public: void SetSelected(const bool _selected);
public: bool IsSelected() const;
public: bool ContainsPoint(const ignition::math::Vector2i &_pt) const;
protected: void dragEnterEvent(QDragEnterEvent *_evt);
protected: void dropEvent(QDropEvent *_evt);
protected: void mouseMoveEvent(QMouseEvent *_event);
protected: void mousePressEvent(QMouseEvent *_event);
private: void SetMultiVariableMode(const bool _enable);
private: void UpdateStyleSheet();
private: bool IsDragValid(QDropEvent *_evt);
Q_SIGNALS: void VariableAdded(const unsigned int _id,
const std::string &_name);
Q_SIGNALS: void VariableRemoved(const unsigned int _id);
Q_SIGNALS: void VariableMoved(const unsigned int _id);
Q_SIGNALS: void VariableLabelChanged(const std::string &_label);
public: static const unsigned int EmptyVariable;
private: std::unique_ptr<VariablePillPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::VariablePill::VariablePill
VariablePill(QWidget *_parent=nullptr)
Constructor.
gazebo::gui::VariablePill::ContainsPoint
bool ContainsPoint(const ignition::math::Vector2i &_pt) const
Check if a point is inside the widget.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::VariablePillContainer
A container for holding variable pills.
Definition: VariablePillContainer.hh:37
gazebo::gui::VariablePill::dropEvent
void dropEvent(QDropEvent *_evt)
Used to accept drop events.
system.hh
gazebo::gui::VariablePill::~VariablePill
virtual ~VariablePill()
Destructor.
gazebo::gui::VariablePill::EmptyVariable
static const unsigned int EmptyVariable
Empty variable id used to indicate non-existent variable.
Definition: VariablePill.hh:169
gazebo::gui::VariablePill::IsSelected
bool IsSelected() const
Return the selected state of this variable pill.
gazebo::gui::VariablePill::VariableLabelChanged
void VariableLabelChanged(const std::string &_label)
Qt signal emitted when the variable pill's text has changed.
gazebo::gui::VariablePill::SetName
void SetName(const std::string &_name)
Set a unique name for this variable.
gazebo::gui::VariablePill::VariablePills
std::map< unsigned int, VariablePill * > & VariablePills() const
Get the a child variable pill.
gazebo::gui::VariablePill::Name
std::string Name() const
Get the unique name for this variable.
gazebo::gui::VariablePill::Id
unsigned int Id() const
Get the unique id of this variable pill.
gazebo::gui::VariablePill::Text
std::string Text() const
Get the text label for this variable pill.
gazebo::gui::VariablePill
A variable pill.
Definition: VariablePill.hh:40
gazebo::gui::VariablePill::mousePressEvent
void mousePressEvent(QMouseEvent *_event)
Qt mouse move event.
gazebo::gui::VariablePill::Parent
VariablePill * Parent() const
Get the parent of this variable pill.
gazebo::gui::VariablePill::RemoveVariablePill
void RemoveVariablePill(VariablePill *_variable)
Remove a child variable pill.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::VariablePill::VariableAdded
void VariableAdded(const unsigned int _id, const std::string &_name)
Qt signal emitted when a child variable pill is added.
gazebo::gui::VariablePill::VariableRemoved
void VariableRemoved(const unsigned int _id)
Qt signal emitted when a child variable pill is removed.
gazebo::gui::VariablePill::SetParent
void SetParent(VariablePill *_parent)
Set the parent of this variable pill.
gazebo::gui::VariablePill::Container
VariablePillContainer * Container() const
Get the container which holds this variable pill.
gazebo::gui::VariablePill::SetSelected
void SetSelected(const bool _selected)
Set the selected state of this variable pill.
gazebo::gui::VariablePill::VariableMoved
void VariableMoved(const unsigned int _id)
Qt signal emitted when an existing variable pill is added as a child of this variable pill.
gazebo::gui::VariablePill::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *_evt)
Used to accept drag enter events.
gazebo::gui::VariablePill::SetText
void SetText(const std::string &_text)
Set the text label for this variable pill.
gazebo::gui::VariablePill::VariablePillByName
VariablePill * VariablePillByName(const std::string &_name)
Get a child variable pill by its unique name.
gazebo::gui::VariablePill::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *_event)
Qt mouse press event.
gazebo::gui::VariablePill::AddVariablePill
void AddVariablePill(VariablePill *_variable)
Add a child variable pill.
gazebo::gui::VariablePill::SetContainer
void SetContainer(VariablePillContainer *_container)
Set the container which holds this variable pill.
gazebo::gui::VariablePill::VariablePillCount
unsigned int VariablePillCount() const
Get the number of child variable pills.