Skip to content

Commit

Permalink
Set correct frame style in composermap widget, update python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 4, 2012
1 parent 4b3e817 commit 9d3b505
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/core/qgscomposermap.sip
Expand Up @@ -57,6 +57,12 @@ class QgsComposerMap : QgsComposerItem
Top
};

enum GridFrameStyle
{
NoGridFrame = 0,
Zebra //black / white pattern
};

/**@deprecated*/
void draw( QPainter *painter, const QgsRectangle& extent, const QSize& size, int dpi );

Expand Down Expand Up @@ -222,6 +228,16 @@ class QgsComposerMap : QgsComposerItem
/**@note: this function was added in version 1.9*/
GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const;

/**Set grid frame style (NoGridFrame or Zebra)
@note: this function was added in version 1.9*/
void setGridFrameStyle( GridFrameStyle style );
GridFrameStyle gridFrameStyle() const;

/**Set grid frame width
@note: this function was added in version 1.9*/
void setGridFrameWidth( double w );
double gridFrameWidth() const;

/**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;
Expand Down
12 changes: 12 additions & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -349,6 +349,18 @@ void QgsComposerMapWidget::updateGuiElements()

mCrossWidthSpinBox->setValue( mComposerMap->crossLength() );

//grid frame
mFrameWidthSpinBox->setValue( mComposerMap->gridFrameWidth() );
QgsComposerMap::GridFrameStyle gridFrameStyle = mComposerMap->gridFrameStyle();
if ( gridFrameStyle == QgsComposerMap::Zebra )
{
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "Zebra" ) ) );
}
else //NoGridFrame
{
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
}

//grid annotation position
initAnnotationPositionBox( mAnnotationPositionLeftComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Left ) );
initAnnotationPositionBox( mAnnotationPositionRightComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Right ) );
Expand Down
4 changes: 4 additions & 0 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -692,6 +692,8 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
gridElem.setAttribute( "penColorGreen", mGridPen.color().green() );
gridElem.setAttribute( "penColorBlue", mGridPen.color().blue() );
gridElem.setAttribute( "crossLength", QString::number( mCrossLength ) );
gridElem.setAttribute( "gridFrameStyle", mGridFrameStyle );
gridElem.setAttribute( "gridFrameWidth", QString::number( mGridFrameWidth ) );

//grid annotation
QDomElement annotationElem = doc.createElement( "Annotation" );
Expand Down Expand Up @@ -813,6 +815,8 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d
gridElem.attribute( "penColorGreen", "0" ).toInt(),
gridElem.attribute( "penColorBlue", "0" ).toInt() ) );
mCrossLength = gridElem.attribute( "crossLength", "3" ).toDouble();
mGridFrameStyle = ( QgsComposerMap::GridFrameStyle )gridElem.attribute( "gridFrameStyle", "0" ).toInt();
mGridFrameWidth = gridElem.attribute( "gridFrameWidth", "2.0" ).toDouble();

QDomNodeList annotationNodeList = gridElem.elementsByTagName( "Annotation" );
if ( annotationNodeList.size() > 0 )
Expand Down

0 comments on commit 9d3b505

Please sign in to comment.