Eclipse SUMO - Simulation of Urban MObility
GUIOSGManipulator.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A custom camera manipulator to interact with the OSG view directly
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #ifdef HAVE_OSG
24 
25 #include "GUIOSGHeader.h"
26 
27 class GUIOSGView;
28 
29 enum ManipulatorMode {
30  MODE_EGO = 0,
31  MODE_WALK,
32  MODE_TERRAIN
33 };
34 
35 class GUIOSGManipulator : public osgGA::TerrainManipulator {
36 public:
37  GUIOSGManipulator(GUIOSGView* parent, ManipulatorMode initMode = MODE_TERRAIN, bool verticalFixed = true, double eyeHeight = 1.7);
38  ~GUIOSGManipulator();
39  bool performMovementLeftMouseButton(const double eventTimeDelta, const double dx, const double dy) override;
40  bool performMovementMiddleMouseButton(const double eventTimeDelta, const double dx, const double dy) override;
41  bool performMovementRightMouseButton(const double eventTimeDelta, const double dx, const double dy) override;
42  bool performMouseDeltaMovement(const float dx, const float dy) override;
43  bool handleMouseMove(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
44  bool handleMouseDrag(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
45  bool handleMousePush(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
46  bool handleMouseRelease(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
47  bool handleMouseDeltaMovement(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
48  bool handleKeyDown(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
49  bool handleKeyUp(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
50  void rotateYawPitch(osg::Quat& rotation, const double yaw, const double pitch, const osg::Vec3d& localUp);
52  void setByMatrix(const osg::Matrixd& matrix) override;
54  osg::Matrixd getMatrix() const override;
56  osg::Matrixd getInverseMatrix() const override;
58  void updateHUDText();
59 protected:
60  void centerMousePointer(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
61 private:
63  GUIOSGManipulator() = delete;
64  GUIOSGManipulator(const GUIOSGManipulator& g);
65 private:
67  GUIOSGView* myParent;
69  ManipulatorMode myCurrentMode;
70  //double myWalkEyeHeight;
71  double myMoveSpeed;
72  osg::Vec3d myMove;
73 };
74 
75 #endif