QGIS API Documentation  2.5.0-Master
 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 {
9  setupUi( this );
10 
11  mXMinLineEdit->setValidator( new QDoubleValidator( this ) );
12  mXMaxLineEdit->setValidator( new QDoubleValidator( this ) );
13  mYMinLineEdit->setValidator( new QDoubleValidator( this ) );
14  mYMaxLineEdit->setValidator( new QDoubleValidator( this ) );
15 
16  connect( mCurrentExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromCurrent() ) );
17  connect( mOriginalExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromOriginal() ) );
18 }
19 
20 
21 void QgsExtentGroupBox::setOriginalExtent( const QgsRectangle& originalExtent, const QgsCoordinateReferenceSystem& originalCrs )
22 {
25 }
26 
27 
28 void QgsExtentGroupBox::setCurrentExtent( const QgsRectangle& currentExtent, const QgsCoordinateReferenceSystem& currentCrs )
29 {
32 }
33 
35 {
36  mOutputCrs = outputCrs;
37 }
38 
39 
41 {
42  QgsRectangle extent;
43  if ( mOutputCrs == srcCrs )
44  {
45  extent = r;
46  }
47  else
48  {
49  QgsCoordinateTransform ct( srcCrs, mOutputCrs );
50  extent = ct.transformBoundingBox( r );
51  }
52 
53  mXMinLineEdit->setText( QgsRasterBlock::printValue( extent.xMinimum() ) );
54  mXMaxLineEdit->setText( QgsRasterBlock::printValue( extent.xMaximum() ) );
55  mYMinLineEdit->setText( QgsRasterBlock::printValue( extent.yMinimum() ) );
56  mYMaxLineEdit->setText( QgsRasterBlock::printValue( extent.yMaximum() ) );
57 
58  mExtentState = state;
59 
60  updateTitle();
61 
62  emit extentChanged( extent );
63 }
64 
65 
67 {
69 
70  updateTitle();
71 
72  emit extentChanged( outputExtent() );
73 }
74 
75 
77 {
78  QString msg;
79  switch ( mExtentState )
80  {
81  case OriginalExtent:
82  msg = tr( "layer" );
83  break;
84  case CurrentExtent:
85  msg = tr( "map view" );
86  break;
87  case UserExtent:
88  msg = tr( "user defined" );
89  break;
90  default:
91  break;
92  }
93  msg = tr( "Extent (current: %1)" ).arg( msg );
94 
95  setTitle( msg );
96 }
97 
98 
100 {
102 }
103 
104 
106 {
108 }
109 
110 
112 {
113  setOutputExtent( extent, crs, UserExtent );
114 }
115 
116 
118 {
119  return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
120  mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
121 }
extent manually entered/modified by the user
ExtentState mExtentState
A rectangle specified with double values.
Definition: qgsrectangle.h:35
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)
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:194
QgsExtentGroupBox(QWidget *parent=0)
QgsCoordinateReferenceSystem mOutputCrs
QgsCoordinateReferenceSystem mOriginalCrs
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:199
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:184
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
QgsRectangle transformBoundingBox(const QgsRectangle theRect, TransformDirection direction=ForwardTransform) const
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) ...
QgsRectangle mOriginalExtent
void setOriginalExtent(const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs)
Setup original extent - should be called as part of initialization.
QgsCoordinateReferenceSystem mCurrentCrs
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:189
#define tr(sourceText)