Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/osgview/GUIOSGManipulator.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GUIOSGManipulator.h
15
/// @author Mirko Barthauer
16
/// @date 27.11.2022
17
///
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);
51
/// @brief Set the position of the manipulator using a 4x4 matrix.
52
void setByMatrix(const osg::Matrixd& matrix) override;
53
/// @brief Get the position of the manipulator as 4x4 matrix.
54
osg::Matrixd getMatrix() const override;
55
/// @brief Get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.
56
osg::Matrixd getInverseMatrix() const override;
57
/// @brief Note the current manipulator mode in the HUD
58
void updateHUDText();
59
protected:
60
void centerMousePointer(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
61
private:
62
/// @brief invalidated standard constructor
63
GUIOSGManipulator() = delete;
64
GUIOSGManipulator(const GUIOSGManipulator& g);
65
private:
66
/// @brief ref to parent view for callback
67
GUIOSGView* myParent;
68
/// @brief remember which ManipulatorMode we use
69
ManipulatorMode myCurrentMode;
70
//double myWalkEyeHeight;
71
double myMoveSpeed;
72
osg::Vec3d myMove;
73
};
74
75
#endif
76
77