pick-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_PICK_HANDLER_HH
18 #define GEPETTO_GUI_PICK_HANDLER_HH
19 
20 #include <gepetto/gui/fwd.hh>
21 
22 #include <osg/ref_ptr>
23 #include <osgGA/GUIEventHandler>
24 
25 #include <QObject>
26 #include <QModelIndex>
27 
29 
30 namespace osgUtil {
31  class LineSegmentIntersector;
32 }
33 
34 namespace gepetto {
35  namespace gui {
36  class PointIntersector;
37 
38  class PickHandler : public osgGA::GUIEventHandler
39  {
40  public:
42 
43  virtual ~PickHandler();
44 
45  virtual bool handle( const osgGA::GUIEventAdapter& ea,
46  osgGA::GUIActionAdapter& aa );
47 
48  void getUsage (osg::ApplicationUsage &usage) const;
49 
50  private:
51  typedef osg::ref_ptr<osgUtil::LineSegmentIntersector> LineSegmentIntersector;
52 
53  void computeLineIntersection (osgGA::GUIActionAdapter& aa,
54  const float& x, const float& y);
55 
57  LineSegmentIntersector computeLineOrPointIntersection (
58  osgGA::GUIActionAdapter& aa, const float& x, const float& y);
59 
60  void selectionNodeUnderCursor (osgGA::GUIActionAdapter& aa,
61  const float& x, const float& y, int modMask);
62 
63  void centerViewToMouse (osgGA::GUIActionAdapter& aa,
64  const float& x, const float& y);
65 
66  void setCameraToSelected (osgGA::GUIActionAdapter& aa, bool zoom);
67 
68  QtOsgKeyboard mapper_;
70  OSGWidget* parent_;
71  bool pushed_;
72  float lastX_, lastY_;
73 
74  LineSegmentIntersector lineIntersector_;
75  osg::ref_ptr<PointIntersector> pointIntersector_;
76  };
77  }
78 }
79 
80 #endif // GEPETTO_GUI_PICK_HANDLER_HH
Definition: pick-handler.hh:38
Definition: action-search-bar.hh:27
Definition: pick-handler.hh:30
Widget that displays scenes.
Definition: osgwidget.hh:45
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
Definition: qt-osg-keyboard.hh:26