Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE][composer] Add button to view current map item extent in mai…
…n map canvas
  • Loading branch information
nyalldawson committed Apr 21, 2014
1 parent d0f40b9 commit f5a60a4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 29 deletions.
18 changes: 18 additions & 0 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -15,6 +15,8 @@
* *
***************************************************************************/

#include "qgisapp.h"
#include "qgsmapcanvas.h"
#include "qgscomposermapwidget.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
Expand Down Expand Up @@ -333,6 +335,22 @@ void QgsComposerMapWidget::on_mSetToMapCanvasExtentButton_clicked()
}
}

void QgsComposerMapWidget::on_mViewExtentInCanvasButton_clicked()
{
if ( !mComposerMap )
{
return;
}

QgsRectangle currentMapExtent = *( mComposerMap->currentMapExtent() );

if ( !currentMapExtent.isEmpty() )
{
QgisApp::instance()->mapCanvas()->setExtent( currentMapExtent );
QgisApp::instance()->mapCanvas()->refresh();
}
}

void QgsComposerMapWidget::on_mXMinLineEdit_editingFinished()
{
updateComposerExtentFromGui();
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposermapwidget.h
Expand Up @@ -39,6 +39,7 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void on_mScaleLineEdit_editingFinished();
void on_mMapRotationSpinBox_valueChanged( double value );
void on_mSetToMapCanvasExtentButton_clicked();
void on_mViewExtentInCanvasButton_clicked();
void on_mUpdatePreviewButton_clicked();
void on_mKeepLayerListCheckBox_stateChanged( int state );
void on_mDrawCanvasItemsCheckBox_stateChanged( int state );
Expand Down
65 changes: 36 additions & 29 deletions src/ui/qgscomposermapwidgetbase.ui
Expand Up @@ -56,7 +56,7 @@
<x>0</x>
<y>0</y>
<width>439</width>
<height>1638</height>
<height>1671</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -174,25 +174,25 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QLineEdit" name="mYMaxLineEdit"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mXMaxLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mXMaxLabel">
<item row="0" column="0">
<widget class="QLabel" name="mXMinLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>X max</string>
<string>X min</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>mXMaxLineEdit</cstring>
<cstring>mXMinLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mXMinLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mYMinLabel">
<property name="text">
Expand All @@ -206,6 +206,25 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mYMinLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mXMaxLabel">
<property name="text">
<string>X max</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>mXMaxLineEdit</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mXMaxLineEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mYMaxLabel">
<property name="text">
Expand All @@ -219,32 +238,20 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mXMinLineEdit"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mYMinLineEdit"/>
<item row="3" column="1">
<widget class="QLineEdit" name="mYMaxLineEdit"/>
</item>
<item row="4" column="0" colspan="4">
<item row="4" column="0" colspan="2">
<widget class="QPushButton" name="mSetToMapCanvasExtentButton">
<property name="text">
<string>Set to map canvas extent</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mXMinLabel">
<property name="enabled">
<bool>true</bool>
</property>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="mViewExtentInCanvasButton">
<property name="text">
<string>X min</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>mXMinLineEdit</cstring>
<string>View extent in map canvas</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit f5a60a4

Please sign in to comment.