25 #include <QPaintEvent>
26 #include <QResizeEvent>
27 #include <QMouseEvent>
38 setObjectName(
"panningWidget" );
39 setMinimumSize( 5, 5 );
40 setAttribute( Qt::WA_NoSystemBackground );
46 QRegion reg( 0, 0, s.width(), s.height() );
47 QRegion reg2( 2, 2, s.width() - 4, s.height() - 4 );
48 QRegion reg3 = reg.subtracted( reg2 );
57 QRect r( QPoint( 0, 0 ),
size() );
61 p.setBrush( Qt::red );
72 , mMapCanvas( mapCanvas )
75 setObjectName(
"theOverviewCanvas" );
99 QWidget::resizeEvent( e );
106 QPainter paint(
this );
107 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
136 if ( ur.x() >= 0 && ur.x() < width() )
138 if ( ll.x() >= 0 && ll.x() < width() )
140 if ( ur.y() >= 0 && ur.y() < height() )
142 if ( ll.y() >= 0 && ll.y() < height() )
146 QgsDebugMsg(
"panning: extent out of overview area" );
153 int x1 =
static_cast<int>( ur.x() + 0.5 ), x2 = static_cast<int>( ll.x() + 0.5 );
154 int y1 =
static_cast<int>( ur.y() + 0.5 ), y2 = static_cast<int>( ll.y() + 0.5 );
166 if ( x1 == INT_MIN && x2 == INT_MAX )
168 if ( y1 == INT_MIN && y2 == INT_MAX )
172 QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
175 if ( r.width() < 5 && x1 > INT_MIN + 2 )
177 r.setX( r.x() - (( 5 - r.width() ) / 2 ) );
180 if ( r.height() < 5 && y1 > INT_MIN + 2 )
182 r.setY( r.y() - (( 5 - r.height() ) / 2 ) );
186 QgsDebugMsg( QString(
"panning: extent to widget: [%1,%2] [%3x%4]" ).arg( x1 ).arg( y1 ).arg( r.width() ).arg( r.height() ) );
219 if ( e->button() == Qt::LeftButton )
233 QgsDebugMsg( QString(
"panning: new position: [%1,%2] [%3x%4]" ).arg( rect.left() ).arg( rect.top() ).arg( rect.width() ).arg( rect.height() ) );
244 if (( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
310 palette.setColor( backgroundRole(), color );
311 setPalette( palette );
316 QgsDebugMsg(
"layerSet: " + layerSet.join(
", " ) );
QPoint mPanningCursorOffset
position of cursor inside panning widget
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
void mouseMoveEvent(QMouseEvent *e)
Overridden mouse move event.
void setXMaximum(double x)
Set the maximum x value.
QgsRectangle fullExtent() const
returns current extent of layer set
void destinationSrsChanged()
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setExtent(const QgsRectangle &r)
Set the extent of the map canvas.
QgsMapCanvas * mMapCanvas
main map canvas - used to get/set extent
QgsMapRendererQImageJob * mJob
for rendering overview
QgsPoint transform(const QgsPoint &p) const
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
void refresh()
Repaints the canvas map.
void resizeEvent(QResizeEvent *e)
Overridden resize event.
const QgsMapToPixel & mapToPixel() const
void setBackgroundColor(const QColor &color)
changes background color
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
virtual QImage renderedImage()=0
Get a preview/resulting image.
Map canvas is a class for displaying all GIS data types on a canvas.
Enable drawing of labels on top of the map.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Perform transforms between map coordinates and device coordinates.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
QgsPanningWidget * mPanningWidget
widget for panning map in overview
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
QgsMapSettings mSettings
map settings used for rendering of the overview map
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void setYMinimum(double y)
Set the minimum y value.
void paintEvent(QPaintEvent *pe)
Overridden paint event.
void refresh()
renders overview and updates panning widget
A class to represent a point geometry.
void mapRenderingFinished()
virtual void start()=0
Start the rendering job and immediately return.
void hasCrsTransformEnabled(bool flag)
QgsPoint toMapCoordinates(int x, int y) const
Job implementation that renders everything sequentially in one thread.
void setBackgroundColor(const QColor &color)
Set the background color of the map.
QPixmap mPixmap
pixmap where the map is stored
void setLayerSet(const QStringList &layerSet)
updates layer set for overview
void setOutputSize(const QSize &size)
Set the size of the resulting map image.
void setYMaximum(double y)
Set the maximum y value.
void mouseReleaseEvent(QMouseEvent *e)
Overridden mouse release event.
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
QgsMapOverviewCanvas(QWidget *parent=0, QgsMapCanvas *mapCanvas=NULL)
double width() const
Width of the rectangle.
double xMinimum() const
Get the x minimum value (left side of rectangle)
void updatePanningWidget(const QPoint &pos)
called when panning to reflect mouse movement
void setXMinimum(double x)
Set the minimum x value.
double height() const
Height of the rectangle.
void drawExtentRect()
used for overview canvas to reflect changed extent in main map canvas
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
QStringList layerSet() const
QgsRectangle fullExtent() const
Returns the combined exent for all layers on the map canvas.
void mousePressEvent(QMouseEvent *e)
Overridden mouse press event.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.