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