GCC Code Coverage Report


Directory: ./
File: include/gepetto/gui/selection-handler.hh
Date: 2024-08-14 11:04:57
Exec Total Coverage
Lines: 0 7 0.0%
Branches: 0 0 -%

Line Branch Exec Source
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 <gepetto/gui/fwd.hh>
21 // This include must be include before any other Qt include for GLDEBUGPROC
22 #include <QComboBox>
23 #include <QKeyEvent>
24 #include <QVector3D>
25 #include <QWidget>
26
27 namespace gepetto {
28 namespace gui {
29 /// Base class to define selection mode.
30 /// \note The class has no pure virtual method in order to be used in python.
31 class SelectionMode : public QObject {
32 Q_OBJECT
33 public:
34 SelectionMode(WindowsManagerPtr_t wsm) : wsm_(wsm) {}
35 ~SelectionMode() {}
36
37 virtual void reset() { currentSelected_ = ""; }
38
39 QString currentBody() { return currentSelected_; }
40
41 signals:
42 void selectedBodies(QStringList selectedBodies);
43
44 public slots:
45 /// Slot called when a body is selected.
46 /// \param name body's name
47 /// \param position click position
48 virtual void onSelect(SelectionEvent* event) = 0;
49
50 virtual QString getName() { return "None"; }
51
52 protected:
53 QString currentSelected_;
54 WindowsManagerPtr_t wsm_;
55 };
56
57 /// Class that allows to select one body.
58 class UniqueSelection : public SelectionMode {
59 Q_OBJECT
60 public:
61 UniqueSelection(WindowsManagerPtr_t wsm);
62 ~UniqueSelection();
63
64 public slots:
65 virtual void onSelect(SelectionEvent* event);
66 virtual QString getName() { return "Unique"; }
67 };
68
69 class MultiSelection : public SelectionMode {
70 Q_OBJECT
71 public:
72 MultiSelection(WindowsManagerPtr_t wsm);
73 ~MultiSelection();
74
75 virtual void reset();
76
77 public slots:
78 virtual void onSelect(SelectionEvent* event);
79 virtual QString getName() { return "Multi"; }
80
81 protected:
82 QStringList selectedBodies_;
83 };
84
85 class SelectionHandler : public QComboBox {
86 Q_OBJECT
87 public:
88 SelectionHandler(WindowsManagerPtr_t wsm, QWidget* parent = 0);
89 ~SelectionHandler();
90
91 SelectionMode* mode();
92
93 public slots:
94 /// Add a mode to the list of available mode.
95 /// \param mode mode to add
96 void addMode(SelectionMode* mode);
97
98 private slots:
99 void getBodies(QStringList selectedBodies);
100 void changeMode(int index);
101
102 private:
103 void initWidget();
104
105 std::vector<SelectionMode*> modes_;
106 int index_;
107 WindowsManagerPtr_t wsm_;
108 QStringList selected_;
109 };
110 } // namespace gui
111 } // namespace gepetto
112
113 #endif /* GEPETTO_GUI_SELECTION_HANDLER_H__ */
114