gepetto-viewer  4.13.0
An user-friendly Graphical Interface
selection-handler.hh
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef GEPETTO_GUI_SELECTION_HANDLER_H__
18 #define GEPETTO_GUI_SELECTION_HANDLER_H__
19 
20 #include <QComboBox>
21 #include <QKeyEvent>
22 #include <QVector3D>
23 #include <QWidget>
24 #include <gepetto/gui/fwd.hh>
25 
26 namespace gepetto {
27 namespace gui {
30 class SelectionMode : public QObject {
31  Q_OBJECT
32  public:
35 
36  virtual void reset() { currentSelected_ = ""; }
37 
38  QString currentBody() { return currentSelected_; }
39 
40  signals:
41  void selectedBodies(QStringList selectedBodies);
42 
43  public slots:
47  virtual void onSelect(SelectionEvent* event) = 0;
48 
49  virtual QString getName() { return "None"; }
50 
51  protected:
54 };
55 
58  Q_OBJECT
59  public:
62 
63  public slots:
64  virtual void onSelect(SelectionEvent* event);
65  virtual QString getName() { return "Unique"; }
66 };
67 
68 class MultiSelection : public SelectionMode {
69  Q_OBJECT
70  public:
73 
74  virtual void reset();
75 
76  public slots:
77  virtual void onSelect(SelectionEvent* event);
78  virtual QString getName() { return "Multi"; }
79 
80  protected:
81  QStringList selectedBodies_;
82 };
83 
84 class SelectionHandler : public QComboBox {
85  Q_OBJECT
86  public:
87  SelectionHandler(WindowsManagerPtr_t wsm, QWidget* parent = 0);
89 
91 
92  public slots:
95  void addMode(SelectionMode* mode);
96 
97  private slots:
98  void getBodies(QStringList selectedBodies);
99  void changeMode(int index);
100 
101  private:
102  void initWidget();
103 
104  std::vector<SelectionMode*> modes_;
105  int index_;
106  WindowsManagerPtr_t wsm_;
107  QStringList selected_;
108 };
109 } // namespace gui
110 } // namespace gepetto
111 
112 #endif /* GEPETTO_GUI_SELECTION_HANDLER_H__ */
virtual QString getName()
Definition: selection-handler.hh:78
virtual void onSelect(SelectionEvent *event)
virtual void onSelect(SelectionEvent *event)=0
SelectionHandler(WindowsManagerPtr_t wsm, QWidget *parent=0)
SelectionMode(WindowsManagerPtr_t wsm)
Definition: selection-handler.hh:33
virtual void reset()
Definition: selection-handler.hh:36
void selectedBodies(QStringList selectedBodies)
Definition: selection-event.hh:30
virtual QString getName()
Definition: selection-handler.hh:49
QStringList selectedBodies_
Definition: selection-handler.hh:81
Definition: selection-handler.hh:30
Class that allows to select one body.
Definition: selection-handler.hh:57
Definition: action-search-bar.hh:26
UniqueSelection(WindowsManagerPtr_t wsm)
virtual QString getName()
Definition: selection-handler.hh:65
void addMode(SelectionMode *mode)
QString currentBody()
Definition: selection-handler.hh:38
~SelectionMode()
Definition: selection-handler.hh:34
virtual void onSelect(SelectionEvent *event)
Definition: selection-handler.hh:84
MultiSelection(WindowsManagerPtr_t wsm)
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
QString currentSelected_
Definition: selection-handler.hh:52
Definition: selection-handler.hh:68
WindowsManagerPtr_t wsm_
Definition: selection-handler.hh:53