Skip to content
Permalink
Browse files
apply #2712 and #2716 with slight modification. Thanks to Charles Timko.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13517 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 17, 2010
1 parent 5edec9d commit e5cbbfd81671e5819aca5bbec4269a552928a1ca
Showing with 21 additions and 6 deletions.
  1. +4 −0 python/gui/qgsmapcanvas.sip
  2. +8 −6 src/app/qgisapp.cpp
  3. +5 −0 src/gui/qgsmapcanvas.cpp
  4. +4 −0 src/gui/qgsmapcanvas.h
@@ -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 );
@@ -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 );
@@ -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 )
@@ -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 );

0 comments on commit e5cbbfd

Please sign in to comment.