Commit 9fd87d94 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files
parent 472f5f32
Pipeline #17151 failed with stage
in 6 seconds
2021-02-23 (version 1.17):
2021-03-10 (version 1.17):
* fixed bug that crashed plugin on plugin unload
* added bulk loading from time series definition files
* fixes to run with QGIS 3.18+
* move to next/previous observation with arrow right/left
* move to next/previous observation window with CTRL + arrow right/left or A/D
......@@ -54,7 +54,7 @@ class QpsMapLayerConfigWidget(QgsMapLayerConfigWidget):
def __init__(self, mapLayer: QgsMapLayer, canvas: QgsMapCanvas, *args, **kwds):
assert isinstance(mapLayer, QgsMapLayer)
assert isinstance(canvas, QgsMapCanvas)
# assert isinstance(canvas, QgsMapCanvas)
super().__init__(mapLayer, canvas, *args, **kwds)
self.mMapLayer = mapLayer
self.mCanvas = canvas
......@@ -24,35 +24,33 @@
import typing
import pathlib
from qgis.core import *
from qgis.core import QgsRasterLayer, \
from qgis.core import QgsRasterLayer, QgsMapLayer, \
QgsRasterRenderer, \
QgsSingleBandGrayRenderer, \
QgsSingleBandColorDataRenderer, \
QgsSingleBandPseudoColorRenderer, \
QgsMultiBandColorRenderer, \
QgsPalettedRasterRenderer, \
QgsColorRampShader, QgsRasterShaderFunction, QgsRasterShader
from qgis.gui import *
QgsColorRampShader, QgsRasterShaderFunction, QgsRasterShader, \
from qgis.gui import QgsMapCanvas, QgsMapLayerConfigWidget, QgsMapLayerConfigWidgetFactory, QgsRasterBandComboBox
from qgis.PyQt.QtWidgets import *
from qgis.PyQt.QtWidgets import QSlider, QWidget, QStackedWidget, QLabel
from qgis.PyQt.QtGui import QIcon
import numpy as np
from ..layerconfigwidgets.core import QpsMapLayerConfigWidget
from ..utils import loadUi, parseWavelength, UnitLookup
class RasterBandConfigWidget(QpsMapLayerConfigWidget):
def icon() -> QIcon:
return QIcon(':/qps/ui/icons/rasterband_select.svg')
class RasterBandConfigWidget(QpsMapLayerConfigWidget):
def __init__(self, layer:QgsRasterLayer, canvas:QgsMapCanvas, parent:QWidget=None):
def __init__(self, layer: QgsRasterLayer, canvas: QgsMapCanvas, parent: QWidget = None):
super(RasterBandConfigWidget, self).__init__(layer, canvas, parent=parent)
pathUi = pathlib.Path(__file__).parents[1] / 'ui' / 'rasterbandconfigwidget.ui'
loadUi(pathUi, self)
assert isinstance(layer, QgsRasterLayer)
self.mCanvas = canvas
self.mLayer = layer
......@@ -113,6 +111,9 @@ class RasterBandConfigWidget(QpsMapLayerConfigWidget):
self.setPanelTitle('Band Selection')
def icon(self) -> QIcon:
return QIcon(':/qps/ui/icons/rasterband_select.svg')
def syncToLayer(self, *args):
renderer = self.mLayer.renderer()
......@@ -205,7 +206,7 @@ class RasterBandConfigWidget(QpsMapLayerConfigWidget):
def wlBand(self, wlKey:str) -> int:
def wlBand(self, wlKey: str) -> int:
Returns the band number for a wavelength
:param wlKey:
......@@ -216,11 +217,11 @@ class RasterBandConfigWidget(QpsMapLayerConfigWidget):
from ..utils import LUT_WAVELENGTH
if isinstance(self.mWL, np.ndarray):
targetWL = float(LUT_WAVELENGTH[wlKey])
return int(np.argmin(np.abs(self.mWL - targetWL)))+1
return int(np.argmin(np.abs(self.mWL - targetWL))) + 1
return None
def setWL(self, wlRegions:tuple):
def setWL(self, wlRegions: tuple):
r = self.renderer().clone()
if isinstance(r, (QgsSingleBandGrayRenderer, QgsSingleBandPseudoColorRenderer, QgsSingleBandColorDataRenderer)):
band = self.wlBand(wlRegions[0])
......@@ -236,16 +237,15 @@ class RasterBandConfigWidget(QpsMapLayerConfigWidget):
def setDockMode(self, dockMode:bool):
def setDockMode(self, dockMode: bool):
class RasterBandConfigWidgetFactory(QgsMapLayerConfigWidgetFactory):
def __init__(self):
super(RasterBandConfigWidgetFactory, self).__init__('Raster Band', RasterBandConfigWidget.icon())
self.setTitle('Band Selection')
super(RasterBandConfigWidgetFactory, self).__init__('Raster Band', QIcon(':/qps/ui/icons/rasterband_select.svg'))
s = ""
def supportsLayer(self, layer):
if isinstance(layer, QgsRasterLayer):
......@@ -259,7 +259,14 @@ class RasterBandConfigWidgetFactory(QgsMapLayerConfigWidgetFactory):
def supportsStyleDock(self):
return True
def createWidget(self, layer, canvas, dockWidget=True, parent=None) -> QgsMapLayerConfigWidget:
def icon(self) -> QIcon:
return QIcon(':/qps/ui/icons/rasterband_select.svg')
def title(self) -> str:
return 'Raster Band'
def createWidget(self, layer: QgsMapLayer, canvas: QgsMapCanvas, dockWidget: bool=True, parent=None) -> QgsMapLayerConfigWidget:
w = RasterBandConfigWidget(layer, canvas, parent=parent)
return w
......@@ -1010,16 +1010,22 @@ def showLayerPropertiesDialog(layer: QgsMapLayer,
print(ex, file=sys.stderr)
dialog = LayerPropertiesDialog(layer, canvas=canvas)
if modal == True:
return dialog.exec_()
dialog = None
if False:
if isinstance(layer, QgsVectorLayer):
dialog = QgsVectorLayerProperties(layer, canvas)
elif isinstance(layer, QgsRasterLayer):
dialog = QgsRasterLayerProperties(layer, canvas)
return dialog
dialog = LayerPropertiesDialog(layer, canvas=canvas)
if dialog:
if modal == True:
return dialog.exec_()
return dialog
return None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment