Skip to content

Commit

Permalink
[FEATURE][composer] Add button to view current map item extent in mai…
Browse files Browse the repository at this point in the history
…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 "qgscomposermapwidget.h"
#include "qgscomposeritemwidget.h" #include "qgscomposeritemwidget.h"
#include "qgscomposition.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() void QgsComposerMapWidget::on_mXMinLineEdit_editingFinished()
{ {
updateComposerExtentFromGui(); 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_mScaleLineEdit_editingFinished();
void on_mMapRotationSpinBox_valueChanged( double value ); void on_mMapRotationSpinBox_valueChanged( double value );
void on_mSetToMapCanvasExtentButton_clicked(); void on_mSetToMapCanvasExtentButton_clicked();
void on_mViewExtentInCanvasButton_clicked();
void on_mUpdatePreviewButton_clicked(); void on_mUpdatePreviewButton_clicked();
void on_mKeepLayerListCheckBox_stateChanged( int state ); void on_mKeepLayerListCheckBox_stateChanged( int state );
void on_mDrawCanvasItemsCheckBox_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> <x>0</x>
<y>0</y> <y>0</y>
<width>439</width> <width>439</width>
<height>1638</height> <height>1671</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
Expand Down Expand Up @@ -174,25 +174,25 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="3" column="1"> <item row="0" column="0">
<widget class="QLineEdit" name="mYMaxLineEdit"/> <widget class="QLabel" name="mXMinLabel">
</item> <property name="enabled">
<item row="2" column="1"> <bool>true</bool>
<widget class="QLineEdit" name="mXMaxLineEdit"/> </property>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mXMaxLabel">
<property name="text"> <property name="text">
<string>X max</string> <string>X min</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>mXMaxLineEdit</cstring> <cstring>mXMinLineEdit</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="mXMinLineEdit"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="mYMinLabel"> <widget class="QLabel" name="mYMinLabel">
<property name="text"> <property name="text">
Expand All @@ -206,6 +206,25 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="3" column="0">
<widget class="QLabel" name="mYMaxLabel"> <widget class="QLabel" name="mYMaxLabel">
<property name="text"> <property name="text">
Expand All @@ -219,32 +238,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="mXMinLineEdit"/> <widget class="QLineEdit" name="mYMaxLineEdit"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mYMinLineEdit"/>
</item> </item>
<item row="4" column="0" colspan="4"> <item row="4" column="0" colspan="2">
<widget class="QPushButton" name="mSetToMapCanvasExtentButton"> <widget class="QPushButton" name="mSetToMapCanvasExtentButton">
<property name="text"> <property name="text">
<string>Set to map canvas extent</string> <string>Set to map canvas extent</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="5" column="0" colspan="2">
<widget class="QLabel" name="mXMinLabel"> <widget class="QPushButton" name="mViewExtentInCanvasButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>X min</string> <string>View extent in map canvas</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>mXMinLineEdit</cstring>
</property> </property>
</widget> </widget>
</item> </item>
Expand Down

0 comments on commit f5a60a4

Please sign in to comment.