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.subtract( reg2 );
57 QRect r( QPoint( 0, 0 ),
size() );
61 p.setBrush( Qt::red );
71 : QWidget( parent ), mMapCanvas( mapCanvas )
73 setObjectName(
"theOverviewCanvas" );
103 QPainter paint(
this );
104 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
134 if ( ur.x() >= 0 && ur.x() < width() )
136 if ( ll.x() >= 0 && ll.x() < width() )
138 if ( ur.y() >= 0 && ur.y() < height() )
140 if ( ll.y() >= 0 && ll.y() < height() )
144 QgsDebugMsg(
"panning: extent out of overview area" );
151 int x1 =
static_cast<int>( ur.x() + 0.5 ), x2 = static_cast<int>( ll.x() + 0.5 );
152 int y1 =
static_cast<int>( ur.y() + 0.5 ), y2 = static_cast<int>( ll.y() + 0.5 );
164 if ( x1 == INT_MIN && x2 == INT_MAX )
166 if ( y1 == INT_MIN && y2 == INT_MAX )
170 QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
173 if ( r.width() < 5 && x1 > INT_MIN + 2 )
175 r.setX( r.x() - (( 5 - r.width() ) / 2 ) );
178 if ( r.height() < 5 && y1 > INT_MIN + 2 )
180 r.setY( r.y() - (( 5 - r.height() ) / 2 ) );
184 QgsDebugMsg( QString(
"panning: extent to widget: [%1,%2] [%3x%4]" ).arg( x1 ).arg( y1 ).arg( r.width() ).arg( r.height() ) );
217 if ( e->button() == Qt::LeftButton )
231 QgsDebugMsg( QString(
"panning: new position: [%1,%2] [%3x%4]" ).arg( rect.left() ).arg( rect.top() ).arg( rect.width() ).arg( rect.height() ) );
242 if (( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
269 painter.setRenderHint( QPainter::Antialiasing );
290 palette.setColor( backgroundRole(), color );
291 setPalette( palette );
296 QgsDebugMsg(
"layerSet: " + layerSet.join(
", " ) );
QSize mNewSize
resized canvas size
const QgsMapToPixel * coordinateTransform()
QPoint mPanningCursorOffset
position of cursor inside panning widget
A rectangle specified with double values.
void render(QPainter *painter, double *forceWidthScale=0)
starts rendering @ param forceWidthScale Force a specific scale factor for line widths and marker siz...
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.
void destinationSrsChanged()
bool mAntiAliasing
indicates whether antialiasing will be used for rendering
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsRectangle extent() const
returns current extent
void setExtent(const QgsRectangle &r)
Set the extent of the map canvas.
QgsMapCanvas * mMapCanvas
main map canvas - used to get/set extent
QgsPoint transform(const QgsPoint &p) const
void refresh()
Repaints the canvas map.
void resizeEvent(QResizeEvent *e)
Overridden resize event.
QColor mBgColor
background color
void setProjectionsEnabled(bool enabled)
sets whether to use projections for this layer set
void enableOverviewMode(bool isOverview=true)
sets whether map image will be for overview
void setLayerSet(const QStringList &layers)
change current layer set
A non GUI class for rendering a map layer set onto a QPainter.
void setBackgroundColor(const QColor &color)
changes background color
Map canvas is a class for displaying all GIS data types on a canvas.
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
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void setYMinimum(double y)
Set the minimum y value.
bool setExtent(const QgsRectangle &extent)
sets extent and checks whether suitable (returns false if not)
void paintEvent(QPaintEvent *pe)
Overridden paint event.
void setOutputSize(QSize size, int dpi)
void refresh()
renders overview and updates panning widget
A class to represent a point geometry.
void updateFullExtent()
updates extent of the layer set
void hasCrsTransformEnabled(bool flag)
QgsPoint toMapCoordinates(int x, int y) const
QgsRectangle fullExtent()
returns current extent of layer set
QPixmap mPixmap
pixmap where the map is stored
void setLayerSet(const QStringList &layerSet)
updates layer set for overview
void setYMaximum(double y)
Set the maximum y value.
void mouseReleaseEvent(QMouseEvent *e)
Overridden mouse release event.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs, bool refreshCoordinateTransformInfo=true)
sets destination coordinate reference system
QgsMapRenderer * mapRenderer()
Class for storing a coordinate reference system (CRS)
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.
QgsMapRenderer * mMapRenderer
for rendering overview
double xMinimum() const
Get the x minimum value (left side of rectangle)
QStringList & layerSet()
returns current layer set
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 mousePressEvent(QMouseEvent *e)
Overridden mouse press event.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.