void GLWidget::setYTranslation(const float distance) { if(distance != yTrans) { yTrans = distance; emit yTranslationChanged(distance); updateGL(); } }
void OpenGLContainer::setXYTranslation(int speedX, int speedY) { // Covers both positive and negative values for y // TODO After the settings dialog is added make the defaul translation factor (here: .01) changable // I've noticed that the more zoomed out the scene is the less noticable the translation is if I use a constant factor // (here: .01). However if I combine this factor with the zoom level the translation speed gradually increases the more // zoomed out the scene is (and decreases upon zoom in), which leads to a very nice adaptive navigation xTrans += .01 * speedX * zZoom; // The multiplication with -1 inverts the movement so that moving the mouse cursor upwards translates upwards yTrans += .01 * speedY * zZoom * (-1); std::cout << "(x: " << QString::number(xTrans, 'g', 3).toUtf8().constData() << "; y: " << QString::number(yTrans, 'g', 3).toUtf8().constData() << ")" << std::endl; emit xTranslationChanged(xTrans); emit yTranslationChanged(yTrans); updateGL(); }