Added speed factor in camera control

This commit is contained in:
Michaël Lemaire 2015-07-22 21:30:56 +02:00
parent 48d5cb6174
commit efcbeecf3e
3 changed files with 26 additions and 5 deletions

View file

@ -152,8 +152,8 @@ void TextureLayerDefinition::applyPreset(TextureLayerPreset preset)
displacement_height = 0.1;
displacement_scaling = 1.0;
displacement_offset = 0.0;
material->base = colorToHSL(Color(1.0, 1.0, 1.0, 1.0));
material->reflection = 0.25;
material->base = colorToHSL(Color(5.0, 5.0, 5.0, 1.0));
material->reflection = 0.02;
material->shininess = 0.6;
break;
default:

View file

@ -59,7 +59,8 @@ void OpenGLView::paint()
void OpenGLView::wheelEvent(QWheelEvent *event)
{
window->getCamera()->processZoom(0.1 * (double)event->angleDelta().y());
double factor = getSpeedFactor(event);
window->getCamera()->processZoom(0.1 * factor * (double)event->angleDelta().y());
}
void OpenGLView::mousePressEvent(QMouseEvent *event)
@ -75,14 +76,15 @@ void OpenGLView::mouseReleaseEvent(QMouseEvent *)
void OpenGLView::mouseMoveEvent(QMouseEvent *event)
{
double factor = getSpeedFactor(event);
QPointF diff = event->windowPos() - mouse_pos;
if (mouse_button == Qt::LeftButton)
{
window->getCamera()->processScroll(-0.1 * diff.x(), 0.1 * diff.y());
window->getCamera()->processPanning(0.006 * factor * diff.x(), 0.002 * factor * diff.y());
}
else if (mouse_button == Qt::RightButton)
{
window->getCamera()->processPanning(0.006 * diff.x(), 0.002 * diff.y());
window->getCamera()->processScroll(-0.1 * factor * diff.x(), 0.1 * factor * diff.y());
}
mouse_pos = event->windowPos();
}
@ -94,3 +96,19 @@ void OpenGLView::timerEvent(QTimerEvent *)
window->update();
}
}
double OpenGLView::getSpeedFactor(QInputEvent *event)
{
if (event->modifiers() & Qt::ControlModifier)
{
return 0.2;
}
else if (event->modifiers() & Qt::ShiftModifier)
{
return 3.0;
}
else
{
return 1.0;
}
}

View file

@ -25,6 +25,9 @@ protected:
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void timerEvent(QTimerEvent *event) override;
private:
double getSpeedFactor(QInputEvent *event);
private:
bool initialized;
MainModelerWindow *window;