gepetto-viewer  4.13.0
An user-friendly Graphical Interface
selection-event.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_EVENT_HH
18 #define GEPETTO_GUI_SELECTION_EVENT_HH
19 
20 #include <gepetto/viewer/node.h>
21 
22 #include <QAtomicInt>
23 #include <QObject>
24 #include <QString>
25 #include <QVector3D>
26 #include <gepetto/gui/fwd.hh>
27 
28 namespace gepetto {
29 namespace gui {
30 class SelectionEvent : public QObject {
31  Q_OBJECT
32 
33  public:
35 
37  Qt::KeyboardModifiers modKey = Qt::NoModifier)
38  : type_(t),
39  node_(node),
40  modKey_(modKey),
41  hasIntersection_(false),
42  c_(-1) {
43  if (node) nodeName_ = QString::fromStdString(node->getID());
44  }
45 
46  SelectionEvent(const Type& t, Qt::KeyboardModifiers modKey)
47  : type_(t), modKey_(modKey), hasIntersection_(false), c_(-1) {}
48 
49  void setupIntersection(
50  const osgUtil::LineSegmentIntersector::Intersection& it);
51 
52  const NodePtr_t& node() const { return node_; }
53 
54  void modKey(const Qt::KeyboardModifiers& m) { modKey_ = m; }
55 
58  void setCounter(int c) { c_ = c; }
59 
60  public slots:
61  Type type() const { return type_; }
62  QString nodeName() const { return nodeName_; }
63  Qt::KeyboardModifiers modKey() const { return modKey_; }
64 
65  bool hasIntersection() { return hasIntersection_; }
66  const unsigned int& primitiveIndex() const { return primitiveIndex_; }
67  QVector3D normal(bool local) const {
68  return (local ? localNormal_ : worldNormal_);
69  }
70  QVector3D point(bool local) const {
71  return (local ? localPoint_ : worldPoint_);
72  }
77  void done();
78 
79  private:
80  Type type_;
81  QString nodeName_;
82  NodePtr_t node_;
83  Qt::KeyboardModifiers modKey_;
84 
85  bool hasIntersection_;
86  unsigned int primitiveIndex_;
87  QVector3D localPoint_, localNormal_, worldPoint_, worldNormal_;
88  QAtomicInt c_;
89 };
90 } // namespace gui
91 } // namespace gepetto
92 
93 #endif // GEPETTO_GUI_SELECTION_EVENT_HH
Type type() const
Definition: selection-event.hh:61
QVector3D point(bool local) const
Definition: selection-event.hh:70
SelectionEvent(const Type &t, Qt::KeyboardModifiers modKey)
Definition: selection-event.hh:46
const NodePtr_t & node() const
Definition: selection-event.hh:52
void setCounter(int c)
Definition: selection-event.hh:58
QString nodeName() const
Definition: selection-event.hh:62
QVector3D normal(bool local) const
Definition: selection-event.hh:67
SelectionEvent(const Type &t, NodePtr_t node=NodePtr_t(), Qt::KeyboardModifiers modKey=Qt::NoModifier)
Definition: selection-event.hh:36
Definition: selection-event.hh:34
Definition: selection-event.hh:30
void setupIntersection(const osgUtil::LineSegmentIntersector::Intersection &it)
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:50
Definition: action-search-bar.hh:26
const unsigned int & primitiveIndex() const
Definition: selection-event.hh:66
void modKey(const Qt::KeyboardModifiers &m)
Definition: selection-event.hh:54
Type
Definition: selection-event.hh:34
bool hasIntersection()
Definition: selection-event.hh:65
Definition: selection-event.hh:34
Qt::KeyboardModifiers modKey() const
Definition: selection-event.hh:63