Skip to content

Commit

Permalink
Add GUI elements to change composer map grid annotation format
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Aug 9, 2012
1 parent 5821e2b commit fa57840
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 30 deletions.
23 changes: 23 additions & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -51,6 +51,10 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );

mAnnotationFormatComboBox->insertItem( 0, tr( "Decimal" ) );
mAnnotationFormatComboBox->insertItem( 1, tr( "DegreeMinute" ) );
mAnnotationFormatComboBox->insertItem( 2, tr( "DegreeMinuteSecond" ) );

insertAnnotationPositionEntries( mAnnotationPositionLeftComboBox );
insertAnnotationPositionEntries( mAnnotationPositionRightComboBox );
insertAnnotationPositionEntries( mAnnotationPositionTopComboBox );
Expand Down Expand Up @@ -372,6 +376,10 @@ void QgsComposerMapWidget::updateGuiElements()
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
}

//grid annotation format
QgsComposerMap::GridAnnotationFormat gf = mComposerMap->gridAnnotationFormat();
mAnnotationFormatComboBox->setCurrentIndex(( int )gf );

//grid annotation position
initAnnotationPositionBox( mAnnotationPositionLeftComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Left ) );
initAnnotationPositionBox( mAnnotationPositionRightComboBox, mComposerMap->gridAnnotationPosition( QgsComposerMap::Right ) );
Expand Down Expand Up @@ -457,6 +465,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
mLineColorButton->blockSignals( b );
mDrawAnnotationCheckBox->blockSignals( b );
mAnnotationFontButton->blockSignals( b );
mAnnotationFormatComboBox->blockSignals( b );
mAnnotationPositionLeftComboBox->blockSignals( b );
mAnnotationPositionRightComboBox->blockSignals( b );
mAnnotationPositionTopComboBox->blockSignals( b );
Expand Down Expand Up @@ -767,6 +776,20 @@ void QgsComposerMapWidget::on_mDistanceToMapFrameSpinBox_valueChanged( double d
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mAnnotationFormatComboBox_currentIndexChanged( int index )
{
if ( !mComposerMap )
{
return;
}

mComposerMap->beginCommand( tr( "Annotation format changed" ) );
mComposerMap->setGridAnnotationFormat(( QgsComposerMap::GridAnnotationFormat )index );
mComposerMap->updateBoundingRect();
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text )
{
handleChangedAnnotationPosition( QgsComposerMap::Left, text );
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscomposermapwidget.h
Expand Up @@ -63,6 +63,8 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void on_mAnnotationFontButton_clicked();
void on_mDistanceToMapFrameSpinBox_valueChanged( double d );

void on_mAnnotationFormatComboBox_currentIndexChanged( int index );

//annotation position
void on_mAnnotationPositionLeftComboBox_currentIndexChanged( const QString& text );
void on_mAnnotationPositionRightComboBox_currentIndexChanged( const QString& text );
Expand Down
3 changes: 3 additions & 0 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -262,6 +262,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border );
GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const;

void setGridAnnotationFormat( GridAnnotationFormat f ) { mGridAnnotationFormat = f; }
GridAnnotationFormat gridAnnotationFormat() const { return mGridAnnotationFormat; }

/**Set grid frame style (NoGridFrame or Zebra)
@note: this function was added in version 1.9*/
void setGridFrameStyle( GridFrameStyle style ) { mGridFrameStyle = style; }
Expand Down
70 changes: 40 additions & 30 deletions src/ui/qgscomposermapwidgetbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<width>265</width>
<height>483</height>
</rect>
</property>
Expand All @@ -33,8 +33,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>230</width>
<height>395</height>
<width>255</width>
<height>392</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -251,8 +251,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>230</width>
<height>395</height>
<width>255</width>
<height>392</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -359,8 +359,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>218</width>
<height>716</height>
<width>238</width>
<height>770</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -591,9 +591,9 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<item row="5" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelLeft">
<property name="text">
<string>Annotation position left side</string>
Expand All @@ -606,10 +606,10 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="mAnnotationPositionLeftComboBox"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelRight">
<property name="text">
<string>Annotation position right side</string>
Expand All @@ -622,10 +622,10 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="mAnnotationPositionRightComboBox"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelTop">
<property name="text">
<string>Annotation position top side</string>
Expand All @@ -638,10 +638,10 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="mAnnotationPositionTopComboBox"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelBottom">
<property name="text">
<string>Annotation position bottom side</string>
Expand All @@ -654,10 +654,10 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="mAnnotationPositionBottomComboBox"/>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="mAnnotationDirectionLabelLeft">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
Expand All @@ -673,10 +673,10 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxLeft"/>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="mAnnotationDirectionLabelRight">
<property name="text">
<string>Annotation direction right side</string>
Expand All @@ -689,10 +689,10 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxRight"/>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="mAnnotationDirectionLabelTop">
<property name="text">
<string>Annotation direction top side</string>
Expand All @@ -702,10 +702,10 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxTop"/>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="mAnnotationDirectionLabeBottom">
<property name="text">
<string>Annotation direction bottom side</string>
Expand All @@ -715,19 +715,29 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxBottom"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mAnnotationFormatLabel">
<property name="text">
<string>Annotation format</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mAnnotationFormatComboBox"/>
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QPushButton" name="mAnnotationFontButton">
<property name="text">
<string>Font...</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="mDistanceToFrameLabel">
<property name="text">
<string>Distance to map frame</string>
Expand All @@ -740,10 +750,10 @@
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<item row="7" column="2" colspan="2">
<widget class="QDoubleSpinBox" name="mDistanceToMapFrameSpinBox"/>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="mCoordinatePrecisionLabel">
<property name="text">
<string>Coordinate precision</string>
Expand All @@ -756,10 +766,10 @@
</property>
</widget>
</item>
<item row="7" column="2" colspan="2">
<item row="8" column="2" colspan="2">
<widget class="QSpinBox" name="mCoordinatePrecisionSpinBox"/>
</item>
<item row="8" column="0">
<item row="9" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down

0 comments on commit fa57840

Please sign in to comment.