diff --git a/python/core/qgscoordinatetransform.sip b/python/core/qgscoordinatetransform.sip index 320bdd722948..f64d52b41b1e 100644 --- a/python/core/qgscoordinatetransform.sip +++ b/python/core/qgscoordinatetransform.sip @@ -103,17 +103,17 @@ class QgsCoordinateTransform : QObject */ QgsPoint transform(const double x, const double y,TransformDirection direction=ForwardTransform); - /*! Transform a QgsRect to the dest Coordinate system + /*! Transform a QgsRectangle to the dest Coordinate system * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, * otherwise points are transformed from map canvas CS to layerCS. * It assumes that rect is a bounding box, and creates a bounding box * in the proejcted CS, so that all points in source rectangle is within * returned rectangle. - * @param QgsRect rect to transform + * @param QgsRectangle rect to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ - QgsRect transformBoundingBox(const QgsRect theRect,TransformDirection direction=ForwardTransform); + QgsRectangle transformBoundingBox(const QgsRectangle theRect,TransformDirection direction=ForwardTransform); // Same as for the other transform() functions, but alters the x // and y variables in place. The second one works with good old-fashioned @@ -124,14 +124,14 @@ class QgsCoordinateTransform : QObject //void transformInPlace(std::vector& x, std::vector& y, std::vector& z, // TransformDirection direction = ForwardTransform); - /*! Transform a QgsRect to the dest Coordinate system + /*! Transform a QgsRectangle to the dest Coordinate system * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, * otherwise points are transformed from map canvas CS to layerCS. - * @param QgsRect rect to transform + * @param QgsRectangle rect to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ - QgsRect transform(const QgsRect theRect,TransformDirection direction=ForwardTransform); + QgsRectangle transform(const QgsRectangle theRect,TransformDirection direction=ForwardTransform); /*! Transform an array of coordinates to a different Coordinate System * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, @@ -139,7 +139,7 @@ class QgsCoordinateTransform : QObject * @param x x cordinate of point to transform * @param y y coordinate of point to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ void transformCoords( const int &numPoint, double *x, double *y, double *z,TransformDirection direction=ForwardTransform); diff --git a/python/core/qgsdataprovider.sip b/python/core/qgsdataprovider.sip index cade6286f39a..a301ed2bb798 100644 --- a/python/core/qgsdataprovider.sip +++ b/python/core/qgsdataprovider.sip @@ -40,9 +40,9 @@ class QgsDataProvider : QObject /** * Get the extent of the layer - * @return QgsRect containing the extent of the layer + * @return QgsRectangle containing the extent of the layer */ - virtual QgsRect extent() = 0; + virtual QgsRectangle extent() = 0; /** diff --git a/python/core/qgsgeometry.sip b/python/core/qgsgeometry.sip index 87c69f496586..29278fb875d3 100644 --- a/python/core/qgsgeometry.sip +++ b/python/core/qgsgeometry.sip @@ -50,7 +50,7 @@ class QgsGeometry /** construct geometry from a multipolygon */ static QgsGeometry* fromMultiPolygon(const QgsMultiPolygon& multipoly) /Factory/; /** construct geometry from a rectangle */ - static QgsGeometry* fromRect(const QgsRect& rect) /Factory/; + static QgsGeometry* fromRect(const QgsRectangle& rect) /Factory/; typedef unsigned int size_t; @@ -210,10 +210,10 @@ not disjoint with existing polygons of the feature*/ int makeDifference(QgsGeometry* other); /**Returns the bounding box of this feature*/ - QgsRect boundingBox(); + QgsRectangle boundingBox(); /** Test for intersection with a rectangle (uses GEOS) */ - bool intersects(const QgsRect& r); + bool intersects(const QgsRectangle& r); /** Test for intersection with a geoemetry (uses GEOS) */ bool intersects(QgsGeometry* geometry); diff --git a/python/core/qgslabel.sip b/python/core/qgslabel.sip index dead16559272..153f8dd06319 100644 --- a/python/core/qgslabel.sip +++ b/python/core/qgslabel.sip @@ -44,7 +44,7 @@ public: /** \brief render label * \param sizeScale global scale factor for size in pixels, labels in map units are not scaled */ - void renderLabel ( QPainter* painter, QgsRect& viewExtent, + void renderLabel ( QPainter* painter, QgsRectangle& viewExtent, QgsCoordinateTransform* coordinateTransform, QgsMapToPixel *transform, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=0, double sizeScale = 1, double rasterScaleFactor = 1); diff --git a/python/core/qgsmaplayer.sip b/python/core/qgsmaplayer.sip index 3f4e3968439a..c81534dda3f5 100644 --- a/python/core/qgsmaplayer.sip +++ b/python/core/qgsmaplayer.sip @@ -71,7 +71,7 @@ public: virtual void drawLabels(QgsRenderContext& rendererContext); /** Return the extent of the layer as a QRect */ - const QgsRect extent(); + const QgsRectangle extent(); /*! Return the status of the layer. An invalid layer is one which has a bad datasource * or other problem. Child classes set this flag when intialized diff --git a/python/core/qgsmaprenderer.sip b/python/core/qgsmaprenderer.sip index f5ccbfa51f35..df8101b13dbc 100644 --- a/python/core/qgsmaprenderer.sip +++ b/python/core/qgsmaprenderer.sip @@ -23,10 +23,10 @@ class QgsMapRenderer : QObject void render(QPainter* painter); //! sets extent and checks whether suitable (returns false if not) - bool setExtent(const QgsRect& extent); + bool setExtent(const QgsRectangle& extent); //! returns current extent - QgsRect extent(); + QgsRectangle extent(); const QgsMapToPixel* coordinateTransform(); @@ -54,7 +54,7 @@ class QgsMapRenderer : QObject QSize outputSize(); //! transform extent in layer's CRS to extent in output CRS - QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent); + QgsRectangle layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRectangle extent); //! transform coordinates from layer's CRS to output CRS QgsPoint layerToMapCoordinates(QgsMapLayer* theLayer, QgsPoint point); @@ -63,7 +63,7 @@ class QgsMapRenderer : QObject QgsPoint mapToLayerCoordinates(QgsMapLayer* theLayer, QgsPoint point); //! transform rect's coordinates from output CRS to layer's CRS - QgsRect mapToLayerCoordinates(QgsMapLayer* theLayer, QgsRect rect); + QgsRectangle mapToLayerCoordinates(QgsMapLayer* theLayer, QgsRectangle rect); //! sets whether to use projections for this layer set void setProjectionsEnabled(bool enabled); @@ -78,7 +78,7 @@ class QgsMapRenderer : QObject const QgsCoordinateReferenceSystem& destinationSrs(); //! returns current extent of layer set - QgsRect fullExtent(); + QgsRectangle fullExtent(); //! returns current layer set QStringList& layerSet(); @@ -126,7 +126,7 @@ class QgsMapRenderer : QObject * source CRS coordinates, and if it was split, returns true, and * also sets the contents of the r2 parameter */ - bool splitLayersExtent(QgsMapLayer* layer, QgsRect& extent, QgsRect& r2); + bool splitLayersExtent(QgsMapLayer* layer, QgsRectangle& extent, QgsRectangle& r2); }; diff --git a/python/core/qgsrasterdataprovider.sip b/python/core/qgsrasterdataprovider.sip index 53bcc57fdd37..a2703ccbf7ec 100644 --- a/python/core/qgsrasterdataprovider.sip +++ b/python/core/qgsrasterdataprovider.sip @@ -57,7 +57,7 @@ public: // TODO: Document this better. /** \brief Renders the layer as an image */ - virtual QImage* draw(const QgsRect & viewExtent, int pixelWidth, int pixelHeight) = 0; + virtual QImage* draw(const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight) = 0; /** Returns a bitmask containing the supported capabilities Note, some capabilities may change depending on whether diff --git a/python/core/qgsrect.sip b/python/core/qgsrect.sip index b499cb9cde0f..66c6065e2fcc 100644 --- a/python/core/qgsrect.sip +++ b/python/core/qgsrect.sip @@ -1,25 +1,25 @@ -/*! \class QgsRect +/*! \class QgsRectangle * \brief A rectangle specified with double values. * - * QgsRect is used to store a rectangle when double values are required. + * QgsRectangle is used to store a rectangle when double values are required. * Examples are storing a layer extent or the current view extent of a map */ -class QgsRect +class QgsRectangle { %TypeHeaderCode -#include +#include %End public: //! Constructor - QgsRect(double xmin=0, double ymin=0, double xmax=0, double ymax=0); + QgsRectangle(double xmin=0, double ymin=0, double xmax=0, double ymax=0); //! Construct a rectangle from two points. The rectangle is normalized after construction. - QgsRect(const QgsPoint & p1, const QgsPoint & p2); + QgsRectangle(const QgsPoint & p1, const QgsPoint & p2); //! Copy constructor - QgsRect(const QgsRect &other); + QgsRectangle(const QgsRectangle &other); //! Destructor - ~QgsRect(); + ~QgsRectangle(); //! Set the rectangle from two QgsPoints. The rectangle is //normalised after construction. void set(const QgsPoint& p1, const QgsPoint& p2); @@ -38,13 +38,13 @@ class QgsRect // and max corner is at min. It is NOT normalized. void setMinimal(); //! Get the x maximum value (right side of rectangle) - double xMax() const; + double xMaximum() const; //! Get the x maximum value (right side of rectangle) - double xMin() const; + double xMinimum() const; //! Get the x minimum value (left side of rectangle) - double yMax() const; + double yMaximum() const; //! Get the y maximum value (top side of rectangle) - double yMin() const; + double yMinimum() const; //! Normalize the rectangle so it has non-negative width/height void normalize(); //! Width of the rectangle @@ -58,11 +58,11 @@ class QgsRect //! Expand the rectangle to support zoom out scaling void expand(double, const QgsPoint *c = 0); //! return the intersection with the given rectangle - QgsRect intersect(QgsRect *rect); + QgsRectangle intersect(QgsRectangle *rect); //! returns true when rectangle intersects with other rectangle - bool intersects(const QgsRect& rect) const; + bool intersects(const QgsRectangle& rect) const; //! expand the rectangle so that covers both the original rectangle and the given rectangle - void combineExtentWith(QgsRect *rect); + void combineExtentWith(QgsRectangle *rect); //! expand the rectangle so that covers both the original rectangle and the given point void combineExtentWith(double x, double y); //! test if rectangle is empty @@ -78,14 +78,14 @@ class QgsRect /*! Comparison operator @return True if rectangles are equal */ - bool operator==(const QgsRect &r1) const; + bool operator==(const QgsRectangle &r1) const; /*! Comparison operator @return False if rectangles are equal */ - bool operator!=(const QgsRect &r1) const; + bool operator!=(const QgsRectangle &r1) const; /** updates rectangle to include passed argument */ - void unionRect(const QgsRect& rect); + void unionRect(const QgsRectangle& rect); }; diff --git a/python/core/qgsrendercontext.sip b/python/core/qgsrendercontext.sip index 51a8016f35f5..f1677323c2ec 100644 --- a/python/core/qgsrendercontext.sip +++ b/python/core/qgsrendercontext.sip @@ -16,7 +16,7 @@ class QgsRenderContext const QgsCoordinateTransform* coordinateTransform() const; - const QgsRect& extent() const; + const QgsRectangle& extent() const; const QgsMapToPixel& mapToPixel() const; @@ -35,7 +35,7 @@ class QgsRenderContext /**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/ void setCoordinateTransform(QgsCoordinateTransform* t); void setMapToPixel(const QgsMapToPixel& mtp); - void setExtent(const QgsRect& extent); + void setExtent(const QgsRectangle& extent); void setDrawEditingInformation(bool b); void setRenderingStopped(bool stopped); void setScaleFactor(double factor); diff --git a/python/core/qgsscalecalculator.sip b/python/core/qgsscalecalculator.sip index 96cf6fa25a79..f8edf545c17a 100644 --- a/python/core/qgsscalecalculator.sip +++ b/python/core/qgsscalecalculator.sip @@ -47,19 +47,19 @@ class QgsScaleCalculator /** * Calculate the scale - * @param mapExtent QgsRect containing the current map extent + * @param mapExtent QgsRectangle containing the current map extent * @param canvasWidth Width of the map canvas in pixel (physical) units * @return scale of current map view */ - double calculate(QgsRect &mapExtent, int canvasWidth); + double calculate(QgsRectangle &mapExtent, int canvasWidth); /** * Calculate the distance between to points in geographic coordinates. * Used to calculate scale for map views with geographic (decimal degree) * data. - * @param mapExtent QgsRect containing the current map extent + * @param mapExtent QgsRectangle containing the current map extent */ - double calculateGeographicDistance(QgsRect &mapExtent); + double calculateGeographicDistance(QgsRectangle &mapExtent); }; diff --git a/python/core/qgsspatialindex.sip b/python/core/qgsspatialindex.sip index 68c00198cf92..a0ddc085b802 100644 --- a/python/core/qgsspatialindex.sip +++ b/python/core/qgsspatialindex.sip @@ -34,7 +34,7 @@ public: /* queries */ /** returns features that intersect the specified rectangle */ - QList intersects(QgsRect rect); + QList intersects(QgsRectangle rect); /** returns nearest neighbors (their count is specified by second parameter) */ QList nearestNeighbor(QgsPoint point, int neighbors); diff --git a/python/core/qgsvectordataprovider.sip b/python/core/qgsvectordataprovider.sip index d7654553e331..5e06c9947d58 100644 --- a/python/core/qgsvectordataprovider.sip +++ b/python/core/qgsvectordataprovider.sip @@ -52,7 +52,7 @@ class QgsVectorDataProvider : QgsDataProvider * false if a test based on bounding box is sufficient */ virtual void select(QList fetchAttributes = QList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false) = 0; diff --git a/python/core/qgsvectorlayer.sip b/python/core/qgsvectorlayer.sip index 4e9318eaf027..cb3050fe428b 100644 --- a/python/core/qgsvectorlayer.sip +++ b/python/core/qgsvectorlayer.sip @@ -65,7 +65,7 @@ public: int selectedFeatureCount(); /** Select features found within the search rectangle (in layer's coordinates) */ - void select(QgsRect & rect, bool lock); + void select(QgsRectangle & rect, bool lock); /** Select not selected features and deselect selected ones */ void invertSelection(); @@ -79,8 +79,8 @@ public: /** Change selection to the new set of features */ void setSelectedFeatures(const QSet& ids); - /** Returns the bounding box of the selected features. If there is no selection, QgsRect(0,0,0,0) is returned */ - QgsRect boundingBoxOfSelected(); + /** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */ + QgsRectangle boundingBoxOfSelected(); /** Copies the symbology settings from another layer. Returns true in case of success */ bool copySymbologySettings(const QgsMapLayer& other); @@ -158,7 +158,7 @@ public: virtual QString subsetString(); void select(QList fetchAttributes = QList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false); diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index aad0e76384e9..817a2db9b879 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -77,12 +77,12 @@ class QgsMapCanvas : QGraphicsView double mapUnitsPerPixel() const; //! Returns the current zoom exent of the map canvas - QgsRect extent() const; + QgsRectangle extent() const; //! Returns the combined exent for all layers on the map canvas - QgsRect fullExtent() const; + QgsRectangle fullExtent() const; //! Set the extent of the map canvas - void setExtent(const QgsRect & r); + void setExtent(const QgsRectangle & r); //! Zoom to the full extent of all layers void zoomToFullExtent(); diff --git a/python/gui/qgsmapcanvasitem.sip b/python/gui/qgsmapcanvasitem.sip index b3456eb48376..798a392d1a9f 100644 --- a/python/gui/qgsmapcanvasitem.sip +++ b/python/gui/qgsmapcanvasitem.sip @@ -36,10 +36,10 @@ class QgsMapCanvasItem : QGraphicsItem void setPanningOffset(const QPoint& point); //! returns canvas item rectangle - QgsRect rect() const; + QgsRectangle rect() const; //! sets canvas item rectangle - void setRect(const QgsRect& r); + void setRect(const QgsRectangle& r); //! transformation from screen coordinates to map coordinates QgsPoint toMapCoordinates(const QPoint& point); diff --git a/python/gui/qgsmapoverviewcanvas.sip b/python/gui/qgsmapoverviewcanvas.sip index ac1778ff18fa..1179866b7c0e 100644 --- a/python/gui/qgsmapoverviewcanvas.sip +++ b/python/gui/qgsmapoverviewcanvas.sip @@ -26,7 +26,7 @@ class QgsMapOverviewCanvas : QWidget void enableAntiAliasing(bool flag); - void updateFullExtent(const QgsRect& rect); + void updateFullExtent(const QgsRectangle& rect); public slots: diff --git a/python/gui/qgsmaptool.sip b/python/gui/qgsmaptool.sip index 2c0908867089..522407ec86bf 100644 --- a/python/gui/qgsmaptool.sip +++ b/python/gui/qgsmaptool.sip @@ -85,7 +85,7 @@ class QgsMapTool : QObject QgsPoint toLayerCoordinates(QgsMapLayer* layer, const QgsPoint& point); //! trnasformation of the rect from map coordinates to layer's coordinates - QgsRect toLayerCoordinates(QgsMapLayer* layer, const QgsRect& rect); + QgsRectangle toLayerCoordinates(QgsMapLayer* layer, const QgsRectangle& rect); //! transformation from map coordinates to screen coordinates QPoint toCanvasCoordinates(const QgsPoint& point); diff --git a/src/app/composer/qgscomposermapwidget.cpp b/src/app/composer/qgscomposermapwidget.cpp index 94d547dd34fa..613c1e4d276d 100644 --- a/src/app/composer/qgscomposermapwidget.cpp +++ b/src/app/composer/qgscomposermapwidget.cpp @@ -149,13 +149,13 @@ void QgsComposerMapWidget::on_mSetToMapCanvasExtentButton_clicked() const QgsMapRenderer* renderer = mComposerMap->mapRenderer(); if ( renderer ) { - QgsRect canvasExtent = renderer->extent(); + QgsRectangle canvasExtent = renderer->extent(); //fill text into line edits - mXMinLineEdit->setText( QString::number( canvasExtent.xMin() ) ); - mXMaxLineEdit->setText( QString::number( canvasExtent.xMax() ) ); - mYMinLineEdit->setText( QString::number( canvasExtent.yMin() ) ); - mYMaxLineEdit->setText( QString::number( canvasExtent.yMax() ) ); + mXMinLineEdit->setText( QString::number( canvasExtent.xMinimum() ) ); + mXMaxLineEdit->setText( QString::number( canvasExtent.xMaximum() ) ); + mYMinLineEdit->setText( QString::number( canvasExtent.yMinimum() ) ); + mYMaxLineEdit->setText( QString::number( canvasExtent.yMaximum() ) ); mComposerMap->setNewExtent( canvasExtent ); } @@ -229,11 +229,11 @@ void QgsComposerMapWidget::updateGuiElements() } //composer map extent - QgsRect composerMapExtent = mComposerMap->extent(); - mXMinLineEdit->setText( QString::number( composerMapExtent.xMin(), 'f', 3 ) ); - mXMaxLineEdit->setText( QString::number( composerMapExtent.xMax(), 'f', 3 ) ); - mYMinLineEdit->setText( QString::number( composerMapExtent.yMin(), 'f', 3 ) ); - mYMaxLineEdit->setText( QString::number( composerMapExtent.yMax(), 'f', 3 ) ); + QgsRectangle composerMapExtent = mComposerMap->extent(); + mXMinLineEdit->setText( QString::number( composerMapExtent.xMinimum(), 'f', 3 ) ); + mXMaxLineEdit->setText( QString::number( composerMapExtent.xMaximum(), 'f', 3 ) ); + mYMinLineEdit->setText( QString::number( composerMapExtent.yMinimum(), 'f', 3 ) ); + mYMaxLineEdit->setText( QString::number( composerMapExtent.yMaximum(), 'f', 3 ) ); } } @@ -256,7 +256,7 @@ void QgsComposerMapWidget::updateComposerExtentFromGui() ymax = mYMaxLineEdit->text().toDouble( &conversionSuccess ); if ( !conversionSuccess ) {return;} - QgsRect newExtent( xmin, ymin, xmax, ymax ); + QgsRectangle newExtent( xmin, ymin, xmax, ymax ); mComposerMap->setNewExtent( newExtent ); } diff --git a/src/app/legend/qgslegend.cpp b/src/app/legend/qgslegend.cpp index ed9b992de65d..1f812d2bcf88 100755 --- a/src/app/legend/qgslegend.cpp +++ b/src/app/legend/qgslegend.cpp @@ -1754,7 +1754,7 @@ void QgsLegend::legendLayerZoom() QgsMapLayer* theLayer; bool first( true ); - QgsRect extent; + QgsRectangle extent; for ( std::list::iterator it = layerFiles.begin(); it != layerFiles.end(); ++it ) { @@ -1762,7 +1762,7 @@ void QgsLegend::legendLayerZoom() if ( !theLayer ) continue; - QgsRect lyrExtent = mMapCanvas->mapRenderer()->layerExtentToOutputExtent( theLayer, theLayer->extent() ); + QgsRectangle lyrExtent = mMapCanvas->mapRenderer()->layerExtentToOutputExtent( theLayer, theLayer->extent() ); if ( !lyrExtent.isFinite() ) lyrExtent = theLayer->extent(); diff --git a/src/app/main.cpp b/src/app/main.cpp index c6295532ebea..570a9aa1a95e 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -69,7 +69,7 @@ typedef SInt32 SRefCon; #include #include "qgsexception.h" #include "qgsproject.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgslogger.h" static const char * const ident_ = "$Id$"; @@ -641,7 +641,7 @@ int main( int argc, char *argv[] ) else { // set extent from parsed values - QgsRect rect( coords[0], coords[1], coords[2], coords[3] ); + QgsRectangle rect( coords[0], coords[1], coords[2], coords[3] ); qgis->setExtent( rect ); } } diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 4f75e57d2496..c3f489f505fa 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -126,7 +126,7 @@ #include "qgsproviderregistry.h" #include "qgsrasterlayer.h" #include "qgsrasterlayerproperties.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsrenderer.h" #include "qgsserversourceselect.h" #include "qgsvectordataprovider.h" @@ -4608,7 +4608,7 @@ void QgisApp::addMapLayer( QgsMapLayer *theMapLayer ) } -void QgisApp::setExtent( QgsRect theRect ) +void QgisApp::setExtent( QgsRectangle theRect ) { mMapCanvas->setExtent( theRect ); } @@ -4856,7 +4856,7 @@ void QgisApp::showExtents() return; } // update the statusbar with the current extents. - QgsRect myExtents = mMapCanvas->extent(); + QgsRectangle myExtents = mMapCanvas->extent(); mCoordsLabel->setText( QString( tr( "Extents: " ) ) + myExtents.toString( true ) ); //ensure the label is big enough if ( mCoordsLabel->width() > mCoordsLabel->minimumWidth() ) diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index e5308782eae8..d92290cf06df 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -52,7 +52,7 @@ class QgsProviderRegistry; class QgsPythonDialog; class QgsPythonUtils; class QgsRasterLayer; -class QgsRect; +class QgsRectangle; class QgsVectorLayer; #include @@ -116,7 +116,7 @@ class QgisApp : public QMainWindow void addMapLayer( QgsMapLayer *theMapLayer ); /** Set the extents of the map canvas */ - void setExtent( QgsRect theRect ); + void setExtent( QgsRectangle theRect ); //! Remove all layers from the map and legend - reimplements same method from qgisappbase void removeAllLayers(); /** Open a raster or vector file; ignore other files. diff --git a/src/app/qgsattributetable.cpp b/src/app/qgsattributetable.cpp index e57b5b324638..f6fa1533aa34 100644 --- a/src/app/qgsattributetable.cpp +++ b/src/app/qgsattributetable.cpp @@ -479,7 +479,7 @@ void QgsAttributeTable::fillTable( QgsVectorLayer *layer ) QgsFeatureList features; if ( layer->selectedFeatureCount() == 0 ) { - layer->select( layer->pendingAllAttributesList(), QgsRect(), false ); + layer->select( layer->pendingAllAttributesList(), QgsRectangle(), false ); QgsFeature f; while ( layer->nextFeature( f ) ) diff --git a/src/app/qgsattributetabledisplay.cpp b/src/app/qgsattributetabledisplay.cpp index 5aa401ccf257..241a33697f94 100644 --- a/src/app/qgsattributetabledisplay.cpp +++ b/src/app/qgsattributetabledisplay.cpp @@ -372,7 +372,7 @@ void QgsAttributeTableDisplay::doSearch( QString searchString ) mSearchIds.clear(); - mLayer->select( mLayer->pendingAllAttributesList(), QgsRect(), false ); + mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false ); QgsFeature f; while ( mLayer->nextFeature( f ) ) diff --git a/src/app/qgsbookmarkitem.cpp b/src/app/qgsbookmarkitem.cpp index 8f20be46aa42..fd6e5ed5bdbd 100644 --- a/src/app/qgsbookmarkitem.cpp +++ b/src/app/qgsbookmarkitem.cpp @@ -21,12 +21,12 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsbookmarkitem.h" #include "qgslogger.h" QgsBookmarkItem::QgsBookmarkItem( QString name, QString projectTitle, - QgsRect viewExtent, int srid, QString dbPath ) + QgsRectangle viewExtent, int srid, QString dbPath ) : mName( name ), mProjectTitle( projectTitle ), mViewExtent( viewExtent ), mSrid( srid ), mUserDbPath( dbPath ) { @@ -59,10 +59,10 @@ void QgsBookmarkItem::store() sqlStream << "insert into tbl_bookmarks values(null,'" << mName << "','" << mProjectTitle << "'," << - mViewExtent.xMin() << "," << - mViewExtent.yMin() << "," << - mViewExtent.xMax() << "," << - mViewExtent.yMax() << "," << + mViewExtent.xMinimum() << "," << + mViewExtent.yMinimum() << "," << + mViewExtent.xMaximum() << "," << + mViewExtent.yMaximum() << "," << mSrid << ")"; QgsDebugMsg( QString( "Storing bookmark using: %1" ).arg( sql ) ); diff --git a/src/app/qgsbookmarkitem.h b/src/app/qgsbookmarkitem.h index 83609d34939f..69a434878e11 100644 --- a/src/app/qgsbookmarkitem.h +++ b/src/app/qgsbookmarkitem.h @@ -20,7 +20,7 @@ #define QGSBOOKMARKITEM_H #include -#include "qgsrect.h" +#include "qgsrectangle.h" /*! * \class QgsBookmarkItem @@ -32,7 +32,7 @@ class QgsBookmarkItem public: //! Constructs a bookmark item QgsBookmarkItem( QString name, QString projectTitle, - QgsRect viewExtent, int srid, QString databasePath ); + QgsRectangle viewExtent, int srid, QString databasePath ); //! Default destructor ~QgsBookmarkItem(); //! Store the bookmark in the database @@ -43,7 +43,7 @@ class QgsBookmarkItem //! Project that this bookmark was created from QString mProjectTitle; //! Extent of the view for the bookmark - QgsRect mViewExtent; + QgsRectangle mViewExtent; //! SRID of the canvas coordinate system when the bookmark was created int mSrid; //! Full path to the user database diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp index c94903cc61d7..a0ade55d6b27 100644 --- a/src/app/qgsbookmarks.cpp +++ b/src/app/qgsbookmarks.cpp @@ -226,7 +226,7 @@ void QgsBookmarks::zoomToBookmark() QString xmax = QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 2 ) ); QString ymax = QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 3 ) ); // set the extent to the bookmark - QgisApp::instance()->setExtent( QgsRect( xmin.toDouble(), + QgisApp::instance()->setExtent( QgsRectangle( xmin.toDouble(), ymin.toDouble(), xmax.toDouble(), ymax.toDouble() ) ); diff --git a/src/app/qgsgraduatedsymboldialog.cpp b/src/app/qgsgraduatedsymboldialog.cpp index eb98eebb3660..e52ee5e41e69 100644 --- a/src/app/qgsgraduatedsymboldialog.cpp +++ b/src/app/qgsgraduatedsymboldialog.cpp @@ -516,7 +516,7 @@ int QgsGraduatedSymbolDialog::quantilesFromVectorLayer( std::list& resul double currentValue; int index = 0; - provider->select( attList, QgsRect(), false ); + provider->select( attList, QgsRectangle(), false ); while ( provider->nextFeature( currentFeature ) ) { currentAttributeMap = currentFeature.attributeMap(); diff --git a/src/app/qgsmapserverexport.cpp b/src/app/qgsmapserverexport.cpp index da74bbe5f831..77d1951486c8 100644 --- a/src/app/qgsmapserverexport.cpp +++ b/src/app/qgsmapserverexport.cpp @@ -21,7 +21,7 @@ email : sherman at mrcc.com #include "qgshelpviewer.h" #include "qgsmapcanvas.h" #include "qgsmaplayer.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsvectorlayer.h" #include "qgsvectordataprovider.h" @@ -166,9 +166,9 @@ void QgsMapserverExport::writeMapFile() // extent mapFile << "\n# Extent based on full extent of QGIS view" << std::endl; mapFile << "EXTENT "; - QgsRect extent = map->extent(); - mapFile << extent.xMin() << " " << extent.yMin() << " "; - mapFile << extent.xMax() << " " << extent.yMax() << std::endl; + QgsRectangle extent = map->extent(); + mapFile << extent.xMinimum() << " " << extent.yMinimum() << " "; + mapFile << extent.xMaximum() << " " << extent.yMaximum() << std::endl; // units mapFile << "UNITS " << cmbMapUnits->currentText().toLocal8Bit().data() << std::endl; // image info diff --git a/src/app/qgsmaptoolidentify.cpp b/src/app/qgsmaptoolidentify.cpp index e92c864e56f0..b4488200154b 100644 --- a/src/app/qgsmaptoolidentify.cpp +++ b/src/app/qgsmaptoolidentify.cpp @@ -176,18 +176,18 @@ void QgsMapToolIdentify::identifyRasterWmsLayer( const QgsPoint& point ) //if WMS layer does not cover the view origin, //we need to map the view pixel coordinates //to WMS layer pixel coordinates - QgsRect viewExtent = mCanvas->extent(); + QgsRectangle viewExtent = mCanvas->extent(); double mapUnitsPerPixel = mCanvas->mapUnitsPerPixel(); if ( mapUnitsPerPixel == 0 ) { return; } - double xMinView = viewExtent.xMin(); - double yMaxView = viewExtent.yMax(); + double xMinView = viewExtent.xMinimum(); + double yMaxView = viewExtent.yMaximum(); - QgsRect layerExtent = layer->extent(); - double xMinLayer = layerExtent.xMin(); - double yMaxLayer = layerExtent.yMax(); + QgsRectangle layerExtent = layer->extent(); + double xMinLayer = layerExtent.xMinimum(); + double yMaxLayer = layerExtent.yMaximum(); double i, j; @@ -258,7 +258,7 @@ void QgsMapToolIdentify::identifyVectorLayer( const QgsPoint& point ) // create the search rectangle double searchRadius = mCanvas->extent().width() * ( identifyValue / 100.0 ); - QgsRect r; + QgsRectangle r; r.setXMinimum( point.x() - searchRadius ); r.setXMaximum( point.x() + searchRadius ); r.setYMinimum( point.y() - searchRadius ); diff --git a/src/app/qgsmaptoolmovefeature.cpp b/src/app/qgsmaptoolmovefeature.cpp index 1aa7ec074fac..d49857885d40 100644 --- a/src/app/qgsmaptoolmovefeature.cpp +++ b/src/app/qgsmaptoolmovefeature.cpp @@ -72,7 +72,7 @@ void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e ) QgsPoint layerCoords = toLayerCoordinates(( QgsMapLayer* )vlayer, e->pos() ); QSettings settings; double searchRadius = settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble(); - QgsRect selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, + QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); vlayer->select( QgsAttributeList(), selectRect, true ); diff --git a/src/app/qgsmaptoolselect.cpp b/src/app/qgsmaptoolselect.cpp index c6e0ea21fb89..34d51d709447 100644 --- a/src/app/qgsmaptoolselect.cpp +++ b/src/app/qgsmaptoolselect.cpp @@ -112,7 +112,7 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e ) QgsPoint ll = transform->toMapCoordinates( mSelectRect.left(), mSelectRect.bottom() ); QgsPoint ur = transform->toMapCoordinates( mSelectRect.right(), mSelectRect.top() ); - QgsRect search( ll.x(), ll.y(), ur.x(), ur.y() ); + QgsRectangle search( ll.x(), ll.y(), ur.x(), ur.y() ); // if Ctrl key is pressed, selected features will be added to selection // instead of removing old selection diff --git a/src/app/qgssearchquerybuilder.cpp b/src/app/qgssearchquerybuilder.cpp index ebdb0c513d9c..b394d69f399a 100644 --- a/src/app/qgssearchquerybuilder.cpp +++ b/src/app/qgssearchquerybuilder.cpp @@ -108,7 +108,7 @@ void QgsSearchQueryBuilder::getFieldValues( int limit ) QgsAttributeList attrs; attrs.append( fieldIndex ); - provider->select( attrs, QgsRect(), false ); + provider->select( attrs, QgsRectangle(), false ); lstValues->setCursor( Qt::WaitCursor ); // Block for better performance @@ -195,7 +195,7 @@ long QgsSearchQueryBuilder::countRecords( QString searchString ) const QgsFieldMap& fields = provider->fields(); QgsAttributeList allAttributes = provider->attributeIndexes(); - provider->select( allAttributes, QgsRect(), false ); + provider->select( allAttributes, QgsRectangle(), false ); while ( provider->nextFeature( feat ) ) { diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 172b6b78c581..f3d1f7a629ce 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -719,7 +719,7 @@ QString QgsVectorLayerProperties::metadata() //------------- - QgsRect myExtent = layer->extent(); + QgsRectangle myExtent = layer->extent(); myMetadata += ""; myMetadata += tr( "Extents:" ); myMetadata += ""; @@ -727,13 +727,13 @@ QString QgsVectorLayerProperties::metadata() myMetadata += ""; myMetadata += tr( "In layer spatial reference system units : " ) + tr( "xMin,yMin " ) + - QString::number( myExtent.xMin() ) + + QString::number( myExtent.xMinimum() ) + "," + - QString::number( myExtent.yMin() ) + + QString::number( myExtent.yMinimum() ) + tr( " : xMax,yMax " ) + - QString::number( myExtent.xMax() ) + + QString::number( myExtent.xMaximum() ) + "," + - QString::number( myExtent.yMax() ); + QString::number( myExtent.yMaximum() ); myMetadata += ""; //extents in project cs @@ -742,17 +742,17 @@ QString QgsVectorLayerProperties::metadata() { /* // TODO: currently disabled, will revisit later [MD] - QgsRect myProjectedExtent = coordinateTransform->transformBoundingBox(layer->extent()); + QgsRectangle myProjectedExtent = coordinateTransform->transformBoundingBox(layer->extent()); myMetadata += ""; myMetadata += tr("In project spatial reference system units : ") + tr("xMin,yMin ") + - QString::number(myProjectedExtent.xMin()) + + QString::number(myProjectedExtent.xMinimum()) + "," + - QString::number( myProjectedExtent.yMin()) + + QString::number( myProjectedExtent.yMinimum()) + tr(" : xMax,yMax ") + - QString::number(myProjectedExtent.xMax()) + + QString::number(myProjectedExtent.xMaximum()) + "," + - QString::number(myProjectedExtent.yMax()); + QString::number(myProjectedExtent.yMaximum()); myMetadata += ""; */ diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a9e7806f7592..50209cff0e94 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -37,7 +37,7 @@ SET(QGIS_CORE_SRCS qgsproviderregistry.cpp qgsrasterdataprovider.cpp qgsrendercontext.cpp - qgsrect.cpp + qgsrectangle.cpp qgsrunprocess.cpp qgsscalecalculator.cpp qgssearchstring.cpp @@ -265,7 +265,7 @@ qgsproviderextentcalcevent.h qgsprovidermetadata.h qgsproviderregistry.h qgsrasterdataprovider.h -qgsrect.h +qgsrectangle.h qgsrendercontext.h qgsrunprocess.h qgsscalecalculator.h diff --git a/src/core/composer/qgscomposeritem.cpp b/src/core/composer/qgscomposeritem.cpp index 3775d0538476..f3f8a76d7c07 100644 --- a/src/core/composer/qgscomposeritem.cpp +++ b/src/core/composer/qgscomposeritem.cpp @@ -24,7 +24,7 @@ #include "qgscomposeritem.h" #include -#include "qgsrect.h" //just for debugging +#include "qgsrectangle.h" //just for debugging #include "qgslogger.h" #define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter diff --git a/src/core/composer/qgscomposermap.cpp b/src/core/composer/qgscomposermap.cpp index 094f5759a8c0..ac60ef55380d 100644 --- a/src/core/composer/qgscomposermap.cpp +++ b/src/core/composer/qgscomposermap.cpp @@ -90,7 +90,7 @@ QgsComposerMap::~QgsComposerMap() /* This function is called by paint() and cache() to render the map. It does not override any functions from QGraphicsItem. */ -void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize& size, int dpi ) +void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const QSize& size, int dpi ) { if ( !painter ) { @@ -156,7 +156,7 @@ void QgsComposerMap::cache( void ) double mapUnitsPerPixel = mExtent.width() / w; // WARNING: ymax in QgsMapToPixel is device height!!! - QgsMapToPixel transform( mapUnitsPerPixel, h, mExtent.yMin(), mExtent.xMin() ); + QgsMapToPixel transform( mapUnitsPerPixel, h, mExtent.yMinimum(), mExtent.xMinimum() ); mCachePixmap.fill( QColor( 255, 255, 255 ) ); @@ -270,10 +270,10 @@ void QgsComposerMap::moveContent( double dx, double dy ) double xMoveMapCoord = mExtent.width() * xRatio; double yMoveMapCoord = -( mExtent.height() * yRatio ); - mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord ); - mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord ); - mExtent.setYMinimum( mExtent.yMin() + yMoveMapCoord ); - mExtent.setYMaximum( mExtent.yMax() + yMoveMapCoord ); + mExtent.setXMinimum( mExtent.xMinimum() + xMoveMapCoord ); + mExtent.setXMaximum( mExtent.xMaximum() + xMoveMapCoord ); + mExtent.setYMinimum( mExtent.yMinimum() + yMoveMapCoord ); + mExtent.setYMaximum( mExtent.yMaximum() + yMoveMapCoord ); emit extentChanged(); cache(); update(); @@ -295,14 +295,14 @@ void QgsComposerMap::zoomContent( int delta, double x, double y ) double zoomFactor = settings.value( "/qgis/zoom_factor", 2.0 ).toDouble(); //find out new center point - double centerX = ( mExtent.xMax() + mExtent.xMin() ) / 2; - double centerY = ( mExtent.yMax() + mExtent.yMin() ) / 2; + double centerX = ( mExtent.xMaximum() + mExtent.xMinimum() ) / 2; + double centerY = ( mExtent.yMaximum() + mExtent.yMinimum() ) / 2; if ( zoomMode != 0 ) { //find out map coordinates of mouse position - double mapMouseX = mExtent.xMin() + ( x / rect().width() ) * ( mExtent.xMax() - mExtent.xMin() ); - double mapMouseY = mExtent.yMin() + ( 1 - ( y / rect().height() ) ) * ( mExtent.yMax() - mExtent.yMin() ); + double mapMouseX = mExtent.xMinimum() + ( x / rect().width() ) * ( mExtent.xMaximum() - mExtent.xMinimum() ); + double mapMouseY = mExtent.yMinimum() + ( 1 - ( y / rect().height() ) ) * ( mExtent.yMaximum() - mExtent.yMinimum() ); if ( zoomMode == 1 ) //zoom and recenter { centerX = mapMouseX; @@ -319,13 +319,13 @@ void QgsComposerMap::zoomContent( int delta, double x, double y ) if ( delta > 0 ) { - newIntervalX = ( mExtent.xMax() - mExtent.xMin() ) / zoomFactor; - newIntervalY = ( mExtent.yMax() - mExtent.yMin() ) / zoomFactor; + newIntervalX = ( mExtent.xMaximum() - mExtent.xMinimum() ) / zoomFactor; + newIntervalY = ( mExtent.yMaximum() - mExtent.yMinimum() ) / zoomFactor; } else if ( delta < 0 ) { - newIntervalX = ( mExtent.xMax() - mExtent.xMin() ) * zoomFactor; - newIntervalY = ( mExtent.yMax() - mExtent.yMin() ) * zoomFactor; + newIntervalX = ( mExtent.xMaximum() - mExtent.xMinimum() ) * zoomFactor; + newIntervalY = ( mExtent.yMaximum() - mExtent.yMinimum() ) * zoomFactor; } else //no need to zoom { @@ -352,14 +352,14 @@ void QgsComposerMap::setSceneRect( const QRectF& rectangle ) //QGraphicsRectItem::update(); double newHeight = mExtent.width() * h / w ; - mExtent = QgsRect( mExtent.xMin(), mExtent.yMin(), mExtent.xMax(), mExtent.yMin() + newHeight ); + mExtent = QgsRectangle( mExtent.xMinimum(), mExtent.yMinimum(), mExtent.xMaximum(), mExtent.yMinimum() + newHeight ); mCacheUpdated = false; emit extentChanged(); cache(); update(); } -void QgsComposerMap::setNewExtent( const QgsRect& extent ) +void QgsComposerMap::setNewExtent( const QgsRectangle& extent ) { if ( mExtent == extent ) { @@ -386,10 +386,10 @@ void QgsComposerMap::setNewScale( double scaleDenominator ) double scaleRatio = scaleDenominator / currentScaleDenominator; - double newXMax = mExtent.xMin() + scaleRatio * ( mExtent.xMax() - mExtent.xMin() ); - double newYMax = mExtent.yMin() + scaleRatio * ( mExtent.yMax() - mExtent.yMin() ); + double newXMax = mExtent.xMinimum() + scaleRatio * ( mExtent.xMaximum() - mExtent.xMinimum() ); + double newYMax = mExtent.yMinimum() + scaleRatio * ( mExtent.yMaximum() - mExtent.yMinimum() ); - QgsRect newExtent( mExtent.xMin(), mExtent.yMin(), newXMax, newYMax ); + QgsRectangle newExtent( mExtent.xMinimum(), mExtent.yMinimum(), newXMax, newYMax ); mExtent = newExtent; mCacheUpdated = false; emit extentChanged(); @@ -491,10 +491,10 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) //extent QDomElement extentElem = doc.createElement( "Extent" ); - extentElem.setAttribute( "xmin", QString::number( mExtent.xMin() ) ); - extentElem.setAttribute( "xmax", QString::number( mExtent.xMax() ) ); - extentElem.setAttribute( "ymin", QString::number( mExtent.yMin() ) ); - extentElem.setAttribute( "ymax", QString::number( mExtent.yMax() ) ); + extentElem.setAttribute( "xmin", QString::number( mExtent.xMinimum() ) ); + extentElem.setAttribute( "xmax", QString::number( mExtent.xMaximum() ) ); + extentElem.setAttribute( "ymin", QString::number( mExtent.yMinimum() ) ); + extentElem.setAttribute( "ymax", QString::number( mExtent.yMaximum() ) ); composerMapElem.appendChild( extentElem ); mCacheUpdated = false; @@ -539,7 +539,7 @@ bool QgsComposerMap::readXML( const QDomElement& itemElem, const QDomDocument& d ymin = extentElem.attribute( "ymin" ).toDouble(); ymax = extentElem.attribute( "ymax" ).toDouble(); - mExtent = QgsRect( xmin, ymin, xmax, ymax ); + mExtent = QgsRectangle( xmin, ymin, xmax, ymax ); } mDrawing = false; diff --git a/src/core/composer/qgscomposermap.h b/src/core/composer/qgscomposermap.h index 70d970279a88..bc37b923050f 100644 --- a/src/core/composer/qgscomposermap.h +++ b/src/core/composer/qgscomposermap.h @@ -19,7 +19,7 @@ //#include "ui_qgscomposermapbase.h" #include "qgscomposeritem.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include #include #include @@ -62,7 +62,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB @param extent map extent @param size size in scene coordinates @param dpi scene dpi*/ - void draw( QPainter *painter, const QgsRect& extent, const QSize& size, int dpi ); + void draw( QPainter *painter, const QgsRectangle& extent, const QSize& size, int dpi ); /** \brief Reimplementation of QCanvasItem::paint - draw on canvas */ void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); @@ -103,7 +103,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB void setNewScale( double scaleDenominator ); /**Sets new Extent and changes width, height (and implicitely also scale)*/ - void setNewExtent( const QgsRect& extent ); + void setNewExtent( const QgsRectangle& extent ); PreviewMode previewMode() {return mPreviewMode;} void setPreviewMode( PreviewMode m ) {mPreviewMode = m;} @@ -111,7 +111,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB // Set cache outdated void setCacheUpdated( bool u = false ); - QgsRect extent() const {return mExtent;} + QgsRectangle extent() const {return mExtent;} const QgsMapRenderer* mapRenderer() const {return mMapRenderer;} @@ -153,7 +153,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB // Map region in map units realy used for rendering // It can be the same as mUserExtent, but it can be bigger in on dimension if mCalculate==Scale, // so that full rectangle in paper is used. - QgsRect mExtent; + QgsRectangle mExtent; // Cache used in composer preview // NOTE: QCanvasView is slow with bigger images but the spped does not decrease with image size. @@ -177,7 +177,7 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapB double mLastScaleFactorX; /**Store the last map extent to decide if cache needs to be updatet*/ - QgsRect mCachedMapExtent; + QgsRectangle mCachedMapExtent; /**Offset in x direction for showing map cache image*/ double mXOffset; diff --git a/src/core/composer/qgscomposerscalebar.cpp b/src/core/composer/qgscomposerscalebar.cpp index 139f320ff023..df006008c968 100644 --- a/src/core/composer/qgscomposerscalebar.cpp +++ b/src/core/composer/qgscomposerscalebar.cpp @@ -21,7 +21,7 @@ #include "qgsnumericscalebarstyle.h" #include "qgssingleboxscalebarstyle.h" #include "qgsticksscalebarstyle.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include #include #include @@ -97,7 +97,7 @@ void QgsComposerScaleBar::refreshSegmentMillimeters() if ( mComposerMap ) { //get extent of composer map - QgsRect composerMapRect = mComposerMap->extent(); + QgsRectangle composerMapRect = mComposerMap->extent(); //get mm dimension of composer map QRectF composerItemRect = mComposerMap->rect(); @@ -135,7 +135,7 @@ void QgsComposerScaleBar::applyDefaultSettings() { //calculate mNumUnitsPerSegment QRectF composerItemRect = mComposerMap->rect(); - QgsRect composerMapRect = mComposerMap->extent(); + QgsRectangle composerMapRect = mComposerMap->extent(); double proposedScaleBarLength = composerMapRect.width() / 4; int powerOf10 = int ( pow( 10.0, int ( log( proposedScaleBarLength ) / log( 10.0 ) ) ) ); // from scalebar plugin diff --git a/src/core/qgscoordinatetransform.cpp b/src/core/qgscoordinatetransform.cpp index 02d467a27cd6..7a10bb9b0dba 100644 --- a/src/core/qgscoordinatetransform.cpp +++ b/src/core/qgscoordinatetransform.cpp @@ -248,14 +248,14 @@ QgsPoint QgsCoordinateTransform::transform( const double theX, const double theY } } -QgsRect QgsCoordinateTransform::transform( const QgsRect theRect, TransformDirection direction ) const +QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, TransformDirection direction ) const { if ( mShortCircuit || !mInitialisedFlag ) return theRect; // transform x - double x1 = theRect.xMin(); - double y1 = theRect.yMin(); - double x2 = theRect.xMax(); - double y2 = theRect.yMax(); + double x1 = theRect.xMinimum(); + double y1 = theRect.yMinimum(); + double x2 = theRect.xMaximum(); + double y2 = theRect.yMaximum(); // Number of points to reproject------+ // | @@ -275,16 +275,16 @@ QgsRect QgsCoordinateTransform::transform( const QgsRect theRect, TransformDirec #ifdef QGISDEBUG QgsDebugMsg( "Rect projection..." ); - QgsLogger::debug( "Xmin : ", theRect.xMin(), 1, __FILE__, __FUNCTION__, __LINE__ ); + QgsLogger::debug( "Xmin : ", theRect.xMinimum(), 1, __FILE__, __FUNCTION__, __LINE__ ); QgsLogger::debug( "-->", x1, 1, __FILE__, __FUNCTION__, __LINE__ ); - QgsLogger::debug( "Ymin : ", theRect.yMin(), 1, __FILE__, __FUNCTION__, __LINE__ ); + QgsLogger::debug( "Ymin : ", theRect.yMinimum(), 1, __FILE__, __FUNCTION__, __LINE__ ); QgsLogger::debug( "-->", y1, 1, __FILE__, __FUNCTION__, __LINE__ ); - QgsLogger::debug( "Xmax : ", theRect.xMax(), 1, __FILE__, __FUNCTION__, __LINE__ ); + QgsLogger::debug( "Xmax : ", theRect.xMaximum(), 1, __FILE__, __FUNCTION__, __LINE__ ); QgsLogger::debug( "-->", x2, 1, __FILE__, __FUNCTION__, __LINE__ ); - QgsLogger::debug( "Ymax : ", theRect.yMax(), 1, __FILE__, __FUNCTION__, __LINE__ ); + QgsLogger::debug( "Ymax : ", theRect.yMaximum(), 1, __FILE__, __FUNCTION__, __LINE__ ); QgsLogger::debug( "-->", y2, 1, __FILE__, __FUNCTION__, __LINE__ ); #endif - return QgsRect( x1, y1, x2, y2 ); + return QgsRectangle( x1, y1, x2, y2 ); } void QgsCoordinateTransform::transformInPlace( double& x, double& y, double& z, @@ -335,9 +335,9 @@ void QgsCoordinateTransform::transformInPlace( std::vector& x, } -QgsRect QgsCoordinateTransform::transformBoundingBox( const QgsRect rect, TransformDirection direction ) const +QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle rect, TransformDirection direction ) const { - // Calculate the bounding box of a QgsRect in the source CRS + // Calculate the bounding box of a QgsRectangle in the source CRS // when projected to the destination CRS (or the inverse). // This is done by looking at a number of points spread evenly // across the rectangle @@ -347,7 +347,7 @@ QgsRect QgsCoordinateTransform::transformBoundingBox( const QgsRect rect, Transf static const int numP = 8; - QgsRect bb_rect; + QgsRectangle bb_rect; bb_rect.setMinimal(); // We're interfacing with C-style vectors in the @@ -364,13 +364,13 @@ QgsRect QgsCoordinateTransform::transformBoundingBox( const QgsRect rect, Transf double dx = rect.width() / ( double )( numP - 1 ); double dy = rect.height() / ( double )( numP - 1 ); - double pointY = rect.yMin(); + double pointY = rect.yMinimum(); for ( int i = 0; i < numP ; i++ ) { // Start at right edge - double pointX = rect.xMin(); + double pointX = rect.xMinimum(); for ( int j = 0; j < numP; j++ ) { diff --git a/src/core/qgscoordinatetransform.h b/src/core/qgscoordinatetransform.h index 437ebf3d39ce..9e7b5f161134 100644 --- a/src/core/qgscoordinatetransform.h +++ b/src/core/qgscoordinatetransform.h @@ -23,7 +23,7 @@ //qgis includes #include "qgspoint.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgscsexception.h" #include "qgscoordinatereferencesystem.h" class QDomNode; @@ -138,17 +138,17 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject */ QgsPoint transform( const double x, const double y, TransformDirection direction = ForwardTransform ) const; - /*! Transform a QgsRect to the dest Coordinate system + /*! Transform a QgsRectangle to the dest Coordinate system * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, * otherwise points are transformed from map canvas CS to layerCS. * It assumes that rect is a bounding box, and creates a bounding box * in the proejcted CS, so that all points in source rectangle is within * returned rectangle. - * @param QgsRect rect to transform + * @param QgsRectangle rect to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ - QgsRect transformBoundingBox( const QgsRect theRect, TransformDirection direction = ForwardTransform ) const; + QgsRectangle transformBoundingBox( const QgsRectangle theRect, TransformDirection direction = ForwardTransform ) const; // Same as for the other transform() functions, but alters the x // and y variables in place. The second one works with good old-fashioned @@ -158,14 +158,14 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject void transformInPlace( std::vector& x, std::vector& y, std::vector& z, TransformDirection direction = ForwardTransform ) const; - /*! Transform a QgsRect to the dest Coordinate system + /*! Transform a QgsRectangle to the dest Coordinate system * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, * otherwise points are transformed from map canvas CS to layerCS. - * @param QgsRect rect to transform + * @param QgsRectangle rect to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ - QgsRect transform( const QgsRect theRect, TransformDirection direction = ForwardTransform ) const; + QgsRectangle transform( const QgsRectangle theRect, TransformDirection direction = ForwardTransform ) const; /*! Transform an array of coordinates to a different Coordinate System * If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS, @@ -173,7 +173,7 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject * @param x x cordinate of point to transform * @param y y coordinate of point to transform * @param direction TransformDirection (defaults to ForwardTransform) - * @return QgsRect in Destination Coordinate System + * @return QgsRectangle in Destination Coordinate System */ void transformCoords( const int &numPoint, double *x, double *y, double *z, TransformDirection direction = ForwardTransform ) const; diff --git a/src/core/qgsdataprovider.h b/src/core/qgsdataprovider.h index 290edd40c55e..f4e27820f8a0 100644 --- a/src/core/qgsdataprovider.h +++ b/src/core/qgsdataprovider.h @@ -22,7 +22,7 @@ #include #include -class QgsRect; +class QgsRectangle; class QgsCoordinateReferenceSystem; @@ -86,9 +86,9 @@ class CORE_EXPORT QgsDataProvider : public QObject /** * Get the extent of the layer - * @return QgsRect containing the extent of the layer + * @return QgsRectangle containing the extent of the layer */ - virtual QgsRect extent() = 0; + virtual QgsRectangle extent() = 0; /** diff --git a/src/core/qgsfeature.cpp b/src/core/qgsfeature.cpp index 9d0095b78272..e12208167182 100644 --- a/src/core/qgsfeature.cpp +++ b/src/core/qgsfeature.cpp @@ -16,7 +16,7 @@ email : sherman at mrcc.com #include "qgsfeature.h" #include "qgsgeometry.h" -#include "qgsrect.h" +#include "qgsrectangle.h" /** \class QgsFeature * \brief Encapsulates a spatial feature with attributes diff --git a/src/core/qgsfeature.h b/src/core/qgsfeature.h index 46ec3bbf733d..c5c5e2a2a74e 100644 --- a/src/core/qgsfeature.h +++ b/src/core/qgsfeature.h @@ -23,7 +23,7 @@ email : sherman at mrcc.com #include class QgsGeometry; -class QgsRect; +class QgsRectangle; class QgsFeature; // key = field index, value = field value diff --git a/src/core/qgsgeometry.cpp b/src/core/qgsgeometry.cpp index 8e93aedce7d8..c08321dc1391 100644 --- a/src/core/qgsgeometry.cpp +++ b/src/core/qgsgeometry.cpp @@ -23,7 +23,7 @@ email : morb at ozemail dot com dot au #include "qgsapplication.h" #include "qgslogger.h" #include "qgspoint.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgslogger.h" #define DEFAULT_QUADRANT_SEGMENTS 8 @@ -491,14 +491,14 @@ QgsGeometry* QgsGeometry::fromMultiPolygon( const QgsMultiPolygon& multipoly ) } } -QgsGeometry* QgsGeometry::fromRect( const QgsRect& rect ) +QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect ) { QgsPolyline ring; - ring.append( QgsPoint( rect.xMin(), rect.yMin() ) ); - ring.append( QgsPoint( rect.xMax(), rect.yMin() ) ); - ring.append( QgsPoint( rect.xMax(), rect.yMax() ) ); - ring.append( QgsPoint( rect.xMin(), rect.yMax() ) ); - ring.append( QgsPoint( rect.xMin(), rect.yMin() ) ); + ring.append( QgsPoint( rect.xMinimum(), rect.yMinimum() ) ); + ring.append( QgsPoint( rect.xMaximum(), rect.yMinimum() ) ); + ring.append( QgsPoint( rect.xMaximum(), rect.yMaximum() ) ); + ring.append( QgsPoint( rect.xMinimum(), rect.yMaximum() ) ); + ring.append( QgsPoint( rect.xMinimum(), rect.yMinimum() ) ); QgsPolygon polygon; polygon.append( ring ); @@ -3258,7 +3258,7 @@ int QgsGeometry::makeDifference( QgsGeometry* other ) return 0; } -QgsRect QgsGeometry::boundingBox() +QgsRectangle QgsGeometry::boundingBox() { double xmin = std::numeric_limits::max(); double ymin = std::numeric_limits::max(); @@ -3287,7 +3287,7 @@ QgsRect QgsGeometry::boundingBox() if ( !mGeometry ) { QgsDebugMsg( "WKB geometry not available!" ); - return QgsRect( 0, 0, 0, 0 ); + return QgsRectangle( 0, 0, 0, 0 ); } // consider endian when fetching feature type //wkbType = (mGeometry[0] == 1) ? mGeometry[1] : mGeometry[4]; //MH: Does not work for 25D geometries @@ -3530,14 +3530,14 @@ QgsRect QgsGeometry::boundingBox() default: QgsDebugMsg( "Unknown WkbType ENCOUNTERED" ); - return QgsRect( 0, 0, 0, 0 ); + return QgsRectangle( 0, 0, 0, 0 ); break; } - return QgsRect( xmin, ymin, xmax, ymax ); + return QgsRectangle( xmin, ymin, xmax, ymax ); } -bool QgsGeometry::intersects( const QgsRect& r ) +bool QgsGeometry::intersects( const QgsRectangle& r ) { QgsGeometry* g = fromRect( r ); bool res = intersects( g ); diff --git a/src/core/qgsgeometry.h b/src/core/qgsgeometry.h index aaa544d52604..7e2209f5c1c5 100644 --- a/src/core/qgsgeometry.h +++ b/src/core/qgsgeometry.h @@ -47,7 +47,7 @@ typedef QVector QgsMultiPolyline; /** a collection of QgsPolygons that share a common collection of attributes */ typedef QVector QgsMultiPolygon; -class QgsRect; +class QgsRectangle; /** \ingroup core * A geometry is the spatial representation of a feature. @@ -95,7 +95,7 @@ class CORE_EXPORT QgsGeometry /** construct geometry from a multipolygon */ static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly ); /** construct geometry from a rectangle */ - static QgsGeometry* fromRect( const QgsRect& rect ); + static QgsGeometry* fromRect( const QgsRectangle& rect ); /** Set the geometry, feeding in a geometry in GEOS format. This class will take ownership of the buffer. @@ -256,10 +256,10 @@ class CORE_EXPORT QgsGeometry int makeDifference( QgsGeometry* other ); /**Returns the bounding box of this feature*/ - QgsRect boundingBox(); + QgsRectangle boundingBox(); /** Test for intersection with a rectangle (uses GEOS) */ - bool intersects( const QgsRect& r ); + bool intersects( const QgsRectangle& r ); /** Test for intersection with a geoemetry (uses GEOS) */ bool intersects( QgsGeometry* geometry ); diff --git a/src/core/qgslabel.cpp b/src/core/qgslabel.cpp index ada05c46d39c..5eb3b34a2cf6 100644 --- a/src/core/qgslabel.cpp +++ b/src/core/qgslabel.cpp @@ -30,7 +30,7 @@ #include "qgsgeometry.h" #include "qgsfield.h" #include "qgslogger.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsmaptopixel.h" #include "qgscoordinatetransform.h" @@ -82,7 +82,7 @@ QString QgsLabel::fieldValue( int attr, QgsFeature &feature ) } } -void QgsLabel::renderLabel( QPainter * painter, const QgsRect& viewExtent, +void QgsLabel::renderLabel( QPainter * painter, const QgsRectangle& viewExtent, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel *transform, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes, diff --git a/src/core/qgslabel.h b/src/core/qgslabel.h index b84997a8655d..32a8f4e48093 100644 --- a/src/core/qgslabel.h +++ b/src/core/qgslabel.h @@ -32,7 +32,7 @@ class QgsPoint; class QgsFeature; class QgsField; class QgsLabelAttributes; -class QgsRect; +class QgsRectangle; class QgsMapToPixel; class QgsCoordinateTransform; @@ -85,7 +85,7 @@ class CORE_EXPORT QgsLabel /** \brief render label * \param sizeScale global scale factor for size in pixels, labels in map units are not scaled */ - void renderLabel( QPainter* painter, const QgsRect& viewExtent, + void renderLabel( QPainter* painter, const QgsRectangle& viewExtent, const QgsCoordinateTransform* coordinateTransform, const QgsMapToPixel *transform, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0, double sizeScale = 1., double rasterScaleFactor = 1.0); diff --git a/src/core/qgsmaplayer.cpp b/src/core/qgsmaplayer.cpp index 9228a6a962cf..159dbfb228d6 100644 --- a/src/core/qgsmaplayer.cpp +++ b/src/core/qgsmaplayer.cpp @@ -32,7 +32,7 @@ #include #include "qgslogger.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgssymbol.h" #include "qgsmaplayer.h" #include "qgscoordinatereferencesystem.h" @@ -123,7 +123,7 @@ QString const & QgsMapLayer::source() const return mDataSource; } -QgsRect QgsMapLayer::extent() const +QgsRectangle QgsMapLayer::extent() const { return mLayerExtent; } diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h index b2c7cc6026f4..d2e53ba97dc6 100644 --- a/src/core/qgsmaplayer.h +++ b/src/core/qgsmaplayer.h @@ -24,7 +24,7 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" class QgsRenderContext; class QgsCoordinateReferenceSystem; @@ -85,7 +85,7 @@ class CORE_EXPORT QgsMapLayer : public QObject virtual void drawLabels( QgsRenderContext& rendererContext ); /** Return the extent of the layer as a QRect */ - QgsRect extent() const; + QgsRectangle extent() const; /*! Return the status of the layer. An invalid layer is one which has a bad datasource * or other problem. Child classes set this flag when intialized @@ -318,7 +318,7 @@ class CORE_EXPORT QgsMapLayer : public QObject unsigned int mTransparencyLevel; /** Extent of the layer */ - QgsRect mLayerExtent; + QgsRectangle mLayerExtent; /** Indicates if the layer is valid and can be drawn */ bool mValid; diff --git a/src/core/qgsmaprenderer.cpp b/src/core/qgsmaprenderer.cpp index 6797faa7538b..405f907aeec9 100644 --- a/src/core/qgsmaprenderer.cpp +++ b/src/core/qgsmaprenderer.cpp @@ -62,7 +62,7 @@ QgsMapRenderer::~QgsMapRenderer() } -QgsRect QgsMapRenderer::extent() const +QgsRectangle QgsMapRenderer::extent() const { return mExtent; } @@ -73,7 +73,7 @@ void QgsMapRenderer::updateScale() mScale = mScaleCalculator->calculate( mExtent, mSize.width() ); } -bool QgsMapRenderer::setExtent( const QgsRect& extent ) +bool QgsMapRenderer::setExtent( const QgsRectangle& extent ) { // Don't allow zooms where the current extent is so small that it @@ -94,8 +94,8 @@ bool QgsMapRenderer::setExtent( const QgsRect& extent ) { // Use abs() on the extent to avoid the case where the extent is // symmetrical about 0. - double xMean = ( fabs( extent.xMin() ) + fabs( extent.xMax() ) ) * 0.5; - double yMean = ( fabs( extent.yMin() ) + fabs( extent.yMax() ) ) * 0.5; + double xMean = ( fabs( extent.xMinimum() ) + fabs( extent.xMaximum() ) ) * 0.5; + double yMean = ( fabs( extent.yMinimum() ) + fabs( extent.yMaximum() ) ) * 0.5; double xRange = extent.width() / xMean; double yRange = extent.height() / yMean; @@ -155,19 +155,19 @@ void QgsMapRenderer::adjustExtentToSize() if ( mapUnitsPerPixelY > mapUnitsPerPixelX ) { - dymin = mExtent.yMin(); - dymax = mExtent.yMax(); + dymin = mExtent.yMinimum(); + dymax = mExtent.yMaximum(); whitespace = (( myWidth * mMapUnitsPerPixel ) - mExtent.width() ) * 0.5; - dxmin = mExtent.xMin() - whitespace; - dxmax = mExtent.xMax() + whitespace; + dxmin = mExtent.xMinimum() - whitespace; + dxmax = mExtent.xMaximum() + whitespace; } else { - dxmin = mExtent.xMin(); - dxmax = mExtent.xMax(); + dxmin = mExtent.xMinimum(); + dxmax = mExtent.xMaximum(); whitespace = (( myHeight * mMapUnitsPerPixel ) - mExtent.height() ) * 0.5; - dymin = mExtent.yMin() - whitespace; - dymax = mExtent.yMax() + whitespace; + dymin = mExtent.yMinimum() - whitespace; + dymax = mExtent.yMaximum() + whitespace; } #ifdef QGISDEBUG @@ -253,7 +253,7 @@ void QgsMapRenderer::render( QPainter* painter ) QListIterator li( mLayerSet ); li.toBack(); - QgsRect r1, r2; + QgsRectangle r1, r2; while ( li.hasPrevious() ) { @@ -397,7 +397,7 @@ void QgsMapRenderer::render( QPainter* painter ) if ( hasCrsTransformEnabled() ) { - QgsRect r1 = mExtent; + QgsRectangle r1 = mExtent; split = splitLayersExtent( ml, r1, r2 ); ct = new QgsCoordinateTransform( ml->srs(), *mDestCRS ); mRenderContext.setExtent( r1 ); @@ -493,7 +493,7 @@ const QgsCoordinateReferenceSystem& QgsMapRenderer::destinationSrs() } -bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRect& extent, QgsRect& r2 ) +bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRectangle& extent, QgsRectangle& r2 ) { bool split = false; @@ -504,7 +504,7 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRect& extent, Qgs QgsCoordinateTransform tr( layer->srs(), *mDestCRS ); #ifdef QGISDEBUG - // QgsLogger::debug("Getting extent of canvas in layers CS. Canvas is ", extent, __FILE__, __FUNCTION__, __LINE__); + // QgsLogger::debug("Getting extent of canvas in layers CS. Canvas is ", extent, __FILE__, __FUNCTION__, __LINE__); #endif // Split the extent into two if the source CRS is // geographic and the extent crosses the split in @@ -517,10 +517,10 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRect& extent, Qgs { // Note: ll = lower left point // and ur = upper right point - QgsPoint ll = tr.transform( extent.xMin(), extent.yMin(), + QgsPoint ll = tr.transform( extent.xMinimum(), extent.yMinimum(), QgsCoordinateTransform::ReverseTransform ); - QgsPoint ur = tr.transform( extent.xMax(), extent.yMax(), + QgsPoint ur = tr.transform( extent.xMaximum(), extent.yMaximum(), QgsCoordinateTransform::ReverseTransform ); if ( ll.x() > ur.x() ) @@ -543,15 +543,15 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRect& extent, Qgs { Q_UNUSED( cse ); QgsLogger::warning( "Transform error caught in " + QString( __FILE__ ) + ", line " + QString::number( __LINE__ ) ); - extent = QgsRect( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX ); - r2 = QgsRect( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX ); + extent = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX ); + r2 = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX ); } } return split; } -QgsRect QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRect extent ) +QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) { if ( hasCrsTransformEnabled() ) { @@ -616,7 +616,7 @@ QgsPoint QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint return point; } -QgsRect QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRect rect ) +QgsRectangle QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) { if ( hasCrsTransformEnabled() ) { @@ -641,7 +641,7 @@ void QgsMapRenderer::updateFullExtent() QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance(); // reset the map canvas extent since the extent may now be smaller - // We can't use a constructor since QgsRect normalizes the rectangle upon construction + // We can't use a constructor since QgsRectangle normalizes the rectangle upon construction mFullExtent.setMinimal(); // iterate through the map layers and test each layers extent @@ -661,7 +661,7 @@ void QgsMapRenderer::updateFullExtent() // Layer extents are stored in the coordinate system (CS) of the // layer. The extent must be projected to the canvas CS - QgsRect extent = layerExtentToOutputExtent( lyr, lyr->extent() ); + QgsRectangle extent = layerExtentToOutputExtent( lyr, lyr->extent() ); QgsDebugMsg( "Output extent: " + extent.toString() ); mFullExtent.unionRect( extent ); @@ -676,20 +676,20 @@ void QgsMapRenderer::updateFullExtent() // rectangle a bit. If they are all at zero, do something a bit // more crude. - if ( mFullExtent.xMin() == 0.0 && mFullExtent.xMax() == 0.0 && - mFullExtent.yMin() == 0.0 && mFullExtent.yMax() == 0.0 ) + if ( mFullExtent.xMinimum() == 0.0 && mFullExtent.xMaximum() == 0.0 && + mFullExtent.yMinimum() == 0.0 && mFullExtent.yMaximum() == 0.0 ) { mFullExtent.set( -1.0, -1.0, 1.0, 1.0 ); } else { const double padFactor = 1e-8; - double widthPad = mFullExtent.xMin() * padFactor; - double heightPad = mFullExtent.yMin() * padFactor; - double xmin = mFullExtent.xMin() - widthPad; - double xmax = mFullExtent.xMax() + widthPad; - double ymin = mFullExtent.yMin() - heightPad; - double ymax = mFullExtent.yMax() + heightPad; + double widthPad = mFullExtent.xMinimum() * padFactor; + double heightPad = mFullExtent.yMinimum() * padFactor; + double xmin = mFullExtent.xMinimum() - widthPad; + double xmax = mFullExtent.xMaximum() + widthPad; + double ymin = mFullExtent.yMinimum() - heightPad; + double ymax = mFullExtent.yMaximum() + heightPad; mFullExtent.set( xmin, ymin, xmax, ymax ); } } @@ -697,7 +697,7 @@ void QgsMapRenderer::updateFullExtent() QgsDebugMsg( "Full extent: " + mFullExtent.toString() ); } -QgsRect QgsMapRenderer::fullExtent() +QgsRectangle QgsMapRenderer::fullExtent() { updateFullExtent(); return mFullExtent; @@ -746,7 +746,7 @@ bool QgsMapRenderer::readXML( QDomNode & theNode ) // set extent - QgsRect aoi; + QgsRectangle aoi; QDomNode extentNode = theNode.namedItem( "extent" ); QDomNode xminNode = extentNode.namedItem( "xmin" ); @@ -824,11 +824,11 @@ bool QgsMapRenderer::writeXML( QDomNode & theNode, QDomDocument & theDoc ) QDomElement xMax = theDoc.createElement( "xmax" ); QDomElement yMax = theDoc.createElement( "ymax" ); - QgsRect r = extent(); - QDomText xMinText = theDoc.createTextNode( QString::number( r.xMin(), 'f' ) ); - QDomText yMinText = theDoc.createTextNode( QString::number( r.yMin(), 'f' ) ); - QDomText xMaxText = theDoc.createTextNode( QString::number( r.xMax(), 'f' ) ); - QDomText yMaxText = theDoc.createTextNode( QString::number( r.yMax(), 'f' ) ); + QgsRectangle r = extent(); + QDomText xMinText = theDoc.createTextNode( QString::number( r.xMinimum(), 'f' ) ); + QDomText yMinText = theDoc.createTextNode( QString::number( r.yMinimum(), 'f' ) ); + QDomText xMaxText = theDoc.createTextNode( QString::number( r.xMaximum(), 'f' ) ); + QDomText yMaxText = theDoc.createTextNode( QString::number( r.yMaximum(), 'f' ) ); xMin.appendChild( xMinText ); yMin.appendChild( yMinText ); diff --git a/src/core/qgsmaprenderer.h b/src/core/qgsmaprenderer.h index e97af9953a2c..6f97a5ac5506 100644 --- a/src/core/qgsmaprenderer.h +++ b/src/core/qgsmaprenderer.h @@ -21,7 +21,7 @@ #include #include "qgis.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsrendercontext.h" class QDomDocument; @@ -62,10 +62,10 @@ class CORE_EXPORT QgsMapRenderer : public QObject void render( QPainter* painter ); //! sets extent and checks whether suitable (returns false if not) - bool setExtent( const QgsRect& extent ); + bool setExtent( const QgsRectangle& extent ); //! returns current extent - QgsRect extent() const; + QgsRectangle extent() const; const QgsMapToPixel* coordinateTransform() { return &( mRenderContext.mapToPixel() ); } @@ -97,7 +97,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject QSize outputSize(); //! transform extent in layer's CRS to extent in output CRS - QgsRect layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRect extent ); + QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ); //! transform coordinates from layer's CRS to output CRS QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ); @@ -106,7 +106,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ); //! transform rect's coordinates from output CRS to layer's CRS - QgsRect mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRect rect ); + QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ); //! sets whether to use projections for this layer set void setProjectionsEnabled( bool enabled ); @@ -125,7 +125,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject OutputUnits outputUnits() const {return mOutputUnits;} //! returns current extent of layer set - QgsRect fullExtent(); + QgsRectangle fullExtent(); //! returns current layer set QStringList& layerSet(); @@ -176,7 +176,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject * source CRS coordinates, and if it was split, returns true, and * also sets the contents of the r2 parameter */ - bool splitLayersExtent( QgsMapLayer* layer, QgsRect& extent, QgsRect& r2 ); + bool splitLayersExtent( QgsMapLayer* layer, QgsRectangle& extent, QgsRectangle& r2 ); protected: @@ -193,7 +193,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject QgsScaleCalculator * mScaleCalculator; //! current extent to be drawn - QgsRect mExtent; + QgsRectangle mExtent; //! indicates whether it's map image for overview bool mOverview; @@ -210,7 +210,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject QStringList mLayerSet; //! full extent of the layer set - QgsRect mFullExtent; + QgsRectangle mFullExtent; //! tool for measuring QgsDistanceArea* mDistArea; diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index 7508f91b8332..29cc15c368e1 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -23,7 +23,7 @@ #include #include "qgslogger.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsvectorlayer.h" #include "qgsrasterlayer.h" #include "qgsmaplayerregistry.h" diff --git a/src/core/qgsproviderextentcalcevent.cpp b/src/core/qgsproviderextentcalcevent.cpp index f809641746c2..34736cae13eb 100644 --- a/src/core/qgsproviderextentcalcevent.cpp +++ b/src/core/qgsproviderextentcalcevent.cpp @@ -20,7 +20,7 @@ #include "qgsproviderextentcalcevent.h" #include "qgis.h" -QgsProviderExtentCalcEvent::QgsProviderExtentCalcEvent( QgsRect* layerExtent ) +QgsProviderExtentCalcEvent::QgsProviderExtentCalcEvent( QgsRectangle* layerExtent ) : QEvent( static_cast( QGis::ProviderExtentCalcEvent ) ), le( layerExtent ) { @@ -28,7 +28,7 @@ QgsProviderExtentCalcEvent::QgsProviderExtentCalcEvent( QgsRect* layerExtent ) } -QgsRect* QgsProviderExtentCalcEvent::layerExtent() const +QgsRectangle* QgsProviderExtentCalcEvent::layerExtent() const { return le; } diff --git a/src/core/qgsproviderextentcalcevent.h b/src/core/qgsproviderextentcalcevent.h index 2f8c7f5a1b69..7f8e4205f83b 100644 --- a/src/core/qgsproviderextentcalcevent.h +++ b/src/core/qgsproviderextentcalcevent.h @@ -21,7 +21,7 @@ #define QGSPROVIDEREXTENTCALCEVENT_H #include -class QgsRect; +class QgsRectangle; /** \ingroup core * A custom event that is designed to be fired when a layer extent has been fully calculated. @@ -45,14 +45,14 @@ class CORE_EXPORT QgsProviderExtentCalcEvent : public QEvent public: - QgsProviderExtentCalcEvent( QgsRect* layerExtent ); + QgsProviderExtentCalcEvent( QgsRectangle* layerExtent ); - QgsRect* layerExtent() const; + QgsRectangle* layerExtent() const; private: - QgsRect* le; + QgsRectangle* le; }; diff --git a/src/core/qgsrasterdataprovider.h b/src/core/qgsrasterdataprovider.h index 8a9b7e238a1c..73255ff0b8bd 100644 --- a/src/core/qgsrasterdataprovider.h +++ b/src/core/qgsrasterdataprovider.h @@ -86,7 +86,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider // TODO: Document this better. /** \brief Renders the layer as an image */ - virtual QImage* draw( QgsRect const & viewExtent, int pixelWidth, int pixelHeight ) = 0; + virtual QImage* draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) = 0; /** Returns a bitmask containing the supported capabilities Note, some capabilities may change depending on whether diff --git a/src/core/qgsrect.cpp b/src/core/qgsrectangle.cpp similarity index 67% rename from src/core/qgsrect.cpp rename to src/core/qgsrectangle.cpp index 74d39f4ea1bd..bebe83bbe55c 100644 --- a/src/core/qgsrect.cpp +++ b/src/core/qgsrectangle.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - qgsrect.cpp - description + qgsrectangle.cpp - description ------------------- begin : Sat Jun 22 2002 copyright : (C) 2002 by Gary E.Sherman @@ -23,29 +23,29 @@ #include #include "qgspoint.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgslogger.h" -QgsRect::QgsRect( double newxmin, double newymin, double newxmax, double newymax ) +QgsRectangle::QgsRectangle( double newxmin, double newymin, double newxmax, double newymax ) : xmin( newxmin ), ymin( newymin ), xmax( newxmax ), ymax( newymax ) { normalize(); } -QgsRect::QgsRect( QgsPoint const & p1, QgsPoint const & p2 ) +QgsRectangle::QgsRectangle( QgsPoint const & p1, QgsPoint const & p2 ) { set( p1, p2 ); } -QgsRect::QgsRect( const QgsRect &r ) +QgsRectangle::QgsRectangle( const QgsRectangle &r ) { - xmin = r.xMin(); - ymin = r.yMin(); - xmax = r.xMax(); - ymax = r.yMax(); + xmin = r.xMinimum(); + ymin = r.yMinimum(); + xmax = r.xMaximum(); + ymax = r.yMaximum(); } -void QgsRect::set( const QgsPoint& p1, const QgsPoint& p2 ) +void QgsRectangle::set( const QgsPoint& p1, const QgsPoint& p2 ) { xmin = p1.x(); xmax = p2.x(); @@ -54,7 +54,7 @@ void QgsRect::set( const QgsPoint& p1, const QgsPoint& p2 ) normalize(); } -void QgsRect::set( double xmin_, double ymin_, double xmax_, double ymax_ ) +void QgsRectangle::set( double xmin_, double ymin_, double xmax_, double ymax_ ) { xmin = xmin_; ymin = ymin_; @@ -63,7 +63,7 @@ void QgsRect::set( double xmin_, double ymin_, double xmax_, double ymax_ ) normalize(); } -void QgsRect::normalize() +void QgsRectangle::normalize() { if ( xmin > xmax ) { @@ -73,10 +73,10 @@ void QgsRect::normalize() { std::swap( ymin, ymax ); } -} // QgsRect::normalize() +} // QgsRectangle::normalize() -void QgsRect::setMinimal() +void QgsRectangle::setMinimal() { xmin = std::numeric_limits::max(); ymin = std::numeric_limits::max(); @@ -84,7 +84,7 @@ void QgsRect::setMinimal() ymax = -std::numeric_limits::max(); } -void QgsRect::scale( double scaleFactor, const QgsPoint * cp ) +void QgsRectangle::scale( double scaleFactor, const QgsPoint * cp ) { // scale from the center double centerX, centerY; @@ -106,7 +106,7 @@ void QgsRect::scale( double scaleFactor, const QgsPoint * cp ) ymax = centerY + newHeight / 2.0; } -void QgsRect::expand( double scaleFactor, const QgsPoint * cp ) +void QgsRectangle::expand( double scaleFactor, const QgsPoint * cp ) { // scale from the center double centerX, centerY; @@ -129,23 +129,23 @@ void QgsRect::expand( double scaleFactor, const QgsPoint * cp ) ymax = centerY + newHeight; } -QgsRect QgsRect::intersect( QgsRect * rect ) const +QgsRectangle QgsRectangle::intersect( QgsRectangle * rect ) const { - QgsRect intersection = QgsRect(); - //If they don't actually intersect an empty QgsRect should be returned + QgsRectangle intersection = QgsRectangle(); + //If they don't actually intersect an empty QgsRectangle should be returned if ( !rect || !intersects( *rect ) ) { return intersection; } - intersection.setXMinimum( xmin > rect->xMin() ? xmin : rect->xMin() ); - intersection.setXMaximum( xmax < rect->xMax() ? xmax : rect->xMax() ); - intersection.setYMinimum( ymin > rect->yMin() ? ymin : rect->yMin() ); - intersection.setYMaximum( ymax < rect->yMax() ? ymax : rect->yMax() ); + intersection.setXMinimum( xmin > rect->xMinimum() ? xmin : rect->xMinimum() ); + intersection.setXMaximum( xmax < rect->xMaximum() ? xmax : rect->xMaximum() ); + intersection.setYMinimum( ymin > rect->yMinimum() ? ymin : rect->yMinimum() ); + intersection.setYMaximum( ymax < rect->yMaximum() ? ymax : rect->yMaximum() ); return intersection; } -bool QgsRect::intersects( const QgsRect& rect ) const +bool QgsRectangle::intersects( const QgsRectangle& rect ) const { double x1 = ( xmin > rect.xmin ? xmin : rect.xmin ); double x2 = ( xmax < rect.xmax ? xmax : rect.xmax ); @@ -157,18 +157,18 @@ bool QgsRect::intersects( const QgsRect& rect ) const } -void QgsRect::combineExtentWith( QgsRect * rect ) +void QgsRectangle::combineExtentWith( QgsRectangle * rect ) { - xmin = (( xmin < rect->xMin() ) ? xmin : rect->xMin() ); - xmax = (( xmax > rect->xMax() ) ? xmax : rect->xMax() ); + xmin = (( xmin < rect->xMinimum() ) ? xmin : rect->xMinimum() ); + xmax = (( xmax > rect->xMaximum() ) ? xmax : rect->xMaximum() ); - ymin = (( ymin < rect->yMin() ) ? ymin : rect->yMin() ); - ymax = (( ymax > rect->yMax() ) ? ymax : rect->yMax() ); + ymin = (( ymin < rect->yMinimum() ) ? ymin : rect->yMinimum() ); + ymax = (( ymax > rect->yMaximum() ) ? ymax : rect->yMaximum() ); } -void QgsRect::combineExtentWith( double x, double y ) +void QgsRectangle::combineExtentWith( double x, double y ) { xmin = (( xmin < x ) ? xmin : x ); @@ -179,7 +179,7 @@ void QgsRect::combineExtentWith( double x, double y ) } -bool QgsRect::isEmpty() const +bool QgsRectangle::isEmpty() const { if ( xmax <= xmin || ymax <= ymin ) { @@ -191,7 +191,7 @@ bool QgsRect::isEmpty() const } } -QString QgsRect::asWktCoordinates() const +QString QgsRectangle::asWktCoordinates() const { QString rep = QString::number( xmin, 'f', 16 ) + " " + @@ -203,7 +203,7 @@ QString QgsRect::asWktCoordinates() const } // Return a string representation of the rectangle with automatic or high precision -QString QgsRect::toString( bool automaticPrecision ) const +QString QgsRectangle::toString( bool automaticPrecision ) const { if ( automaticPrecision ) { @@ -223,7 +223,7 @@ QString QgsRect::toString( bool automaticPrecision ) const // overloaded version of above fn to allow precision to be set // Return a string representation of the rectangle with high precision -QString QgsRect::toString( int thePrecision ) const +QString QgsRectangle::toString( int thePrecision ) const { QString rep = QString::number( xmin, 'f', thePrecision ) + @@ -241,7 +241,7 @@ QString QgsRect::toString( int thePrecision ) const // Return the rectangle as a set of polygon coordinates -QString QgsRect::asPolygon() const +QString QgsRectangle::asPolygon() const { // QString rep = tmp.sprintf("%16f %16f,%16f %16f,%16f %16f,%16f %16f,%16f %16f", // xmin, ymin, xmin, ymax, xmax, ymax, xmax, ymin, xmin, ymin); @@ -261,47 +261,47 @@ QString QgsRect::asPolygon() const return rep; -} // QgsRect::asPolygon() const +} // QgsRectangle::asPolygon() const -bool QgsRect::operator==( const QgsRect & r1 ) const +bool QgsRectangle::operator==( const QgsRectangle & r1 ) const { - return ( r1.xMax() == xMax() && - r1.xMin() == xMin() && - r1.yMax() == yMax() && - r1.yMin() == yMin() ); + return ( r1.xMaximum() == xMaximum() && + r1.xMinimum() == xMinimum() && + r1.yMaximum() == yMaximum() && + r1.yMinimum() == yMinimum() ); } -bool QgsRect::operator!=( const QgsRect & r1 ) const +bool QgsRectangle::operator!=( const QgsRectangle & r1 ) const { return ( ! operator==( r1 ) ); } -QgsRect & QgsRect::operator=( const QgsRect & r ) +QgsRectangle & QgsRectangle::operator=( const QgsRectangle & r ) { if ( &r != this ) { - xmax = r.xMax(); - xmin = r.xMin(); - ymax = r.yMax(); - ymin = r.yMin(); + xmax = r.xMaximum(); + xmin = r.xMinimum(); + ymax = r.yMaximum(); + ymin = r.yMinimum(); } return *this; } -void QgsRect::unionRect( const QgsRect& r ) +void QgsRectangle::unionRect( const QgsRectangle& r ) { - if ( r.xMin() < xMin() ) setXMinimum( r.xMin() ); - if ( r.xMax() > xMax() ) setXMaximum( r.xMax() ); - if ( r.yMin() < yMin() ) setYMinimum( r.yMin() ); - if ( r.yMax() > yMax() ) setYMaximum( r.yMax() ); + if ( r.xMinimum() < xMinimum() ) setXMinimum( r.xMinimum() ); + if ( r.xMaximum() > xMaximum() ) setXMaximum( r.xMaximum() ); + if ( r.yMinimum() < yMinimum() ) setYMinimum( r.yMinimum() ); + if ( r.yMaximum() > yMaximum() ) setYMaximum( r.yMaximum() ); } -bool QgsRect::isFinite() const +bool QgsRectangle::isFinite() const { if ( std::numeric_limits::has_infinity ) { diff --git a/src/core/qgsrect.h b/src/core/qgsrectangle.h similarity index 76% rename from src/core/qgsrect.h rename to src/core/qgsrectangle.h index 2c2806f7d0ce..97c5b8c5b1fb 100644 --- a/src/core/qgsrect.h +++ b/src/core/qgsrectangle.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgsrect.h - description + qgsrectangle.h - description ------------------- begin : Sat Jun 22 2002 copyright : (C) 2002 by Gary E.Sherman @@ -29,20 +29,20 @@ class QString; /** \ingroup core * A rectangle specified with double values. * - * QgsRect is used to store a rectangle when double values are required. + * QgsRectangle is used to store a rectangle when double values are required. * Examples are storing a layer extent or the current view extent of a map */ -class CORE_EXPORT QgsRect +class CORE_EXPORT QgsRectangle { public: //! Constructor - QgsRect( double xmin = 0, double ymin = 0, double xmax = 0, double ymax = 0 ); + QgsRectangle( double xmin = 0, double ymin = 0, double xmax = 0, double ymax = 0 ); //! Construct a rectangle from two points. The rectangle is normalized after construction. - QgsRect( QgsPoint const & p1, QgsPoint const & p2 ); + QgsRectangle( QgsPoint const & p1, QgsPoint const & p2 ); //! Copy constructor - QgsRect( const QgsRect &other ); + QgsRectangle( const QgsRectangle &other ); //! Destructor - ~QgsRect(); + ~QgsRectangle(); //! Set the rectangle from two QgsPoints. The rectangle is //normalised after construction. void set( const QgsPoint& p1, const QgsPoint& p2 ); @@ -61,13 +61,13 @@ class CORE_EXPORT QgsRect // and max corner is at min. It is NOT normalized. void setMinimal(); //! Get the x maximum value (right side of rectangle) - double xMax() const; + double xMaximum() const; //! Get the x maximum value (right side of rectangle) - double xMin() const; + double xMinimum() const; //! Get the x minimum value (left side of rectangle) - double yMax() const; + double yMaximum() const; //! Get the y maximum value (top side of rectangle) - double yMin() const; + double yMinimum() const; //! Normalize the rectangle so it has non-negative width/height void normalize(); //! Width of the rectangle @@ -81,11 +81,11 @@ class CORE_EXPORT QgsRect //! Expand the rectangle to support zoom out scaling void expand( double, const QgsPoint *c = 0 ); //! return the intersection with the given rectangle - QgsRect intersect( QgsRect *rect ) const; + QgsRectangle intersect( QgsRectangle *rect ) const; //! returns true when rectangle intersects with other rectangle - bool intersects( const QgsRect& rect ) const; + bool intersects( const QgsRectangle& rect ) const; //! expand the rectangle so that covers both the original rectangle and the given rectangle - void combineExtentWith( QgsRect *rect ); + void combineExtentWith( QgsRectangle *rect ); //! expand the rectangle so that covers both the original rectangle and the given point void combineExtentWith( double x, double y ); //! test if rectangle is empty @@ -101,18 +101,18 @@ class CORE_EXPORT QgsRect /*! Comparison operator @return True if rectangles are equal */ - bool operator==( const QgsRect &r1 ) const; + bool operator==( const QgsRectangle &r1 ) const; /*! Comparison operator @return False if rectangles are equal */ - bool operator!=( const QgsRect &r1 ) const; + bool operator!=( const QgsRectangle &r1 ) const; /*! Assignment operator - * @param r1 QgsRect to assign from + * @param r1 QgsRectangle to assign from */ - QgsRect & operator=( const QgsRect &r1 ); + QgsRectangle & operator=( const QgsRectangle &r1 ); /** updates rectangle to include passed argument */ - void unionRect( const QgsRect& rect ); + void unionRect( const QgsRectangle& rect ); /** Returns true if the rectangle has finite boundaries. Will return false if any of the rectangle boundaries are NaN or Inf. */ @@ -131,65 +131,65 @@ class CORE_EXPORT QgsRect }; -inline QgsRect::~QgsRect() +inline QgsRectangle::~QgsRectangle() { } -inline void QgsRect::setXMinimum( double x ) +inline void QgsRectangle::setXMinimum( double x ) { xmin = x; } -inline void QgsRect::setXMaximum( double x ) +inline void QgsRectangle::setXMaximum( double x ) { xmax = x; } -inline void QgsRect::setYMinimum( double y ) +inline void QgsRectangle::setYMinimum( double y ) { ymin = y; } -inline void QgsRect::setYMaximum( double y ) +inline void QgsRectangle::setYMaximum( double y ) { ymax = y; } -inline double QgsRect::xMax() const +inline double QgsRectangle::xMaximum() const { return xmax; } -inline double QgsRect::xMin() const +inline double QgsRectangle::xMinimum() const { return xmin; } -inline double QgsRect::yMax() const +inline double QgsRectangle::yMaximum() const { return ymax; } -inline double QgsRect::yMin() const +inline double QgsRectangle::yMinimum() const { return ymin; } -inline double QgsRect::width() const +inline double QgsRectangle::width() const { return xmax - xmin; } -inline double QgsRect::height() const +inline double QgsRectangle::height() const { return ymax - ymin; } -inline QgsPoint QgsRect::center() const +inline QgsPoint QgsRectangle::center() const { return QgsPoint( xmin + width() / 2, ymin + height() / 2 ); } -inline std::ostream& operator << ( std::ostream& os, const QgsRect &r ) +inline std::ostream& operator << ( std::ostream& os, const QgsRectangle &r ) { return os << r.toString().toLocal8Bit().data(); } diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index 514e825ea8c7..b96a97905b8b 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -20,7 +20,7 @@ #include "qgscoordinatetransform.h" #include "qgsmaptopixel.h" -#include "qgsrect.h" +#include "qgsrectangle.h" class QPainter; @@ -42,7 +42,7 @@ class CORE_EXPORT QgsRenderContext const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;} - const QgsRect& extent() const {return mExtent;} + const QgsRectangle& extent() const {return mExtent;} const QgsMapToPixel& mapToPixel() const {return mMapToPixel;} @@ -61,7 +61,7 @@ class CORE_EXPORT QgsRenderContext /**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/ void setCoordinateTransform( QgsCoordinateTransform* t ); void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;} - void setExtent( const QgsRect& extent ) {mExtent = extent;} + void setExtent( const QgsRectangle& extent ) {mExtent = extent;} void setDrawEditingInformation( bool b ) {mDrawEditingInformation = b;} void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;} void setScaleFactor( double factor ) {mScaleFactor = factor;} @@ -79,7 +79,7 @@ class CORE_EXPORT QgsRenderContext /**True if vertex markers for editing should be drawn*/ bool mDrawEditingInformation; - QgsRect mExtent; + QgsRectangle mExtent; /**If true then no rendered vector elements should be cached as image*/ bool mForceVectorOutput; diff --git a/src/core/qgsscalecalculator.cpp b/src/core/qgsscalecalculator.cpp index 471cc3e14935..71ba952ffa52 100644 --- a/src/core/qgsscalecalculator.cpp +++ b/src/core/qgsscalecalculator.cpp @@ -20,7 +20,7 @@ #include #include #include "qgslogger.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsscalecalculator.h" QgsScaleCalculator::QgsScaleCalculator( double dpi, QGis::UnitType mapUnits ) @@ -49,7 +49,7 @@ QGis::UnitType QgsScaleCalculator::mapUnits() const return mMapUnits; } -double QgsScaleCalculator::calculate( const QgsRect &mapExtent, int canvasWidth ) +double QgsScaleCalculator::calculate( const QgsRectangle &mapExtent, int canvasWidth ) { double conversionFactor = 0; double delta = 0; @@ -60,11 +60,11 @@ double QgsScaleCalculator::calculate( const QgsRect &mapExtent, int canvasWidth case QGis::Meters: // convert meters to inches conversionFactor = 39.3700787; - delta = mapExtent.xMax() - mapExtent.xMin(); + delta = mapExtent.xMaximum() - mapExtent.xMinimum(); break; case QGis::Feet: conversionFactor = 12.0; - delta = mapExtent.xMax() - mapExtent.xMin(); + delta = mapExtent.xMaximum() - mapExtent.xMinimum(); break; case QGis::Degrees: // degrees require conversion to meters first @@ -86,7 +86,7 @@ double QgsScaleCalculator::calculate( const QgsRect &mapExtent, int canvasWidth } -double QgsScaleCalculator::calculateGeographicDistance( const QgsRect &mapExtent ) +double QgsScaleCalculator::calculateGeographicDistance( const QgsRectangle &mapExtent ) { // need to calculate the x distance in meters // We'll use the middle latitude for the calculation @@ -107,12 +107,12 @@ double QgsScaleCalculator::calculateGeographicDistance( const QgsRect &mapExten // - Use the Halversine formula to calculate the distance from -90 to // +90 degrees at the mean latitude. // - Scale this distance by the number of degrees between - // mapExtent.xMin() and mapExtent.xMax(); + // mapExtent.xMinimum() and mapExtent.xMaximum(); // - For a slight improvemnt, allow for the ellipsoid shape of earth. // For a longitude change of 180 degrees - double lat = ( mapExtent.yMax() + mapExtent.yMin() ) * 0.5; + double lat = ( mapExtent.yMaximum() + mapExtent.yMinimum() ) * 0.5; const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0; double a = pow( cos( lat * rads ), 2 ); double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) ); @@ -122,7 +122,7 @@ double QgsScaleCalculator::calculateGeographicDistance( const QgsRect &mapExten const static double e = 0.0810820288; double radius = ra * ( 1.0 - e * e ) / pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 ); - double meters = ( mapExtent.xMax() - mapExtent.xMin() ) / 180.0 * radius * c; + double meters = ( mapExtent.xMaximum() - mapExtent.xMinimum() ) / 180.0 * radius * c; QgsDebugMsg( "Distance across map extent (m): " + QString::number( meters ) ); diff --git a/src/core/qgsscalecalculator.h b/src/core/qgsscalecalculator.h index 2f4766b41bcb..7cd7d1d03ba6 100644 --- a/src/core/qgsscalecalculator.h +++ b/src/core/qgsscalecalculator.h @@ -23,7 +23,7 @@ #include class QString; -class QgsRect; +class QgsRectangle; /** \ingroup core * Calculates scale for a given combination of canvas size, map extent, @@ -67,19 +67,19 @@ class CORE_EXPORT QgsScaleCalculator /** * Calculate the scale - * @param mapExtent QgsRect containing the current map extent + * @param mapExtent QgsRectangle containing the current map extent * @param canvasWidth Width of the map canvas in pixel (physical) units * @return scale of current map view */ - double calculate( const QgsRect &mapExtent, int canvasWidth ); + double calculate( const QgsRectangle &mapExtent, int canvasWidth ); /** * Calculate the distance between two points in geographic coordinates. * Used to calculate scale for map views with geographic (decimal degree) * data. - * @param mapExtent QgsRect containing the current map extent + * @param mapExtent QgsRectangle containing the current map extent */ - double calculateGeographicDistance( const QgsRect &mapExtent ); + double calculateGeographicDistance( const QgsRectangle &mapExtent ); private: diff --git a/src/core/qgsvectordataprovider.cpp b/src/core/qgsvectordataprovider.cpp index 61627ed81db3..f37b31b36474 100644 --- a/src/core/qgsvectordataprovider.cpp +++ b/src/core/qgsvectordataprovider.cpp @@ -52,7 +52,7 @@ bool QgsVectorDataProvider::featureAtId( int featureId, bool fetchGeometry, QgsAttributeList fetchAttributes ) { - select( fetchAttributes, QgsRect(), fetchGeometry ); + select( fetchAttributes, QgsRectangle(), fetchGeometry ); while ( nextFeature( feature ) ) { @@ -311,7 +311,7 @@ void QgsVectorDataProvider::uniqueValues( int index, QList &values ) QgsFeature f; QgsAttributeList keys; keys.append( index ); - select( keys, QgsRect(), false ); + select( keys, QgsRectangle(), false ); QSet set; values.clear(); @@ -345,7 +345,7 @@ void QgsVectorDataProvider::fillMinMaxCache() QgsFeature f; QgsAttributeList keys = mCacheMinValues.keys(); - select( keys, QgsRect(), false ); + select( keys, QgsRectangle(), false ); while ( nextFeature( f ) ) { diff --git a/src/core/qgsvectordataprovider.h b/src/core/qgsvectordataprovider.h index ee3211544d20..3b712cc3ae8f 100644 --- a/src/core/qgsvectordataprovider.h +++ b/src/core/qgsvectordataprovider.h @@ -89,7 +89,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ) = 0; diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index dfb160c753d3..a4537a47b30d 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -329,7 +329,7 @@ QgsVectorFileWriter::writeAsShapefile( QgsVectorLayer* layer, QgsAttributeList allAttr = provider->attributeIndexes(); QgsFeature fet; - provider->select( allAttr, QgsRect(), true ); + provider->select( allAttr, QgsRectangle(), true ); const QgsFeatureIds& ids = layer->selectedFeaturesIds(); diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index a92643284da4..fada0f892712 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -62,7 +62,7 @@ #include "qgsmaptopixel.h" #include "qgspoint.h" #include "qgsproviderregistry.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsrendercontext.h" #include "qgssinglesymbolrenderer.h" #include "qgscoordinatereferencesystem.h" @@ -817,7 +817,7 @@ void QgsVectorLayer::select( int number, bool emitSignal ) } } -void QgsVectorLayer::select( QgsRect & rect, bool lock ) +void QgsVectorLayer::select( QgsRectangle & rect, bool lock ) { // normalize the rectangle rect.normalize(); @@ -846,7 +846,7 @@ void QgsVectorLayer::invertSelection() removeSelection( FALSE ); // don't emit signal - select( QgsAttributeList(), QgsRect(), false ); + select( QgsAttributeList(), QgsRectangle(), false ); QgsFeature fet; while ( nextFeature( fet ) ) @@ -967,17 +967,17 @@ QGis::WkbType QgsVectorLayer::wkbType() const return ( QGis::WkbType )( mWkbType ); } -QgsRect QgsVectorLayer::boundingBoxOfSelected() +QgsRectangle QgsVectorLayer::boundingBoxOfSelected() { if ( mSelectedFeatureIds.size() == 0 )//no selected features { - return QgsRect( 0, 0, 0, 0 ); + return QgsRectangle( 0, 0, 0, 0 ); } - QgsRect r, retval; + QgsRectangle r, retval; - select( QgsAttributeList(), QgsRect(), true ); + select( QgsAttributeList(), QgsRectangle(), true ); retval.setMinimal(); @@ -1000,20 +1000,20 @@ QgsRect QgsVectorLayer::boundingBoxOfSelected() // rectangle a bit. If they are all at zero, do something a bit // more crude. - if ( retval.xMin() == 0.0 && retval.xMax() == 0.0 && - retval.yMin() == 0.0 && retval.yMax() == 0.0 ) + if ( retval.xMinimum() == 0.0 && retval.xMaximum() == 0.0 && + retval.yMinimum() == 0.0 && retval.yMaximum() == 0.0 ) { retval.set( -1.0, -1.0, 1.0, 1.0 ); } else { const double padFactor = 1e-8; - double widthPad = retval.xMin() * padFactor; - double heightPad = retval.yMin() * padFactor; - double xmin = retval.xMin() - widthPad; - double xmax = retval.xMax() + widthPad; - double ymin = retval.yMin() - heightPad; - double ymax = retval.yMax() + heightPad; + double widthPad = retval.xMinimum() * padFactor; + double heightPad = retval.yMinimum() * padFactor; + double xmin = retval.xMinimum() - widthPad; + double xmax = retval.xMaximum() + widthPad; + double ymin = retval.yMinimum() - heightPad; + double ymax = retval.yMaximum() + heightPad; retval.set( xmin, ymin, xmax, ymax ); } } @@ -1057,35 +1057,35 @@ void QgsVectorLayer::updateExtents() // but only when there are some features already if ( mDataProvider->featureCount() != 0 ) { - QgsRect r = mDataProvider->extent(); + QgsRectangle r = mDataProvider->extent(); mLayerExtent.combineExtentWith( &r ); } for ( QgsFeatureList::iterator it = mAddedFeatures.begin(); it != mAddedFeatures.end(); it++ ) { - QgsRect r = it->geometry()->boundingBox(); + QgsRectangle r = it->geometry()->boundingBox(); mLayerExtent.combineExtentWith( &r ); } } else { - select( QgsAttributeList(), QgsRect(), true ); + select( QgsAttributeList(), QgsRectangle(), true ); QgsFeature fet; while ( nextFeature( fet ) ) { if ( fet.geometry() ) { - QgsRect bb = fet.geometry()->boundingBox(); + QgsRectangle bb = fet.geometry()->boundingBox(); mLayerExtent.combineExtentWith( &bb ); } } } - if ( mLayerExtent.xMin() > mLayerExtent.xMax() && mLayerExtent.yMin() > mLayerExtent.yMax() ) + if ( mLayerExtent.xMinimum() > mLayerExtent.xMaximum() && mLayerExtent.yMinimum() > mLayerExtent.yMaximum() ) { // special case when there are no features in provider nor any added - mLayerExtent = QgsRect(); // use rectangle with zero coordinates + mLayerExtent = QgsRectangle(); // use rectangle with zero coordinates } // Send this (hopefully) up the chain to the map canvas @@ -1136,7 +1136,7 @@ void QgsVectorLayer::updateFeatureGeometry( QgsFeature &f ) } -void QgsVectorLayer::select( QgsAttributeList attributes, QgsRect rect, bool fetchGeometries, bool useIntersect ) +void QgsVectorLayer::select( QgsAttributeList attributes, QgsRectangle rect, bool fetchGeometries, bool useIntersect ) { if ( !mDataProvider ) return; @@ -1544,7 +1544,7 @@ int QgsVectorLayer::addRing( const QList& ring ) { int addRingReturnCode = 5; //default: return code for 'ring not inserted' double xMin, yMin, xMax, yMax; - QgsRect bBox; + QgsRectangle bBox; if ( boundingBoxFromPointList( ring, xMin, yMin, xMax, yMax ) == 0 ) { @@ -1659,7 +1659,7 @@ int QgsVectorLayer::splitFeatures( const QList& splitLine, bool topolo { QgsFeatureList newFeatures; //store all the newly created features double xMin, yMin, xMax, yMax; - QgsRect bBox; //bounding box of the split line + QgsRectangle bBox; //bounding box of the split line int returnCode = 0; int splitFunctionReturn; //return code of QgsGeometry::splitGeometry int numberOfSplitedFeatures = 0; @@ -1688,13 +1688,13 @@ int QgsVectorLayer::splitFeatures( const QList& splitLine, bool topolo //if the bbox is a line, try to make a square out of it if ( bBox.width() == 0.0 && bBox.height() > 0 ) { - bBox.setXMinimum( bBox.xMin() - bBox.height() / 2 ); - bBox.setXMaximum( bBox.xMax() + bBox.height() / 2 ); + bBox.setXMinimum( bBox.xMinimum() - bBox.height() / 2 ); + bBox.setXMaximum( bBox.xMaximum() + bBox.height() / 2 ); } else if ( bBox.height() == 0.0 && bBox.width() > 0 ) { - bBox.setYMinimum( bBox.yMin() - bBox.width() / 2 ); - bBox.setYMaximum( bBox.yMax() + bBox.width() / 2 ); + bBox.setYMinimum( bBox.yMinimum() - bBox.width() / 2 ); + bBox.setYMaximum( bBox.yMaximum() + bBox.width() / 2 ); } else { @@ -1773,7 +1773,7 @@ int QgsVectorLayer::removePolygonIntersections( QgsGeometry* geom ) } //get bounding box of geom - QgsRect geomBBox = geom->boundingBox(); + QgsRectangle geomBBox = geom->boundingBox(); //get list of features that intersect this bounding box select( QgsAttributeList(), geomBBox, true, true ); @@ -2155,16 +2155,16 @@ bool QgsVectorLayer::setDataProvider( QString const & provider ) connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) ); // get the extent - QgsRect mbr = mDataProvider->extent(); + QgsRectangle mbr = mDataProvider->extent(); // show the extent QString s = mbr.toString(); QgsDebugMsg( "Extent of layer: " + s ); // store the extent - mLayerExtent.setXMaximum( mbr.xMax() ); - mLayerExtent.setXMinimum( mbr.xMin() ); - mLayerExtent.setYMaximum( mbr.yMax() ); - mLayerExtent.setYMinimum( mbr.yMin() ); + mLayerExtent.setXMaximum( mbr.xMaximum() ); + mLayerExtent.setXMinimum( mbr.xMinimum() ); + mLayerExtent.setYMaximum( mbr.yMaximum() ); + mLayerExtent.setYMinimum( mbr.yMinimum() ); // get and store the feature type mWkbType = mDataProvider->geometryType(); @@ -3126,7 +3126,7 @@ int QgsVectorLayer::snapWithContext( const QgsPoint& startPoint, double snapping } QList featureList; - QgsRect searchRect( startPoint.x() - snappingTolerance, startPoint.y() - snappingTolerance, + QgsRectangle searchRect( startPoint.x() - snappingTolerance, startPoint.y() - snappingTolerance, startPoint.x() + snappingTolerance, startPoint.y() + snappingTolerance ); double sqrSnappingTolerance = snappingTolerance * snappingTolerance; diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index db3ab4289157..9042f1b57538 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -40,12 +40,12 @@ class QgsGeometry; class QgsGeometryVertexIndex; class QgsMapToPixel; class QgsLabel; -class QgsRect; +class QgsRectangle; class QgsRenderer; class QgsVectorDataProvider; class QgsGeometry; -class QgsRect; +class QgsRectangle; typedef QList QgsAttributeList; typedef QSet QgsFeatureIds; @@ -125,7 +125,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer int selectedFeatureCount(); /** Select features found within the search rectangle (in layer's coordinates) */ - void select( QgsRect & rect, bool lock ); + void select( QgsRectangle & rect, bool lock ); /** Select not selected features and deselect selected ones */ void invertSelection(); @@ -139,8 +139,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer /** Change selection to the new set of features */ void setSelectedFeatures( const QgsFeatureIds& ids ); - /** Returns the bounding box of the selected features. If there is no selection, QgsRect(0,0,0,0) is returned */ - QgsRect boundingBoxOfSelected(); + /** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */ + QgsRectangle boundingBoxOfSelected(); /** Copies the symbology settings from another layer. Returns true in case of success */ bool copySymbologySettings( const QgsMapLayer& other ); @@ -218,7 +218,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer virtual QString subsetString(); void select( QgsAttributeList fetchAttributes, - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -623,7 +623,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer QMap< QString, RangeData > mRanges; bool mFetching; - QgsRect mFetchRect; + QgsRectangle mFetchRect; QgsAttributeList mFetchAttributes; QgsAttributeList mFetchNullAttributes; bool mFetchGeometry; diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 739e1bcf0279..c6bf04a487b1 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -26,7 +26,7 @@ email : tim at linfiniti.com #include "qgsrasterlayer.h" #include "qgsrasterpyramid.h" #include "qgsrasterviewport.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsrendercontext.h" #include "qgscoordinatereferencesystem.h" @@ -1315,7 +1315,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) } const QgsMapToPixel& theQgsMapToPixel = rendererContext.mapToPixel(); - const QgsRect& theViewExtent = rendererContext.extent(); + const QgsRectangle& theViewExtent = rendererContext.extent(); QPainter* theQPainter = rendererContext.painter(); if ( !theQPainter ) @@ -1324,7 +1324,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) } // clip raster extent to view extent - QgsRect myRasterExtent = theViewExtent.intersect( &mLayerExtent ); + QgsRectangle myRasterExtent = theViewExtent.intersect( &mLayerExtent ); if ( myRasterExtent.isEmpty() ) { // nothing to do @@ -1347,8 +1347,8 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) // calculate raster pixel offsets from origin to clipped rect // we're only interested in positive offsets where the origin of the raster // is northwest of the origin of the view - myRasterViewPort->rectXOffsetFloat = ( theViewExtent.xMin() - mLayerExtent.xMin() ) / fabs( mGeoTransform[1] ); - myRasterViewPort->rectYOffsetFloat = ( mLayerExtent.yMax() - theViewExtent.yMax() ) / fabs( mGeoTransform[5] ); + myRasterViewPort->rectXOffsetFloat = ( theViewExtent.xMinimum() - mLayerExtent.xMinimum() ) / fabs( mGeoTransform[1] ); + myRasterViewPort->rectYOffsetFloat = ( mLayerExtent.yMaximum() - theViewExtent.yMaximum() ) / fabs( mGeoTransform[5] ); if ( myRasterViewPort->rectXOffsetFloat < 0 ) { @@ -1374,10 +1374,10 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) // So for example, if the user is zoomed in a long way, there may only be e.g. 5x5 pixels retrieved from // the raw raster data, but rasterio will seamlessly scale the up to whatever the screen coordinats are // e.g. a 600x800 display window (see next section below) - myRasterViewPort->clippedXMin = ( myRasterExtent.xMin() - mGeoTransform[0] ) / mGeoTransform[1]; - myRasterViewPort->clippedXMax = ( myRasterExtent.xMax() - mGeoTransform[0] ) / mGeoTransform[1]; - myRasterViewPort->clippedYMin = ( myRasterExtent.yMin() - mGeoTransform[3] ) / mGeoTransform[5]; - myRasterViewPort->clippedYMax = ( myRasterExtent.yMax() - mGeoTransform[3] ) / mGeoTransform[5]; + myRasterViewPort->clippedXMin = ( myRasterExtent.xMinimum() - mGeoTransform[0] ) / mGeoTransform[1]; + myRasterViewPort->clippedXMax = ( myRasterExtent.xMaximum() - mGeoTransform[0] ) / mGeoTransform[1]; + myRasterViewPort->clippedYMin = ( myRasterExtent.yMinimum() - mGeoTransform[3] ) / mGeoTransform[5]; + myRasterViewPort->clippedYMax = ( myRasterExtent.yMaximum() - mGeoTransform[3] ) / mGeoTransform[5]; // Sometimes the Ymin/Ymax are reversed. if ( myRasterViewPort->clippedYMin > myRasterViewPort->clippedYMax ) @@ -1412,8 +1412,8 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) } // get dimensions of clipped raster image in device coordinate space (this is the size of the viewport) - myRasterViewPort->topLeftPoint = theQgsMapToPixel.transform( myRasterExtent.xMin(), myRasterExtent.yMax() ); - myRasterViewPort->bottomRightPoint = theQgsMapToPixel.transform( myRasterExtent.xMax(), myRasterExtent.yMin() ); + myRasterViewPort->topLeftPoint = theQgsMapToPixel.transform( myRasterExtent.xMinimum(), myRasterExtent.yMaximum() ); + myRasterViewPort->bottomRightPoint = theQgsMapToPixel.transform( myRasterExtent.xMaximum(), myRasterExtent.yMinimum() ); myRasterViewPort->drawableAreaXDim = static_cast( fabs(( myRasterViewPort->clippedWidth / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[1] ) ) + 0.5 ); myRasterViewPort->drawableAreaYDim = static_cast( fabs(( myRasterViewPort->clippedHeight / theQgsMapToPixel.mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5 ); @@ -1426,10 +1426,10 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) QgsDebugMsg( QString( "rectYOffset = %1" ).arg( myRasterViewPort->rectYOffset ) ); QgsDebugMsg( QString( "rectYOffsetFloat = %1" ).arg( myRasterViewPort->rectYOffsetFloat ) ); - QgsDebugMsg( QString( "myRasterExtent.xMin() = %1" ).arg( myRasterExtent.xMin() ) ); - QgsDebugMsg( QString( "myRasterExtent.xMax() = %1" ).arg( myRasterExtent.xMax() ) ); - QgsDebugMsg( QString( "myRasterExtent.yMin() = %1" ).arg( myRasterExtent.yMin() ) ); - QgsDebugMsg( QString( "myRasterExtent.yMax() = %1" ).arg( myRasterExtent.yMax() ) ); + QgsDebugMsg( QString( "myRasterExtent.xMinimum() = %1" ).arg( myRasterExtent.xMinimum() ) ); + QgsDebugMsg( QString( "myRasterExtent.xMaximum() = %1" ).arg( myRasterExtent.xMaximum() ) ); + QgsDebugMsg( QString( "myRasterExtent.yMinimum() = %1" ).arg( myRasterExtent.yMinimum() ) ); + QgsDebugMsg( QString( "myRasterExtent.yMaximum() = %1" ).arg( myRasterExtent.yMaximum() ) ); QgsDebugMsg( QString( "topLeftPoint.x() = %1" ).arg( myRasterViewPort->topLeftPoint.x() ) ); QgsDebugMsg( QString( "bottomRightPoint.x() = %1" ).arg( myRasterViewPort->bottomRightPoint.x() ) ); @@ -1779,7 +1779,7 @@ bool QgsRasterLayer::identify( const QgsPoint& thePoint, QMap& QgsDebugMsg( QString::number( x ) + ", " + QString::number( y ) ); - if ( x < mLayerExtent.xMin() || x > mLayerExtent.xMax() || y < mLayerExtent.yMin() || y > mLayerExtent.yMax() ) + if ( x < mLayerExtent.xMinimum() || x > mLayerExtent.xMaximum() || y < mLayerExtent.yMinimum() || y > mLayerExtent.yMaximum() ) { // Outside the raster for ( int i = 1; i <= GDALGetRasterCount( mGdalDataset ); i++ ) @@ -1790,12 +1790,12 @@ bool QgsRasterLayer::identify( const QgsPoint& thePoint, QMap& else { /* Calculate the row / column where the point falls */ - double xres = ( mLayerExtent.xMax() - mLayerExtent.xMin() ) / mWidth; - double yres = ( mLayerExtent.yMax() - mLayerExtent.yMin() ) / mHeight; + double xres = ( mLayerExtent.xMaximum() - mLayerExtent.xMinimum() ) / mWidth; + double yres = ( mLayerExtent.yMaximum() - mLayerExtent.yMinimum() ) / mHeight; // Offset, not the cell index -> flor - int col = ( int ) floor(( x - mLayerExtent.xMin() ) / xres ); - int row = ( int ) floor(( mLayerExtent.yMax() - y ) / yres ); + int col = ( int ) floor(( x - mLayerExtent.xMinimum() ) / xres ); + int row = ( int ) floor(( mLayerExtent.yMaximum() - y ) / yres ); QgsDebugMsg( "row = " + QString::number( row ) + " col = " + QString::number( col ) ); @@ -3096,16 +3096,16 @@ void QgsRasterLayer::setDataProvider( QString const & provider, mDataProvider->setImageCrs( crs ); // get the extent - QgsRect mbr = mDataProvider->extent(); + QgsRectangle mbr = mDataProvider->extent(); // show the extent QString s = mbr.toString(); QgsDebugMsg( "Extent of layer: " + s ); // store the extent - mLayerExtent.setXMaximum( mbr.xMax() ); - mLayerExtent.setXMinimum( mbr.xMin() ); - mLayerExtent.setYMaximum( mbr.yMax() ); - mLayerExtent.setYMinimum( mbr.yMin() ); + mLayerExtent.setXMaximum( mbr.xMaximum() ); + mLayerExtent.setXMinimum( mbr.xMinimum() ); + mLayerExtent.setYMaximum( mbr.yMaximum() ); + mLayerExtent.setYMinimum( mbr.yMinimum() ); // upper case the first letter of the layer name QgsDebugMsg( "mLayerName: " + name() ); diff --git a/src/core/raster/qgsrasterlayer.h b/src/core/raster/qgsrasterlayer.h index bbf130e57885..09c0106c0459 100644 --- a/src/core/raster/qgsrasterlayer.h +++ b/src/core/raster/qgsrasterlayer.h @@ -55,7 +55,7 @@ int CPL_STDCALL progressCallback( double dfComplete, // Forward declarations // class QgsMapToPixel; -class QgsRect; +class QgsRectangle; class QgsRasterBandStats; class QgsRasterPyramid; class QgsRasterLayerProperties; diff --git a/src/core/spatialindex/qgsspatialindex.cpp b/src/core/spatialindex/qgsspatialindex.cpp index 1781b8ebfe59..d9291be6cfa3 100644 --- a/src/core/spatialindex/qgsspatialindex.cpp +++ b/src/core/spatialindex/qgsspatialindex.cpp @@ -18,7 +18,7 @@ #include "qgsgeometry.h" #include "qgsfeature.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgslogger.h" #include "SpatialIndex.h" @@ -78,13 +78,13 @@ QgsSpatialIndex:: ~QgsSpatialIndex() delete mStorageManager; } -Tools::Geometry::Region QgsSpatialIndex::rectToRegion( QgsRect rect ) +Tools::Geometry::Region QgsSpatialIndex::rectToRegion( QgsRectangle rect ) { double pt1[2], pt2[2]; - pt1[0] = rect.xMin(); - pt1[1] = rect.yMin(); - pt2[0] = rect.xMax(); - pt2[1] = rect.yMax(); + pt1[0] = rect.xMinimum(); + pt1[1] = rect.yMinimum(); + pt2[0] = rect.xMaximum(); + pt2[1] = rect.yMaximum(); return Tools::Geometry::Region( pt1, pt2, 2 ); } @@ -138,7 +138,7 @@ bool QgsSpatialIndex::deleteFeature( QgsFeature& f ) return mRTree->deleteData( r, id ); } -QList QgsSpatialIndex::intersects( QgsRect rect ) +QList QgsSpatialIndex::intersects( QgsRectangle rect ) { QList list; QgisVisitor visitor( list ); diff --git a/src/core/spatialindex/qgsspatialindex.h b/src/core/spatialindex/qgsspatialindex.h index e2b63f6d0d9a..7d530ce0c69c 100644 --- a/src/core/spatialindex/qgsspatialindex.h +++ b/src/core/spatialindex/qgsspatialindex.h @@ -38,7 +38,7 @@ namespace Tools } class QgsFeature; -class QgsRect; +class QgsRectangle; class QgsPoint; #include @@ -74,7 +74,7 @@ class CORE_EXPORT QgsSpatialIndex /* queries */ /** returns features that intersect the specified rectangle */ - QList intersects( QgsRect rect ); + QList intersects( QgsRectangle rect ); /** returns nearest neighbors (their count is specified by second parameter) */ QList nearestNeighbor( QgsPoint point, int neighbors ); @@ -82,7 +82,7 @@ class CORE_EXPORT QgsSpatialIndex protected: - Tools::Geometry::Region rectToRegion( QgsRect rect ); + Tools::Geometry::Region rectToRegion( QgsRectangle rect ); bool featureInfo( QgsFeature& f, Tools::Geometry::Region& r, long& id ); diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index b6111a867f0b..934026a15c51 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -415,12 +415,12 @@ void QgsMapCanvas::saveAsImage( QString theFileName, QPixmap * theQPixmap, QStri -QgsRect QgsMapCanvas::extent() const +QgsRectangle QgsMapCanvas::extent() const { return mMapRenderer->extent(); } // extent -QgsRect QgsMapCanvas::fullExtent() const +QgsRectangle QgsMapCanvas::fullExtent() const { return mMapRenderer->fullExtent(); } // extent @@ -440,19 +440,19 @@ void QgsMapCanvas::updateFullExtent() refresh(); } -void QgsMapCanvas::setExtent( QgsRect const & r ) +void QgsMapCanvas::setExtent( QgsRectangle const & r ) { if ( mDrawing ) { return; } - QgsRect current = extent(); + QgsRectangle current = extent(); if ( r.isEmpty() ) { QgsDebugMsg( "Empty extent - keeping old extent with new center!" ); - QgsRect e( QgsPoint( r.center().x() - current.width() / 2.0, r.center().y() - current.height() / 2.0 ), + QgsRectangle e( QgsPoint( r.center().x() - current.width() / 2.0, r.center().y() - current.height() / 2.0 ), QgsPoint( r.center().x() + current.width() / 2.0, r.center().y() + current.height() / 2.0 ) ); mMapRenderer->setExtent( e ); } @@ -496,7 +496,7 @@ void QgsMapCanvas::zoomToFullExtent() return; } - QgsRect extent = fullExtent(); + QgsRectangle extent = fullExtent(); // If the full extent is an empty set, don't do the zoom if ( !extent.isEmpty() ) { @@ -517,7 +517,7 @@ void QgsMapCanvas::zoomToPreviousExtent() return; } - QgsRect current = extent(); + QgsRectangle current = extent(); setExtent( mLastExtent ); mLastExtent = current; refresh(); @@ -558,7 +558,7 @@ void QgsMapCanvas::zoomToSelected() if ( lyr ) { - QgsRect rect = mMapRenderer->layerExtentToOutputExtent( lyr, lyr->boundingBoxOfSelected() ); + QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( lyr, lyr->boundingBoxOfSelected() ); // no selected features, only one selected point feature //or two point features with the same x- or y-coordinates @@ -601,17 +601,17 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e ) { // Don't want to interfer with mouse events - QgsRect currentExtent = mMapRenderer->extent(); - double dx = fabs(( currentExtent.xMax() - currentExtent.xMin() ) / 4 ); - double dy = fabs(( currentExtent.yMax() - currentExtent.yMin() ) / 4 ); + QgsRectangle currentExtent = mMapRenderer->extent(); + double dx = fabs(( currentExtent.xMaximum() - currentExtent.xMinimum() ) / 4 ); + double dy = fabs(( currentExtent.yMaximum() - currentExtent.yMinimum() ) / 4 ); switch ( e->key() ) { case Qt::Key_Left: QgsDebugMsg( "Pan left" ); - currentExtent.setXMinimum( currentExtent.xMin() - dx ); - currentExtent.setXMaximum( currentExtent.xMax() - dx ); + currentExtent.setXMinimum( currentExtent.xMinimum() - dx ); + currentExtent.setXMaximum( currentExtent.xMaximum() - dx ); setExtent( currentExtent ); refresh(); break; @@ -619,8 +619,8 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e ) case Qt::Key_Right: QgsDebugMsg( "Pan right" ); - currentExtent.setXMinimum( currentExtent.xMin() + dx ); - currentExtent.setXMaximum( currentExtent.xMax() + dx ); + currentExtent.setXMinimum( currentExtent.xMinimum() + dx ); + currentExtent.setXMaximum( currentExtent.xMaximum() + dx ); setExtent( currentExtent ); refresh(); break; @@ -628,8 +628,8 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e ) case Qt::Key_Up: QgsDebugMsg( "Pan up" ); - currentExtent.setYMaximum( currentExtent.yMax() + dy ); - currentExtent.setYMinimum( currentExtent.yMin() + dy ); + currentExtent.setYMaximum( currentExtent.yMaximum() + dy ); + currentExtent.setYMinimum( currentExtent.yMinimum() + dy ); setExtent( currentExtent ); refresh(); break; @@ -637,8 +637,8 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e ) case Qt::Key_Down: QgsDebugMsg( "Pan down" ); - currentExtent.setYMaximum( currentExtent.yMax() - dy ); - currentExtent.setYMinimum( currentExtent.yMin() - dy ); + currentExtent.setYMaximum( currentExtent.yMaximum() - dy ); + currentExtent.setYMinimum( currentExtent.yMinimum() - dy ); setExtent( currentExtent ); refresh(); break; @@ -879,7 +879,7 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e ) mousePos.y() + (( oldCenter.y() - mousePos.y() ) * scaleFactor ) ); // same as zoomWithCenter (no coordinate transformations are needed) - QgsRect extent = mMapRenderer->extent(); + QgsRectangle extent = mMapRenderer->extent(); extent.scale( scaleFactor, &newCenter ); setExtent( extent ); refresh(); @@ -902,7 +902,7 @@ void QgsMapCanvas::zoom( bool zoomIn ) { double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor ); - QgsRect r = mMapRenderer->extent(); + QgsRectangle r = mMapRenderer->extent(); r.scale( scaleFactor ); setExtent( r ); refresh(); @@ -919,7 +919,7 @@ void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn ) // transform the mouse pos to map coordinates QgsPoint center = getCoordinateTransform()->toMapPoint( x, y ); - QgsRect r = mMapRenderer->extent(); + QgsRectangle r = mMapRenderer->extent(); r.scale( scaleFactor, ¢er ); setExtent( r ); refresh(); @@ -1122,29 +1122,29 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint ) double dy = fabs( end.y() - start.y() ); // modify the extent - QgsRect r = mMapRenderer->extent(); + QgsRectangle r = mMapRenderer->extent(); if ( end.x() < start.x() ) { - r.setXMinimum( r.xMin() + dx ); - r.setXMaximum( r.xMax() + dx ); + r.setXMinimum( r.xMinimum() + dx ); + r.setXMaximum( r.xMaximum() + dx ); } else { - r.setXMinimum( r.xMin() - dx ); - r.setXMaximum( r.xMax() - dx ); + r.setXMinimum( r.xMinimum() - dx ); + r.setXMaximum( r.xMaximum() - dx ); } if ( end.y() < start.y() ) { - r.setYMaximum( r.yMax() + dy ); - r.setYMinimum( r.yMin() + dy ); + r.setYMaximum( r.yMaximum() + dy ); + r.setYMinimum( r.yMinimum() + dy ); } else { - r.setYMaximum( r.yMax() - dy ); - r.setYMinimum( r.yMin() - dy ); + r.setYMaximum( r.yMaximum() - dy ); + r.setYMinimum( r.yMinimum() - dy ); } @@ -1272,7 +1272,7 @@ void QgsMapCanvas::zoom( double scaleFactor ) return; } - QgsRect r = mMapRenderer->extent(); + QgsRectangle r = mMapRenderer->extent(); r.scale( scaleFactor ); setExtent( r ); refresh(); diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index 50239c86398c..80c04d5b23d3 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -23,7 +23,7 @@ #include #include -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgspoint.h" #include "qgis.h" @@ -129,12 +129,12 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView double mapUnitsPerPixel() const; //! Returns the current zoom exent of the map canvas - QgsRect extent() const; + QgsRectangle extent() const; //! Returns the combined exent for all layers on the map canvas - QgsRect fullExtent() const; + QgsRectangle fullExtent() const; //! Set the extent of the map canvas - void setExtent( QgsRect const & r ); + void setExtent( QgsRectangle const & r ); //! Zoom to the full extent of all layers void zoomToFullExtent(); @@ -409,7 +409,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView QgsMapTool* mLastNonZoomMapTool; //! recently used extent - QgsRect mLastExtent; + QgsRectangle mLastExtent; //! Scale factor multiple for default zoom in/out double mWheelZoomFactor; diff --git a/src/gui/qgsmapcanvasitem.cpp b/src/gui/qgsmapcanvasitem.cpp index 3314652e42fc..052e58293661 100644 --- a/src/gui/qgsmapcanvasitem.cpp +++ b/src/gui/qgsmapcanvasitem.cpp @@ -57,13 +57,13 @@ QPointF QgsMapCanvasItem::toCanvasCoordinates( const QgsPoint& point ) } -QgsRect QgsMapCanvasItem::rect() const +QgsRectangle QgsMapCanvasItem::rect() const { return mRect; } -void QgsMapCanvasItem::setRect( const QgsRect& rect ) +void QgsMapCanvasItem::setRect( const QgsRectangle& rect ) { mRect = rect; //updatePosition(); @@ -71,8 +71,8 @@ void QgsMapCanvasItem::setRect( const QgsRect& rect ) QRectF r; // empty rect by default if ( !mRect.isEmpty() ) { - r.setTopLeft( toCanvasCoordinates( QgsPoint( mRect.xMin(), mRect.yMin() ) ) ); - r.setBottomRight( toCanvasCoordinates( QgsPoint( mRect.xMax(), mRect.yMax() ) ) ); + r.setTopLeft( toCanvasCoordinates( QgsPoint( mRect.xMinimum(), mRect.yMinimum() ) ) ); + r.setBottomRight( toCanvasCoordinates( QgsPoint( mRect.xMaximum(), mRect.yMaximum() ) ) ); r = r.normalized(); } diff --git a/src/gui/qgsmapcanvasitem.h b/src/gui/qgsmapcanvasitem.h index f717c24eeed9..168c6103831d 100644 --- a/src/gui/qgsmapcanvasitem.h +++ b/src/gui/qgsmapcanvasitem.h @@ -18,7 +18,7 @@ #define QGSMAPCANVASITEM_H #include -#include "qgsrect.h" +#include "qgsrectangle.h" class QgsMapCanvas; class QPainter; @@ -60,10 +60,10 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem void setPanningOffset( const QPoint& point ); //! returns canvas item rectangle - QgsRect rect() const; + QgsRectangle rect() const; //! sets canvas item rectangle - void setRect( const QgsRect& r ); + void setRect( const QgsRectangle& r ); //! transformation from screen coordinates to map coordinates QgsPoint toMapCoordinates( const QPoint& point ); @@ -77,7 +77,7 @@ class GUI_EXPORT QgsMapCanvasItem : public QGraphicsItem QgsMapCanvas* mMapCanvas; //! canvas item rectangle (in map coordinates) - QgsRect mRect; + QgsRectangle mRect; //! offset from normal position due current panning operation, //! used when converting map coordinates to move map canvas items diff --git a/src/gui/qgsmapoverviewcanvas.cpp b/src/gui/qgsmapoverviewcanvas.cpp index 70f01c2160e5..69ad826119c6 100644 --- a/src/gui/qgsmapoverviewcanvas.cpp +++ b/src/gui/qgsmapoverviewcanvas.cpp @@ -92,7 +92,7 @@ void QgsMapOverviewCanvas::resizeEvent( QResizeEvent* e ) void QgsMapOverviewCanvas::drawExtentRect() { - const QgsRect& extent = mMapCanvas->extent(); + const QgsRectangle& extent = mMapCanvas->extent(); // show only when valid extent is set if ( extent.isEmpty() ) @@ -102,8 +102,8 @@ void QgsMapOverviewCanvas::drawExtentRect() } const QgsMapToPixel* cXf = mMapRenderer->coordinateTransform(); - QgsPoint ll( extent.xMin(), extent.yMin() ); - QgsPoint ur( extent.xMax(), extent.yMax() ); + QgsPoint ll( extent.xMinimum(), extent.yMinimum() ); + QgsPoint ur( extent.xMaximum(), extent.yMaximum() ); if ( cXf ) { // transform the points before drawing @@ -186,8 +186,8 @@ void QgsMapOverviewCanvas::mouseReleaseEvent( QMouseEvent * e ) QRect rect = mPanningWidget->geometry(); QgsPoint center = cXf->toMapCoordinates( rect.center() ); - QgsRect oldExtent = mMapCanvas->extent(); - QgsRect ext; + QgsRectangle oldExtent = mMapCanvas->extent(); + QgsRectangle ext; ext.setXMinimum( center.x() - oldExtent.width() / 2 ); ext.setXMaximum( center.x() + oldExtent.width() / 2 ); ext.setYMinimum( center.y() - oldExtent.height() / 2 ); @@ -266,7 +266,7 @@ void QgsMapOverviewCanvas::setLayerSet( const QStringList& layerSet ) mMapRenderer->setLayerSet( layerSet ); } -void QgsMapOverviewCanvas::updateFullExtent( const QgsRect& rect ) +void QgsMapOverviewCanvas::updateFullExtent( const QgsRectangle& rect ) { mMapRenderer->setExtent( rect ); drawExtentRect(); diff --git a/src/gui/qgsmapoverviewcanvas.h b/src/gui/qgsmapoverviewcanvas.h index 520ca6cb60d1..523e4e2a01f6 100644 --- a/src/gui/qgsmapoverviewcanvas.h +++ b/src/gui/qgsmapoverviewcanvas.h @@ -30,7 +30,7 @@ class QgsMapCanvas; class QgsMapRenderer; class QgsPanningWidget; // defined in .cpp -class QgsRect; +class QgsRectangle; /** \ingroup gui * A widget that displays an overview map. @@ -60,7 +60,7 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget void enableAntiAliasing( bool flag ) { mAntiAliasing = flag; } - void updateFullExtent( const QgsRect& rect ); + void updateFullExtent( const QgsRectangle& rect ); public slots: diff --git a/src/gui/qgsmaptip.cpp b/src/gui/qgsmaptip.cpp index e6b0bba4685e..7a2806c0c8c8 100644 --- a/src/gui/qgsmaptip.cpp +++ b/src/gui/qgsmaptip.cpp @@ -89,7 +89,7 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPoint & mapPosition, Qgs // create the search rectangle double searchRadius = mpMapCanvas->extent().width() * ( identifyValue / 100.0 ); - QgsRect r; + QgsRectangle r; r.setXMinimum( mapPosition.x() - searchRadius ); r.setXMaximum( mapPosition.x() + searchRadius ); r.setYMinimum( mapPosition.y() - searchRadius ); diff --git a/src/gui/qgsmaptool.cpp b/src/gui/qgsmaptool.cpp index e83aebb662cd..2f7ebafe3938 100644 --- a/src/gui/qgsmaptool.cpp +++ b/src/gui/qgsmaptool.cpp @@ -56,7 +56,7 @@ QgsPoint QgsMapTool::toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point return mCanvas->mapRenderer()->layerToMapCoordinates( layer, point ); } -QgsRect QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, const QgsRect& rect ) +QgsRectangle QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect ) { return mCanvas->mapRenderer()->mapToLayerCoordinates( layer, rect ); } diff --git a/src/gui/qgsmaptool.h b/src/gui/qgsmaptool.h index 2ad3e52f2e69..82bbe43cc951 100644 --- a/src/gui/qgsmaptool.h +++ b/src/gui/qgsmaptool.h @@ -26,7 +26,7 @@ class QgsMapCanvas; class QKeyEvent; class QMouseEvent; class QgsPoint; -class QgsRect; +class QgsRectangle; class QPoint; class QAction; class QAbstractButton; @@ -117,7 +117,7 @@ class GUI_EXPORT QgsMapTool : public QObject QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point ); //! trnasformation of the rect from map coordinates to layer's coordinates - QgsRect toLayerCoordinates( QgsMapLayer* layer, const QgsRect& rect ); + QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect ); //! transformation from map coordinates to screen coordinates QPoint toCanvasCoordinates( const QgsPoint& point ); diff --git a/src/gui/qgsmaptoolzoom.cpp b/src/gui/qgsmaptoolzoom.cpp index 26ef51b4319e..e8839ef4d5cb 100644 --- a/src/gui/qgsmaptoolzoom.cpp +++ b/src/gui/qgsmaptoolzoom.cpp @@ -83,7 +83,7 @@ void QgsMapToolZoom::canvasReleaseEvent( QMouseEvent * e ) QgsPoint ll = coordinateTransform->toMapCoordinates( mZoomRect.left(), mZoomRect.bottom() ); QgsPoint ur = coordinateTransform->toMapCoordinates( mZoomRect.right(), mZoomRect.top() ); - QgsRect r; + QgsRectangle r; r.setXMinimum( ll.x() ); r.setYMinimum( ll.y() ); r.setXMaximum( ur.x() ); @@ -99,7 +99,7 @@ void QgsMapToolZoom::canvasReleaseEvent( QMouseEvent * e ) if ( mZoomOut ) { QgsPoint cer = r.center(); - QgsRect extent = mCanvas->extent(); + QgsRectangle extent = mCanvas->extent(); double sf; if ( mZoomRect.width() > mZoomRect.height() ) diff --git a/src/gui/qgsrubberband.cpp b/src/gui/qgsrubberband.cpp index 0aaf90d773fc..e3078ed0c765 100644 --- a/src/gui/qgsrubberband.cpp +++ b/src/gui/qgsrubberband.cpp @@ -319,7 +319,7 @@ void QgsRubberBand::updateRect() { return; } - QgsRect r( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY, + QgsRectangle r( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY, it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY ); for ( int i = 0; i < mPoints.size(); ++i ) @@ -336,7 +336,7 @@ void QgsRubberBand::updateRect() } else { - setRect( QgsRect() ); + setRect( QgsRectangle() ); } setVisible( mPoints.size() > 0 ); } diff --git a/src/plugins/grass/qgsgrassmodule.cpp b/src/plugins/grass/qgsgrassmodule.cpp index cd3bc7aec7a9..db8dc8f60751 100644 --- a/src/plugins/grass/qgsgrassmodule.cpp +++ b/src/plugins/grass/qgsgrassmodule.cpp @@ -2961,7 +2961,7 @@ void QgsGrassModuleSelection::updateSelection() if ( keyField < 0 ) return; QString cats; - provider->select( allAttributes, QgsRect(), true ); + provider->select( allAttributes, QgsRectangle(), true ); QgsFeature feature; int i = 0; diff --git a/src/plugins/grass/qgsgrassnewmapset.cpp b/src/plugins/grass/qgsgrassnewmapset.cpp index f84580610326..6bddeda951e2 100644 --- a/src/plugins/grass/qgsgrassnewmapset.cpp +++ b/src/plugins/grass/qgsgrassnewmapset.cpp @@ -602,9 +602,9 @@ void QgsGrassNewMapset::setRegionPage() mRegionButton->show(); mSetRegionFrame->show(); - QgsRect ext = mIface->mapCanvas()->extent(); + QgsRectangle ext = mIface->mapCanvas()->extent(); - if ( ext.xMin() >= ext.xMax() || ext.yMin() >= ext.yMax() ) + if ( ext.xMinimum() >= ext.xMaximum() || ext.yMinimum() >= ext.yMaximum() ) { mCurrentRegionButton->setEnabled( false ); } @@ -627,9 +627,9 @@ void QgsGrassNewMapset::setGrassRegionDefaults() QgsDebugMsg( QString( "current project srsid = %1" ).arg( srsid ) ); - QgsRect ext = mIface->mapCanvas()->extent(); + QgsRectangle ext = mIface->mapCanvas()->extent(); bool extSet = false; - if ( ext.xMin() < ext.xMax() && ext.yMin() < ext.yMax() ) + if ( ext.xMinimum() < ext.xMaximum() && ext.yMinimum() < ext.yMaximum() ) { extSet = true; } @@ -641,10 +641,10 @@ void QgsGrassNewMapset::setGrassRegionDefaults() ) ) { - mNorthLineEdit->setText( QString::number( ext.yMax() ) ); - mSouthLineEdit->setText( QString::number( ext.yMin() ) ); - mEastLineEdit->setText( QString::number( ext.xMax() ) ); - mWestLineEdit->setText( QString::number( ext.xMin() ) ); + mNorthLineEdit->setText( QString::number( ext.yMaximum() ) ); + mSouthLineEdit->setText( QString::number( ext.yMinimum() ) ); + mEastLineEdit->setText( QString::number( ext.xMaximum() ) ); + mWestLineEdit->setText( QString::number( ext.xMinimum() ) ); } else if ( mCellHead.proj == PROJECTION_XY ) { @@ -947,7 +947,7 @@ void QgsGrassNewMapset::setCurrentRegion() { QgsDebugMsg( "entered." ); - QgsRect ext = mIface->mapCanvas()->extent(); + QgsRectangle ext = mIface->mapCanvas()->extent(); int srsid = QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectCRSID", 0 ); @@ -959,8 +959,8 @@ void QgsGrassNewMapset::setCurrentRegion() std::vector points; // TODO: this is not perfect - points.push_back( QgsPoint( ext.xMin(), ext.yMin() ) ); - points.push_back( QgsPoint( ext.xMax(), ext.yMax() ) ); + points.push_back( QgsPoint( ext.xMinimum(), ext.yMinimum() ) ); + points.push_back( QgsPoint( ext.xMaximum(), ext.yMaximum() ) ); // TODO add a method, this code is copy-paste from setSelectedRegion if ( srs.isValid() && mSrs.isValid() diff --git a/src/plugins/interpolation/qgsgridfilewriter.cpp b/src/plugins/interpolation/qgsgridfilewriter.cpp index 3216a1cba7b0..e283b5cec721 100644 --- a/src/plugins/interpolation/qgsgridfilewriter.cpp +++ b/src/plugins/interpolation/qgsgridfilewriter.cpp @@ -20,10 +20,10 @@ #include #include -QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRect extent, int nCols, int nRows ): mInterpolator( i ), mOutputFilePath( outputPath ), mInterpolationExtent( extent ), mNumColumns( nCols ), mNumRows( nRows ) +QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows ): mInterpolator( i ), mOutputFilePath( outputPath ), mInterpolationExtent( extent ), mNumColumns( nCols ), mNumRows( nRows ) { - mCellSizeX = ( mInterpolationExtent.xMax() - mInterpolationExtent.xMin() ) / mNumColumns; - mCellSizeY = ( mInterpolationExtent.yMax() - mInterpolationExtent.yMin() ) / mNumRows; + mCellSizeX = ( mInterpolationExtent.xMaximum() - mInterpolationExtent.xMinimum() ) / mNumColumns; + mCellSizeY = ( mInterpolationExtent.yMaximum() - mInterpolationExtent.yMinimum() ) / mNumRows; } QgsGridFileWriter::QgsGridFileWriter(): mInterpolator( 0 ) @@ -55,7 +55,7 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog ) outStream.setRealNumberPrecision( 8 ); writeHeader( outStream ); - double currentYValue = mInterpolationExtent.yMax(); + double currentYValue = mInterpolationExtent.yMaximum(); double currentXValue; double interpolatedValue; @@ -68,7 +68,7 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog ) for ( int i = 0; i < mNumRows; ++i ) { - currentXValue = mInterpolationExtent.xMin(); + currentXValue = mInterpolationExtent.xMinimum(); for ( int j = 0; j < mNumColumns; ++j ) { if ( mInterpolator->interpolatePoint( currentXValue, currentYValue, interpolatedValue ) == 0 ) @@ -103,8 +103,8 @@ int QgsGridFileWriter::writeHeader( QTextStream& outStream ) { outStream << "NCOLS " << mNumColumns << endl; outStream << "NROWS " << mNumRows << endl; - outStream << "XLLCORNER " << mInterpolationExtent.xMin() << endl; - outStream << "YLLCORNER " << mInterpolationExtent.yMin() << endl; + outStream << "XLLCORNER " << mInterpolationExtent.xMinimum() << endl; + outStream << "YLLCORNER " << mInterpolationExtent.yMinimum() << endl; if ( mCellSizeX == mCellSizeY ) //standard way { outStream << "CELLSIZE " << mCellSizeX << endl; diff --git a/src/plugins/interpolation/qgsgridfilewriter.h b/src/plugins/interpolation/qgsgridfilewriter.h index c10ca2f31bbb..2092b0196c5c 100644 --- a/src/plugins/interpolation/qgsgridfilewriter.h +++ b/src/plugins/interpolation/qgsgridfilewriter.h @@ -18,7 +18,7 @@ #ifndef QGSGRIDFILEWRITER_H #define QGSGRIDFILEWRITER_H -#include "qgsrect.h" +#include "qgsrectangle.h" #include #include @@ -29,7 +29,7 @@ class QgsInterpolator; class QgsGridFileWriter { public: - QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRect extent, int nCols, int nRows ); + QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows ); ~QgsGridFileWriter(); /**Writes the grid file. @@ -45,7 +45,7 @@ class QgsGridFileWriter QgsInterpolator* mInterpolator; QString mOutputFilePath; - QgsRect mInterpolationExtent; + QgsRectangle mInterpolationExtent; int mNumColumns; int mNumRows; diff --git a/src/plugins/north_arrow/plugin.cpp b/src/plugins/north_arrow/plugin.cpp index 2d1b4b0199a6..a70168c56ad8 100644 --- a/src/plugins/north_arrow/plugin.cpp +++ b/src/plugins/north_arrow/plugin.cpp @@ -308,7 +308,7 @@ bool QgsNorthArrowPlugin::calculateNorthDirection() QgsCoordinateTransform transform( outputCRS, ourCRS ); - QgsRect extent = mapCanvas.extent(); + QgsRectangle extent = mapCanvas.extent(); QgsPoint p1( extent.center() ); // A point a bit above p1. XXX assumes that y increases up!! // May need to involve the maptopixel transform if this proves diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp index 64382e25a8e7..4dfa0bacfbb2 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp @@ -36,7 +36,7 @@ #include "qgsfield.h" #include "qgslogger.h" #include "qgsmessageoutput.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" #include "qgis.h" @@ -87,7 +87,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri ) mDelimiter.replace( "\\t", "\t" ); // replace "\t" with a real tabulator // Set the selection rectangle to null - mSelectionRectangle = QgsRect(); + mSelectionRectangle = QgsRectangle(); // assume the layer is invalid until proven otherwise mValid = false; if ( mFileName.isEmpty() || mDelimiter.isEmpty() || xField.isEmpty() || yField.isEmpty() ) @@ -118,7 +118,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri ) // now we have the file opened and ready for parsing // set the initial extent - mExtent = QgsRect(); + mExtent = QgsRectangle(); QMap couldBeInt; QMap couldBeDouble; @@ -419,7 +419,7 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature ) void QgsDelimitedTextProvider::select( QgsAttributeList fetchAttributes, - QgsRect rect, + QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { @@ -441,7 +441,7 @@ void QgsDelimitedTextProvider::select( QgsAttributeList fetchAttributes, // Return the extent of the layer -QgsRect QgsDelimitedTextProvider::extent() +QgsRectangle QgsDelimitedTextProvider::extent() { return mExtent; } @@ -500,8 +500,8 @@ bool QgsDelimitedTextProvider::boundsCheck( double x, double y ) if ( mSelectionRectangle.isEmpty() ) return true; - return ( x <= mSelectionRectangle.xMax() ) && ( x >= mSelectionRectangle.xMin() ) && - ( y <= mSelectionRectangle.yMax() ) && ( y >= mSelectionRectangle.yMin() ); + return ( x <= mSelectionRectangle.xMaximum() ) && ( x >= mSelectionRectangle.xMinimum() ) && + ( y <= mSelectionRectangle.yMaximum() ) && ( y >= mSelectionRectangle.yMinimum() ); } int QgsDelimitedTextProvider::capabilities() const diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovider.h b/src/providers/delimitedtext/qgsdelimitedtextprovider.h index 603f04c87a4f..67aebe30ba1b 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovider.h +++ b/src/providers/delimitedtext/qgsdelimitedtextprovider.h @@ -65,7 +65,7 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -145,7 +145,7 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider /** * Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** * Returns true if this is a valid delimited file @@ -185,11 +185,11 @@ class QgsDelimitedTextProvider : public QgsVectorDataProvider int mYFieldIndex; //! Layer extent - QgsRect mExtent; + QgsRectangle mExtent; //! Current selection rectangle - QgsRect mSelectionRectangle; + QgsRectangle mSelectionRectangle; //! Text file QFile *mFile; diff --git a/src/providers/gpx/gpsdata.cpp b/src/providers/gpx/gpsdata.cpp index ba892887b9cd..da904654d234 100644 --- a/src/providers/gpx/gpsdata.cpp +++ b/src/providers/gpx/gpsdata.cpp @@ -152,9 +152,9 @@ GPSData::GPSData() } -QgsRect GPSData::getExtent() const +QgsRectangle GPSData::getExtent() const { - return QgsRect( xMin, yMin, xMax, yMax ); + return QgsRectangle( xMin, yMin, xMax, yMax ); } void GPSData::setNoDataExtent() diff --git a/src/providers/gpx/gpsdata.h b/src/providers/gpx/gpsdata.h index b7d557bf14e8..fac57c12dd17 100644 --- a/src/providers/gpx/gpsdata.h +++ b/src/providers/gpx/gpsdata.h @@ -30,7 +30,7 @@ #include #include -#include "qgsrect.h" +#include "qgsrectangle.h" // workaround for MSVC compiler which already has defined macro max // that interferes with calling std::numeric_limits::max @@ -146,10 +146,10 @@ class GPSData to use a GPSData object in QGIS without parsing a datafile into it. */ GPSData(); - /** This function returns a pointer to a dynamically allocated QgsRect + /** This function returns a pointer to a dynamically allocated QgsRectangle which is the bounding box for this dataset. You'll have to deallocate it yourself. */ - QgsRect getExtent() const; + QgsRectangle getExtent() const; /** Sets a default sensible extent. Only applies when there are no actual data. */ void setNoDataExtent(); diff --git a/src/providers/gpx/qgsgpxprovider.cpp b/src/providers/gpx/qgsgpxprovider.cpp index ffd5f834e1b8..34f255fadfd5 100644 --- a/src/providers/gpx/qgsgpxprovider.cpp +++ b/src/providers/gpx/qgsgpxprovider.cpp @@ -40,7 +40,7 @@ #include "qgsfield.h" #include "qgsgeometry.h" #include "qgscoordinatereferencesystem.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsgpxprovider.h" #include "gpsdata.h" #include "qgslogger.h" @@ -209,9 +209,9 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature ) if ( rte->points.size() == 0 ) continue; - const QgsRect& b( *mSelectionRectangle ); - if (( rte->xMax >= b.xMin() ) && ( rte->xMin <= b.xMax() ) && - ( rte->yMax >= b.yMin() ) && ( rte->yMin <= b.yMax() ) ) + const QgsRectangle& b( *mSelectionRectangle ); + if (( rte->xMax >= b.xMinimum() ) && ( rte->xMin <= b.xMaximum() ) && + ( rte->yMax >= b.yMinimum() ) && ( rte->yMin <= b.yMaximum() ) ) { // some wkb voodoo int nPoints = rte->points.size(); @@ -313,9 +313,9 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature ) if ( totalPoints == 0 ) continue; QgsDebugMsg( "GPX feature track total points: " + QString::number( totalPoints ) ); - const QgsRect& b( *mSelectionRectangle ); - if (( trk->xMax >= b.xMin() ) && ( trk->xMin <= b.xMax() ) && - ( trk->yMax >= b.yMin() ) && ( trk->yMin <= b.yMax() ) ) + const QgsRectangle& b( *mSelectionRectangle ); + if (( trk->xMax >= b.xMinimum() ) && ( trk->xMin <= b.xMaximum() ) && + ( trk->yMax >= b.yMinimum() ) && ( trk->yMin <= b.yMaximum() ) ) { // some wkb voodoo char* geo = new char[9 + 16 * totalPoints]; @@ -407,7 +407,7 @@ bool QgsGPXProvider::nextFeature( QgsFeature& feature ) } void QgsGPXProvider::select( QgsAttributeList fetchAttributes, - QgsRect rect, + QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { @@ -416,11 +416,11 @@ void QgsGPXProvider::select( QgsAttributeList fetchAttributes, if ( rect.isEmpty() ) { - mSelectionRectangle = new QgsRect( extent() ); + mSelectionRectangle = new QgsRectangle( extent() ); } else { - mSelectionRectangle = new QgsRect( rect ); + mSelectionRectangle = new QgsRectangle( rect ); } mAttributesToFetch = fetchAttributes; mFetchGeom = fetchGeometry; @@ -431,7 +431,7 @@ void QgsGPXProvider::select( QgsAttributeList fetchAttributes, // Return the extent of the layer -QgsRect QgsGPXProvider::extent() +QgsRectangle QgsGPXProvider::extent() { return data->getExtent(); } @@ -822,10 +822,10 @@ QVariant QgsGPXProvider::defaultValue( int fieldId ) */ bool QgsGPXProvider::boundsCheck( double x, double y ) { - bool inBounds = ((( x <= mSelectionRectangle->xMax() ) && - ( x >= mSelectionRectangle->xMin() ) ) && - (( y <= mSelectionRectangle->yMax() ) && - ( y >= mSelectionRectangle->yMin() ) ) ); + bool inBounds = ((( x <= mSelectionRectangle->xMaximum() ) && + ( x >= mSelectionRectangle->xMinimum() ) ) && + (( y <= mSelectionRectangle->yMaximum() ) && + ( y >= mSelectionRectangle->yMinimum() ) ) ); QString hit = inBounds ? "true" : "false"; return inBounds; } diff --git a/src/providers/gpx/qgsgpxprovider.h b/src/providers/gpx/qgsgpxprovider.h index 1ca4263aa8b7..9f61537c50d5 100644 --- a/src/providers/gpx/qgsgpxprovider.h +++ b/src/providers/gpx/qgsgpxprovider.h @@ -59,7 +59,7 @@ class QgsGPXProvider : public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -127,7 +127,7 @@ class QgsGPXProvider : public QgsVectorDataProvider /** Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /**Returns true if this is a valid delimited file */ @@ -175,7 +175,7 @@ class QgsGPXProvider : public QgsVectorDataProvider }; static const char* attr[]; //! Current selection rectangle - QgsRect *mSelectionRectangle; + QgsRectangle *mSelectionRectangle; bool mValid; long mNumberFeatures; diff --git a/src/providers/grass/provider.cpp b/src/providers/grass/provider.cpp index 23fc14eaea89..8b51dcc7d402 100644 --- a/src/providers/grass/provider.cpp +++ b/src/providers/grass/provider.cpp @@ -25,7 +25,7 @@ #include "qgsdataprovider.h" #include "qgsfeature.h" #include "qgsfield.h" -#include "qgsrect.h" +#include "qgsrectangle.h" extern "C" { diff --git a/src/providers/grass/qgsgrassprovider.cpp b/src/providers/grass/qgsgrassprovider.cpp index 329dd5b8c839..75c2bf5a6436 100644 --- a/src/providers/grass/qgsgrassprovider.cpp +++ b/src/providers/grass/qgsgrassprovider.cpp @@ -423,7 +423,7 @@ void QgsGrassProvider::resetSelection( bool sel ) } void QgsGrassProvider::select( QgsAttributeList fetchAttributes, - QgsRect rect, + QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { @@ -461,8 +461,8 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes, if ( !useIntersect ) { // select by bounding boxes only BOUND_BOX box; - box.N = rect.yMax(); box.S = rect.yMin(); - box.E = rect.xMax(); box.W = rect.xMin(); + box.N = rect.yMaximum(); box.S = rect.yMinimum(); + box.E = rect.xMaximum(); box.W = rect.xMinimum(); box.T = PORT_DOUBLE_MAX; box.B = -PORT_DOUBLE_MAX; if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY ) { @@ -480,11 +480,11 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes, Polygon = Vect_new_line_struct(); - Vect_append_point( Polygon, rect.xMin(), rect.yMin(), 0 ); - Vect_append_point( Polygon, rect.xMax(), rect.yMin(), 0 ); - Vect_append_point( Polygon, rect.xMax(), rect.yMax(), 0 ); - Vect_append_point( Polygon, rect.xMin(), rect.yMax(), 0 ); - Vect_append_point( Polygon, rect.xMin(), rect.yMin(), 0 ); + Vect_append_point( Polygon, rect.xMinimum(), rect.yMinimum(), 0 ); + Vect_append_point( Polygon, rect.xMaximum(), rect.yMinimum(), 0 ); + Vect_append_point( Polygon, rect.xMaximum(), rect.yMaximum(), 0 ); + Vect_append_point( Polygon, rect.xMinimum(), rect.yMaximum(), 0 ); + Vect_append_point( Polygon, rect.xMinimum(), rect.yMinimum(), 0 ); if ( mLayerType == POINT || mLayerType == CENTROID || mLayerType == LINE || mLayerType == BOUNDARY ) { @@ -512,12 +512,12 @@ void QgsGrassProvider::select( QgsAttributeList fetchAttributes, -QgsRect QgsGrassProvider::extent() +QgsRectangle QgsGrassProvider::extent() { BOUND_BOX box; Vect_get_map_box( mMap, &box ); - return QgsRect( box.W, box.S, box.E, box.N ); + return QgsRectangle( box.W, box.S, box.E, box.N ); } /** diff --git a/src/providers/grass/qgsgrassprovider.h b/src/providers/grass/qgsgrassprovider.h index 6c61e77c916e..ce9986e97d6f 100644 --- a/src/providers/grass/qgsgrassprovider.h +++ b/src/providers/grass/qgsgrassprovider.h @@ -132,7 +132,7 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider * @note This function works only until first edit operation! (category index used) */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -164,7 +164,7 @@ class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider /** Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** * Get the field information for the layer diff --git a/src/providers/memory/qgsmemoryprovider.cpp b/src/providers/memory/qgsmemoryprovider.cpp index e9d837397e5b..fba435d9b20d 100644 --- a/src/providers/memory/qgsmemoryprovider.cpp +++ b/src/providers/memory/qgsmemoryprovider.cpp @@ -150,7 +150,7 @@ bool QgsMemoryProvider::featureAtId( int featureId, void QgsMemoryProvider::select( QgsAttributeList fetchAttributes, - QgsRect rect, + QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { @@ -187,7 +187,7 @@ void QgsMemoryProvider::rewind() } -QgsRect QgsMemoryProvider::extent() +QgsRectangle QgsMemoryProvider::extent() { return mExtent; } @@ -370,7 +370,7 @@ void QgsMemoryProvider::updateExtent() { if ( mFeatures.count() == 0 ) { - mExtent = QgsRect(); + mExtent = QgsRectangle(); } else { diff --git a/src/providers/memory/qgsmemoryprovider.h b/src/providers/memory/qgsmemoryprovider.h index 12782b56ea66..0c492b17feed 100644 --- a/src/providers/memory/qgsmemoryprovider.h +++ b/src/providers/memory/qgsmemoryprovider.h @@ -42,7 +42,7 @@ class QgsMemoryProvider : public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -168,7 +168,7 @@ class QgsMemoryProvider : public QgsVectorDataProvider /** * Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** * Returns true if this is a valid provider @@ -186,7 +186,7 @@ class QgsMemoryProvider : public QgsVectorDataProvider // fields QgsFieldMap mFields; QGis::WkbType mWkbType; - QgsRect mExtent; + QgsRectangle mExtent; // features QgsFeatureMap mFeatures; @@ -194,7 +194,7 @@ class QgsMemoryProvider : public QgsVectorDataProvider // selection QgsAttributeList mSelectAttrs; - QgsRect mSelectRect; + QgsRectangle mSelectRect; QgsGeometry* mSelectRectGeom; bool mSelectGeometry, mSelectUseIntersect; QgsFeatureMap::iterator mSelectIterator; diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index 5b53c4343e4f..a460c0de7d89 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -254,7 +254,7 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature ) } OGRFeatureH fet; - QgsRect selectionRect; + QgsRectangle selectionRect; while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) != NULL ) { @@ -284,7 +284,7 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature ) if ( mUseIntersect ) { //precise test for intersection with search rectangle - //first make QgsRect from OGRPolygon + //first make QgsRectangle from OGRPolygon OGREnvelope env; memset( &env, 0, sizeof( env ) ); if ( mSelectionRectangle ) @@ -327,7 +327,7 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature ) } } -void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRect rect, bool fetchGeometry, bool useIntersect ) +void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { mUseIntersect = useIntersect; mAttributesToFetch = fetchAttributes; @@ -383,7 +383,7 @@ unsigned char * QgsOgrProvider::getGeometryPointer( OGRFeatureH fet ) } -QgsRect QgsOgrProvider::extent() +QgsRectangle QgsOgrProvider::extent() { OGREnvelope *ext = ( OGREnvelope * ) extent_; mExtentRect.set( ext->MinX, ext->MinY, ext->MaxX, ext->MaxY ); diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index e00eeba80729..4fda5458d443 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -16,7 +16,7 @@ email : sherman at mrcc.com ***************************************************************************/ /* $Id$ */ -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsvectordataprovider.h" class QgsFeature; @@ -61,7 +61,7 @@ class QgsOgrProvider : public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -117,7 +117,7 @@ class QgsOgrProvider : public QgsVectorDataProvider /** Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** Restart reading features from previous select operation */ virtual void rewind(); @@ -230,7 +230,7 @@ class QgsOgrProvider : public QgsVectorDataProvider /**This member variable receives the same value as extent_ in the method QgsOgrProvider::extent(). The purpose is to prevent a memory leak*/ - QgsRect mExtentRect; + QgsRectangle mExtentRect; OGRLayerH ogrLayer; // OGR Driver that was actually used to open the layer diff --git a/src/providers/postgres/qgspostgisbox2d.cpp b/src/providers/postgres/qgspostgisbox2d.cpp index bcf6ac1d946a..40b8e8383c3a 100644 --- a/src/providers/postgres/qgspostgisbox2d.cpp +++ b/src/providers/postgres/qgspostgisbox2d.cpp @@ -22,7 +22,7 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgspostgisbox2d.h" #include "qgslogger.h" diff --git a/src/providers/postgres/qgspostgisbox2d.h b/src/providers/postgres/qgspostgisbox2d.h index 22275cd0d000..f9647754110d 100644 --- a/src/providers/postgres/qgspostgisbox2d.h +++ b/src/providers/postgres/qgspostgisbox2d.h @@ -22,7 +22,7 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" /*! * \brief PostgreSQL/PostGIS "box3d" representation and transformation @@ -40,7 +40,7 @@ */ -class QgsPostGisBox2d : public QgsRect +class QgsPostGisBox2d : public QgsRectangle { public: diff --git a/src/providers/postgres/qgspostgisbox3d.cpp b/src/providers/postgres/qgspostgisbox3d.cpp index 1639bc7682f5..f346c6fda19d 100644 --- a/src/providers/postgres/qgspostgisbox3d.cpp +++ b/src/providers/postgres/qgspostgisbox3d.cpp @@ -22,7 +22,7 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgspostgisbox3d.h" #include "qgslogger.h" diff --git a/src/providers/postgres/qgspostgisbox3d.h b/src/providers/postgres/qgspostgisbox3d.h index a8e5155cf173..2681a823d464 100644 --- a/src/providers/postgres/qgspostgisbox3d.h +++ b/src/providers/postgres/qgspostgisbox3d.h @@ -22,7 +22,7 @@ #include -#include "qgsrect.h" +#include "qgsrectangle.h" /*! * \brief PostgreSQL/PostGIS "box3d" representation and transformation @@ -37,7 +37,7 @@ */ -class QgsPostGisBox3d : public QgsRect +class QgsPostGisBox3d : public QgsRectangle { public: diff --git a/src/providers/postgres/qgspostgrescountthread.cpp b/src/providers/postgres/qgspostgrescountthread.cpp index 5fe5052fdc81..95263d5897db 100644 --- a/src/providers/postgres/qgspostgrescountthread.cpp +++ b/src/providers/postgres/qgspostgrescountthread.cpp @@ -22,7 +22,7 @@ #include #include "qgis.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgsprovidercountcalcevent.h" diff --git a/src/providers/postgres/qgspostgresextentthread.cpp b/src/providers/postgres/qgspostgresextentthread.cpp index 3e649708d417..1b247f8f1359 100644 --- a/src/providers/postgres/qgspostgresextentthread.cpp +++ b/src/providers/postgres/qgspostgresextentthread.cpp @@ -25,7 +25,7 @@ #include #include "qgis.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgspostgresextentthread.h" @@ -132,7 +132,7 @@ void QgsPostgresExtentThread::run() s = box3d.substr( 0, box3d.find_first_of( " " ) ); double maxy = strtod( s.c_str(), NULL ); - layerExtent = new QgsRect( minx, miny, maxx, maxy ); + layerExtent = new QgsRectangle( minx, miny, maxx, maxy ); /* layerExtent.setXMaximum(maxx); @@ -142,7 +142,7 @@ void QgsPostgresExtentThread::run() */ - QgsDebugMsg( QString( "Set extents to: %1, %2 %3, %4" ).arg( layerExtent->xMin() ).arg( layerExtent->yMin() ).arg( layerExtent->xMax() ).arg( layerExtent->yMax() ) ); + QgsDebugMsg( QString( "Set extents to: %1, %2 %3, %4" ).arg( layerExtent->xMinimum() ).arg( layerExtent->yMinimum() ).arg( layerExtent->xMaximum() ).arg( layerExtent->yMaximum() ) ); // clear query result PQclear( result ); diff --git a/src/providers/postgres/qgspostgresextentthread.h b/src/providers/postgres/qgspostgresextentthread.h index 6b9d8eaa12ef..82d4ca98cc17 100644 --- a/src/providers/postgres/qgspostgresextentthread.h +++ b/src/providers/postgres/qgspostgresextentthread.h @@ -137,16 +137,16 @@ class QgsPostgresExtentThread : public QThread QObject* callbackObject; //QgsPostgresProvider* callbackObject; -// typedef void (QgsPostgresProvider::*tFunction)(QgsRect* rect); +// typedef void (QgsPostgresProvider::*tFunction)(QgsRectangle* rect); // QgsPostgresProvider *cInst; // tFunction pFunction; -// QgsRectCallbackTemplate callbackFunction; +// QgsRectangleCallbackTemplate callbackFunction; /** * Rectangle that contains the extent (bounding box) of the layer */ - QgsRect* layerExtent; + QgsRectangle* layerExtent; }; diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index 05796a8068f8..5fc7024de36f 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "qgsprovidercountcalcevent.h" @@ -512,7 +512,7 @@ bool QgsPostgresProvider::getFeature( PGresult *queryResult, int row, bool fetch } } -void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRect rect, bool fetchGeometry, bool useIntersect ) +void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { QString cursorName = QString( "qgisf%1" ).arg( providerId ); @@ -659,16 +659,16 @@ QgsDataSourceURI& QgsPostgresProvider::getURI() return mUri; } -void QgsPostgresProvider::setExtent( QgsRect& newExtent ) +void QgsPostgresProvider::setExtent( QgsRectangle& newExtent ) { - layerExtent.setXMaximum( newExtent.xMax() ); - layerExtent.setXMinimum( newExtent.xMin() ); - layerExtent.setYMaximum( newExtent.yMax() ); - layerExtent.setYMinimum( newExtent.yMin() ); + layerExtent.setXMaximum( newExtent.xMaximum() ); + layerExtent.setXMinimum( newExtent.xMinimum() ); + layerExtent.setYMaximum( newExtent.yMaximum() ); + layerExtent.setYMinimum( newExtent.yMinimum() ); } // TODO - make this function return the real extent_ -QgsRect QgsPostgresProvider::extent() +QgsRectangle QgsPostgresProvider::extent() { return layerExtent; //extent_->MinX, extent_->MinY, extent_->MaxX, extent_->MaxY); } @@ -2331,10 +2331,10 @@ void QgsPostgresProvider::calculateExtents() QTextOStream( &xMsg ).precision( 18 ); QTextOStream( &xMsg ).width( 18 ); QTextOStream( &xMsg ) << "QgsPostgresProvider: Set extents to: " - << layerExtent.xMin() << ", " - << layerExtent.yMin() << " " - << layerExtent.xMax() << ", " - << layerExtent.yMax(); + << layerExtent.xMinimum() << ", " + << layerExtent.yMinimum() << " " + << layerExtent.xMaximum() << ", " + << layerExtent.yMaximum(); QgsDebugMsg( xMsg ); #endif #endif @@ -2358,7 +2358,7 @@ void QgsPostgresProvider::customEvent( QEvent * e ) // extent with it. { - QgsRect* r = (( QgsProviderExtentCalcEvent* ) e )->layerExtent(); + QgsRectangle* r = (( QgsProviderExtentCalcEvent* ) e )->layerExtent(); setExtent( *r ); } diff --git a/src/providers/postgres/qgspostgresprovider.h b/src/providers/postgres/qgspostgresprovider.h index 0736b68e7066..681dfc5e311f 100644 --- a/src/providers/postgres/qgspostgresprovider.h +++ b/src/providers/postgres/qgspostgresprovider.h @@ -24,7 +24,7 @@ extern "C" #include } #include "qgsvectordataprovider.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include #include #include @@ -83,7 +83,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -151,11 +151,11 @@ class QgsPostgresProvider : public QgsVectorDataProvider * Changes the stored extent for this layer to the supplied extent. * For example, this is called when the extent worker thread has a result. */ - void setExtent( QgsRect& newExtent ); + void setExtent( QgsRectangle& newExtent ); /** Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** * Get the name of the primary key for the layer */ @@ -400,7 +400,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider /** * Rectangle that contains the extent (bounding box) of the layer */ - QgsRect layerExtent; + QgsRectangle layerExtent; /** * Number of features in the layer diff --git a/src/providers/wfs/qgswfsdata.cpp b/src/providers/wfs/qgswfsdata.cpp index 532f6ae8d2bb..b70ca6121bd8 100644 --- a/src/providers/wfs/qgswfsdata.cpp +++ b/src/providers/wfs/qgswfsdata.cpp @@ -13,7 +13,7 @@ * * ***************************************************************************/ #include "qgswfsdata.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" #include #include @@ -28,7 +28,7 @@ const QString GML_NAMESPACE = "http://www.opengis.net/gml"; QgsWFSData::QgsWFSData( const QString& uri, - QgsRect* extent, + QgsRectangle* extent, QgsCoordinateReferenceSystem* srs, QList &features, const QString& geometryAttribute, @@ -453,7 +453,7 @@ QString QgsWFSData::readTsFromAttribute( const XML_Char** attr ) const return " "; } -int QgsWFSData::createBBoxFromCoordinateString( QgsRect* bb, const QString& coordString ) const +int QgsWFSData::createBBoxFromCoordinateString( QgsRectangle* bb, const QString& coordString ) const { if ( !bb ) { diff --git a/src/providers/wfs/qgswfsdata.h b/src/providers/wfs/qgswfsdata.h index 95c117669804..d31d395dd590 100644 --- a/src/providers/wfs/qgswfsdata.h +++ b/src/providers/wfs/qgswfsdata.h @@ -25,7 +25,7 @@ #include #include #include -class QgsRect; +class QgsRectangle; class QgsCoordinateReferenceSystem; @@ -36,7 +36,7 @@ class QgsWFSData: public QObject public: QgsWFSData( const QString& uri, - QgsRect* extent, + QgsRectangle* extent, QgsCoordinateReferenceSystem* srs, QList &features, const QString& geometryAttribute, @@ -107,7 +107,7 @@ class QgsWFSData: public QObject QString readTsFromAttribute( const XML_Char** attr ) const; /**Creates a rectangle from a coordinate string. @return 0 in case of success*/ - int createBBoxFromCoordinateString( QgsRect* bb, const QString& coordString ) const; + int createBBoxFromCoordinateString( QgsRectangle* bb, const QString& coordString ) const; /**Creates a set of points from a coordinate string. @param points list that will contain the created points @param coordString the text containing the coordinates @@ -129,7 +129,7 @@ class QgsWFSData: public QObject QString mUri; //results are members such that handler routines are able to manipulate them /**Bounding box of the layer*/ - QgsRect* mExtent; + QgsRectangle* mExtent; /**Source srs of the layer*/ QgsCoordinateReferenceSystem* mSrs; /**The features of the layer*/ diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index 986da2d5e139..259dafde5448 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -138,7 +138,7 @@ QgsCoordinateReferenceSystem QgsWFSProvider::crs() return mSourceCRS; } -QgsRect QgsWFSProvider::extent() +QgsRectangle QgsWFSProvider::extent() { return mExtent; } @@ -149,7 +149,7 @@ bool QgsWFSProvider::isValid() } void QgsWFSProvider::select( QgsAttributeList fetchAttributes, - QgsRect rect, + QgsRectangle rect, bool fetchGeometry, bool useIntersect ) { @@ -580,7 +580,7 @@ int QgsWFSProvider::guessAttributesFromFile( const QString& uri, QString& geomet return 0; } -int QgsWFSProvider::getExtentFromGML2( QgsRect* extent, const QDomElement& wfsCollectionElement ) const +int QgsWFSProvider::getExtentFromGML2( QgsRectangle* extent, const QDomElement& wfsCollectionElement ) const { QDomNodeList boundedByList = wfsCollectionElement.elementsByTagNameNS( GML_NAMESPACE, "boundedBy" ); if ( boundedByList.length() < 1 ) diff --git a/src/providers/wfs/qgswfsprovider.h b/src/providers/wfs/qgswfsprovider.h index 85dcc27e1e8e..e1c2ce84b07d 100644 --- a/src/providers/wfs/qgswfsprovider.h +++ b/src/providers/wfs/qgswfsprovider.h @@ -20,11 +20,11 @@ #include #include "qgis.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" #include "qgsvectordataprovider.h" -class QgsRect; +class QgsRectangle; class QgsSpatialIndex; /**A provider reading features from a WFS server*/ @@ -54,7 +54,7 @@ class QgsWFSProvider: public QgsVectorDataProvider * false if a test based on bounding box is sufficient */ virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(), - QgsRect rect = QgsRect(), + QgsRectangle rect = QgsRectangle(), bool fetchGeometry = true, bool useIntersect = false ); @@ -75,7 +75,7 @@ class QgsWFSProvider: public QgsVectorDataProvider /* Inherited from QgsDataProvider */ - QgsRect extent(); + QgsRectangle extent(); bool isValid(); QString name() const; QString description() const; @@ -105,9 +105,9 @@ class QgsWFSProvider: public QgsVectorDataProvider /**The encoding used for request/response. Can be GET, POST or SOAP*/ REQUEST_ENCODING mEncoding; /**Bounding box for the layer*/ - QgsRect mExtent; + QgsRectangle mExtent; /**Spatial filter for the layer*/ - QgsRect mSpatialFilter; + QgsRectangle mSpatialFilter; /**Flag if precise intersection test is needed. Otherwise, every feature is returned (even if a filter is set)*/ bool mUseIntersect; /**A spatial index for fast access to a feature subset*/ @@ -147,7 +147,7 @@ class QgsWFSProvider: public QgsVectorDataProvider int guessAttributesFromFile( const QString& uri, QString& geometryAttribute, std::list& thematicAttributes ) const; //GML2 specific methods - int getExtentFromGML2( QgsRect* extent, const QDomElement& wfsCollectionElement ) const; + int getExtentFromGML2( QgsRectangle* extent, const QDomElement& wfsCollectionElement ) const; int getFeaturesFromGML2( const QDomElement& wfsCollectionElement, const QString& geometryAttribute ); diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index b4b621496f8f..5071027e2191 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -24,7 +24,7 @@ #include #include "qgscoordinatetransform.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include "qgscoordinatereferencesystem.h" #include "qgshttptransaction.h" @@ -273,7 +273,7 @@ void QgsWmsProvider::setImageCrs( QString const & crs ) } -QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int pixelHeight ) +QImage* QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) { QgsDebugMsg( "Entering." ); @@ -318,18 +318,18 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p if ( changeXY ) { bbox = QString( "%1,%2,%3,%4" ). - arg( viewExtent.yMin(), 0, 'f' ). - arg( viewExtent.xMin(), 0, 'f' ). - arg( viewExtent.yMax(), 0, 'f' ). - arg( viewExtent.xMax(), 0, 'f' ); + arg( viewExtent.yMinimum(), 0, 'f' ). + arg( viewExtent.xMinimum(), 0, 'f' ). + arg( viewExtent.yMaximum(), 0, 'f' ). + arg( viewExtent.xMaximum(), 0, 'f' ); } else { bbox = QString( "%1,%2,%3,%4" ). - arg( viewExtent.xMin(), 0, 'f' ). - arg( viewExtent.yMin(), 0, 'f' ). - arg( viewExtent.xMax(), 0, 'f' ). - arg( viewExtent.yMax(), 0, 'f' ); + arg( viewExtent.xMinimum(), 0, 'f' ). + arg( viewExtent.yMinimum(), 0, 'f' ). + arg( viewExtent.xMaximum(), 0, 'f' ). + arg( viewExtent.yMaximum(), 0, 'f' ); } // Width in WMS format @@ -1383,7 +1383,7 @@ void QgsWmsProvider::parseLayer( QDomElement const & e, QgsWmsLayerProperty& lay QgsDebugMsg( " LLBB is: '" + e1.attribute( "maxy" ) + "'." ); #endif - layerProperty.ex_GeographicBoundingBox = QgsRect( + layerProperty.ex_GeographicBoundingBox = QgsRectangle( e1.attribute( "minx" ).toDouble(), e1.attribute( "miny" ).toDouble(), e1.attribute( "maxx" ).toDouble(), @@ -1404,14 +1404,14 @@ void QgsWmsProvider::parseLayer( QDomElement const & e, QgsWmsLayerProperty& lay nBLat = nBoundLatitudeElem.text().toDouble( &nBOk ); if ( wBOk && eBOk && sBOk && nBOk ) { - layerProperty.ex_GeographicBoundingBox = QgsRect( wBLong, sBLat, eBLong, nBLat ); + layerProperty.ex_GeographicBoundingBox = QgsRectangle( wBLong, sBLat, eBLong, nBLat ); } } else if ( e1.tagName() == "BoundingBox" ) { // TODO: overwrite inherited QgsWmsBoundingBoxProperty bbox; - bbox.box = QgsRect( e1.attribute( "minx" ).toDouble(), + bbox.box = QgsRectangle( e1.attribute( "minx" ).toDouble(), e1.attribute( "miny" ).toDouble(), e1.attribute( "maxx" ).toDouble(), e1.attribute( "maxy" ).toDouble() @@ -1656,7 +1656,7 @@ void QgsWmsProvider::parseServiceException( QDomElement const & e ) -QgsRect QgsWmsProvider::extent() +QgsRectangle QgsWmsProvider::extent() { if ( extentDirty ) { @@ -1744,7 +1744,7 @@ bool QgsWmsProvider::calculateExtent() { QgsDebugMsg( "Sublayer Iterator: " + *it ); // This is the extent for the layer name in *it - QgsRect extent = extentForLayer.find( *it )->second; + QgsRectangle extent = extentForLayer.find( *it )->second; // Convert to the user's CRS as required try diff --git a/src/providers/wms/qgswmsprovider.h b/src/providers/wms/qgswmsprovider.h index d4456f516900..847921868cd4 100644 --- a/src/providers/wms/qgswmsprovider.h +++ b/src/providers/wms/qgswmsprovider.h @@ -25,7 +25,7 @@ #include #include "qgsrasterdataprovider.h" -#include "qgsrect.h" +#include "qgsrectangle.h" #include #include @@ -151,7 +151,7 @@ struct QgsWmsServiceProperty struct QgsWmsBoundingBoxProperty { QString crs; - QgsRect box; // consumes minx, miny, maxx, maxy. + QgsRectangle box; // consumes minx, miny, maxx, maxy. double resx; // spatial resolution (in CRS units) double resy; // spatial resolution (in CRS units) }; @@ -278,7 +278,7 @@ struct QgsWmsLayerProperty QString abstract; QStringList keywordList; std::vector crs; // coord ref sys - QgsRect ex_GeographicBoundingBox; + QgsRectangle ex_GeographicBoundingBox; std::vector boundingBox; std::vector dimension; QgsWmsAttributionProperty attribution; @@ -434,7 +434,7 @@ class QgsWmsProvider : public QgsRasterDataProvider * \warning A pointer to an QImage is used, as a plain QImage seems to have difficulty being * shared across library boundaries */ - QImage * draw( QgsRect const & viewExtent, int pixelWidth, int pixelHeight ); + QImage * draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ); // /** Experimental function only **/ @@ -444,7 +444,7 @@ class QgsWmsProvider : public QgsRasterDataProvider /** Return the extent for this data layer */ - virtual QgsRect extent(); + virtual QgsRectangle extent(); /** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult * pointer and setting it to 0 @@ -710,7 +710,7 @@ class QgsWmsProvider : public QgsRasterDataProvider /** * Rectangle that contains the extent (bounding box) of the layer */ - QgsRect layerExtent; + QgsRectangle layerExtent; /** * Capabilities of the WMS Server (raw) @@ -740,7 +740,7 @@ class QgsWmsProvider : public QgsRasterDataProvider /** * extents per layer (in WMS CRS:84 datum) */ - std::map extentForLayer; + std::map extentForLayer; /** * available CRSs per layer @@ -786,7 +786,7 @@ class QgsWmsProvider : public QgsRasterDataProvider /** * The previous parameter to draw(). */ - QgsRect cachedViewExtent; + QgsRectangle cachedViewExtent; /** * The previous parameter to draw(). diff --git a/tools/mapserver_export/qgsmapserverexport.cpp b/tools/mapserver_export/qgsmapserverexport.cpp index 70a4cd278711..308810b06f20 100644 --- a/tools/mapserver_export/qgsmapserverexport.cpp +++ b/tools/mapserver_export/qgsmapserverexport.cpp @@ -297,9 +297,9 @@ void QgsMapserverExport::writeMapFile() // extent mapFile << "\n# Extent based on full extent of QGIS view" << std::endl; mapFile << "EXTENT "; - QgsRect extent = map->extent(); - mapFile << extent.xMin() << " " << extent.yMin() << " "; - mapFile << extent.xMax() << " " << extent.yMax() << std::endl; + QgsRectangle extent = map->extent(); + mapFile << extent.xMinimum() << " " << extent.yMinimum() << " "; + mapFile << extent.xMaximum() << " " << extent.yMaximum() << std::endl; // units mapFile << "UNITS " << cmbMapUnits->currentText().toLocal8Bit().data() << std::endl; // image info