Skip to content
Permalink
Browse files

[FEATURE][composer] Add marker style for map grids (fix #9381)

  • Loading branch information
nyalldawson committed Jul 13, 2014
1 parent a44e48c commit 8650597b7f96e522a4a3a5c115a248a26fb9af97
@@ -61,6 +61,7 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsCo

mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );
mGridTypeComboBox->insertItem( 2, tr( "Markers" ) );

mAnnotationFormatComboBox->insertItem( 0, tr( "Decimal" ) );
mAnnotationFormatComboBox->insertItem( 1, tr( "DegreeMinute" ) );
@@ -1006,15 +1007,6 @@ void QgsComposerMapWidget::updateOverviewSymbolMarker()
}
}

void QgsComposerMapWidget::updateLineSymbolMarker()
{
if ( mComposerMap )
{
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mComposerMap->gridLineSymbol(), mGridLineStyleButton->iconSize() );
mGridLineStyleButton->setIcon( icon );
}
}

void QgsComposerMapWidget::refreshMapComboBox()
{
if ( !mComposerMap )
@@ -1287,17 +1279,35 @@ void QgsComposerMapWidget::setGridItems( const QgsComposerMapGrid* grid )
mGridFrameFill2ColorButton->setColor( grid->gridFrameFillColor2() );

QgsComposerMap::GridStyle gridStyle = grid->gridStyle();
if ( gridStyle == QgsComposerMap::Cross )
{
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Cross" ) ) );
mCrossWidthSpinBox->setEnabled( true );
mCrossWidthLabel->setEnabled( true );
}
else
{
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Solid" ) ) );
mCrossWidthSpinBox->setEnabled( false );
mCrossWidthLabel->setEnabled( false );
switch ( gridStyle )
{
case QgsComposerMap::Cross:
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Cross" ) ) );
mCrossWidthSpinBox->setVisible( true );
mCrossWidthLabel->setVisible( true );
mGridLineStyleButton->setVisible( true );
mLineStyleLabel->setVisible( true );
mGridMarkerStyleButton->setVisible( false );
mMarkerStyleLabel->setVisible( false );
break;
case QgsComposerMap::Markers:
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Markers" ) ) );
mCrossWidthSpinBox->setVisible( false );
mCrossWidthLabel->setVisible( false );
mGridLineStyleButton->setVisible( false );
mLineStyleLabel->setVisible( false );
mGridMarkerStyleButton->setVisible( true );
mMarkerStyleLabel->setVisible( true );
break;
case QgsComposerMap::Solid:
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Solid" ) ) );
mCrossWidthSpinBox->setVisible( false );
mCrossWidthLabel->setVisible( false );
mGridLineStyleButton->setVisible( true );
mLineStyleLabel->setVisible( true );
mGridMarkerStyleButton->setVisible( false );
mMarkerStyleLabel->setVisible( false );
break;
}

//grid frame
@@ -1315,7 +1325,9 @@ void QgsComposerMapWidget::setGridItems( const QgsComposerMapGrid* grid )
}

//line style
updateLineSymbolMarker( grid );
updateGridLineSymbolMarker( grid );
//marker style
updateGridMarkerSymbolMarker( grid );

mGridBlendComboBox->setBlendMode( grid->blendMode() );

@@ -1361,7 +1373,7 @@ void QgsComposerMapWidget::setGridItems( const QgsComposerMapGrid* grid )
blockGridItemsSignals( false );
}

void QgsComposerMapWidget::updateLineSymbolMarker( const QgsComposerMapGrid* grid )
void QgsComposerMapWidget::updateGridLineSymbolMarker( const QgsComposerMapGrid* grid )
{
if ( grid )
{
@@ -1371,6 +1383,16 @@ void QgsComposerMapWidget::updateLineSymbolMarker( const QgsComposerMapGrid* gri
}
}

void QgsComposerMapWidget::updateGridMarkerSymbolMarker( const QgsComposerMapGrid *grid )
{
if ( grid )
{
QgsMarkerSymbolV2* nonConstSymbol = const_cast<QgsMarkerSymbolV2*>( grid->gridMarkerSymbol() ); //bad
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( nonConstSymbol, mGridMarkerStyleButton->iconSize() );
mGridMarkerStyleButton->setIcon( icon );
}
}

void QgsComposerMapWidget::on_mGridLineStyleButton_clicked()
{
QgsComposerMapGrid* grid = currentGrid();
@@ -1386,7 +1408,32 @@ void QgsComposerMapWidget::on_mGridLineStyleButton_clicked()
{
mComposerMap->beginCommand( tr( "Grid line style changed" ) );
grid->setGridLineSymbol( newSymbol );
updateLineSymbolMarker();
updateGridLineSymbolMarker( grid );
mComposerMap->endCommand();
mComposerMap->update();
}
else
{
delete newSymbol;
}
}

void QgsComposerMapWidget::on_mGridMarkerStyleButton_clicked()
{
QgsComposerMapGrid* grid = currentGrid();
if ( !grid )
{
return;
}

QgsMarkerSymbolV2* newSymbol = dynamic_cast<QgsMarkerSymbolV2*>( grid->gridMarkerSymbol()->clone() );
QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), 0 );

if ( d.exec() == QDialog::Accepted )
{
mComposerMap->beginCommand( tr( "Grid markers style changed" ) );
grid->setGridMarkerSymbol( newSymbol );
updateGridMarkerSymbolMarker( grid );
mComposerMap->endCommand();
mComposerMap->update();
}
@@ -1617,14 +1664,32 @@ void QgsComposerMapWidget::on_mGridTypeComboBox_currentIndexChanged( const QStri
if ( text == tr( "Cross" ) )
{
grid->setGridStyle( QgsComposerMap::Cross );
mCrossWidthSpinBox->setEnabled( true );
mCrossWidthLabel->setEnabled( true );
mCrossWidthSpinBox->setVisible( true );
mCrossWidthLabel->setVisible( true );
mGridLineStyleButton->setVisible( true );
mLineStyleLabel->setVisible( true );
mGridMarkerStyleButton->setVisible( false );
mMarkerStyleLabel->setVisible( false );
}
else if ( text == tr( "Markers" ) )
{
grid->setGridStyle( QgsComposerMap::Markers );
mCrossWidthSpinBox->setVisible( false );
mCrossWidthLabel->setVisible( false );
mGridLineStyleButton->setVisible( false );
mLineStyleLabel->setVisible( false );
mGridMarkerStyleButton->setVisible( true );
mMarkerStyleLabel->setVisible( true );
}
else
{
grid->setGridStyle( QgsComposerMap::Solid );
mCrossWidthSpinBox->setEnabled( false );
mCrossWidthLabel->setEnabled( false );
mCrossWidthSpinBox->setVisible( false );
mCrossWidthLabel->setVisible( false );
mGridLineStyleButton->setVisible( true );
mLineStyleLabel->setVisible( true );
mGridMarkerStyleButton->setVisible( false );
mMarkerStyleLabel->setVisible( false );
}
mComposerMap->update();
mComposerMap->endCommand();
@@ -75,8 +75,8 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
void setGridItemsEnabled( bool enabled );
void setGridItems( const QgsComposerMapGrid* grid );
void blockGridItemsSignals( bool block );
void updateLineSymbolMarker( const QgsComposerMapGrid* grid );
void on_mGridLineStyleButton_clicked();
void on_mGridMarkerStyleButton_clicked();
void on_mIntervalXSpinBox_editingFinished();
void on_mIntervalYSpinBox_editingFinished();
void on_mOffsetXSpinBox_valueChanged( double value );
@@ -156,7 +156,8 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
void initAnnotationDirectionBox( QComboBox* c, QgsComposerMap::GridAnnotationDirection dir );

void updateOverviewSymbolMarker();
void updateLineSymbolMarker();
void updateGridLineSymbolMarker( const QgsComposerMapGrid* grid );
void updateGridMarkerSymbolMarker( const QgsComposerMapGrid* grid );

/**Updates the map combo box with the current composer map ids*/
void refreshMapComboBox();
@@ -65,7 +65,8 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
enum GridStyle
{
Solid = 0, //solid lines
Cross //only draw line crossings
Cross, //only draw line crossings
Markers
};

enum GridAnnotationPosition

0 comments on commit 8650597

Please sign in to comment.