mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
caf: Add support for user controlled fixed rotation sensitivity in trackball based navigations
This commit is contained in:
@@ -334,6 +334,8 @@ double caf::RotationSensitivityCalculator::calculateSensitivity(QMouseEvent* eve
|
||||
double sensitivity = 1.0;
|
||||
|
||||
if ( m_isEnabled )
|
||||
{
|
||||
if ( m_fixedSensitivity == std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
auto presentTime = eventWhenRotating->timestamp();
|
||||
@@ -347,7 +349,7 @@ double caf::RotationSensitivityCalculator::calculateSensitivity(QMouseEvent* eve
|
||||
mouseVelocity /= 1.0e-3*timeSinceLast;
|
||||
|
||||
double mouseVelocityLength = mouseVelocity.length();
|
||||
double mouseVelocityLengthCorr = 0.3*mouseVelocityLength + 0.7*m_lastMouseVelocityLenght;
|
||||
double mouseVelocityLengthCorr = 0.1*mouseVelocityLength + 0.9*m_lastMouseVelocityLenght;
|
||||
|
||||
double slowLimit = 170.0;
|
||||
|
||||
@@ -359,9 +361,14 @@ double caf::RotationSensitivityCalculator::calculateSensitivity(QMouseEvent* eve
|
||||
m_lastMouseVelocityLenght = 0.8*mouseVelocityLength + 0.2*m_lastMouseVelocityLenght;
|
||||
|
||||
//openDebugWindow();
|
||||
//std::cout << sensitivity << " Speed: " << mouseVelocity.length() << " " << mouseVelocityLengthCorr << " \tDelta " << deltaX << ", " << deltaY << " "<< timeSinceLast << std::endl;
|
||||
//std::cout << sensitivity << " Speed: Raw: " << mouseVelocityLength << " Smooth: " << mouseVelocityLengthCorr << " \tDelta " << deltaX << ", " << deltaY << " "<< timeSinceLast << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
sensitivity = m_fixedSensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
return sensitivity;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class QMouseEvent;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class RotationSensitivityCalculator
|
||||
{
|
||||
public:
|
||||
@@ -56,9 +57,12 @@ public:
|
||||
, m_lastPosY(0)
|
||||
, m_lastMouseVelocityLenght(200)
|
||||
, m_isEnabled(false)
|
||||
, m_fixedSensitivity(std::numeric_limits<double>::infinity())
|
||||
{}
|
||||
|
||||
void enable(bool enable) { m_isEnabled = enable; }
|
||||
void enableAdaptiveRotationSensitivity(bool enable) { m_isEnabled = enable; m_fixedSensitivity = std::numeric_limits<double>::infinity(); }
|
||||
void enableFixedSensitivity(double senstivity) { m_isEnabled = true; m_fixedSensitivity = senstivity;}
|
||||
|
||||
void init(QMouseEvent* eventAtRotationStart);
|
||||
|
||||
double calculateSensitivity(QMouseEvent* eventWhenRotating);
|
||||
@@ -69,6 +73,7 @@ private:
|
||||
int m_lastPosY;
|
||||
unsigned long m_lastTime;
|
||||
double m_lastMouseVelocityLenght;
|
||||
double m_fixedSensitivity;
|
||||
};
|
||||
|
||||
} // End namespace caf
|
||||
@@ -92,7 +97,8 @@ public:
|
||||
~TrackBallBasedNavigation() override;
|
||||
void enableEventEating(bool enable) { m_consumeEvents = enable; }
|
||||
void enableRotation(bool enable) { m_isRotationEnabled = enable; }
|
||||
void enableAdaptiveRotationSensitivity(bool enable) { m_roationSensitivityCalculator.enable(enable); }
|
||||
void enableAdaptiveRotationSensitivity(bool enable) { m_roationSensitivityCalculator.enableAdaptiveRotationSensitivity(enable); }
|
||||
void enableFixedSensitivity(double senstivity) { m_roationSensitivityCalculator.enableFixedSensitivity(senstivity); }
|
||||
|
||||
protected:
|
||||
// General navigation policy overrides
|
||||
|
||||
Reference in New Issue
Block a user