Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
LETG
Rename bands
Commits
2818dc08
Commit
2818dc08
authored
Sep 15, 2021
by
PIERSON Julie
Browse files
removing unused code
parent
1800ad10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
48 deletions
+9
-48
BandTableWidget.py
BandTableWidget.py
+9
-14
merge_rename_bands_algorithm.py
merge_rename_bands_algorithm.py
+0
-34
No files found.
BandTableWidget.py
View file @
2818dc08
...
...
@@ -23,25 +23,17 @@ __date__ = '2021-09-14'
__copyright__
=
'(C) 2021 by J. Pierson, UMR 6554 LETG, CNRS'
import
os
import
codecs
from
qgis.PyQt
import
uic
from
qgis.PyQt.QtCore
import
pyqtSlot
,
QDir
from
qgis.PyQt.QtCore
import
pyqtSlot
from
qgis.PyQt.QtWidgets
import
(
QTreeWidgetItem
,
QFileDialog
,
QMessageBox
,
QInputDialog
,
QColorDialog
)
from
qgis.PyQt.QtXml
import
QDomDocument
from
qgis.core
import
(
QgsApplication
,
QgsMapLayer
,
QgsMapLayerProxyModel
)
from
qgis.analysis
import
QgsRelief
from
processing.gui.wrappers
import
WidgetWrapper
from
processing.tools
import
system
from
osgeo
import
gdal
pluginPath
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -91,6 +83,7 @@ class BandTableWidget(BASE, WIDGET):
def
_removeBandData
(
self
,):
self
.
bandClassTree
.
clear
()
# remove selected line in table when remove button is clicked
@
pyqtSlot
()
def
on_btnRemove_clicked
(
self
):
selectedItems
=
self
.
bandClassTree
.
selectedItems
()
...
...
@@ -98,6 +91,7 @@ class BandTableWidget(BASE, WIDGET):
self
.
bandClassTree
.
invisibleRootItem
().
removeChild
(
item
)
item
=
None
# move down selected line in table when down button is clicked
@
pyqtSlot
()
def
on_btnDown_clicked
(
self
):
selectedItems
=
self
.
bandClassTree
.
selectedItems
()
...
...
@@ -108,6 +102,7 @@ class BandTableWidget(BASE, WIDGET):
self
.
bandClassTree
.
insertTopLevelItem
(
currentIndex
+
1
,
item
)
self
.
bandClassTree
.
setCurrentItem
(
item
)
# move up selected line in table when up button is clicked
@
pyqtSlot
()
def
on_btnUp_clicked
(
self
):
selectedItems
=
self
.
bandClassTree
.
selectedItems
()
...
...
@@ -118,6 +113,7 @@ class BandTableWidget(BASE, WIDGET):
self
.
bandClassTree
.
insertTopLevelItem
(
currentIndex
-
1
,
item
)
self
.
bandClassTree
.
setCurrentItem
(
item
)
# when a cell in 3rd column is clicked, open dialog box for entering value
@
pyqtSlot
(
QTreeWidgetItem
,
int
)
def
on_bandClassTree_itemDoubleClicked
(
self
,
item
,
column
):
if
not
item
:
...
...
@@ -131,6 +127,8 @@ class BandTableWidget(BASE, WIDGET):
if
ok
:
item
.
setText
(
2
,
str
(
d
))
# return table values in a list, one element for each row
# [['band 1', 'old name 1', 'new name 1'], ['band 2', 'old name 2', 'new name 2']]
def
bandNames
(
self
):
band_names
=
[]
for
i
in
range
(
self
.
bandClassTree
.
topLevelItemCount
()):
...
...
@@ -140,9 +138,6 @@ class BandTableWidget(BASE, WIDGET):
band_names
.
append
(
row
)
return
band_names
def
layerName
(
self
):
pass
def
setLayer
(
self
,
layer
):
QMessageBox
.
information
(
None
,
self
.
tr
(
'tralala'
),
self
.
tr
(
'coucou'
))
self
.
layer
=
layer
...
...
merge_rename_bands_algorithm.py
View file @
2818dc08
...
...
@@ -31,18 +31,12 @@ __copyright__ = '(C) 2021 by J. Pierson, UMR 6554 LETG, CNRS'
__revision__
=
'$Format:%H$'
from
qgis.PyQt.QtCore
import
QCoreApplication
from
qgis.PyQt.QtGui
import
QIcon
,
QColor
from
qgis.core
import
(
QgsProcessing
,
QgsProcessingAlgorithm
,
QgsProcessingParameterRasterLayer
,
QgsProcessingParameterMatrix
,
QgsProcessingParameterDefinition
,
QgsProcessingParameterString
,
QgsProcessingParameterRasterDestination
)
from
processing.algs.qgis.QgisAlgorithm
import
QgisAlgorithm
from
processing.gui.wrappers
import
WidgetWrapper
#import BandTableWidget
from
qgis.PyQt.QtWidgets
import
QTableWidget
from
osgeo
import
gdal
# custom band table widget
...
...
@@ -74,32 +68,6 @@ class ParameterBandTable(QgsProcessingParameterDefinition):
return
value
.
split
(
';'
)
class
TableWidget
(
WidgetWrapper
):
"""
QTable widget
"""
def
createWidget
(
self
):
self
.
_combo
=
QTableWidget
()
# row count
self
.
_combo
.
setRowCount
(
1
)
# column count
self
.
_combo
.
setColumnCount
(
2
)
# column headers
self
.
_combo
.
setHorizontalHeaderLabels
([
"Name"
,
"Future name"
])
return
self
.
_combo
def
value
(
self
):
# retrieve table values [["name 1", "future name 1"], ["name 2", "future name 2"], ...]
table
=
[]
nrow
=
self
.
_combo
.
rowCount
()
#ncol = self._combo.columnCount()
for
i
in
range
(
nrow
):
table
.
append
([
self
.
_combo
.
cellWidget
(
i
,
0
),
self
.
_combo
.
cellWidget
(
i
,
1
)])
return
table
class
MergeAndRenameAlgorithm
(
QgsProcessingAlgorithm
):
"""
This is an algorithm that takes a raster layer and
...
...
@@ -143,8 +111,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
"""
# RETRIEVE INPUTS AND OUTPUT
#input_param = self.parameterAsRasterLayer(parameters, self.INPUT, context)
#bandData = ParameterBandTable.parseValue(parameters[self.INPUT])
band_data
=
ParameterBandTable
.
tableValuesAsList
(
parameters
[
self
.
INPUT
])
output_raster_path
=
self
.
parameterAsOutputLayer
(
parameters
,
self
.
OUTPUT
,
context
)
...
...
Write
Preview
Markdown
is supported
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