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__ */
gepetto::gui::WindowsManagerPtr_t
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
gepetto::gui::SelectionHandler::addMode
void addMode(SelectionMode *mode)
gepetto::gui::SelectionMode::onSelect
virtual void onSelect(SelectionEvent *event)=0
gepetto
Definition: action-search-bar.hh:26
gepetto::gui::SelectionMode::currentBody
QString currentBody()
Definition: selection-handler.hh:38
gepetto::gui::SelectionMode::SelectionMode
SelectionMode(WindowsManagerPtr_t wsm)
Definition: selection-handler.hh:33
gepetto::gui::UniqueSelection::onSelect
virtual void onSelect(SelectionEvent *event)
gepetto::gui::SelectionHandler::mode
SelectionMode * mode()
gepetto::gui::SelectionMode::getName
virtual QString getName()
Definition: selection-handler.hh:49
gepetto::gui::MultiSelection::selectedBodies_
QStringList selectedBodies_
Definition: selection-handler.hh:81
gepetto::gui::SelectionMode::wsm_
WindowsManagerPtr_t wsm_
Definition: selection-handler.hh:53
gepetto::gui::UniqueSelection
Class that allows to select one body.
Definition: selection-handler.hh:57
gepetto::gui::UniqueSelection::UniqueSelection
UniqueSelection(WindowsManagerPtr_t wsm)
fwd.hh
gepetto::gui::MultiSelection::reset
virtual void reset()
gepetto::gui::MultiSelection::MultiSelection
MultiSelection(WindowsManagerPtr_t wsm)
gepetto::gui::UniqueSelection::~UniqueSelection
~UniqueSelection()
gepetto::gui::MultiSelection::onSelect
virtual void onSelect(SelectionEvent *event)
gepetto::gui::SelectionEvent
Definition: selection-event.hh:30
gepetto::gui::SelectionHandler
Definition: selection-handler.hh:84
gepetto::gui::SelectionHandler::SelectionHandler
SelectionHandler(WindowsManagerPtr_t wsm, QWidget *parent=0)
gepetto::gui::SelectionHandler::~SelectionHandler
~SelectionHandler()
gepetto::gui::MultiSelection::getName
virtual QString getName()
Definition: selection-handler.hh:78
gepetto::gui::SelectionMode::reset
virtual void reset()
Definition: selection-handler.hh:36
gepetto::gui::SelectionMode::~SelectionMode
~SelectionMode()
Definition: selection-handler.hh:34
gepetto::gui::MultiSelection::~MultiSelection
~MultiSelection()
gepetto::gui::SelectionMode
Definition: selection-handler.hh:30
gepetto::gui::MultiSelection
Definition: selection-handler.hh:68
gepetto::gui::UniqueSelection::getName
virtual QString getName()
Definition: selection-handler.hh:65
gepetto::gui::SelectionMode::selectedBodies
void selectedBodies(QStringList selectedBodies)
gepetto::gui::SelectionMode::currentSelected_
QString currentSelected_
Definition: selection-handler.hh:52