Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
328e92df
Commit
328e92df
authored
Nov 01, 2020
by
Benjamin Jakimow
Browse files
updated QPS
fixed MapTool context menus
parent
7c969287
Pipeline
#13346
failed
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
eotimeseriesviewer/externals/qps/__init__.py
View file @
328e92df
...
...
@@ -27,10 +27,11 @@
import
pathlib
import
sys
import
typing
from
qgis.core
import
QgsApplication
import
warnings
from
qgis.core
import
QgsApplication
,
Qgis
from
qgis.gui
import
QgsMapLayerConfigWidgetFactory
MIN_QGIS_VERSION
=
'3.14'
__version__
=
'1.0'
DIR_QPS
=
pathlib
.
Path
(
__file__
).
parent
...
...
@@ -40,6 +41,8 @@ QPS_RESOURCE_FILE = DIR_QPS / 'qpsresources_rc.py'
MAPLAYER_CONFIGWIDGET_FACTORIES
=
list
()
if
Qgis
.
QGIS_VERSION
<
MIN_QGIS_VERSION
:
warnings
.
warn
(
f
'Your QGIS is outdated. Please update to QGIS >=
{
MIN_QGIS_VERSION
}
'
,
RuntimeWarning
)
def
registerMapLayerConfigWidgetFactory
(
factory
:
QgsMapLayerConfigWidgetFactory
):
"""
...
...
eotimeseriesviewer/externals/qps/enmap.tif
LFS
View file @
328e92df
No preview for this file type
eotimeseriesviewer/externals/qps/maptools.py
View file @
328e92df
...
...
@@ -236,6 +236,9 @@ class CursorLocationMapTool(QgsMapToolEmitPoint):
self
.
marker
.
setIconType
(
QgsVertexMarker
.
ICON_CROSS
)
# or ICON_CROSS, ICON_X
self
.
hideRubberband
()
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
return
QgsMapTool
.
ShowContextMenu
def
setMouseButtons
(
self
,
listOfButtons
):
assert
isinstance
(
listOfButtons
)
self
.
mButtons
=
listOfButtons
...
...
@@ -311,14 +314,19 @@ class MapToolCenter(CursorLocationMapTool):
:type canvas: QgsMapCanvas
"""
super
(
MapToolCenter
,
self
).
__init__
(
canvas
)
self
.
sigLocationRequest
.
connect
(
self
.
setMapCenter
)
self
.
sigLocationRequest
[
QgsCoordinateReferenceSystem
,
QgsPointXY
].
\
connect
(
lambda
crs
,
pt
:
self
.
setMapCenter
(
SpatialPoint
(
crs
,
pt
)))
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
return
QgsMapTool
.
ShowContextMenu
def
setMapCenter
(
self
,
point
:
SpatialPoint
):
"""
Call to center the linked QgsMapCanvas to a point
:param point: SpatialPoint to center the map canvas to.
"""
point
=
point
.
toCrs
(
self
.
canvas
().
destinationCrs
())
assert
isinstance
(
point
,
SpatialPoint
)
point
=
point
.
toCrs
(
self
.
canvas
().
mapSettings
().
destinationCrs
())
if
isinstance
(
point
,
SpatialPoint
):
self
.
canvas
().
setCenter
(
point
)
self
.
canvas
().
refresh
()
...
...
@@ -336,12 +344,11 @@ class PixelScaleExtentMapTool(QgsMapTool):
self
.
setCursor
(
self
.
mCursor
)
canvas
.
setCursor
(
self
.
mCursor
)
def
flags
(
self
):
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
"""
:return:
"""
return
QgsMapTool
.
Transient
return
QgsMapTool
.
Transient
|
QgsMapTool
.
ShowContextMenu
def
canvasReleaseEvent
(
self
,
mouseEvent
:
QgsMapMouseEvent
):
"""
...
...
@@ -385,7 +392,7 @@ class FullExtentMapTool(QgsMapTool):
self
.
canvas
().
zoomToFullExtent
()
def
flags
(
self
):
return
QgsMapTool
.
Transient
return
QgsMapTool
.
Transient
|
QgsMapTool
.
ShowContextMenu
class
PointLayersMapTool
(
CursorLocationMapTool
):
...
...
@@ -396,6 +403,8 @@ class PointLayersMapTool(CursorLocationMapTool):
self
.
identifyMode
=
QgsMapToolIdentify
.
LayerSelection
QgsMapToolIdentify
.
__init__
(
self
,
canvas
)
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
return
QgsMapTool
.
ShowContextMenu
class
SpatialExtentMapTool
(
QgsMapToolEmitPoint
):
"""
...
...
@@ -410,6 +419,9 @@ class SpatialExtentMapTool(QgsMapToolEmitPoint):
self
.
setStyle
(
Qt
.
red
,
1
)
self
.
reset
()
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
return
QgsMapTool
.
ShowContextMenu
def
setStyle
(
self
,
color
:
QColor
,
width
:
int
):
"""
Sets the style of the rectangle shows when selecting the SpatialExtent
...
...
@@ -486,6 +498,9 @@ class RectangleMapTool(QgsMapToolEmitPoint):
self
.
rubberBand
.
setWidth
(
1
)
self
.
reset
()
def
flags
(
self
)
->
QgsMapTool
:
return
QgsMapTool
.
ShowContextMenu
def
reset
(
self
):
self
.
startPoint
=
self
.
endPoint
=
None
self
.
isEmittingPoint
=
False
...
...
@@ -1723,6 +1738,9 @@ class QgsMapToolSelect(QgsMapTool):
self
.
mSelectionHandler
.
geometryChanged
.
connect
(
self
.
selectFeatures
)
self
.
setSelectionMode
(
QgsMapToolSelectionHandler
.
SelectionMode
.
SelectSimple
)
def
flags
(
self
)
->
QgsMapTool
.
Flags
:
return
QgsMapTool
.
ShowContextMenu
def
setSelectionMode
(
self
,
selectionMode
:
QgsMapToolSelectionHandler
.
SelectionMode
):
self
.
mSelectionHandler
.
setSelectionMode
(
selectionMode
)
if
selectionMode
==
QgsMapToolSelectionHandler
.
SelectionMode
.
SelectSimple
:
...
...
eotimeseriesviewer/mapcanvas.py
View file @
328e92df
...
...
@@ -43,7 +43,7 @@ from qgis.core import QgsMapLayer, QgsRasterLayer, QgsVectorLayer, QgsContrastEn
from
qgis.gui
import
QgsMapCanvas
,
QgisInterface
,
QgsFloatingWidget
,
QgsUserInputWidget
,
\
QgsAdvancedDigitizingDockWidget
,
QgsMapCanvasItem
,
\
QgsMapTool
,
QgsMapToolPan
,
QgsMapToolZoom
,
QgsMapToolCapture
,
QgsMapToolIdentify
,
\
QgsGeometryRubberBand
QgsGeometryRubberBand
,
QgsMapMouseEvent
from
.externals.qps.classification.classificationscheme
import
ClassificationScheme
,
ClassInfo
...
...
@@ -396,7 +396,7 @@ class MapCanvas(QgsMapCanvas):
self
.
mMapLayerStore
:
QgsProject
=
QgsProject
.
instance
()
if
Qgis
.
QGIS_VERSION
>=
'3.16'
:
self
.
contextMenuAboutToShow
.
connect
(
self
.
cre
ateContextMenu
)
self
.
contextMenuAboutToShow
.
connect
(
self
.
popul
ateContextMenu
)
self
.
mMapTools
=
None
...
...
@@ -887,7 +887,7 @@ class MapCanvas(QgsMapCanvas):
"""
return
self
.
grab
()
def
cre
ateContextMenu
(
self
,
menu
:
QMenu
,
pos
:
QPoint
):
def
popul
ateContextMenu
(
self
,
menu
:
QMenu
,
pos
:
QPoint
):
"""
Creates the MapCanvas context menu with options relevant for pixel position ``pos``.
:param pos: QPoint
...
...
@@ -1252,19 +1252,22 @@ class MapCanvas(QgsMapCanvas):
r
.
setInput
(
proxyLayer
.
dataProvider
())
proxyLayer
.
setRenderer
(
r
)
def
contextMenuEvent
(
self
,
event
:
QContextMenuEvent
):
"""
Create and shows the MapCanvas context menu.
:param event: QEvent
"""
def
mousePressEvent
(
self
,
event
:
QMouseEvent
):
if
Qgis
.
QGIS_VERSION
>=
'3.16'
:
super
(
MapCanvas
,
self
).
contextMenu
Event
(
event
)
super
(
MapCanvas
,
self
).
mousePress
Event
(
event
)
else
:
if
not
isinstance
(
self
.
mapTool
(),
QgsMapToolCapture
):
menu
=
QMenu
()
self
.
createContextMenu
(
menu
,
event
.
pos
())
menu
.
exec_
(
event
.
globalPos
())
if
event
.
button
()
==
Qt
.
RightButton
:
mt
:
QgsMapTool
=
self
.
mapTool
()
if
isinstance
(
mt
,
QgsMapTool
):
if
bool
(
mt
.
flags
()
&
QgsMapTool
.
ShowContextMenu
):
menu
=
QMenu
()
mt
.
populateContextMenu
(
menu
)
self
.
populateContextMenu
(
menu
,
event
.
pos
())
menu
.
exec_
(
event
.
globalPos
())
return
super
().
mousePressEvent
(
event
)
def
addLayers2QGIS
(
self
,
mapLayers
):
import
qgis.utils
...
...
tests/test_mapvisualization.py
View file @
328e92df
...
...
@@ -320,7 +320,7 @@ class TestMapVisualization(EOTSVTestCase):
self
.
assertIsInstance
(
mv
,
MapView
)
for
l
in
mv
.
layers
():
eotsv
.
setCurrentLayer
(
l
)
mv
.
mMapLayerTreeViewMenuProvider
.
cre
ateContextMenu
()
mv
.
mMapLayerTreeViewMenuProvider
.
popul
ateContextMenu
()
def
test_renderer
(
self
):
styleFiles
=
file_search
(
os
.
path
.
dirname
(
__file__
),
'style*.txt'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment