[QGIS Commit] r14840 - in branches/threading-branch/src: core core/composer gui plugins/coordinate_capture

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Dec 4 15:56:07 EST 2010


Author: wonder
Date: 2010-12-04 12:56:07 -0800 (Sat, 04 Dec 2010)
New Revision: 14840

Modified:
   branches/threading-branch/src/core/composer/qgscomposermap.cpp
   branches/threading-branch/src/core/qgsmaprenderer.cpp
   branches/threading-branch/src/core/qgsmaprenderer.h
   branches/threading-branch/src/gui/qgsmapcanvas.cpp
   branches/threading-branch/src/gui/qgsmapoverviewcanvas.cpp
   branches/threading-branch/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
Log:
Use QFlags for rendering hints in map renderer


Modified: branches/threading-branch/src/core/composer/qgscomposermap.cpp
===================================================================
--- branches/threading-branch/src/core/composer/qgscomposermap.cpp	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/core/composer/qgscomposermap.cpp	2010-12-04 20:56:07 UTC (rev 14840)
@@ -135,16 +135,8 @@
     painter->setRenderHint( QPainter::Antialiasing );
   }
 
-  QgsRenderContext* theRendererContext = theMapRenderer.rendererContext();
-  if ( theRendererContext )
-  {
-    theRendererContext->setDrawEditingInformation( false );
-    theRendererContext->setRenderingStopped( false );
-  }
+  theMapRenderer.setRenderHint( QgsMapRenderer::ForceVectorOutput );
 
-  // force vector output (no caching of marker images etc.)
-  theRendererContext->setForceVectorOutput( true );
-
   //force composer map scale for scale dependent visibility
   double bk_scale = theMapRenderer.scale();
   theMapRenderer.setScale( scale() );

Modified: branches/threading-branch/src/core/qgsmaprenderer.cpp
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.cpp	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/core/qgsmaprenderer.cpp	2010-12-04 20:56:07 UTC (rev 14840)
@@ -54,7 +54,7 @@
   mThreadingEnabled = false;
   mCache = NULL;
 
-  next.overview = false;
+  next.hints = 0;
   next.dpi = 96;
   next.size = QSize( 0, 0 );
   next.projectionsEnabled = false;
@@ -226,7 +226,7 @@
   mRenderTime.start();
 #endif
 
-  mRenderContext.setDrawEditingInformation( !curr.overview );
+  mRenderContext.setDrawEditingInformation( !curr.hints.testFlag( DrawEditingInformation ) );
   mRenderContext.setPainter( painter );
   mRenderContext.setCoordinateTransform( 0 );
   //this flag is only for stopping during the current rendering progress,
@@ -266,7 +266,7 @@
 void QgsMapRenderer::finishRendering()
 {
   // render labels for vector layers (not using PAL)
-  if ( !curr.overview )
+  if ( !curr.hints.testFlag( NoLabeling ) )
   {
     renderLabels();
   }
@@ -362,7 +362,9 @@
     //QgsDebugMsg( "  Scale dep. visibility enabled? " + QString( "%1" ).arg( ml->hasScaleBasedVisibility() ) );
     //QgsDebugMsg( "  Input extent: " + ml->extent().toString() );
 
-    if ( ml->hasScaleBasedVisibility() && ( ml->minimumScale() > curr.scale || ml->maximumScale() < curr.scale ) && ! curr.overview )
+    if ( ! ( curr.hints & IgnoreScaleBasedVisibility ) &&
+         ml->hasScaleBasedVisibility() &&
+         ( ml->minimumScale() > curr.scale || ml->maximumScale() < curr.scale ) )
     {
       QgsDebugMsg( "Layer not rendered because it is not within the defined "
                    "visibility scale range" );
@@ -586,7 +588,7 @@
   tctx.ctx = mRenderContext;
 
   QPainter* painter = new QPainter(tctx.img);
-  painter->setRenderHint( QPainter::Antialiasing, curr.antialiasingEnabled );
+  painter->setRenderHint( QPainter::Antialiasing, curr.hints.testFlag( Antialiasing ) );
   tctx.ctx.setPainter( painter );
 
   // schedule DRAW to a list
@@ -614,7 +616,7 @@
 
       // alter painter
       QPainter * mypPainter = new QPainter( &cacheImage );
-      mypPainter->setRenderHint( QPainter::Antialiasing, curr.antialiasingEnabled );
+      mypPainter->setRenderHint( QPainter::Antialiasing, curr.hints.testFlag( Antialiasing ) );
       mRenderContext.setPainter( mypPainter );
 
       // DRAW!
@@ -1290,7 +1292,8 @@
 
 void QgsMapRenderer::enableOverviewMode( bool isOverview )
 {
-  next.overview = isOverview;
+  setRenderHints( NoLabeling | IgnoreScaleBasedVisibility, isOverview );
+  setRenderHints( DrawEditingInformation, !isOverview );
 }
 
 void QgsMapRenderer::setOutputUnits( OutputUnits u )
@@ -1323,11 +1326,6 @@
 
 }
 
-void QgsMapRenderer::setAntialiasingEnabled( bool enabled )
-{
-  next.antialiasingEnabled = enabled;
-}
-
 double QgsMapRenderer::scale() const
 {
   return next.scale;
@@ -1358,11 +1356,6 @@
   return next.labelingEngine;
 }
 
-bool QgsMapRenderer::isAntialiasingEnabled() const
-{
-  return next.antialiasingEnabled;
-}
-
 void QgsMapRenderer::clearCache()
 {
   if ( mDrawing )
@@ -1388,6 +1381,27 @@
   }
 }
 
+void QgsMapRenderer::setRenderHint( RenderHint hint, bool on )
+{
+  if ( on )
+    next.hints |= hint;
+  else
+    next.hints &= ~hint;
+}
+
+void QgsMapRenderer::setRenderHints( RenderHints hints, bool on )
+{
+  if ( on )
+    next.hints |= hints;
+  else
+    next.hints &= ~hints;
+}
+
+bool QgsMapRenderer::testRenderHint( RenderHint hint ) const
+{
+  return next.hints.testFlag( hint );
+}
+
 // ------------------------
 
 QgsMapRendererCache::QgsMapRendererCache()

Modified: branches/threading-branch/src/core/qgsmaprenderer.h
===================================================================
--- branches/threading-branch/src/core/qgsmaprenderer.h	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/core/qgsmaprenderer.h	2010-12-04 20:56:07 UTC (rev 14840)
@@ -23,6 +23,7 @@
 #include <QFutureWatcher>
 #include <QTime>
 #include <QImage>
+#include <QFlags>
 
 #include "qgis.h"
 #include "qgsrectangle.h"
@@ -227,6 +228,22 @@
     //! Added in QGIS v1.4
     void setLabelingEngine( QgsLabelingEngineInterface* iface );
 
+    enum RenderHint {
+        Antialiasing = 0x01,
+        ForceVectorOutput = 0x02,
+        DrawEditingInformation = 0x04,
+        NoLabeling = 0x08,
+        IgnoreScaleBasedVisibility = 0x10,
+        MultipleThreads = 0x20
+        // ??? Caching = 0x10,
+    };
+
+    Q_DECLARE_FLAGS(RenderHints, RenderHint)
+
+    void setRenderHint( RenderHint hint, bool on = true );
+    void setRenderHints( RenderHints hints, bool on = true );
+    bool testRenderHint( RenderHint hint ) const;
+
     //! Enable or disable rendering in multiple threads on multiprocessor computers
     //! Added in QGIS v1.6
     void setThreadingEnabled( bool use );
@@ -243,12 +260,6 @@
     //! Added in QGIS v1.6
     bool isCachingEnabled() const { return mCache != NULL; }
 
-    //! Added in QGIS v1.6
-    void setAntialiasingEnabled( bool enabled );
-
-    //! Added in QGIS v1.6
-    bool isAntialiasingEnabled() const;
-
     //! Schedule a redraw of the layers.
     //! This function returns immediately after starting the asynchronous rendering process.
     //! Any previous rendering operations must be finished/canceled first.
@@ -369,9 +380,6 @@
       //! current extent to be drawn
       QgsRectangle extent;
 
-      //! indicates whether it's map image for overview
-      bool overview;
-
       QSize size;
 
       //! detemines whether on the fly projection support is enabled
@@ -389,7 +397,7 @@
       //! Labeling engine (NULL by default)
       QgsLabelingEngineInterface* labelingEngine;
 
-      bool antialiasingEnabled;
+      RenderHints hints;
 
     } Parameters;
 
@@ -424,5 +432,7 @@
 };
 
 
+Q_DECLARE_OPERATORS_FOR_FLAGS(QgsMapRenderer::RenderHints)
+
 #endif
 

Modified: branches/threading-branch/src/gui/qgsmapcanvas.cpp
===================================================================
--- branches/threading-branch/src/gui/qgsmapcanvas.cpp	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/gui/qgsmapcanvas.cpp	2010-12-04 20:56:07 UTC (rev 14840)
@@ -102,6 +102,7 @@
   setFocusPolicy( Qt::StrongFocus );
 
   mMapRenderer = new QgsMapRenderer;
+  mMapRenderer->setRenderHint( QgsMapRenderer::DrawEditingInformation, true );
 
   // create map canvas item which will show the map
   mMap = new QgsMapCanvasMap( this );
@@ -156,7 +157,7 @@
 
 void QgsMapCanvas::enableAntiAliasing( bool theFlag )
 {
-  mMapRenderer->setAntialiasingEnabled( theFlag );
+  mMapRenderer->setRenderHint( QgsMapRenderer::Antialiasing, theFlag );
 
   if ( mMapOverview )
     mMapOverview->enableAntiAliasing( theFlag );

Modified: branches/threading-branch/src/gui/qgsmapoverviewcanvas.cpp
===================================================================
--- branches/threading-branch/src/gui/qgsmapoverviewcanvas.cpp	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/gui/qgsmapoverviewcanvas.cpp	2010-12-04 20:56:07 UTC (rev 14840)
@@ -253,7 +253,7 @@
   painter.begin( &mPixmap );
 
   // antialiasing
-  mMapRenderer->setAntialiasingEnabled( mAntiAliasing );
+  mMapRenderer->setRenderHint( QgsMapRenderer::Antialiasing, mAntiAliasing );
 
   // render image
   mMapRenderer->render( &painter );

Modified: branches/threading-branch/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp
===================================================================
--- branches/threading-branch/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp	2010-12-04 20:50:02 UTC (rev 14839)
+++ branches/threading-branch/src/plugins/coordinate_capture/coordinatecapturemaptool.cpp	2010-12-04 20:56:07 UTC (rev 14840)
@@ -58,11 +58,6 @@
 
 void CoordinateCaptureMapTool::canvasReleaseEvent( QMouseEvent * thepEvent )
 {
-  if ( !mpMapCanvas || mpMapCanvas->isDrawing() )
-  {
-    return;
-  }
-
   QgsPoint myOriginalPoint =
     mCanvas->getCoordinateTransform()->toMapCoordinates( thepEvent->x(), thepEvent->y() );
   emit mouseClicked( myOriginalPoint );



More information about the QGIS-commit mailing list