[FEATURE][composer] Add tick styles for frames. Options include
drawing ticks only inside the map frame, drawing ticks outside the frame, or drawing ticks both inside and outside the frame. (fix #6954) (Sponsored by NIWA, New Zealand)
@ -102,7 +102,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsCo
|
||||
mGridFrameFill2ColorButton->setShowNoColor( true );
|
||||
|
||||
//set initial state of frame style controls
|
||||
toggleFrameControls( false );
|
||||
toggleFrameControls( false, false );
|
||||
|
||||
if ( composerMap )
|
||||
{
|
||||
@ -695,17 +695,17 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
|
||||
blockOverviewItemsSignals( b );
|
||||
}
|
||||
|
||||
void QgsComposerMapWidget::toggleFrameControls( bool frameEnabled )
|
||||
void QgsComposerMapWidget::toggleFrameControls( bool frameEnabled, bool frameFillEnabled )
|
||||
{
|
||||
//set status of frame controls
|
||||
mFrameWidthSpinBox->setEnabled( frameEnabled );
|
||||
mGridFramePenSizeSpinBox->setEnabled( frameEnabled );
|
||||
mGridFramePenColorButton->setEnabled( frameEnabled );
|
||||
mGridFrameFill1ColorButton->setEnabled( frameEnabled );
|
||||
mGridFrameFill2ColorButton->setEnabled( frameEnabled );
|
||||
mGridFrameFill1ColorButton->setEnabled( frameFillEnabled );
|
||||
mGridFrameFill2ColorButton->setEnabled( frameFillEnabled );
|
||||
mFrameWidthLabel->setEnabled( frameEnabled );
|
||||
mFramePenLabel->setEnabled( frameEnabled );
|
||||
mFrameFillLabel->setEnabled( frameEnabled );
|
||||
mFrameFillLabel->setEnabled( frameFillEnabled );
|
||||
mCheckGridLeftSide->setEnabled( frameEnabled );
|
||||
mCheckGridRightSide->setEnabled( frameEnabled );
|
||||
mCheckGridTopSide->setEnabled( frameEnabled );
|
||||
@ -1209,15 +1209,28 @@ void QgsComposerMapWidget::setGridItems( const QgsComposerMapGrid* grid )
|
||||
//grid frame
|
||||
mFrameWidthSpinBox->setValue( grid->gridFrameWidth() );
|
||||
QgsComposerMap::GridFrameStyle gridFrameStyle = grid->gridFrameStyle();
|
||||
if ( gridFrameStyle == QgsComposerMap::Zebra )
|
||||
switch ( gridFrameStyle )
|
||||
{
|
||||
mFrameStyleComboBox->setCurrentIndex( 1 );
|
||||
toggleFrameControls( true );
|
||||
}
|
||||
else //NoGridFrame
|
||||
{
|
||||
mFrameStyleComboBox->setCurrentIndex( 0 );
|
||||
toggleFrameControls( false );
|
||||
case QgsComposerMap::Zebra:
|
||||
mFrameStyleComboBox->setCurrentIndex( 1 );
|
||||
toggleFrameControls( true, true );
|
||||
break;
|
||||
case QgsComposerMap::InteriorTicks:
|
||||
mFrameStyleComboBox->setCurrentIndex( 2 );
|
||||
toggleFrameControls( true, false );
|
||||
break;
|
||||
case QgsComposerMap::ExteriorTicks:
|
||||
mFrameStyleComboBox->setCurrentIndex( 3 );
|
||||
toggleFrameControls( true, false );
|
||||
break;
|
||||
case QgsComposerMap::InteriorExteriorTicks:
|
||||
mFrameStyleComboBox->setCurrentIndex( 4 );
|
||||
toggleFrameControls( true, false );
|
||||
break;
|
||||
default:
|
||||
mFrameStyleComboBox->setCurrentIndex( 0 );
|
||||
toggleFrameControls( false, false );
|
||||
break;
|
||||
}
|
||||
|
||||
mCheckGridLeftSide->setChecked( grid->testGridFrameSideFlag( QgsComposerMapGrid::FrameLeft ) );
|
||||
@ -1557,12 +1570,27 @@ void QgsComposerMapWidget::on_mFrameStyleComboBox_currentIndexChanged( const QSt
|
||||
if ( text == tr( "Zebra" ) )
|
||||
{
|
||||
grid->setGridFrameStyle( QgsComposerMap::Zebra );
|
||||
toggleFrameControls( true );
|
||||
toggleFrameControls( true, true );
|
||||
}
|
||||
else if ( text == tr( "Interior ticks" ) )
|
||||
{
|
||||
grid->setGridFrameStyle( QgsComposerMap::InteriorTicks );
|
||||
toggleFrameControls( true, false );
|
||||
}
|
||||
else if ( text == tr( "Exterior ticks" ) )
|
||||
{
|
||||
grid->setGridFrameStyle( QgsComposerMap::ExteriorTicks );
|
||||
toggleFrameControls( true, false );
|
||||
}
|
||||
else if ( text == tr( "Interior and exterior ticks" ) )
|
||||
{
|
||||
grid->setGridFrameStyle( QgsComposerMap::InteriorExteriorTicks );
|
||||
toggleFrameControls( true, false );
|
||||
}
|
||||
else //no frame
|
||||
{
|
||||
grid->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
toggleFrameControls( false );
|
||||
toggleFrameControls( false, false );
|
||||
}
|
||||
mComposerMap->updateBoundingRect();
|
||||
mComposerMap->update();
|
||||
|
@ -179,7 +179,7 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
|
||||
void refreshMapComboBox();
|
||||
|
||||
/**Enables/disables grid frame related controls*/
|
||||
void toggleFrameControls( bool frameEnabled );
|
||||
void toggleFrameControls( bool frameEnabled , bool frameFillEnabled );
|
||||
|
||||
/**Enables or disables the atlas margin and predefined scales radio depending on the atlas coverage layer type*/
|
||||
void toggleAtlasScalingOptionsByLayerType();
|
||||
|
@ -96,7 +96,10 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
|
||||
enum GridFrameStyle
|
||||
{
|
||||
NoGridFrame = 0,
|
||||
Zebra // black/white pattern
|
||||
Zebra, // black/white pattern
|
||||
InteriorTicks,
|
||||
ExteriorTicks,
|
||||
InteriorExteriorTicks
|
||||
};
|
||||
|
||||
/**Enum for different frame borders*/
|
||||
|
@ -451,13 +451,6 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
|
||||
QPointF intersectionPoint, crossEnd1, crossEnd2;
|
||||
for ( ; vIt != verticalLines.constEnd(); ++vIt )
|
||||
{
|
||||
//start mark
|
||||
if ( mGridStyle == QgsComposerMap::Cross )
|
||||
{
|
||||
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( vIt->second.p1(), vIt->second.p2(), mCrossLength );
|
||||
drawGridLine( QLineF( vIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
|
||||
}
|
||||
|
||||
//test for intersection with every horizontal line
|
||||
hIt = horizontalLines.constBegin();
|
||||
for ( ; hIt != horizontalLines.constEnd(); ++hIt )
|
||||
@ -480,12 +473,6 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
|
||||
}
|
||||
}
|
||||
}
|
||||
//end mark
|
||||
if ( mGridStyle == QgsComposerMap::Cross )
|
||||
{
|
||||
QPointF crossEnd2 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( vIt->second.p2(), vIt->second.p1(), mCrossLength );
|
||||
drawGridLine( QLineF( vIt->second.p2() * dotsPerMM, crossEnd2 * dotsPerMM ), context );
|
||||
}
|
||||
}
|
||||
if ( mGridStyle == QgsComposerMap::Markers )
|
||||
{
|
||||
@ -497,10 +484,6 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
|
||||
hIt = horizontalLines.constBegin();
|
||||
for ( ; hIt != horizontalLines.constEnd(); ++hIt )
|
||||
{
|
||||
//start mark
|
||||
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( hIt->second.p1(), hIt->second.p2(), mCrossLength );
|
||||
drawGridLine( QLineF( hIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
|
||||
|
||||
vIt = verticalLines.constBegin();
|
||||
for ( ; vIt != verticalLines.constEnd(); ++vIt )
|
||||
{
|
||||
@ -515,9 +498,6 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
|
||||
drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
|
||||
}
|
||||
}
|
||||
//end mark
|
||||
crossEnd1 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( hIt->second.p2(), hIt->second.p1(), mCrossLength );
|
||||
drawGridLine( QLineF( hIt->second.p2() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -592,6 +572,30 @@ void QgsComposerMapGrid::drawGridFrameBorder( QPainter* p, const QMap< double, d
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( mGridFrameStyle )
|
||||
{
|
||||
case QgsComposerMap::Zebra:
|
||||
drawGridFrameZebraBorder( p, borderPos, border );
|
||||
break;
|
||||
case QgsComposerMap::InteriorTicks:
|
||||
case QgsComposerMap::ExteriorTicks:
|
||||
case QgsComposerMap::InteriorExteriorTicks:
|
||||
drawGridFrameTicks( p, borderPos, border );
|
||||
break;
|
||||
|
||||
case QgsComposerMap::NoGridFrame:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgsComposerMapGrid::drawGridFrameZebraBorder( QPainter* p, const QMap< double, double >& borderPos, QgsComposerMap::Border border ) const
|
||||
{
|
||||
if ( !mComposerMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMap< double, double > pos = borderPos;
|
||||
|
||||
double currentCoord = 0;
|
||||
@ -658,6 +662,72 @@ void QgsComposerMapGrid::drawGridFrameBorder( QPainter* p, const QMap< double, d
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerMapGrid::drawGridFrameTicks( QPainter* p, const QMap< double, double >& borderPos, QgsComposerMap::Border border ) const
|
||||
{
|
||||
if ( !mComposerMap )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double width = 0;
|
||||
double height = 0;
|
||||
|
||||
//set pen to current frame pen
|
||||
QPen framePen = QPen( mGridFramePenColor );
|
||||
framePen.setWidthF( mGridFramePenThickness );
|
||||
framePen.setCapStyle( Qt::FlatCap );
|
||||
p->setBrush( Qt::NoBrush );
|
||||
p->setPen( framePen );
|
||||
|
||||
QMap< double, double >::const_iterator posIt = borderPos.constBegin();
|
||||
for ( ; posIt != borderPos.constEnd(); ++posIt )
|
||||
{
|
||||
if ( border == QgsComposerMap::Left || border == QgsComposerMap::Right )
|
||||
{
|
||||
y = posIt.key();
|
||||
height = 0;
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
width = mGridFrameWidth;
|
||||
x = ( border == QgsComposerMap::Left ) ? 0 : mComposerMap->rect().width() - mGridFrameWidth;
|
||||
}
|
||||
else if ( mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
width = mGridFrameWidth;
|
||||
x = ( border == QgsComposerMap::Left ) ? - mGridFrameWidth : mComposerMap->rect().width();
|
||||
}
|
||||
else if ( mGridFrameStyle == QgsComposerMap::InteriorExteriorTicks )
|
||||
{
|
||||
width = mGridFrameWidth * 2;
|
||||
x = ( border == QgsComposerMap::Left ) ? - mGridFrameWidth : mComposerMap->rect().width() - mGridFrameWidth;
|
||||
}
|
||||
}
|
||||
else //top or bottom
|
||||
{
|
||||
x = posIt.key();
|
||||
width = 0;
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
height = mGridFrameWidth;
|
||||
y = ( border == QgsComposerMap::Top ) ? 0 : mComposerMap->rect().height() - mGridFrameWidth;
|
||||
}
|
||||
else if ( mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
height = mGridFrameWidth;
|
||||
y = ( border == QgsComposerMap::Top ) ? -mGridFrameWidth : mComposerMap->rect().height();
|
||||
}
|
||||
else if ( mGridFrameStyle == QgsComposerMap::InteriorExteriorTicks )
|
||||
{
|
||||
height = mGridFrameWidth * 2;
|
||||
y = ( border == QgsComposerMap::Top ) ? -mGridFrameWidth : mComposerMap->rect().height() - mGridFrameWidth;
|
||||
}
|
||||
}
|
||||
p->drawLine( QLineF( x, y, x + width, y + height ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerMapGrid::drawCoordinateAnnotations( QPainter* p, const QList< QPair< double, QLineF > >& hLines, const QList< QPair< double, QLineF > >& vLines ) const
|
||||
{
|
||||
if ( !p )
|
||||
@ -665,7 +735,6 @@ void QgsComposerMapGrid::drawCoordinateAnnotations( QPainter* p, const QList< QP
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QString currentAnnotationString;
|
||||
QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
|
||||
for ( ; it != hLines.constEnd(); ++it )
|
||||
@ -698,7 +767,15 @@ void QgsComposerMapGrid::drawCoordinateAnnotation( QPainter* p, const QPointF& p
|
||||
double ypos = pos.y();
|
||||
int rotation = 0;
|
||||
|
||||
double gridFrameDistance = ( mGridFrameStyle == QgsComposerMap::NoGridFrame ) ? 0 : mGridFrameWidth + ( mGridFramePenThickness / 2.0 );
|
||||
double gridFrameDistance = 0;
|
||||
if ( mGridFrameStyle != QgsComposerMap::NoGridFrame )
|
||||
{
|
||||
gridFrameDistance = mGridFrameWidth;
|
||||
}
|
||||
if ( mGridFrameStyle == QgsComposerMap::Zebra )
|
||||
{
|
||||
gridFrameDistance += ( mGridFramePenThickness / 2.0 );
|
||||
}
|
||||
|
||||
if ( frameBorder == QgsComposerMap::Left )
|
||||
{
|
||||
@ -709,20 +786,28 @@ void QgsComposerMapGrid::drawCoordinateAnnotation( QPainter* p, const QPointF& p
|
||||
|
||||
if ( mLeftGridAnnotationPosition == QgsComposerMap::InsideMapFrame )
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::Zebra || mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mLeftGridAnnotationDirection == QgsComposerMap::Vertical || mLeftGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos += textHeight + mAnnotationFrameDistance;
|
||||
xpos += textHeight + mAnnotationFrameDistance + gridFrameDistance;
|
||||
ypos += textWidth / 2.0;
|
||||
rotation = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpos += mAnnotationFrameDistance;
|
||||
xpos += mAnnotationFrameDistance + gridFrameDistance;
|
||||
ypos += textHeight / 2.0;
|
||||
}
|
||||
}
|
||||
else if ( mLeftGridAnnotationPosition == QgsComposerMap::OutsideMapFrame ) //Outside map frame
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mLeftGridAnnotationDirection == QgsComposerMap::Vertical || mLeftGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos -= ( mAnnotationFrameDistance + gridFrameDistance );
|
||||
@ -750,20 +835,28 @@ void QgsComposerMapGrid::drawCoordinateAnnotation( QPainter* p, const QPointF& p
|
||||
|
||||
if ( mRightGridAnnotationPosition == QgsComposerMap::InsideMapFrame )
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::Zebra || mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mRightGridAnnotationDirection == QgsComposerMap::Vertical || mRightGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos -= mAnnotationFrameDistance;
|
||||
xpos -= mAnnotationFrameDistance + gridFrameDistance;
|
||||
ypos += textWidth / 2.0;
|
||||
rotation = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpos -= textWidth + mAnnotationFrameDistance;
|
||||
xpos -= textWidth + mAnnotationFrameDistance + gridFrameDistance;
|
||||
ypos += textHeight / 2.0;
|
||||
}
|
||||
}
|
||||
else if ( mRightGridAnnotationPosition == QgsComposerMap::OutsideMapFrame )//OutsideMapFrame
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mRightGridAnnotationDirection == QgsComposerMap::Vertical || mRightGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos += ( textHeight + mAnnotationFrameDistance + gridFrameDistance );
|
||||
@ -790,20 +883,28 @@ void QgsComposerMapGrid::drawCoordinateAnnotation( QPainter* p, const QPointF& p
|
||||
|
||||
if ( mBottomGridAnnotationPosition == QgsComposerMap::InsideMapFrame )
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::Zebra || mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mBottomGridAnnotationDirection == QgsComposerMap::Horizontal || mBottomGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
ypos -= mAnnotationFrameDistance;
|
||||
ypos -= mAnnotationFrameDistance + gridFrameDistance;
|
||||
xpos -= textWidth / 2.0;
|
||||
}
|
||||
else //Vertical
|
||||
{
|
||||
xpos += textHeight / 2.0;
|
||||
ypos -= mAnnotationFrameDistance;
|
||||
ypos -= mAnnotationFrameDistance + gridFrameDistance;
|
||||
rotation = 270;
|
||||
}
|
||||
}
|
||||
else if ( mBottomGridAnnotationPosition == QgsComposerMap::OutsideMapFrame ) //OutsideMapFrame
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mBottomGridAnnotationDirection == QgsComposerMap::Horizontal || mBottomGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
ypos += ( mAnnotationFrameDistance + textHeight + gridFrameDistance );
|
||||
@ -830,20 +931,28 @@ void QgsComposerMapGrid::drawCoordinateAnnotation( QPainter* p, const QPointF& p
|
||||
|
||||
if ( mTopGridAnnotationPosition == QgsComposerMap::InsideMapFrame )
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::Zebra || mGridFrameStyle == QgsComposerMap::ExteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mTopGridAnnotationDirection == QgsComposerMap::Horizontal || mTopGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos -= textWidth / 2.0;
|
||||
ypos += textHeight + mAnnotationFrameDistance;
|
||||
ypos += textHeight + mAnnotationFrameDistance + gridFrameDistance;
|
||||
}
|
||||
else //Vertical
|
||||
{
|
||||
xpos += textHeight / 2.0;
|
||||
ypos += textWidth + mAnnotationFrameDistance;
|
||||
ypos += textWidth + mAnnotationFrameDistance + gridFrameDistance;
|
||||
rotation = 270;
|
||||
}
|
||||
}
|
||||
else if ( mTopGridAnnotationPosition == QgsComposerMap::OutsideMapFrame ) //OutsideMapFrame
|
||||
{
|
||||
if ( mGridFrameStyle == QgsComposerMap::InteriorTicks )
|
||||
{
|
||||
gridFrameDistance = 0;
|
||||
}
|
||||
if ( mTopGridAnnotationDirection == QgsComposerMap::Horizontal || mTopGridAnnotationDirection == QgsComposerMap::BoundaryDirection )
|
||||
{
|
||||
xpos -= textWidth / 2.0;
|
||||
|
@ -332,6 +332,8 @@ class CORE_EXPORT QgsComposerMapGrid
|
||||
void createDefaultGridLineSymbol();
|
||||
void createDefaultGridMarkerSymbol();
|
||||
void drawGridMarker( const QPointF &point, QgsRenderContext &context ) const;
|
||||
void drawGridFrameZebraBorder( QPainter *p, const QMap<double, double> &borderPos, QgsComposerMap::Border border ) const;
|
||||
void drawGridFrameTicks( QPainter *p, const QMap<double, double> &borderPos, QgsComposerMap::Border border ) const;
|
||||
};
|
||||
|
||||
#endif // QGSCOMPOSERMAPGRID_H
|
||||
|
@ -54,7 +54,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-1047</y>
|
||||
<y>-571</y>
|
||||
<width>444</width>
|
||||
<height>2231</height>
|
||||
</rect>
|
||||
@ -822,6 +822,21 @@
|
||||
<string>Zebra</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Interior ticks</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Exterior ticks</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Interior and exterior ticks</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
|
@ -40,6 +40,12 @@ class TestQgsComposerMapGrid: public QObject
|
||||
void frameOnly(); //test if grid "frame/annotation" mode works
|
||||
void zebraStyle(); //test zebra map border style
|
||||
void zebraStyleSides(); //test zebra border on certain sides
|
||||
void interiorTicks(); //test interior tick mode
|
||||
void interiorTicksAnnotated(); //test interior tick mode with annotations
|
||||
void exteriorTicks(); //test exterior tick mode
|
||||
void exteriorTicksAnnotated(); //test exterior tick mode with annotations
|
||||
void interiorExteriorTicks(); //test interior & exterior tick mode
|
||||
void interiorExteriorTicksAnnotated(); //test interior & exterior tick mode with annotations
|
||||
|
||||
private:
|
||||
QgsComposition* mComposition;
|
||||
@ -234,7 +240,166 @@ void TestQgsComposerMapGrid::zebraStyleSides()
|
||||
|
||||
mComposerMap->mapGrids()[0]->setGridFrameSideFlag( QgsComposerMapGrid::FrameBottom, true );
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::interiorTicks()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::InteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_interiorticks", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::interiorTicksAnnotated()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::InteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
mComposerMap->setShowGridAnnotation( true );
|
||||
mComposerMap->setAnnotationFontColor( Qt::black );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_interiorticks_annotated", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker2( "composermap_interiorticks_annotated2", mComposition );
|
||||
bool testResult2 = checker2.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult2 );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
mComposerMap->setShowGridAnnotation( false );
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::exteriorTicks()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::ExteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_exteriorticks", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::exteriorTicksAnnotated()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::ExteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
mComposerMap->setShowGridAnnotation( true );
|
||||
mComposerMap->setAnnotationFontColor( Qt::black );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_exteriorticks_annotated", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker2( "composermap_exteriorticks_annotated2", mComposition );
|
||||
bool testResult2 = checker2.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult2 );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
mComposerMap->setShowGridAnnotation( false );
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::interiorExteriorTicks()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::InteriorExteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_interiorexteriorticks", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
}
|
||||
|
||||
void TestQgsComposerMapGrid::interiorExteriorTicksAnnotated()
|
||||
{
|
||||
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::InteriorExteriorTicks );
|
||||
mComposerMap->setGridFrameWidth( 10 );
|
||||
mComposerMap->setGridFramePenSize( 1 );
|
||||
mComposerMap->setGridFramePenColor( Qt::black );
|
||||
mComposerMap->setGridEnabled( true );
|
||||
mComposerMap->setGridStyle( QgsComposerMap::FrameAnnotationsOnly );
|
||||
mComposerMap->setShowGridAnnotation( true );
|
||||
mComposerMap->setAnnotationFontColor( Qt::black );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::InsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker( "composermap_interiorexteriorticks_annotated", mComposition );
|
||||
bool testResult = checker.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult );
|
||||
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Left );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Right );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Top );
|
||||
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Bottom );
|
||||
|
||||
QgsCompositionChecker checker2( "composermap_interiorexteriorticks_annotated2", mComposition );
|
||||
bool testResult2 = checker2.testComposition( mReport, 0, 100 );
|
||||
QVERIFY( testResult2 );
|
||||
|
||||
mComposerMap->setGridFrameStyle( QgsComposerMap::NoGridFrame );
|
||||
mComposerMap->setShowGridAnnotation( false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QTEST_MAIN( TestQgsComposerMapGrid )
|
||||
#include "moc_testqgscomposermapgrid.cxx"
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 101 KiB |