[QGIS Commit] r9047 - in branches/advanced_printing_branch/src: app/composer core/raster ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Aug 12 02:30:51 EDT 2008


Author: mhugent
Date: 2008-08-12 02:30:51 -0400 (Tue, 12 Aug 2008)
New Revision: 9047

Modified:
   branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposition.h
   branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.cpp
   branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.h
   branches/advanced_printing_branch/src/core/raster/qgsrasterlayer.cpp
   branches/advanced_printing_branch/src/ui/qgscompositionwidgetbase.ui
Log:
Let the user specify printout resolution. But now, the next thing to fix is the scaling of the fonts in composer legend and composer label

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-08-12 06:30:51 UTC (rev 9047)
@@ -315,6 +315,11 @@
   
   if(printDialog.exec() == QDialog::Accepted)
     {
+      //set user-defined resolution
+      if(mComposition)
+	{
+	  printer.setResolution(mComposition->printoutResolution());
+	}
       QPainter p(&printer);
 
       QgsComposition::PlotStyle savedPlotStyle = mComposition->plotStyle();
@@ -325,7 +330,7 @@
       QRect pageRect = printer.pageRect();
       mComposition->render(&p, pageRect, paperRect);
 #else
-      //better in case of custom page size, but only possible with Qt>4.4
+      //better in case of custom page size, but only possible with Qt>=4.4.0
       QRectF paperRectMM = printer.pageRect(QPrinter::Millimeter);
       QRectF paperRectPixel = printer.pageRect(QPrinter::DevicePixel);
       mComposition->render(&p, paperRectPixel, paperRectMM);

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp	2008-08-12 06:30:51 UTC (rev 9047)
@@ -20,6 +20,7 @@
 #include <QDomDocument>
 #include <QDomElement>
 #include <QGraphicsRectItem>
+#include <QPrinter> //to find out screen resolution
 
 QgsComposition::QgsComposition(QgsMapCanvas* mapCanvas): QGraphicsScene(0), mMapCanvas(mapCanvas), mPlotStyle(QgsComposition::Preview), mPaperItem(0)
 {
@@ -30,6 +31,9 @@
   mPaperItem->setBrush(Qt::white);
   addItem(mPaperItem);
   mPaperItem->setZValue(0);
+
+  QPrinter resolutionTest(QPrinter::ScreenResolution);
+  mPrintoutResolution = resolutionTest.resolution();
 }
 
 QgsComposition::QgsComposition(): QGraphicsScene(0), mMapCanvas(0), mPlotStyle(QgsComposition::Preview), mPaperItem(0)

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposition.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposition.h	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposition.h	2008-08-12 06:30:51 UTC (rev 9047)
@@ -63,6 +63,9 @@
    @return id or 0 pointer if the composer map item does not exist*/
   const QgsComposerMap* getComposerMapById(int id) const;
 
+  int printoutResolution() const {return mPrintoutResolution;}
+  void setPrintoutResolution(int dpi){mPrintoutResolution = dpi;}
+
   /**Returns pointer to qgis map canvas*/
   QgsMapCanvas* mapCanvas(){return mMapCanvas;}
 
@@ -80,6 +83,9 @@
   QgsComposition::PlotStyle mPlotStyle;
   QGraphicsRectItem* mPaperItem;
 
+  /**Dpi for printout*/
+  int mPrintoutResolution;
+
   QgsComposition(); //default constructor is forbidden
 };
 

Modified: branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.cpp	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.cpp	2008-08-12 06:30:51 UTC (rev 9047)
@@ -17,6 +17,7 @@
 #include "qgscompositionwidget.h"
 #include "qgscomposition.h"
 #include <QWidget>
+#include <QPrinter> //for screen resolution
 
 QgsCompositionWidget::QgsCompositionWidget(QWidget* parent, QgsComposition* c): QWidget(parent), mComposition(c)
 {
@@ -32,6 +33,12 @@
   
   //read with/height from composition and find suitable entries to display
   displayCompositionWidthHeight();
+
+  //read printout resolution from composition
+  if(mComposition)
+    {
+      mResolutionLineEdit->setText(QString::number(mComposition->printoutResolution()));
+    }
 }
 
 QgsCompositionWidget::QgsCompositionWidget(): QWidget(0), mComposition(0)
@@ -263,3 +270,19 @@
   mPaperOrientationComboBox->blockSignals(false);
   mResolutionLineEdit->blockSignals(false);
 }
+
+void QgsCompositionWidget::on_mResolutionLineEdit_textChanged(const QString& text)
+{
+  bool conversionOk;
+  int resolution = text.toInt(&conversionOk);
+  if(conversionOk && mComposition)
+    {
+      mComposition->setPrintoutResolution(resolution);
+    }
+  else if(mComposition)
+    {
+      //set screen resolution per default
+      QPrinter resolutionInfo(QPrinter::ScreenResolution);
+      mComposition->setPrintoutResolution(resolutionInfo.resolution());
+    }
+}

Modified: branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.h	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/app/composer/qgscompositionwidget.h	2008-08-12 06:30:51 UTC (rev 9047)
@@ -39,6 +39,7 @@
   void on_mPaperOrientationComboBox_currentIndexChanged(const QString& text);
   void on_mPaperWidthLineEdit_editingFinished();
   void on_mPaperHeightLineEdit_editingFinished();
+  void on_mResolutionLineEdit_textChanged(const QString& text);
   
  private:
   QgsComposition* mComposition;

Modified: branches/advanced_printing_branch/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/advanced_printing_branch/src/core/raster/qgsrasterlayer.cpp	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/core/raster/qgsrasterlayer.cpp	2008-08-12 06:30:51 UTC (rev 9047)
@@ -1196,26 +1196,15 @@
   }
   else
   {
-    if ((myRasterViewPort->drawableAreaXDim) > 4000 &&  (myRasterViewPort->drawableAreaYDim > 4000))
-      {
-	// We have scaled one raster pixel to more than 4000 screen pixels. What's the point of showing this layer?
-	// Instead, we just stop displaying the layer. Prevents allocating the entire world of memory for showing
-	// very few pixels.
-	// (Alternatively, we have a very big screen > 2000 x 2000)
-	QgsDebugMsg("Too zoomed in! Displaying raster requires too much memory. Raster will not display");
-      } 
-    else 
-      {
-	// Otherwise use the old-fashioned GDAL direct-drawing style
-	// TODO: Move into its own GDAL provider.
-	
-	// \/\/\/ - commented-out to handle zoomed-in rasters
-	//    draw(theQPainter,myRasterViewPort);
-	// /\/\/\ - commented-out to handle zoomed-in rasters
-	// \/\/\/ - added to handle zoomed-in rasters
-	draw(theQPainter, myRasterViewPort, &theQgsMapToPixel);
-	// /\/\/\ - added to handle zoomed-in rasters
-      }
+    // Otherwise use the old-fashioned GDAL direct-drawing style
+    // TODO: Move into its own GDAL provider.
+    
+    // \/\/\/ - commented-out to handle zoomed-in rasters
+    //    draw(theQPainter,myRasterViewPort);
+    // /\/\/\ - commented-out to handle zoomed-in rasters
+    // \/\/\/ - added to handle zoomed-in rasters
+    draw(theQPainter, myRasterViewPort, &theQgsMapToPixel);
+    // /\/\/\ - added to handle zoomed-in rasters
   }
 
   delete myRasterViewPort;

Modified: branches/advanced_printing_branch/src/ui/qgscompositionwidgetbase.ui
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscompositionwidgetbase.ui	2008-08-11 10:11:41 UTC (rev 9046)
+++ branches/advanced_printing_branch/src/ui/qgscompositionwidgetbase.ui	2008-08-12 06:30:51 UTC (rev 9047)
@@ -206,7 +206,7 @@
     </spacer>
    </item>
    <item row="1" column="0" >
-    <widget class="QLabel" name="textLabel1" >
+    <widget class="QLabel" name="mResolutionLabel" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
        <horstretch>0</horstretch>
@@ -214,7 +214,7 @@
       </sizepolicy>
      </property>
      <property name="text" >
-      <string>Resolution (dpi)</string>
+      <string>Print quality (dpi)</string>
      </property>
      <property name="buddy" >
       <cstring>mResolutionLineEdit</cstring>



More information about the QGIS-commit mailing list