Skip to content

Commit

Permalink
[FEATURE][composer] Add tick styles for frames. Options include
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nyalldawson committed Sep 3, 2014
1 parent 8544185 commit 53fa30f
Show file tree
Hide file tree
Showing 17 changed files with 370 additions and 48 deletions.
58 changes: 43 additions & 15 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposermapwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down
Loading

0 comments on commit 53fa30f

Please sign in to comment.