GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/gui/selection-handler.hh Lines: 0 8 0.0 %
Date: 2020-05-14 11:23:33 Branches: 0 2 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 <QWidget>
21
#include <QComboBox>
22
#include <QVector3D>
23
#include <QKeyEvent>
24
25
#include <gepetto/gui/fwd.hh>
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
    {
33
      Q_OBJECT
34
    public:
35
      SelectionMode(WindowsManagerPtr_t wsm)
36
	: wsm_(wsm)
37
      {}
38
      ~SelectionMode() {}
39
40
      virtual void reset() { currentSelected_ = ""; }
41
42
      QString currentBody () { return currentSelected_; }
43
44
    signals:
45
      void selectedBodies(QStringList selectedBodies);
46
47
    public slots:
48
      /// Slot called when a body is selected.
49
      /// \param name body's name
50
      /// \param position click position
51
      virtual void onSelect(SelectionEvent* event) = 0;
52
53
      virtual QString getName() { return "None"; }
54
55
    protected:
56
      QString currentSelected_;
57
      WindowsManagerPtr_t wsm_;
58
    };
59
60
    /// Class that allows to select one body.
61
    class UniqueSelection : public SelectionMode
62
    {
63
      Q_OBJECT
64
    public:
65
      UniqueSelection(WindowsManagerPtr_t wsm);
66
      ~UniqueSelection();
67
68
    public slots:
69
      virtual void onSelect(SelectionEvent* event);
70
      virtual QString getName() { return "Unique"; }
71
    };
72
73
    class MultiSelection : public SelectionMode
74
    {
75
      Q_OBJECT
76
    public:
77
      MultiSelection(WindowsManagerPtr_t wsm);
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);
95
      ~SelectionHandler();
96
97
      SelectionMode* mode ();
98
99
    public slots:
100
      /// Add a mode to the list of available mode.
101
      /// \param mode mode to add
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__ */