Skip to content
Permalink
Browse files

Follow up grid merge fixes. Repair broken grid tick tests

  • Loading branch information
nyalldawson committed Jul 11, 2014
1 parent 644d6fc commit 494bef0c50ea7624b8521f97996bce25235bfa74
@@ -60,9 +60,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
{
mComposition = composition;
mOverviewFrameMapSymbol = 0;
mGridLineSymbol = 0;
createDefaultOverviewFrameSymbol();
createDefaultGridLineSymbol();

mId = 0;
assignFreeId();
@@ -108,7 +106,6 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition )
, mAtlasMargin( 0.10 )
{
mOverviewFrameMapSymbol = 0;
mGridLineSymbol = 0;
createDefaultOverviewFrameSymbol();

//Offset
@@ -164,7 +161,6 @@ void QgsComposerMap::adjustExtentToItemShape( double itemWidth, double itemHeigh
QgsComposerMap::~QgsComposerMap()
{
delete mOverviewFrameMapSymbol;
delete mGridLineSymbol;
removeGrids();
}

@@ -2381,16 +2377,6 @@ void QgsComposerMap::createDefaultOverviewFrameSymbol()
mOverviewFrameMapSymbol->setAlpha( 0.3 );
}

void QgsComposerMap::createDefaultGridLineSymbol()
{
delete mGridLineSymbol;
QgsStringMap properties;
properties.insert( "color", "0,0,0,255" );
properties.insert( "width", "0.3" );
properties.insert( "capstyle", "flat" );
mGridLineSymbol = QgsLineSymbolV2::createSimple( properties );
}

/*void QgsComposerMap::initGridAnnotationFormatFromProject()
{
QString format = QgsProject::instance()->readEntry( "PositionPrecision", "/DegreeFormat", "D" );
@@ -625,7 +625,7 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
int mOverviewFrameMapId;
/**Drawing style for overview farme*/
QgsFillSymbolV2* mOverviewFrameMapSymbol;
QgsLineSymbolV2* mGridLineSymbol;

/**Blend mode for overview*/
QPainter::CompositionMode mOverviewBlendMode;
bool mOverviewInverted;
@@ -698,7 +698,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
QPointF composerMapPosForItem( const QGraphicsItem* item ) const;
void drawOverviewMapExtent( QPainter* p );
void createDefaultOverviewFrameSymbol();
void createDefaultGridLineSymbol();
//void initGridAnnotationFormatFromProject();

enum PartType
@@ -62,16 +62,15 @@ QgsComposerMapGrid::QgsComposerMapGrid( const QString& name, QgsComposerMap* map
mGridUnit( MapUnit ),
mBlendMode( QPainter::CompositionMode_SourceOver )
{
//debug
mGridLineSymbol = QgsLineSymbolV2::createSimple( QgsStringMap() );

//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mGridAnnotationFont.setFamily( defaultFontString );
}

createDefaultGridLineSymbol();
}

QgsComposerMapGrid::QgsComposerMapGrid(): mComposerMap( 0 )
@@ -83,6 +82,16 @@ QgsComposerMapGrid::~QgsComposerMapGrid()
delete mGridLineSymbol;
}

void QgsComposerMapGrid::createDefaultGridLineSymbol()
{
delete mGridLineSymbol;
QgsStringMap properties;
properties.insert( "color", "0,0,0,255" );
properties.insert( "width", "0.3" );
properties.insert( "capstyle", "flat" );
mGridLineSymbol = QgsLineSymbolV2::createSimple( properties );
}

void QgsComposerMapGrid::setComposerMap( QgsComposerMap* map )
{
mComposerMap = map;
@@ -390,6 +399,10 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
QPointF intersectionPoint, crossEnd1, crossEnd2;
for ( ; vIt != verticalLines.constEnd(); ++vIt )
{
//start mark
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 )
@@ -405,11 +418,18 @@ void QgsComposerMapGrid::drawGridNoTransform( QgsRenderContext &context, double
drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
}
}
//end mark
QPointF crossEnd2 = QgsSymbolLayerV2Utils::pointOnLineWithDistance( vIt->second.p2(), vIt->second.p1(), mCrossLength );
drawGridLine( QLineF( vIt->second.p2() * dotsPerMM, crossEnd2 * dotsPerMM ), context );
}

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 )
{
@@ -424,6 +444,9 @@ 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 );
}
}
}
@@ -307,6 +307,7 @@ class CORE_EXPORT QgsComposerMapGrid
QList< QPair< double, QLineF > > &verticalLines ) const;

void drawGridNoTransform( QgsRenderContext &context, double dotsPerMM, QList<QPair<double, QLineF> > &horizontalLines, QList<QPair<double, QLineF> > &verticalLines ) const;
void createDefaultGridLineSymbol();
};

#endif // QGSCOMPOSERMAPGRID_H

0 comments on commit 494bef0

Please sign in to comment.
You can’t perform that action at this time.