[QGIS Commit] r13765 - trunk/qgis/src/plugins/georeferencer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jun 21 09:17:07 EDT 2010


Author: mhugent
Date: 2010-06-21 13:17:07 +0000 (Mon, 21 Jun 2010)
New Revision: 13765

Modified:
   trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialog.cpp
   trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui
   trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp
Log:
Fix layout problems in georef pdf output by making size of left and right margins a user option

Modified: trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialog.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialog.cpp	2010-06-21 12:11:11 UTC (rev 13764)
+++ trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialog.cpp	2010-06-21 13:17:07 UTC (rev 13765)
@@ -88,6 +88,9 @@
   {
     mPixelsButton->setChecked( true );
   }
+
+  mLeftMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/LeftMarginPDF", "2.0" ).toDouble() );
+  mRightMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/RightMarginPDF", "2.0" ).toDouble() );
 }
 
 void QgsGeorefConfigDialog::writeSettings()
@@ -104,4 +107,6 @@
   {
     s.setValue( "/Plugin-GeoReferencer/Config/ResidualUnits", "mapUnits" );
   }
+  s.setValue( "/Plugin-GeoReferencer/Config/LeftMarginPDF", mLeftMarginSpinBox->value() );
+  s.setValue( "/Plugin-GeoReferencer/Config/RightMarginPDF", mRightMarginSpinBox->value() );
 }

Modified: trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui	2010-06-21 12:11:11 UTC (rev 13764)
+++ trunk/qgis/src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui	2010-06-21 13:17:07 UTC (rev 13765)
@@ -7,13 +7,13 @@
     <x>0</x>
     <y>0</y>
     <width>249</width>
-    <height>249</height>
+    <height>344</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Configure Georeferencer</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2">
+  <layout class="QGridLayout" name="gridLayout_4">
    <item row="0" column="0">
     <widget class="QGroupBox" name="mPointTipGroupBox">
      <property name="title">
@@ -37,23 +37,6 @@
      </layout>
     </widget>
    </item>
-   <item row="2" column="0">
-    <widget class="QCheckBox" name="mShowDockedCheckBox">
-     <property name="text">
-      <string>Show Georeferencer window docked</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
    <item row="1" column="0">
     <widget class="QGroupBox" name="mResidualUnitsGroupBox">
      <property name="title">
@@ -77,6 +60,71 @@
      </layout>
     </widget>
    </item>
+   <item row="2" column="0">
+    <widget class="QGroupBox" name="mPdfReportGroupBox">
+     <property name="title">
+      <string>PDF report</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2">
+      <item row="0" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QLabel" name="label">
+          <property name="text">
+           <string>Left margin</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QDoubleSpinBox" name="mLeftMarginSpinBox">
+          <property name="prefix">
+           <string/>
+          </property>
+          <property name="suffix">
+           <string> mm</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <widget class="QLabel" name="label_2">
+          <property name="text">
+           <string>Right margin</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QDoubleSpinBox" name="mRightMarginSpinBox">
+          <property name="suffix">
+           <string> mm</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QCheckBox" name="mShowDockedCheckBox">
+     <property name="text">
+      <string>Show Georeferencer window docked</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>

Modified: trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp	2010-06-21 12:11:11 UTC (rev 13764)
+++ trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp	2010-06-21 13:17:07 UTC (rev 13765)
@@ -1300,26 +1300,31 @@
   QFont tableContentFont;
   tableContentFont.setPointSize( 9 );
 
+  QSettings s;
+  double leftMargin = s.value( "/Plugin-GeoReferencer/Config/LeftMarginPDF", "2.0" ).toDouble();
+  double rightMargin = s.value( "/Plugin-GeoReferencer/Config/RightMarginPDF", "2.0" ).toDouble();
+  double contentWidth = 210 - ( leftMargin + rightMargin );
+
   //title
   QFileInfo rasterFi( mRasterFileName );
   QgsComposerLabel* titleLabel = new QgsComposerLabel( composition );
   titleLabel->setFont( titleFont );
   titleLabel->setText( rasterFi.fileName() );
   composition->addItem( titleLabel );
-  titleLabel->setSceneRect( QRectF( 2, 5, composition->paperWidth(), 8 ) );
+  titleLabel->setSceneRect( QRectF( leftMargin, 5, contentWidth, 8 ) );
   titleLabel->setFrame( false );
 
   //composer map
   QgsRectangle canvasExtent = mCanvas->extent();
   //calculate width and height considering extent aspect ratio and max Width 206, maxHeight 70
-  double widthExtentRatio = 206 / canvasExtent.width();
+  double widthExtentRatio = contentWidth / canvasExtent.width();
   double heightExtentRatio = 70 / canvasExtent.height();
   double mapWidthMM = 0;
   double mapHeightMM = 0;
   if ( widthExtentRatio < heightExtentRatio )
   {
-    mapWidthMM = 206;
-    mapHeightMM = 206 / canvasExtent.width() * canvasExtent.height();
+    mapWidthMM = contentWidth;
+    mapHeightMM = contentWidth / canvasExtent.width() * canvasExtent.height();
   }
   else
   {
@@ -1327,7 +1332,7 @@
     mapWidthMM = 70 / canvasExtent.height() * canvasExtent.width();
   }
 
-  QgsComposerMap* composerMap = new QgsComposerMap( composition, 2, titleLabel->rect().bottom() + titleLabel->transform().dy(), mapWidthMM, mapHeightMM );
+  QgsComposerMap* composerMap = new QgsComposerMap( composition, leftMargin, titleLabel->rect().bottom() + titleLabel->transform().dy(), mapWidthMM, mapHeightMM );
   composerMap->setLayerSet( canvasRenderer->layerSet() );
   composerMap->setNewExtent( mCanvas->extent() );
   composerMap->setMapCanvas( mCanvas );
@@ -1344,7 +1349,6 @@
   bool wldTransform = transform.getOriginScaleRotation( origin, scaleX, scaleY, rotation );
 
   QString residualUnits;
-  QSettings s;
   if ( s.value( "/Plugin-GeoReferencer/Config/ResidualUnits" ) == "mapUnits" && mGeorefTransform.providesAccurateInverseTransformation() )
   {
     residualUnits = tr( "map units" );
@@ -1362,7 +1366,7 @@
     parameterLabel->setText( parameterTitle );
     parameterLabel->adjustSizeToText();
     composition->addItem( parameterLabel );
-    parameterLabel->setSceneRect( QRectF( 2, composerMap->rect().bottom() + composerMap->transform().dy() + 5, composition->paperWidth(), 8 ) );
+    parameterLabel->setSceneRect( QRectF( leftMargin, composerMap->rect().bottom() + composerMap->transform().dy() + 5, contentWidth, 8 ) );
     parameterLabel->setFrame( false );
 
     //calculate mean error
@@ -1379,7 +1383,7 @@
     row << QString::number( origin.x(), 'f', 3 ) << QString::number( origin.y(), 'f', 3 ) << QString::number( scaleX ) << QString::number( scaleY ) << QString::number( rotation * 180 / M_PI ) << QString::number( meanError );
     parameterTable->addRow( row );
     composition->addItem( parameterTable );
-    parameterTable->setSceneRect( QRectF( 2, parameterLabel->rect().bottom() + parameterLabel->transform().dy() + 5, 50, 20 ) );
+    parameterTable->setSceneRect( QRectF( leftMargin, parameterLabel->rect().bottom() + parameterLabel->transform().dy() + 5, contentWidth, 20 ) );
     parameterTable->setGridStrokeWidth( 0.1 );
     parameterTable->adjustFrameToSize();
   }
@@ -1394,13 +1398,13 @@
   residualLabel->setFont( titleFont );
   residualLabel->setText( tr( "Residuals" ) );
   composition->addItem( residualLabel );
-  residualLabel->setSceneRect( QRectF( 2, previousItem->rect().bottom() + previousItem->transform().dy() + 5, composition->paperWidth(), 6 ) );
+  residualLabel->setSceneRect( QRectF( leftMargin, previousItem->rect().bottom() + previousItem->transform().dy() + 5, contentWidth, 6 ) );
   residualLabel->setFrame( false );
 
   //residual plot
   QgsResidualPlotItem* resPlotItem = new QgsResidualPlotItem( composition );
   composition->addItem( resPlotItem );
-  resPlotItem->setSceneRect( QRectF( 2, residualLabel->rect().bottom() + residualLabel->transform().dy() + 5, composerMap->rect().width(), composerMap->rect().height() ) );
+  resPlotItem->setSceneRect( QRectF( leftMargin, residualLabel->rect().bottom() + residualLabel->transform().dy() + 5, contentWidth, composerMap->rect().height() ) );
   resPlotItem->setExtent( composerMap->extent() );
   resPlotItem->setGCPList( mPoints );
 
@@ -1437,7 +1441,7 @@
 
   composition->addItem( gcpTable );
 
-  gcpTable->setSceneRect( QRectF( 2,  resPlotItem->rect().bottom() + resPlotItem->transform().dy() + 5, 170, 100 ) );
+  gcpTable->setSceneRect( QRectF( leftMargin,  resPlotItem->rect().bottom() + resPlotItem->transform().dy() + 5, contentWidth, 100 ) );
   gcpTable->setGridStrokeWidth( 0.1 );
 
   printer.setResolution( composition->printResolution() );



More information about the QGIS-commit mailing list