Skip to content

Commit

Permalink
Follow up grid merge fixes. Repair broken grid tick tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 11, 2014
1 parent 644d6fc commit 494bef0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
14 changes: 0 additions & 14 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -108,7 +106,6 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition )
, mAtlasMargin( 0.10 )
{
mOverviewFrameMapSymbol = 0;
mGridLineSymbol = 0;
createDefaultOverviewFrameSymbol();

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

Expand Down Expand Up @@ -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" );
Expand Down
3 changes: 1 addition & 2 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions src/core/composer/qgscomposermapgrid.cpp
Expand Up @@ -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 )
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
{
Expand All @@ -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 );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermapgrid.h
Expand Up @@ -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.