VariablePill.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_GUI_PLOT_VARIABLE_PILL_HH_
18 #define GAZEBO_GUI_PLOT_VARIABLE_PILL_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 
24 #include <ignition/math/Helpers.hh>
25 #include <ignition/math/Vector2.hh>
26 
27 #include "gazebo/gui/qt.h"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace gui
33  {
34  // Forward declare private data class
35  class VariablePillPrivate;
36 
37  class VariablePillContainer;
38 
40  class GZ_GUI_VISIBLE VariablePill : public QWidget
41  {
42  Q_OBJECT
43 
46  public: explicit VariablePill(QWidget *_parent = nullptr);
47 
49  public: virtual ~VariablePill();
50 
53  public: unsigned int Id() const;
54 
57  public: void SetName(const std::string &_name);
58 
61  public: std::string Name() const;
62 
65  public: void SetText(const std::string &_text);
66 
69  public: std::string Text() const;
70 
73  public: void SetParent(VariablePill *_parent);
74 
77  public: VariablePill *Parent() const;
78 
81  public: void SetContainer(VariablePillContainer *_container);
82 
85  public: VariablePillContainer *Container() const;
86 
89  public: void AddVariablePill(VariablePill *_variable);
90 
93  public: void RemoveVariablePill(VariablePill *_variable);
94 
98  public: VariablePill *VariablePillByName(const std::string &_name);
99 
102  public: unsigned int VariablePillCount() const;
103 
106  public: std::map<unsigned int, VariablePill *> &VariablePills() const;
107 
110  public: void SetSelected(const bool _selected);
111 
114  public: bool IsSelected() const;
115 
119  public: bool ContainsPoint(const ignition::math::Vector2i &_pt) const;
120 
123  protected: void dragEnterEvent(QDragEnterEvent *_evt);
124 
127  protected: void dropEvent(QDropEvent *_evt);
128 
131  protected: void mouseMoveEvent(QMouseEvent *_event);
132 
135  protected: void mousePressEvent(QMouseEvent *_event);
136 
139  private: void SetMultiVariableMode(const bool _enable);
140 
142  private: void UpdateStyleSheet();
143 
147  private: bool IsDragValid(QDropEvent *_evt);
148 
152  Q_SIGNALS: void VariableAdded(const unsigned int _id,
153  const std::string &_name);
154 
157  Q_SIGNALS: void VariableRemoved(const unsigned int _id);
158 
162  Q_SIGNALS: void VariableMoved(const unsigned int _id);
163 
166  Q_SIGNALS: void VariableLabelChanged(const std::string &_label);
167 
169  public: static const unsigned int EmptyVariable;
170 
173  private: std::unique_ptr<VariablePillPrivate> dataPtr;
174  };
175  }
176 }
177 #endif
static const unsigned int EmptyVariable
Empty variable id used to indicate non-existent variable.
Definition: VariablePill.hh:169
A container for holding variable pills.
Definition: VariablePillContainer.hh:37
A variable pill.
Definition: VariablePill.hh:40