[QGIS Commit] r8260 - in branches/rendercontext-branch/src: app/composer core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Mar 22 02:54:30 EDT 2008


Author: mhugent
Date: 2008-03-22 02:54:29 -0400 (Sat, 22 Mar 2008)
New Revision: 8260

Modified:
   branches/rendercontext-branch/src/app/composer/qgscomposermap.cpp
   branches/rendercontext-branch/src/core/qgsmaprender.cpp
   branches/rendercontext-branch/src/core/qgsrendercontext.cpp
   branches/rendercontext-branch/src/core/qgsrendercontext.h
Log:
Make print composer work again, using render context only for raster layers for now

Modified: branches/rendercontext-branch/src/app/composer/qgscomposermap.cpp
===================================================================
--- branches/rendercontext-branch/src/app/composer/qgscomposermap.cpp	2008-03-21 11:58:36 UTC (rev 8259)
+++ branches/rendercontext-branch/src/app/composer/qgscomposermap.cpp	2008-03-22 06:54:29 UTC (rev 8260)
@@ -23,6 +23,7 @@
 #include "qgsmaptopixel.h"
 #include "qgsproject.h"
 #include "qgsmaprender.h"
+#include "qgsrendercontext.h"
 #include "qgsvectorlayer.h"
 
 #include "qgslabel.h"
@@ -130,6 +131,11 @@
   int nlayers = mMapCanvas->layerCount();
     QgsCoordinateTransform* ct;
 
+    QgsRenderContext theRenderContext;
+    theRenderContext.setPainter(painter);
+    theRenderContext.setExtent(extent);
+    theRenderContext.setMapToPixel(*transform);
+
   for ( int i = nlayers - 1; i >= 0; i-- ) {
     QgsMapLayer *layer = mMapCanvas->getZpos(i);
 
@@ -144,6 +150,8 @@
       ct = NULL;
     }
 
+    theRenderContext.setCoordTransform(ct);
+
     if ( layer->type() == QgsMapLayer::VECTOR ) {
       QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
 
@@ -180,20 +188,19 @@
         double sc = mExtent.width() / (multip*QGraphicsRectItem::rect().width());
               
         QgsMapToPixel trans ( sc, multip*QGraphicsRectItem::rect().height(), mExtent.yMin(), mExtent.xMin() );
-              
+	theRenderContext.setMapToPixel(trans);
+
         painter->save();
         painter->scale( 1./multip, 1./multip);
-        //layer->draw( painter, extent, &trans, ct, FALSE);
+        layer->draw(theRenderContext);
               
         painter->restore();
       } 
       else 
       {
-        //layer->draw( painter, extent, transform, ct, FALSE);
+        layer->draw(theRenderContext);
       }
     }
-    
-    delete ct;
   }
     
   // Draw vector labels
@@ -246,8 +253,6 @@
         }
         vector->drawLabels (  painter, extent, transform, ct, fontScale );
       }
-    
-      delete ct;
     }
   }
     

Modified: branches/rendercontext-branch/src/core/qgsmaprender.cpp
===================================================================
--- branches/rendercontext-branch/src/core/qgsmaprender.cpp	2008-03-21 11:58:36 UTC (rev 8259)
+++ branches/rendercontext-branch/src/core/qgsmaprender.cpp	2008-03-22 06:54:29 UTC (rev 8260)
@@ -302,8 +302,6 @@
 	  }
       }
       
-      delete ct;
-      
       disconnect(ml, SIGNAL(drawingProgress(int,int)), this, SLOT(onDrawingProgress(int,int)));
     }
     else
@@ -356,8 +354,6 @@
 	      mRenderContext.setExtent(r2);
 	      ml->drawLabels(mRenderContext);
 	    }
-          
-          delete ct;
         }
       }
     }

Modified: branches/rendercontext-branch/src/core/qgsrendercontext.cpp
===================================================================
--- branches/rendercontext-branch/src/core/qgsrendercontext.cpp	2008-03-21 11:58:36 UTC (rev 8259)
+++ branches/rendercontext-branch/src/core/qgsrendercontext.cpp	2008-03-22 06:54:29 UTC (rev 8260)
@@ -30,7 +30,7 @@
 
 void QgsRenderContext::setCoordTransform(QgsCoordinateTransform* t) 
 {
-  //delete mCoordTransform;
+  delete mCoordTransform;
   mCoordTransform = t;
 }
 

Modified: branches/rendercontext-branch/src/core/qgsrendercontext.h
===================================================================
--- branches/rendercontext-branch/src/core/qgsrendercontext.h	2008-03-21 11:58:36 UTC (rev 8259)
+++ branches/rendercontext-branch/src/core/qgsrendercontext.h	2008-03-22 06:54:29 UTC (rev 8260)
@@ -51,8 +51,7 @@
 
   //setters
 
-  /**Sets coordinate transformation. QgsRenderContext takes ownership of the pointer and takes \
-   care of releasing the memory properly*/
+  /**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/
   void setCoordTransform(QgsCoordinateTransform* t);
   void setMapToPixel(const QgsMapToPixel& mtp) {mMapToPixel = mtp;}
   void setExtent(const QgsRect& extent){mExtent = extent;}



More information about the QGIS-commit mailing list