apply #2712 and #2716 with slight modification. Thanks to Charles Timko.

git-svn-id: http://svn.osgeo.org/qgis/trunk@13517 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2010-05-17 16:35:55 +00:00
parent e2455a0dce
commit e88a80afc8
4 changed files with 21 additions and 6 deletions

View File

@ -170,6 +170,10 @@ class QgsMapCanvas : QGraphicsView
//! Zoom out with fixed factor
void zoomOut( );
//! Zoom to a specific scale
// added in 1.5
void zoomScale( double scale );
//! Zoom with the factor supplied. Factor > 1 zooms in
void zoomByFactor( double scaleFactor );

View File

@ -1220,6 +1220,12 @@ void QgisApp::showPythonDialog()
mPythonUtils->getError( className, text );
QMessageBox::critical( this, tr( "Error" ), tr( "Failed to open Python console:" ) + "\n" + className + ": " + text );
}
#ifdef Q_WS_MAC
else
{
addWindow( mActionShowPythonDialog );
}
#endif
}
void QgisApp::createActionGroups()
@ -4779,8 +4785,6 @@ void QgisApp::showScale( double theScale )
void QgisApp::userScale()
{
double currentScale = mMapCanvas->scale();
QStringList parts = mScaleEdit->text().split( ':' );
if ( parts.size() == 2 )
{
@ -4789,8 +4793,7 @@ void QgisApp::userScale()
double rightSide = parts.at( 1 ).toDouble( &rightOk );
if ( leftSide > 0.0 && leftOk && rightOk )
{
double wantedScale = rightSide / leftSide;
mMapCanvas->zoomByFactor( wantedScale / currentScale );
mMapCanvas->zoomScale( rightSide / leftSide );
}
}
}
@ -4998,7 +5001,6 @@ void QgisApp::loadPythonSupport()
mActionPluginSeparator2 = mPluginMenu->addSeparator();
mPluginMenu->addAction( mActionShowPythonDialog );
std::cout << "Python support ENABLED :-) " << std::endl; // OK
}
}
@ -5255,7 +5257,7 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
else
{
QMessageBox::critical( this, tr( "Layer is not valid" ),
tr( "The layer is not a valid layer and can not be added to the map" ) );
tr( "The layer %1 is not a valid layer and can not be added to the map" ).arg( vectorLayerPath ) );
delete layer;
mMapCanvas->freeze( false );

View File

@ -1057,6 +1057,11 @@ void QgsMapCanvas::zoomOut()
zoomByFactor( mWheelZoomFactor );
}
void QgsMapCanvas::zoomScale( double newScale )
{
zoomByFactor( newScale / scale() );
}
void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
{
if ( mDrawing )

View File

@ -228,6 +228,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Zoom out with fixed factor
void zoomOut( );
//! Zoom to a specific scale
// added in 1.5
void zoomScale( double scale );
//! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
void zoomByFactor( double scaleFactor );