QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsextentgroupbox.cpp
Go to the documentation of this file.
1 #include "qgsextentgroupbox.h"
2 
4 #include "qgsrasterblock.h"
5 
7  : QgsCollapsibleGroupBox( parent )
8  , mExtentState( OriginalExtent )
9 {
10  setupUi( this );
11 
12  mXMinLineEdit->setValidator( new QDoubleValidator( this ) );
13  mXMaxLineEdit->setValidator( new QDoubleValidator( this ) );
14  mYMinLineEdit->setValidator( new QDoubleValidator( this ) );
15  mYMaxLineEdit->setValidator( new QDoubleValidator( this ) );
16 
17  connect( mCurrentExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromCurrent() ) );
18  connect( mOriginalExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromOriginal() ) );
19 }
20 
21 
22 void QgsExtentGroupBox::setOriginalExtent( const QgsRectangle& originalExtent, const QgsCoordinateReferenceSystem& originalCrs )
23 {
26 }
27 
28 
29 void QgsExtentGroupBox::setCurrentExtent( const QgsRectangle& currentExtent, const QgsCoordinateReferenceSystem& currentCrs )
30 {
33 }
34 
36 {
37  mOutputCrs = outputCrs;
38 }
39 
40 
42 {
43  QgsRectangle extent;
44  if ( mOutputCrs == srcCrs )
45  {
46  extent = r;
47  }
48  else
49  {
50  QgsCoordinateTransform ct( srcCrs, mOutputCrs );
51  extent = ct.transformBoundingBox( r );
52  }
53 
54  mXMinLineEdit->setText( QgsRasterBlock::printValue( extent.xMinimum() ) );
55  mXMaxLineEdit->setText( QgsRasterBlock::printValue( extent.xMaximum() ) );
56  mYMinLineEdit->setText( QgsRasterBlock::printValue( extent.yMinimum() ) );
57  mYMaxLineEdit->setText( QgsRasterBlock::printValue( extent.yMaximum() ) );
58 
59  mExtentState = state;
60 
61  updateTitle();
62 
63  emit extentChanged( extent );
64 }
65 
66 
68 {
70 
71  updateTitle();
72 
73  emit extentChanged( outputExtent() );
74 }
75 
76 
78 {
79  QString msg;
80  switch ( mExtentState )
81  {
82  case OriginalExtent:
83  msg = tr( "layer" );
84  break;
85  case CurrentExtent:
86  msg = tr( "map view" );
87  break;
88  case UserExtent:
89  msg = tr( "user defined" );
90  break;
91  default:
92  break;
93  }
94  msg = tr( "Extent (current: %1)" ).arg( msg );
95 
96  setTitle( msg );
97 }
98 
99 
101 {
103 }
104 
105 
107 {
109 }
110 
111 
113 {
114  setOutputExtent( extent, crs, UserExtent );
115 }
116 
117 
119 {
120  return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
121  mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
122 }
extent manually entered/modified by the user
ExtentState mExtentState
A rectangle specified with double values.
Definition: qgsrectangle.h:35
void setupUi(QWidget *widget)
static QString printValue(double value)
Print double value with all necessary significant digits.
void setOutputExtentFromCurrent()
set output extent to be the same as current extent (may be transformed to output CRS) ...
void extentChanged(const QgsRectangle &r)
emitted when extent is changed
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
void setOutputExtentFromUser(const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs)
set output extent to custom extent (may be transformed to outut CRS)
void clicked(bool checked)
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:192
QgsExtentGroupBox(QWidget *parent=0)
QgsCoordinateReferenceSystem mOutputCrs
QgsCoordinateReferenceSystem mOriginalCrs
QString tr(const char *sourceText, const char *disambiguation, int n)
void setOutputExtent(const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state)
const QgsCoordinateReferenceSystem & currentCrs() const
QgsRectangle mCurrentExtent
QgsRectangle originalExtent() const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:197
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:182
QgsRectangle outputExtent() const
Get the resulting extent - in output CRS coordinates.
void setOutputCrs(const QgsCoordinateReferenceSystem &outputCrs)
Set the output CRS - may need to be used for transformation from original/current extent...
void setCurrentExtent(const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs)
Setup current extent - should be called as part of initialization (or whenever current extent changes...
QgsRectangle currentExtent() const
void setTitle(const QString &title)
const QgsCoordinateReferenceSystem & originalCrs() const
Class for storing a coordinate reference system (CRS)
Class for doing transforms between two map coordinate systems.
void setOutputExtentFromOriginal()
set output extent to be the same as original extent (may be transformed to output CRS) ...
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsRectangle mOriginalExtent
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Setup original extent - should be called as part of initialization.
QgsCoordinateReferenceSystem mCurrentCrs
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:187
QgsRectangle transformBoundingBox(const QgsRectangle &theRect, TransformDirection direction=ForwardTransform, const bool handle180Crossover=false) const