gepetto-viewer  4.12.1
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 <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:
67 
68  public slots:
69  virtual void onSelect(SelectionEvent* event);
70  virtual QString getName() { return "Unique"; }
71  };
72 
74  {
75  Q_OBJECT
76  public:
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_;
113  WindowsManagerPtr_t wsm_;
114  QStringList selected_;
115  };
116  }
117 }
118 
119 #endif /* GEPETTO_GUI_SELECTION_HANDLER_H__ */
gepetto::gui::WindowsManagerPtr_t
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
gepetto::gui::SelectionHandler::addMode
void addMode(SelectionMode *mode)
gepetto::gui::SelectionMode::onSelect
virtual void onSelect(SelectionEvent *event)=0
gepetto
Definition: action-search-bar.hh:27
gepetto::gui::SelectionMode::currentBody
QString currentBody()
Definition: selection-handler.hh:42
gepetto::gui::SelectionMode::SelectionMode
SelectionMode(WindowsManagerPtr_t wsm)
Definition: selection-handler.hh:35
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:53
gepetto::gui::MultiSelection::selectedBodies_
QStringList selectedBodies_
Definition: selection-handler.hh:87
gepetto::gui::SelectionMode::wsm_
WindowsManagerPtr_t wsm_
Definition: selection-handler.hh:57
gepetto::gui::UniqueSelection
Class that allows to select one body.
Definition: selection-handler.hh:61
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:90
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:84
gepetto::gui::SelectionMode::reset
virtual void reset()
Definition: selection-handler.hh:40
gepetto::gui::SelectionMode::~SelectionMode
~SelectionMode()
Definition: selection-handler.hh:38
gepetto::gui::MultiSelection::~MultiSelection
~MultiSelection()
gepetto::gui::SelectionMode
Definition: selection-handler.hh:31
gepetto::gui::MultiSelection
Definition: selection-handler.hh:73
gepetto::gui::UniqueSelection::getName
virtual QString getName()
Definition: selection-handler.hh:70
gepetto::gui::SelectionMode::selectedBodies
void selectedBodies(QStringList selectedBodies)
gepetto::gui::SelectionMode::currentSelected_
QString currentSelected_
Definition: selection-handler.hh:56