Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions swipemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
* (at your option) any later version. *
* *
***************************************************************************/
"""

__author__ = 'Luiz Motta'
__date__ = '2015-10-14'
__copyright__ = '(C) 2018, Luiz Motta'
__revision__ = '$Format:%H$'


The following changes are NOT MY WORK, they are a suggestion from @LreeLenn in ISSUE #19
"""
from qgis.PyQt.QtCore import QRect, QLine, Qt
from qgis.PyQt.QtGui import QColor, QImage

Expand Down Expand Up @@ -55,8 +50,8 @@ def setIsVertical(self, isVertical):
self.isVertical = isVertical

def setLength(self, x, y):
y = int(self.boundingRect().height() - y)
self.length = int(x) if self.isVertical else int(y)
y = self.boundingRect().height() - y
self.length = x if self.isVertical else y
self.update()

def paint(self, painter, *args): # NEED *args for WINDOWS!
Expand All @@ -67,7 +62,6 @@ def paint(self, painter, *args): # NEED *args for WINDOWS!
h = int(self.boundingRect().height() - 2)
w = int(self.length)
line = QLine( w-1,0,w-1,h-1 )

else:
h = int(self.boundingRect().height() - self.length)
w = int(self.boundingRect().width() - 2)
Expand All @@ -94,9 +88,11 @@ def finished():
settings = QgsMapSettings( self.canvas.mapSettings() )
settings.setLayers( self.layers )
settings.setBackgroundColor( QColor( Qt.transparent ) )

settings.setDevicePixelRatio( 1 )

self.setRect( self.canvas.extent() )
job = QgsMapRendererParallelJob( settings )
job.start()
job.finished.connect( finished)
job.waitForFinished()
job.waitForFinished()