Skip to content

Commit

Permalink
Feeling dizzy?
Browse files Browse the repository at this point in the history
It will not get any better if you type "dizzy"
into coordinates box in the status bar!
  • Loading branch information
wonder-sk committed Jun 19, 2014
1 parent 4828c84 commit 20570bf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -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) */
Expand Down Expand Up @@ -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;
Expand Down

3 comments on commit 20570bf

@slarosa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :-D

@3nids
Copy link
Member

@3nids 3nids commented on 20570bf Jun 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol
hard night?

@timlinux
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wonder-sk Haha finally you came up with a good idea for an easter egg

Please sign in to comment.