[QGIS Commit] r8571 -
branches/advanced_printing_branch/src/app/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Jun 1 06:21:43 EDT 2008
Author: mhugent
Date: 2008-06-01 06:21:43 -0400 (Sun, 01 Jun 2008)
New Revision: 8571
Modified:
branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposermap.h
branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h
Log:
set composer map scale from qgscomposermapwidget
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp 2008-06-01 08:48:48 UTC (rev 8570)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp 2008-06-01 10:21:43 UTC (rev 8571)
@@ -36,11 +36,6 @@
#include <iostream>
#include <cmath>
-// round isn't defined by default in msvc
-#ifdef _MSC_VER
- #define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
-#endif
-
QgsComposerMap::QgsComposerMap ( QgsComposition *composition, int id, int x, int y, int width, int height )
: QgsComposerItem(x, y, width,height,0)
{
@@ -238,7 +233,6 @@
mCacheUpdated = u;
}
-//double QgsComposerMap::scale ( void ) { return mScale; }
double QgsComposerMap::scale()
{
QgsScaleCalculator calculator;
@@ -352,7 +346,22 @@
void QgsComposerMap::setNewScale(double scaleDenominator)
{
- //soon...
+ double currentScaleDenominator = scale();
+
+ if(scaleDenominator == currentScaleDenominator)
+ {
+ return;
+ }
+
+ double scaleRatio = scaleDenominator / currentScaleDenominator;
+
+ double newXMax = mExtent.xMin() + scaleRatio * (mExtent.xMax() - mExtent.xMin());
+ double newYMax = mExtent.yMin() + scaleRatio * (mExtent.yMax() - mExtent.yMin());
+
+ QgsRect newExtent(mExtent.xMin(), mExtent.yMin(), newXMax, newYMax);
+ mExtent = newExtent;
+ mCacheUpdated = false;
+ update();
}
double QgsComposerMap::horizontalViewScaleFactor() const
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermap.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermap.h 2008-06-01 08:48:48 UTC (rev 8570)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermap.h 2008-06-01 10:21:43 UTC (rev 8571)
@@ -99,6 +99,9 @@
/** \brief Scale */
double scale ( void );
+ /**Sets new scale and changes only mExtent*/
+ void setNewScale(double scaleDenominator);
+
Calculate calculationMode() {return mCalculate;}
PreviewMode previewMode() {return mPreviewMode;}
void setPreviewMode(PreviewMode m) {mPreviewMode = m;}
@@ -158,8 +161,6 @@
/**Sets new Extent and changes only width and height*/
void setNewExtent(const QgsRect& extent);
- /**Sets new scale and changes only mExtent*/
- void setNewScale(double scaleDenominator);
/**Returns the zoom factor of the graphics view. If no
graphics view exists, the default 1 is returned*/
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp 2008-06-01 08:48:48 UTC (rev 8570)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp 2008-06-01 10:21:43 UTC (rev 8571)
@@ -151,6 +151,24 @@
mComposerMap->update();
}
+void QgsComposerMapWidget::on_mScaleLineEdit_editingFinished()
+{
+ if(!mComposerMap)
+ {
+ return;
+ }
+
+ bool conversionSuccess;
+ double scaleDenominator = mScaleLineEdit->text().toDouble(&conversionSuccess);
+
+ if(!conversionSuccess)
+ {
+ return;
+ }
+
+ mComposerMap->setNewScale(scaleDenominator);
+}
+
void QgsComposerMapWidget::updateSettingsNoSignals()
{
mHeightLineEdit->blockSignals(true);
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h 2008-06-01 08:48:48 UTC (rev 8570)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h 2008-06-01 10:21:43 UTC (rev 8571)
@@ -37,7 +37,8 @@
void on_mHeightLineEdit_editingFinished();
void on_mPreviewModeComboBox_activated(int i);
void on_mCalculateComboBox_activated(int i);
- void on_mFrameCheckBox_stateChanged(int state);
+ void on_mFrameCheckBox_stateChanged(int state);
+ void on_mScaleLineEdit_editingFinished();
/**Updates width and height without notify the composer map (to avoid infinite recursion)*/
void updateSettingsNoSignals();
More information about the QGIS-commit
mailing list