[QGIS Commit] r11849 - in trunk/qgis: python/core src/app/composer
src/core/composer src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Oct 26 11:10:05 EDT 2009
Author: mhugent
Date: 2009-10-26 11:10:04 -0400 (Mon, 26 Oct 2009)
New Revision: 11849
Modified:
trunk/qgis/python/core/qgscomposermap.sip
trunk/qgis/src/app/composer/qgscomposermapwidget.cpp
trunk/qgis/src/app/composer/qgscomposermapwidget.h
trunk/qgis/src/core/composer/qgscomposermap.cpp
trunk/qgis/src/core/composer/qgscomposermap.h
trunk/qgis/src/ui/qgscomposermapwidgetbase.ui
Log:
Possibility to choose the precision of composer grid annotations
Modified: trunk/qgis/python/core/qgscomposermap.sip
===================================================================
--- trunk/qgis/python/core/qgscomposermap.sip 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/python/core/qgscomposermap.sip 2009-10-26 15:10:04 UTC (rev 11849)
@@ -131,52 +131,93 @@
*/
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+ /**Enables a coordinate grid that is shown on top of this composermap.
+ @note this function was added in version 1.4*/
void setGridEnabled( bool enabled );
bool gridEnabled() const;
+ /**Sets coordinate grid style to solid or cross
+ @note this function was added in version 1.4*/
void setGridStyle( GridStyle style );
GridStyle gridStyle() const;
+ /**Sets coordinate interval in x-direction for composergrid.
+ @note this function was added in version 1.4*/
void setGridIntervalX( double interval );
double gridIntervalX() const;
+ /**Sets coordinate interval in y-direction for composergrid.
+ @note this function was added in version 1.4*/
void setGridIntervalY( double interval );
double gridIntervalY() const;
+ /**Sets x-coordinate offset for composer grid
+ @note this function was added in version 1.4*/
void setGridOffsetX( double offset );
double gridOffsetX() const;
+ /**Sets y-coordinate offset for composer grid
+ @note this function was added in version 1.4*/
void setGridOffsetY( double offset );
double gridOffsetY() const;
+ /**Sets the pen to draw composer grid
+ @note this function was added in version 1.4*/
void setGridPen( const QPen& p );
QPen gridPen() const;
+
+ /**Sets with of grid pen
+ @note this function was added in version 1.4*/
void setGridPenWidth( double w );
+
+ /**Sets the color of the grid pen
+ @note this function was added in version 1.4*/
void setGridPenColor( const QColor& c );
+ /**Sets font for grid annotations
+ @note this function was added in version 1.4*/
void setGridAnnotationFont( const QFont& f );
QFont gridAnnotationFont() const;
+ /**Sets coordinate precision for grid annotations
+ @note this function was added in version 1.4*/
+ void setGridAnnotationPrecision( int p );
+ int gridAnnotationPrecision() const;
+
+ /**Sets flag if grid annotation should be shown
+ @note this function was added in version 1.4*/
void setShowGridAnnotation( bool show );
bool showGridAnnotation() const;
+ /**Sets position of grid annotations. Possibilities are inside or outside of the map frame
+ @note this function was added in version 1.4*/
void setGridAnnotationPosition( GridAnnotationPosition p );
GridAnnotationPosition gridAnnotationPosition() const;
+ /**Sets distance between map frame and annotations
+ @note this function was added in version 1.4*/
void setAnnotationFrameDistance( double d ) {mAnnotationFrameDistance = d;}
double annotationFrameDistance() const {return mAnnotationFrameDistance;}
+ /**Sets grid annotation direction. Can be horizontal, vertical, direction of axis and horizontal and vertical
+ @note this function was added in version 1.4*/
void setGridAnnotationDirection( GridAnnotationDirection d );
GridAnnotationDirection gridAnnotationDirection() const;
- /**In case of annotations, the bounding rectangle can be larger than the map item rectangle*/
+ /**In case of annotations, the bounding rectangle can be larger than the map item rectangle
+ @note this function was added in version 1.4*/
QRectF boundingRect() const;
- /**Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle*/
+ /**Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle
+ @note this function was added in version 1.4*/
void updateBoundingRect();
+ /**Sets the rotation of the map content
+ @note this function was added in version 1.4*/
void setRotation(double r);
double rotation() const;
+ /**Sets length of the cros segments (if grid style is cross)
+ @note this function was added in version 1.4*/
void setCrossLength(double l);
double crossLength();
Modified: trunk/qgis/src/app/composer/qgscomposermapwidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposermapwidget.cpp 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/src/app/composer/qgscomposermapwidget.cpp 2009-10-26 15:10:04 UTC (rev 11849)
@@ -365,6 +365,7 @@
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Boundary direction" ) ) );
}
+ mCoordinatePrecisionSpinBox->setValue( mComposerMap->gridAnnotationPrecision() );
QPen gridPen = mComposerMap->gridPen();
mLineWidthSpinBox->setValue( gridPen.widthF() );
@@ -423,6 +424,7 @@
mAnnotationPositionComboBox->blockSignals( b );
mDistanceToMapFrameSpinBox->blockSignals( b );
mAnnotationDirectionComboBox->blockSignals( b );
+ mCoordinatePrecisionSpinBox->blockSignals( b );
}
void QgsComposerMapWidget::on_mUpdatePreviewButton_clicked()
@@ -692,3 +694,13 @@
mGridWidget->setVisible( false );
}
}
+
+void QgsComposerMapWidget::on_mCoordinatePrecisionSpinBox_valueChanged( int value )
+{
+ if ( !mComposerMap )
+ {
+ return;
+ }
+ mComposerMap->setGridAnnotationPrecision( value );
+ mComposerMap->update();
+}
Modified: trunk/qgis/src/app/composer/qgscomposermapwidget.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposermapwidget.h 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/src/app/composer/qgscomposermapwidget.h 2009-10-26 15:10:04 UTC (rev 11849)
@@ -64,6 +64,7 @@
void on_mDrawAnnotationCheckBox_stateChanged( int state );
void on_mAnnotationDirectionComboBox_currentIndexChanged( const QString& text );
void on_mShowGridDialogCheckBox_stateChanged( int state );
+ void on_mCoordinatePrecisionSpinBox_valueChanged( int value );
/**Updates width and height without notify the composer map (to avoid infinite recursion)*/
void updateSettingsNoSignals();
Modified: trunk/qgis/src/core/composer/qgscomposermap.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.cpp 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/src/core/composer/qgscomposermap.cpp 2009-10-26 15:10:04 UTC (rev 11849)
@@ -43,7 +43,7 @@
QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height )
: QgsComposerItem( x, y, width, height, composition ), mKeepLayerSet( false ), mGridEnabled( false ), mGridStyle( Solid ), \
- mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mShowGridAnnotation( false ), \
+ mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), \
mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), \
mRotation( 0 ), mCrossLength( 3 )
{
@@ -75,7 +75,7 @@
QgsComposerMap::QgsComposerMap( QgsComposition *composition )
: QgsComposerItem( 0, 0, 10, 10, composition ), mKeepLayerSet( false ), mGridEnabled( false ), mGridStyle( Solid ), \
- mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mShowGridAnnotation( false ), \
+ mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), \
mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), \
mRotation( 0 ), mCrossLength( 3 )
{
@@ -619,6 +619,7 @@
annotationElem.setAttribute( "frameDistance", mAnnotationFrameDistance );
annotationElem.setAttribute( "direction", mGridAnnotationDirection );
annotationElem.setAttribute( "font", mGridAnnotationFont.toString() );
+ annotationElem.setAttribute( "precision", mGridAnnotationPrecision );
gridElem.appendChild( annotationElem );
composerMapElem.appendChild( gridElem );
@@ -723,6 +724,7 @@
mAnnotationFrameDistance = annotationElem.attribute( "frameDistance", "0" ).toDouble();
mGridAnnotationDirection = QgsComposerMap::GridAnnotationDirection( annotationElem.attribute( "direction", "0" ).toInt() );
mGridAnnotationFont.fromString( annotationElem.attribute( "font", "" ) );
+ mGridAnnotationPrecision = annotationElem.attribute( "precision", "3" ).toInt();
}
}
@@ -860,7 +862,7 @@
QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
for ( ; it != hLines.constEnd(); ++it )
{
- currentAnnotationString = QString::number( it->first );
+ currentAnnotationString = QString::number( it->first, 'f', mGridAnnotationPrecision );
drawCoordinateAnnotation( p, it->second.p1(), currentAnnotationString );
drawCoordinateAnnotation( p, it->second.p2(), currentAnnotationString );
}
@@ -868,7 +870,7 @@
it = vLines.constBegin();
for ( ; it != vLines.constEnd(); ++it )
{
- currentAnnotationString = QString::number( it->first );
+ currentAnnotationString = QString::number( it->first, 'f', mGridAnnotationPrecision );
drawCoordinateAnnotation( p, it->second.p1(), currentAnnotationString );
drawCoordinateAnnotation( p, it->second.p2(), currentAnnotationString );
}
Modified: trunk/qgis/src/core/composer/qgscomposermap.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.h 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/src/core/composer/qgscomposermap.h 2009-10-26 15:10:04 UTC (rev 11849)
@@ -161,52 +161,91 @@
*/
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+ /**Enables a coordinate grid that is shown on top of this composermap.
+ @note this function was added in version 1.4*/
void setGridEnabled( bool enabled ) {mGridEnabled = enabled;}
bool gridEnabled() const { return mGridEnabled; }
+ /**Sets coordinate grid style to solid or cross
+ @note this function was added in version 1.4*/
void setGridStyle( GridStyle style ) {mGridStyle = style;}
GridStyle gridStyle() const { return mGridStyle; }
+ /**Sets coordinate interval in x-direction for composergrid.
+ @note this function was added in version 1.4*/
void setGridIntervalX( double interval ) { mGridIntervalX = interval;}
double gridIntervalX() const { return mGridIntervalX; }
+ /**Sets coordinate interval in y-direction for composergrid.
+ @note this function was added in version 1.4*/
void setGridIntervalY( double interval ) { mGridIntervalY = interval;}
double gridIntervalY() const { return mGridIntervalY; }
+ /**Sets x-coordinate offset for composer grid
+ @note this function was added in version 1.4*/
void setGridOffsetX( double offset ) { mGridOffsetX = offset; }
double gridOffsetX() const { return mGridOffsetX; }
+ /**Sets y-coordinate offset for composer grid
+ @note this function was added in version 1.4*/
void setGridOffsetY( double offset ) { mGridOffsetY = offset; }
double gridOffsetY() const { return mGridOffsetY; }
+ /**Sets the pen to draw composer grid
+ @note this function was added in version 1.4*/
void setGridPen( const QPen& p ) { mGridPen = p; }
QPen gridPen() const { return mGridPen; }
+ /**Sets with of grid pen
+ @note this function was added in version 1.4*/
void setGridPenWidth( double w );
+ /**Sets the color of the grid pen
+ @note this function was added in version 1.4*/
void setGridPenColor( const QColor& c );
+ /**Sets font for grid annotations
+ @note this function was added in version 1.4*/
void setGridAnnotationFont( const QFont& f ) { mGridAnnotationFont = f; }
QFont gridAnnotationFont() const { return mGridAnnotationFont; }
+ /**Sets coordinate precision for grid annotations
+ @note this function was added in version 1.4*/
+ void setGridAnnotationPrecision( int p ) {mGridAnnotationPrecision = p;}
+ int gridAnnotationPrecision() const {return mGridAnnotationPrecision;}
+
+ /**Sets flag if grid annotation should be shown
+ @note this function was added in version 1.4*/
void setShowGridAnnotation( bool show ) {mShowGridAnnotation = show;}
bool showGridAnnotation() const {return mShowGridAnnotation;}
+ /**Sets position of grid annotations. Possibilities are inside or outside of the map frame
+ @note this function was added in version 1.4*/
void setGridAnnotationPosition( GridAnnotationPosition p ) {mGridAnnotationPosition = p;}
GridAnnotationPosition gridAnnotationPosition() const {return mGridAnnotationPosition;}
+ /**Sets distance between map frame and annotations
+ @note this function was added in version 1.4*/
void setAnnotationFrameDistance( double d ) {mAnnotationFrameDistance = d;}
double annotationFrameDistance() const {return mAnnotationFrameDistance;}
+ /**Sets grid annotation direction. Can be horizontal, vertical, direction of axis and horizontal and vertical
+ @note this function was added in version 1.4*/
void setGridAnnotationDirection( GridAnnotationDirection d ) {mGridAnnotationDirection = d;}
GridAnnotationDirection gridAnnotationDirection() const {return mGridAnnotationDirection;}
- /**In case of annotations, the bounding rectangle can be larger than the map item rectangle*/
+ /**In case of annotations, the bounding rectangle can be larger than the map item rectangle
+ @note this function was added in version 1.4*/
QRectF boundingRect() const;
- /**Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle*/
+ /**Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle
+ @note this function was added in version 1.4*/
void updateBoundingRect();
+ /**Sets the rotation of the map content
+ @note this function was added in version 1.4*/
void setRotation( double r ) { mRotation = r; }
double rotation() const { return mRotation; }
+ /**Sets length of the cros segments (if grid style is cross)
+ @note this function was added in version 1.4*/
void setCrossLength( double l ) {mCrossLength = l;}
double crossLength() {return mCrossLength;}
@@ -295,6 +334,8 @@
QPen mGridPen;
/**Font for grid line annotation*/
QFont mGridAnnotationFont;
+ /**Digits after the dot*/
+ int mGridAnnotationPrecision;
/**True if coordinate values should be drawn*/
bool mShowGridAnnotation;
/**Annotation position inside or outside of map frame*/
Modified: trunk/qgis/src/ui/qgscomposermapwidgetbase.ui
===================================================================
--- trunk/qgis/src/ui/qgscomposermapwidgetbase.ui 2009-10-26 14:00:06 UTC (rev 11848)
+++ trunk/qgis/src/ui/qgscomposermapwidgetbase.ui 2009-10-26 15:10:04 UTC (rev 11849)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>482</width>
- <height>641</height>
+ <height>677</height>
</rect>
</property>
<property name="sizePolicy">
@@ -412,6 +412,16 @@
</property>
</widget>
</item>
+ <item row="8" column="0" colspan="2">
+ <widget class="QLabel" name="mCoordinatePrecisionLabel">
+ <property name="text">
+ <string>Coordinate precision</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2">
+ <widget class="QSpinBox" name="mCoordinatePrecisionSpinBox"/>
+ </item>
</layout>
</widget>
</item>
More information about the QGIS-commit
mailing list