mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-03 15:11:49 -05:00
Add InteractionHandler to global property gui
Add property to interactionhandler to enable/disable rotational and zoom friction
This commit is contained in:
@@ -261,6 +261,10 @@ public:
|
||||
~OrbitalInteractionMode();
|
||||
|
||||
virtual void update(double deltaTime);
|
||||
|
||||
void setRotationalFriction(bool friction);
|
||||
void setZoomFriction(bool friction);
|
||||
|
||||
protected:
|
||||
void updateMouseStatesFromInput(double deltaTime);
|
||||
void updateCameraStateFromMouseStates();
|
||||
@@ -274,6 +278,9 @@ protected:
|
||||
|
||||
glm::dquat _localCameraRotation;
|
||||
glm::dquat _globalCameraRotation;
|
||||
|
||||
bool _rotationalFriction;
|
||||
bool _zoomFriction;
|
||||
};
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
@@ -360,6 +367,9 @@ private:
|
||||
// Properties
|
||||
properties::StringProperty _origin;
|
||||
properties::StringProperty _coordinateSystem;
|
||||
|
||||
properties::BoolProperty _rotationalFriction;
|
||||
properties::BoolProperty _zoomFriction;
|
||||
};
|
||||
|
||||
#endif // USE_OLD_INTERACTIONHANDLER
|
||||
|
||||
@@ -67,9 +67,9 @@ public:
|
||||
GuiHelpComponent _help;
|
||||
GuiOriginComponent _origin;
|
||||
GuiPerformanceComponent _performance;
|
||||
GuiPropertyComponent _globalProperty;
|
||||
GuiPropertyComponent _property;
|
||||
GuiPropertyComponent _screenSpaceProperty;
|
||||
GuiPropertyComponent _globalProperty;
|
||||
GuiTimeComponent _time;
|
||||
GuiIswaComponent _iswa;
|
||||
};
|
||||
|
||||
@@ -164,9 +164,9 @@ namespace gui {
|
||||
|
||||
GUI::GUI()
|
||||
: GuiComponent()
|
||||
, _globalProperty("Global")
|
||||
, _property("Properties")
|
||||
, _screenSpaceProperty("ScreenSpace Properties")
|
||||
, _globalProperty("Global")
|
||||
{}
|
||||
|
||||
GUI::~GUI() {
|
||||
@@ -369,12 +369,12 @@ void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
|
||||
void GUI::endFrame() {
|
||||
render();
|
||||
|
||||
if (_globalProperty.isEnabled())
|
||||
_globalProperty.render();
|
||||
if (_property.isEnabled())
|
||||
_property.render();
|
||||
if (_screenSpaceProperty.isEnabled())
|
||||
_screenSpaceProperty.render();
|
||||
if (_globalProperty.isEnabled())
|
||||
_globalProperty.render();
|
||||
if (_performance.isEnabled())
|
||||
_performance.render();
|
||||
if (_help.isEnabled())
|
||||
|
||||
@@ -16,6 +16,9 @@ helper.setCommonKeys = function()
|
||||
|
||||
openspace.bindKey("COMMA", "openspace.setRenderer('Framebuffer');")
|
||||
openspace.bindKey("PERIOD", "openspace.setRenderer('ABuffer');")
|
||||
|
||||
openspace.bindKey("f", helper.property.invert('Interaction.rotationalFriction'))
|
||||
openspace.bindKey("Shift+f", helper.property.invert('Interaction.zoomFriction'))
|
||||
end
|
||||
|
||||
helper.setDeltaTimeKeys = function(t)
|
||||
|
||||
@@ -440,7 +440,10 @@ bool OpenSpaceEngine::initialize() {
|
||||
_gui->initialize();
|
||||
_gui->_globalProperty.setSource(
|
||||
[&]() {
|
||||
std::vector<properties::PropertyOwner*> res = { _settingsEngine.get() };
|
||||
std::vector<properties::PropertyOwner*> res = {
|
||||
_settingsEngine.get(),
|
||||
_interactionHandler.get()
|
||||
};
|
||||
return res;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -756,14 +756,22 @@ OrbitalInteractionMode::OrbitalInteractionMode(
|
||||
, _globalRotationMouseState(velocityScaleFactor)
|
||||
, _localRotationMouseState(velocityScaleFactor)
|
||||
, _truckMovementMouseState(velocityScaleFactor)
|
||||
, _rollMouseState(velocityScaleFactor) {
|
||||
, _rollMouseState(velocityScaleFactor)
|
||||
, _rotationalFriction(true)
|
||||
, _zoomFriction(true)
|
||||
{}
|
||||
|
||||
OrbitalInteractionMode::~OrbitalInteractionMode() {}
|
||||
|
||||
void OrbitalInteractionMode::setRotationalFriction(bool friction) {
|
||||
_rotationalFriction = friction;
|
||||
}
|
||||
|
||||
OrbitalInteractionMode::~OrbitalInteractionMode() {
|
||||
|
||||
void OrbitalInteractionMode::setZoomFriction(bool friction) {
|
||||
_zoomFriction = friction;
|
||||
}
|
||||
|
||||
|
||||
void OrbitalInteractionMode::updateMouseStatesFromInput(double deltaTime) {
|
||||
glm::dvec2 mousePosition = _inputState->getMousePosition();
|
||||
|
||||
@@ -794,10 +802,12 @@ void OrbitalInteractionMode::updateMouseStatesFromInput(double deltaTime) {
|
||||
}
|
||||
else { // !button1Pressed
|
||||
_localRotationMouseState.previousPosition = mousePosition;
|
||||
_localRotationMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
|
||||
_globalRotationMouseState.previousPosition = mousePosition;
|
||||
_globalRotationMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
|
||||
if (_rotationalFriction) {
|
||||
_localRotationMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
_globalRotationMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
}
|
||||
}
|
||||
if (button2Pressed) {
|
||||
glm::dvec2 mousePositionDelta =
|
||||
@@ -806,7 +816,9 @@ void OrbitalInteractionMode::updateMouseStatesFromInput(double deltaTime) {
|
||||
}
|
||||
else { // !button2Pressed
|
||||
_truckMovementMouseState.previousPosition = mousePosition;
|
||||
_truckMovementMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
if (_zoomFriction) {
|
||||
_truckMovementMouseState.velocity.set(glm::dvec2(0, 0));
|
||||
}
|
||||
}
|
||||
if (button3Pressed) {
|
||||
glm::dvec2 mousePositionDelta =
|
||||
@@ -992,7 +1004,10 @@ void GlobeBrowsingInteractionMode::update(double deltaTime) {
|
||||
// InteractionHandler
|
||||
InteractionHandler::InteractionHandler()
|
||||
: _origin("origin", "Origin", "")
|
||||
, _coordinateSystem("coordinateSystem", "Coordinate System", "") {
|
||||
, _coordinateSystem("coordinateSystem", "Coordinate System", "")
|
||||
, _rotationalFriction("rotationalFriction", "Rotational Friction", true)
|
||||
, _zoomFriction("zoomFriction", "Zoom Friction", true)
|
||||
{
|
||||
setName("Interaction");
|
||||
|
||||
_origin.onChange([this]() {
|
||||
@@ -1010,6 +1025,7 @@ InteractionHandler::InteractionHandler()
|
||||
});
|
||||
addProperty(_coordinateSystem);
|
||||
|
||||
|
||||
// Create the interactionModes
|
||||
_inputState = std::shared_ptr<InputState>(new InputState());
|
||||
_orbitalInteractionMode = std::shared_ptr<OrbitalInteractionMode>(
|
||||
@@ -1022,6 +1038,22 @@ InteractionHandler::InteractionHandler()
|
||||
|
||||
// Set the interactionMode
|
||||
_currentInteractionMode = _orbitalInteractionMode;
|
||||
|
||||
_rotationalFriction.onChange([&]() {
|
||||
_orbitalInteractionMode->setRotationalFriction(_rotationalFriction);
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
_globebrowsingInteractionMode->setRotationalFriction(_rotationalFriction);
|
||||
#endif
|
||||
});
|
||||
addProperty(_rotationalFriction);
|
||||
|
||||
_zoomFriction.onChange([&]() {
|
||||
_orbitalInteractionMode->setZoomFriction(_zoomFriction);
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
_globebrowsingInteractionMode->setZoomFriction(_zoomFriction);
|
||||
#endif
|
||||
});
|
||||
addProperty(_zoomFriction);
|
||||
}
|
||||
|
||||
InteractionHandler::~InteractionHandler() {
|
||||
|
||||
Reference in New Issue
Block a user