VariablePillContainer.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_CONTAINER_HH_
18 #define GAZEBO_GUI_PLOT_VARIABLE_PILL_CONTAINER_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "gazebo/gui/qt.h"
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace gui
30  {
31  // Forward declare private data class
32  class VariablePillContainerPrivate;
33 
34  class VariablePill;
35 
37  class GZ_GUI_VISIBLE VariablePillContainer : public QWidget
38  {
39  Q_OBJECT
40 
43  public: explicit VariablePillContainer(QWidget *_parent = nullptr);
44 
46  public: virtual ~VariablePillContainer();
47 
50  public: void SetText(const std::string &_text);
51 
54  public: std::string Text() const;
55 
59  public: void SetMaxSize(const int _max);
60 
64  public: int MaxSize() const;
65 
69  public: void SetVariablePillLabel(const unsigned int _id,
70  const std::string &_text);
71 
76  public: unsigned int AddVariablePill(const std::string &_name,
77  const unsigned int _targetId = VariablePill::EmptyVariable);
78 
82  public: void AddVariablePill(VariablePill *_variable,
83  const unsigned int _targetId = VariablePill::EmptyVariable);
84 
87  public: void RemoveVariablePill(VariablePill *_variable);
88 
91  public: void RemoveVariablePill(const unsigned int _id);
92 
95  public: unsigned int VariablePillCount() const;
96 
100  public: VariablePill *GetVariablePill(const unsigned int _id) const;
101 
104  public: void SetSelected(VariablePill *_variable);
105 
108  protected: void dragEnterEvent(QDragEnterEvent *_evt);
109 
112  protected: void dropEvent(QDropEvent *_evt);
113 
116  protected: virtual void keyPressEvent(QKeyEvent *_event);
117 
120  protected: void mouseReleaseEvent(QMouseEvent *_event);
121 
125  private: bool IsDragValid(QDropEvent *_evt) const;
126 
133  Q_SIGNALS: void VariableAdded(const unsigned int _id,
134  const std::string &_name, const unsigned int _targetId);
135 
142  Q_SIGNALS: void VariableRemoved(const unsigned int _id,
143  const unsigned int _targetId);
144 
150  Q_SIGNALS: void VariableMoved(const unsigned int _id,
151  const unsigned int _targetId);
152 
156  Q_SIGNALS: void VariableLabelChanged(const unsigned int _id,
157  const std::string &_label);
158 
162  private slots: void OnAddVariable(const unsigned int _id,
163  const std::string &_label);
164 
167  private slots: void OnRemoveVariable(const unsigned int _id);
168 
171  private slots: void OnMoveVariable(const unsigned int _id);
172 
176  private slots: void OnSetVariableLabel(const std::string &_label);
177 
180  private: std::unique_ptr<VariablePillContainerPrivate> dataPtr;
181  };
182  }
183 }
184 #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