Feeling dizzy?

It will not get any better if you type "dizzy"
into coordinates box in the status bar!
This commit is contained in:
Martin Dobias 2014-06-19 15:48:19 +07:00
parent 4828c84b7b
commit 20570bfa3e
2 changed files with 36 additions and 0 deletions

View File

@ -1724,6 +1724,8 @@ void QgisApp::createStatusBar()
mCoordsEdit->setToolTip( tr( "Current map coordinate (lat,lon or east,north)" ) );
statusBar()->addPermanentWidget( mCoordsEdit, 0 );
connect( mCoordsEdit, SIGNAL( returnPressed() ), this, SLOT( userCenter() ) );
mDizzyTimer = new QTimer( this );
connect( mDizzyTimer, SIGNAL( timeout() ), this, SLOT( dizzy() ) );
// add a label to show current scale
mScaleLabel = new QLabel( QString(), statusBar() );
@ -6605,8 +6607,36 @@ void QgisApp::userScale()
mMapCanvas->zoomScale( 1.0 / mScaleEdit->scale() );
}
void QgisApp::dizzy()
{
// constants should go to options so that people can customize them to their taste
int d = 10; // max. translational dizziness offset
int r = 4; // max. rotational dizzines angle
QRectF rect = mMapCanvas->sceneRect();
if ( rect.x() < -d || rect.x() > d || rect.y() < -d || rect.y() > d )
return; // do not affect panning
rect.moveTo(( rand() % ( 2 * d ) ) - d, ( rand() % ( 2 * d ) ) - d );
mMapCanvas->setSceneRect( rect );
QTransform matrix;
matrix.rotate(( rand() % ( 2 * r ) ) - r );
mMapCanvas->setTransform( matrix );
}
void QgisApp::userCenter()
{
if ( mCoordsEdit->text() == "dizzy" )
{
// sometimes you may feel a bit dizzy...
if ( mDizzyTimer->isActive() )
{
mDizzyTimer->stop();
mMapCanvas->setSceneRect( mMapCanvas->viewport()->rect() );
mMapCanvas->setTransform( QTransform() );
}
else
mDizzyTimer->start( 100 );
}
QStringList parts = mCoordsEdit->text().split( ',' );
if ( parts.size() != 2 )
return;

View File

@ -1230,6 +1230,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 2.3 */
void activateDeuteranopePreview();
/** Make the user feel dizzy */
void dizzy();
signals:
/** emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
@ -1542,6 +1545,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
QTimer *mpMapTipsTimer;
//! Helps to make people dizzy
QTimer* mDizzyTimer;
/** Point of last mouse position in map coordinates (used with MapTips)
*/
QgsPoint mLastMapPosition;