@@ -113,8 +113,6 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
113113 mScene ->addItem ( mMap );
114114 mScene ->update (); // porting??
115115
116- moveCanvasContents ( true );
117-
118116 connect ( mMapRenderer , SIGNAL ( drawError ( QgsMapLayer* ) ), this , SLOT ( showError ( QgsMapLayer* ) ) );
119117
120118 // TODO: propagate signals to map renderer?
@@ -126,9 +124,12 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
126124 connect ( QgsProject::instance (), SIGNAL ( writeProject ( QDomDocument & ) ),
127125 this , SLOT ( writeProject ( QDomDocument & ) ) );
128126
129- mSettings .setOutputDpi (120 ); // TODO: what to set ???
130127 mSettings .setOutputSize ( size () );
131128 mMap ->resize ( size () );
129+ setSceneRect ( 0 , 0 , size ().width (), size ().height () );
130+ mScene ->setSceneRect ( QRectF ( 0 , 0 , size ().width (), size ().height () ) );
131+
132+ moveCanvasContents ( true );
132133
133134#ifdef Q_OS_WIN
134135 // Enable touch event on Windows.
@@ -287,7 +288,6 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
287288 }
288289
289290 mSettings .setLayers ( layerSet );
290- // mMapRenderer->setLayerSet( layerSet );
291291
292292 for ( i = 0 ; i < layerCount (); i++ )
293293 {
@@ -540,19 +540,9 @@ QgsRectangle QgsMapCanvas::extent() const
540540
541541QgsRectangle QgsMapCanvas::fullExtent () const
542542{
543- return mapSettings ().fullExtent (); // mMapRenderer->fullExtent();
543+ return mapSettings ().fullExtent ();
544544} // extent
545545
546- void QgsMapCanvas::updateFullExtent ()
547- {
548- // projection settings have changed
549- /*
550- QgsDebugMsg( "updating full extent" );
551-
552- mMapRenderer->updateFullExtent();
553- refresh();
554- */
555- }
556546
557547void QgsMapCanvas::setExtent ( QgsRectangle const & r )
558548{
@@ -564,12 +554,10 @@ void QgsMapCanvas::setExtent( QgsRectangle const & r )
564554 QgsRectangle e ( QgsPoint ( r.center ().x () - current.width () / 2.0 , r.center ().y () - current.height () / 2.0 ),
565555 QgsPoint ( r.center ().x () + current.width () / 2.0 , r.center ().y () + current.height () / 2.0 ) );
566556 mSettings .setExtent ( e );
567- // mMapRenderer->setExtent( e );
568557 }
569558 else
570559 {
571560 mSettings .setExtent ( r );
572- // mMapRenderer->setExtent( r );
573561 }
574562 emit extentsChanged ();
575563 updateScale ();
@@ -641,7 +629,6 @@ void QgsMapCanvas::zoomToPreviousExtent()
641629 {
642630 mLastExtentIndex --;
643631 mSettings .setExtent ( mLastExtent [mLastExtentIndex ] );
644- // mMapRenderer->setExtent( mLastExtent[mLastExtentIndex] );
645632 emit extentsChanged ();
646633 updateScale ();
647634 if ( mMapOverview )
@@ -662,7 +649,6 @@ void QgsMapCanvas::zoomToNextExtent()
662649 {
663650 mLastExtentIndex ++;
664651 mSettings .setExtent ( mLastExtent [mLastExtentIndex ] );
665- // mMapRenderer->setExtent( mLastExtent[mLastExtentIndex] );
666652 emit extentsChanged ();
667653 updateScale ();
668654 if ( mMapOverview )
@@ -993,6 +979,8 @@ void QgsMapCanvas::resizeEvent( QResizeEvent * e )
993979 mMap ->resize ( lastSize );
994980 mScene ->setSceneRect ( QRectF ( 0 , 0 , lastSize.width (), lastSize.height () ) );
995981
982+ moveCanvasContents ( true );
983+
996984 // notify canvas items of change
997985 updateCanvasItemPositions ();
998986
@@ -1005,22 +993,6 @@ void QgsMapCanvas::resizeEvent( QResizeEvent * e )
1005993
1006994void QgsMapCanvas::paintEvent ( QPaintEvent *e )
1007995{
1008- /*
1009- if ( mPainting || mDrawing )
1010- {
1011- //cancel current render progress
1012- if ( mMapRenderer )
1013- {
1014- QgsRenderContext* theRenderContext = mMapRenderer->rendererContext();
1015- if ( theRenderContext )
1016- {
1017- theRenderContext->setRenderingStopped( true );
1018- }
1019- }
1020- return;
1021- }
1022- */
1023-
1024996 QGraphicsView::paintEvent ( e );
1025997} // paintEvent
1026998
@@ -1284,7 +1256,6 @@ double QgsMapCanvas::mapUnitsPerPixel() const
12841256void QgsMapCanvas::setMapUnits ( QGis::UnitType u )
12851257{
12861258 QgsDebugMsg ( " Setting map units to " + QString::number ( static_cast <int >( u ) ) );
1287- // mMapRenderer->setMapUnits( u );
12881259 mSettings .setMapUnits ( u );
12891260}
12901261
@@ -1331,6 +1302,8 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
13311302 // move map image and other items to standard position
13321303 moveCanvasContents ( true ); // true means reset
13331304
1305+ mMap ->mapDragged ( releasePoint - mCanvasProperties ->rubberStartPoint );
1306+
13341307 // use start and end box points to calculate the extent
13351308 QgsPoint start = getCoordinateTransform ()->toMapCoordinates ( mCanvasProperties ->rubberStartPoint );
13361309 QgsPoint end = getCoordinateTransform ()->toMapCoordinates ( releasePoint );
@@ -1341,7 +1314,6 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
13411314 double dx = qAbs ( end.x () - start.x () );
13421315 double dy = qAbs ( end.y () - start.y () );
13431316
1344-
13451317 // modify the extent
13461318 QgsRectangle r = mapSettings ().visibleExtent ();
13471319
@@ -1386,9 +1358,6 @@ void QgsMapCanvas::panAction( QMouseEvent * e )
13861358
13871359 // move all map canvas items
13881360 moveCanvasContents ();
1389-
1390- // update canvas
1391- // updateContents(); // TODO: need to update?
13921361}
13931362
13941363void QgsMapCanvas::moveCanvasContents ( bool reset )
@@ -1397,28 +1366,7 @@ void QgsMapCanvas::moveCanvasContents( bool reset )
13971366 if ( !reset )
13981367 pnt += mCanvasProperties ->mouseLastXY - mCanvasProperties ->rubberStartPoint ;
13991368
1400- mMap ->setPanningOffset ( pnt );
1401-
1402- QList<QGraphicsItem*> list = mScene ->items ();
1403- QList<QGraphicsItem*>::iterator it = list.begin ();
1404- while ( it != list.end () )
1405- {
1406- QGraphicsItem* item = *it;
1407-
1408- if ( item != mMap )
1409- {
1410- // this tells map canvas item to draw with offset
1411- QgsMapCanvasItem* canvasItem = dynamic_cast <QgsMapCanvasItem *>( item );
1412- if ( canvasItem )
1413- canvasItem->setPanningOffset ( pnt );
1414- }
1415-
1416- it++;
1417- }
1418-
1419- // show items
1420- updateCanvasItemPositions ();
1421-
1369+ setSceneRect ( -pnt.x (), -pnt.y (), size ().width (), size ().height () );
14221370}
14231371
14241372void QgsMapCanvas::showError ( QgsMapLayer * mapLayer )
0 commit comments