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 <QWidget>
21 #include <QComboBox>
22 #include <QVector3D>
23 #include <QKeyEvent>
24 
25 #include <gepetto/gui/fwd.hh>
26 
27 namespace gepetto {
28  namespace gui {
31  class SelectionMode : public QObject
32  {
33  Q_OBJECT
34  public:
36  : wsm_(wsm)
37  {}
39 
40  virtual void reset() { currentSelected_ = ""; }
41 
42  QString currentBody () { return currentSelected_; }
43 
44  signals:
45  void selectedBodies(QStringList selectedBodies);
46 
47  public slots:
51  virtual void onSelect(SelectionEvent* event) = 0;
52 
53  virtual QString getName() { return "None"; }
54 
55  protected:
58  };
59 
62  {
63  Q_OBJECT
64  public:
66  ~UniqueSelection();
67 
68  public slots:
69  virtual void onSelect(SelectionEvent* event);
70  virtual QString getName() { return "Unique"; }
71  };
72 
74  {
75  Q_OBJECT
76  public:
78  ~MultiSelection();
79 
80  virtual void reset();
81 
82  public slots:
83  virtual void onSelect(SelectionEvent* event);
84  virtual QString getName() { return "Multi"; }
85 
86  protected:
87  QStringList selectedBodies_;
88  };
89 
90  class SelectionHandler : public QComboBox
91  {
92  Q_OBJECT
93  public:
94  SelectionHandler(WindowsManagerPtr_t wsm, QWidget* parent = 0);
96 
97  SelectionMode* mode ();
98 
99  public slots:
102  void addMode(SelectionMode *mode);
103 
104  private slots:
105  void getBodies(QStringList selectedBodies);
106  void changeMode(int index);
107 
108  private:
109  void initWidget();
110 
111  std::vector<SelectionMode *> modes_;
112  int index_;
114  QStringList selected_;
115  };
116  }
117 }
118 
119 #endif /* GEPETTO_GUI_SELECTION_HANDLER_H__ */
virtual QString getName()
Definition: selection-handler.hh:84
virtual void onSelect(SelectionEvent *event)=0
SelectionMode(WindowsManagerPtr_t wsm)
Definition: selection-handler.hh:35
virtual void reset()
Definition: selection-handler.hh:40
void selectedBodies(QStringList selectedBodies)
Definition: selection-event.hh:30
virtual QString getName()
Definition: selection-handler.hh:53
QStringList selectedBodies_
Definition: selection-handler.hh:87
Definition: selection-handler.hh:31
Class that allows to select one body.
Definition: selection-handler.hh:61
Definition: action-search-bar.hh:27
virtual QString getName()
Definition: selection-handler.hh:70
QString currentBody()
Definition: selection-handler.hh:42
~SelectionMode()
Definition: selection-handler.hh:38
Definition: selection-handler.hh:90
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
QString currentSelected_
Definition: selection-handler.hh:56
Definition: selection-handler.hh:73
WindowsManagerPtr_t wsm_
Definition: selection-handler.hh:57