-
Notifications
You must be signed in to change notification settings - Fork 5
/
qrvt.py
1899 lines (1708 loc) · 107 KB
/
qrvt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QRVT
A QGIS plugin
RVT plugin lets you compute different visualizations from raster DEM.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2020-10-12
git sha : $Format:%H$
copyright : (C) 2020 by Research Centre of the Slovenian Academy of Sciences and Arts and
University of Ljubljana, Faculty of Civil and Geodetic Engineering
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import importlib
import time
import subprocess
import threading
import json
import os
import sys
import webbrowser
import PyQt5
from PyQt5.QtCore import QSettings, QTranslator, qVersion, QCoreApplication, QFile, QFileInfo, Qt, QThread, QRunnable, \
QThreadPool
from PyQt5.QtGui import QIcon, QMovie, QPixmap, QPalette, QColor, QPainterPath
from PyQt5.QtWidgets import QAction, QFileDialog, QGroupBox, QLineEdit, QCheckBox, QComboBox, QWidget, QLabel, \
QProgressBar, QApplication, QMessageBox, QErrorMessage, QDialog, QDesktopWidget
from PyQt5 import uic
from qgis.core import QgsProject, QgsRasterLayer, QgsTask, QgsApplication, Qgis
from osgeo import gdal
try:
import scipy
except:
# try to install scipy
subprocess.check_call([sys.executable, "-m", "pip", "install", "scipy"])
import scipy
import numpy as np
# Initialize Qt resources from file resources.py
from .resources import *
# Import the code for the dialog
from .qrvt_dialog import QRVTDialog
sys.path.append(os.path.dirname(__file__))
import rvt.tile
importlib.reload(rvt.tile)
import rvt.default
importlib.reload(rvt.default)
import rvt.blend
importlib.reload(rvt.blend)
import rvt.blend_func
importlib.reload(rvt.blend_func)
import rvt.vis
importlib.reload(rvt.vis)
from .processing_provider.provider import Provider
class LoadingScreenDlg:
"""Loading screen animation."""
def __init__(self, gif_path):
self.dlg = QDialog()
self.dlg.setWindowTitle("Loading")
self.dlg.setWindowModality(False)
self.dlg.setFixedSize(200, 200)
self.dlg.setWindowFlags(Qt.X11BypassWindowManagerHint | Qt.CustomizeWindowHint)
pal = QPalette()
role = QPalette.Background
pal.setColor(role, QColor(255, 255, 255))
self.dlg.setPalette(pal)
self.label_animation = QLabel(self.dlg)
self.movie = QMovie(gif_path)
self.label_animation.setMovie(self.movie)
def start_animation(self):
self.movie.start()
self.dlg.show()
def stop_animation(self):
self.movie.stop()
self.dlg.done(0)
class AboutDlg:
"""About dialog."""
def __init__(self):
self.dlg = QDialog()
uic.loadUi(os.path.join(os.path.dirname(__file__), 'qrvt_dialog_about.ui'), self.dlg)
self.dlg.setWindowTitle("About")
self.dlg.setWindowFlags(Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint)
self.dlg.setWindowModality(False)
# if close button clicked
self.dlg.button_close.clicked.connect(self.dlg.close)
# if report a bug button clicked
self.dlg.button_report_bug.clicked.connect(lambda: self.button_report_bug_clicked())
self.dlg.exec_()
def button_report_bug_clicked(self):
webbrowser.open('https://github.com/EarthObservation/rvt-qgis/issues')
class QRVT:
"""QGIS Plugin Implementation."""
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'QRVT_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = QRVTDialog()
# resize window
# try:
# # self.dlg.adjustSize() # resize dialog to fit content, doesn't work as before because of scroll area
# # size_dlg = self.dlg.size() # get curr size
# size_screen = QDesktopWidget().screenGeometry(-1) # get screen size
# self.dlg.resize(size_screen.width() * 2 / 3, size_screen.height() * 4 / 5)
# except:
# pass
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Relief Visualization Toolbox')
if self.iface:
self.toolbar = self.iface.addToolBar(u'Relief Visualization Toolbox')
self.toolbar.setObjectName(u'Relief Visualization Toolbox')
self.cwd = os.getcwd()
self.rvt_select_input = {} # qgis DEM rasters, available in rvt select box
# if a layer is added / removed update the available raster layers in the
# selection dialog
QgsProject.instance().layersAdded.connect(lambda: self.load_raster_layers())
QgsProject.instance().layersRemoved.connect(lambda: self.load_raster_layers())
# read settings from .json file and fill visualizations dialog
self.default = rvt.default.DefaultValues()
self.default_settings_path = os.path.abspath(os.path.join(self.plugin_dir, "settings", "default_settings.json"))
if os.path.isfile(self.default_settings_path): # if default_settings.json exists
self.default.read_default_from_file(self.default_settings_path) # load values in dialog
else: # if doesn't exist
if not os.path.exists(os.path.dirname(self.default_settings_path)): # if dir settings doesn't exists
os.makedirs(os.path.dirname(self.default_settings_path)) # create settings dir
self.default.save_default_to_file(self.default_settings_path) # create default_settings.json
# blender
# read combinations
self.default_blender_combinations_path = os.path.abspath(os.path.join(self.plugin_dir, "settings",
"default_blender_combinations.json"))
self.default_blender_combinations = rvt.blend.BlenderCombinations()
self.default_blender_combinations.read_from_file(self.default_blender_combinations_path)
self.load_combinations2cb() # loads combinations to combo box
self.combination = rvt.blend.BlenderCombination() # current combination
# dlg layers
self.dlg_combo_vis_list = [self.dlg.combo1_vis, self.dlg.combo2_vis, self.dlg.combo3_vis,
self.dlg.combo4_vis, self.dlg.combo5_vis]
self.dlg_combo_norm_list = [self.dlg.combo1_norm, self.dlg.combo2_norm, self.dlg.combo3_norm,
self.dlg.combo4_norm, self.dlg.combo5_norm]
self.dlg_line_min_list = [self.dlg.line1_min, self.dlg.line2_min, self.dlg.line3_min, self.dlg.line4_min,
self.dlg.line5_min]
self.dlg_line_max_list = [self.dlg.line1_max, self.dlg.line2_max, self.dlg.line3_max, self.dlg.line4_max,
self.dlg.line5_max]
self.dlg_combo_blend_mode_list = [self.dlg.combo1_blend_mode, self.dlg.combo2_blend_mode,
self.dlg.combo3_blend_mode, self.dlg.combo4_blend_mode,
self.dlg.combo5_blend_mode]
self.dlg_scroll_opacity_list = [self.dlg.scroll1_opacity, self.dlg.scroll2_opacity, self.dlg.scroll3_opacity,
self.dlg.scroll4_opacity, self.dlg.scroll5_opacity]
self.dlg_label_opacity_list = [self.dlg.label1_opacity, self.dlg.label2_opacity, self.dlg.label3_opacity,
self.dlg.label4_opacity, self.dlg.label5_opacity]
# load terrains settings
self.terrains_settings = rvt.blend.TerrainsSettings()
self.terrains_settings_path = os.path.abspath(os.path.join(self.plugin_dir, "settings",
"default_terrains_settings.json"))
self.terrains_settings.read_from_file(self.terrains_settings_path)
self.load_terrains_settings2dlg()
self.terrain_settings = rvt.blend.TerrainSettings()
# on init (first) load blender combination
self.load_blender_combination()
self.combo_vis_check()
self.slider_opacity_label_check()
self.load_default2dlg() # load values in dialog
# loading gif path
self.gif_path = os.path.join(self.plugin_dir, "loading.gif")
# processing provider
self.provider = None
# task manager
self.tm = QgsApplication.taskManager()
# is already calculating something
self.is_calculating = False
# add all gui events (button clicks, cb state changes, ...)
self.add_gui_events()
# load saved plugin size if exists
self.plugin_size_json_path = os.path.abspath(os.path.join(self.plugin_dir, "settings", "plugin_size.json"))
if os.path.isfile(self.plugin_size_json_path):
self.load_plugin_size(self.plugin_size_json_path)
def initProcessing(self):
self.provider = Provider()
QgsApplication.processingRegistry().addProvider(self.provider)
# noinspection PyMethodMayBeStatic
def tr(self, message):
"""Get the translation for a string using Qt translation API.
We implement this ourselves since we do not inherit QObject.
:param message: String for translation.
:type message: str, QString
:returns: Translated version of message.
:rtype: QString
"""
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('QRVT', message)
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
add_to_menu=True,
add_to_toolbar=True,
status_tip=None,
whats_this=None,
parent=None):
"""Add a toolbar icon to the toolbar.
:param icon_path: Path to the icon for this action. Can be a resource
path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
:type icon_path: str
:param text: Text that should be shown in menu items for this action.
:type text: str
:param callback: Function to be called when the action is triggered.
:type callback: function
:param enabled_flag: A flag indicating if the action should be enabled
by default. Defaults to True.
:type enabled_flag: bool
:param add_to_menu: Flag indicating whether the action should also
be added to the menu. Defaults to True.
:type add_to_menu: bool
:param add_to_toolbar: Flag indicating whether the action should also
be added to the toolbar. Defaults to True.
:type add_to_toolbar: bool
:param status_tip: Optional text to show in a popup when mouse pointer
hovers over the action.
:type status_tip: str
:param parent: Parent widget for the new action. Defaults None.
:type parent: QWidget
:param whats_this: Optional text to show in the status bar when the
mouse pointer hovers over the action.
:returns: The action that was created. Note that the action is also
added to self.actions list.
:rtype: QAction
"""
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
# Adds plugin icon to Plugins toolbar
self.iface.addToolBarIcon(action)
if add_to_menu:
self.iface.addPluginToRasterMenu(
self.menu,
action)
self.actions.append(action)
return action
def initGui(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "icon.png"))
self.add_action(
icon_path,
text=self.tr(u'Relief Visualization Toolbox'),
callback=self.run,
parent=self.iface.mainWindow())
self.initProcessing()
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
QgsApplication.processingRegistry().removeProvider(self.provider)
for action in self.actions:
self.iface.removePluginRasterMenu(self.menu,
action)
self.iface.removeToolBarIcon(action)
def run(self):
"""Run method that performs all the real work"""
self.load_raster_layers()
# show the dialog
self.dlg.show()
def add_gui_events(self):
# about button clicked
self.dlg.button_about.clicked.connect(lambda: AboutDlg())
# save to rast loc checkbox
self.dlg.check_sav_rast_loc.stateChanged.connect(lambda: self.checkbox_save_to_rast_loc())
# save to pressed
self.dlg.button_save_to.clicked.connect(lambda: self.save_to_clicked())
# close the application if the exit button is pressed
self.dlg.button_close.clicked.connect(self.dlg.close)
self.dlg.button_close_2.clicked.connect(self.dlg.close)
self.dlg.button_select_all.clicked.connect(lambda: self.activate_all_visualizations())
self.dlg.button_select_none.clicked.connect(lambda: self.deactivate_all_visualizations())
self.dlg.button_sel_all_dem.clicked.connect(lambda: self.activate_all_dem())
self.dlg.button_sel_none_dem.clicked.connect(lambda: self.deactivate_all_dem())
# VISUALIZATIONS
# start button pressed
self.dlg.button_start.clicked.connect(lambda: self.compute_visualizations_clicked())
self.dlg.button_start.clicked.connect(
lambda: self.save_plugin_size(self.plugin_size_json_path)) # save plugin size
# check float 8bit checkbox changes
self.check_checkbox_float_8bit_change()
# check svf noise rem
self.dlg.check_svf_noise.stateChanged.connect(lambda: self.checkbox_svf_noise_check())
# BLENDER
# check if blender combination changed
self.check_combination_change()
# if tab widget changes set visualization checkboxes from blender layers
self.dlg.tab_widget.currentChanged.connect(lambda: self.combo_vis_check())
# preset terrain values
self.check_preset_terrain_settings_change()
# check if any value in blender layers dialog changed
self.check_dlg_blender_layers_change()
# check float 8bit checkbox changes in blender
self.check_blender_checkbox_float_8bit_change()
# add combination button clicked
self.dlg.buttton_comb_add.clicked.connect(lambda: self.add_combination_clicked())
# remove combination button clicked
self.dlg.button_comb_rem.clicked.connect(lambda: self.remove_combination_clicked())
# save to combination button clicked
self.dlg.button_save_comb.clicked.connect(lambda: self.save_combination_to_clicked())
# load from combination button clicked
self.dlg.button_load_comb.clicked.connect(lambda: self.load_combination_from_clicked())
# blend images button clicked
self.dlg.button_blend.clicked.connect(lambda: self.compute_blended_image_clicked())
self.dlg.button_blend.clicked.connect(
lambda: self.save_plugin_size(self.plugin_size_json_path)) # save plugin size
# OTHER
# Cut-off button clicked
self.dlg.button_cutoff.clicked.connect(lambda: self.compute_cut_off_norm_8bit_clicked())
# Fill no-data
self.check_fill_no_data_other_fill_method_combo_change()
self.dlg.button_fill_no_data.clicked.connect(lambda: self.compute_fill_no_data_clicked())
def load_raster_layers(self):
rvt_select_input = {}
self.dlg.select_input_files.clear()
for layer in QgsProject.instance().mapLayers().values():
# If layer is a raster and it is not a multiband type
if layer.type() == 1 and layer.bandCount() == 1:
layer_name = layer.name()
layer_path = layer.dataProvider().dataSourceUri()
self.dlg.select_input_files.addItem(layer_name)
rvt_select_input[layer_name] = layer_path
self.rvt_select_input = rvt_select_input
def activate_all_dem(self):
self.dlg.select_input_files.selectAllOptions()
def deactivate_all_dem(self):
self.dlg.select_input_files.deselectAllOptions()
def checkbox_save_to_rast_loc(self):
""""Check box save to raster location state changed."""
if self.dlg.check_sav_rast_loc.isChecked():
self.dlg.line_save_loc.setEnabled(False)
self.dlg.button_save_to.setEnabled(False)
else:
self.dlg.line_save_loc.setEnabled(True)
self.dlg.button_save_to.setEnabled(True)
def save_to_clicked(self):
"""Save to button clicked"""
save_dir = str(QFileDialog.getExistingDirectory(self.dlg, 'Select a directory'))
self.dlg.line_save_loc.setText(save_dir)
def checkbox_svf_noise_check(self):
if self.dlg.check_svf_noise.isChecked():
self.dlg.combo_svf_noise.setEnabled(True)
else:
self.dlg.combo_svf_noise.setEnabled(False)
def activate_all_visualizations(self):
"""Activate all visualizations."""
self.dlg.group_hillshade.setChecked(True)
self.dlg.group_hillshade_multiple.setChecked(True)
self.dlg.group_slope.setChecked(True)
self.dlg.group_local_relief.setChecked(True)
self.dlg.group_sky_view.setChecked(True)
self.dlg.group_anisotropic.setChecked(True)
self.dlg.group_openess_pos.setChecked(True)
self.dlg.group_openess_neg.setChecked(True)
# self.dlg.group_illumination.setChecked(True)
self.dlg.group_local_dominance.setChecked(True)
self.dlg.group_multi_relief.setChecked(True)
self.dlg.group_multi_scale_top_pos.setChecked(True)
def deactivate_all_visualizations(self):
"""Deactivate all visualizations."""
self.dlg.group_hillshade.setChecked(False)
self.dlg.group_hillshade_multiple.setChecked(False)
self.dlg.group_slope.setChecked(False)
self.dlg.group_local_relief.setChecked(False)
self.dlg.group_sky_view.setChecked(False)
self.dlg.group_anisotropic.setChecked(False)
self.dlg.group_openess_pos.setChecked(False)
self.dlg.group_openess_neg.setChecked(False)
# self.dlg.group_illumination.setChecked(False)
self.dlg.group_local_dominance.setChecked(False)
self.dlg.group_multi_relief.setChecked(False)
self.dlg.group_multi_scale_top_pos.setChecked(False)
def check_dlg_blender_layers_change(self):
"""Check if any layer (combo box, line edit, scroll slider) in blender layers dialog changed
and do events."""
for i_layer in range(5):
# vis combo boxes
self.dlg_combo_vis_list[i_layer].currentIndexChanged.connect(lambda: self.combo_vis_check())
self.dlg_combo_vis_list[i_layer].currentIndexChanged.connect(lambda: self.check_dlg_comb_default_combs())
# norm combo boxes
self.dlg_combo_norm_list[i_layer].currentIndexChanged.connect(lambda: self.check_dlg_comb_default_combs())
# min lines
self.dlg_line_min_list[i_layer].textChanged.connect(lambda: self.check_dlg_comb_default_combs())
# max lines
self.dlg_line_max_list[i_layer].textChanged.connect(lambda: self.check_dlg_comb_default_combs())
# blending mode combo boxes
self.dlg_combo_blend_mode_list[i_layer].currentIndexChanged.connect(
lambda: self.check_dlg_comb_default_combs())
# opacity slider
self.dlg_scroll_opacity_list[i_layer].valueChanged.connect(lambda: self.slider_opacity_label_check())
self.dlg_scroll_opacity_list[i_layer].valueChanged.connect(lambda: self.check_dlg_comb_default_combs())
def check_preset_terrain_settings_change(self):
self.dlg.chech_terrain_preset.stateChanged.connect(lambda: self.load_terrain2dlg())
self.dlg.combo_terrains.currentIndexChanged.connect(lambda: self.load_terrain2dlg())
def load_terrain2dlg(self):
# checkbox use preset values for terrain type
if self.dlg.chech_terrain_preset.checkState():
self.dlg.combo_terrains.setEnabled(True) # enable combobox
selected_terrain = str(self.dlg.combo_terrains.currentText())
terrain_setting = self.terrains_settings.select_terrain_settings_by_name(selected_terrain)
self.load_dlg2combination()
self.load_dlg2default()
terrain_setting.apply_terrain(self.default, self.combination)
self.load_combination2dlg(self.combination, terrain_bool=True)
self.load_default2dlg()
else:
self.dlg.combo_terrains.setEnabled(False) # disable combobox
self.load_dlg2terrain()
self.load_dlg2default()
self.load_dlg2combination()
def slider_opacity_label_check(self):
"""Change scroll slider label value according to scroll slider value."""
for i_layer in range(5):
self.dlg_label_opacity_list[i_layer].setText(str(self.dlg_scroll_opacity_list[i_layer].value()))
def load_dlg2combination(self):
"""Get combination (rvt.blend.BlenderCombination()) from blender dlg."""
combination = rvt.blend.BlenderCombination()
for i_layer in range(5):
visualization = str(self.dlg_combo_vis_list[i_layer].currentText())
norm = str(self.dlg_combo_norm_list[i_layer].currentText())
minimum = float(self.dlg_line_min_list[i_layer].text())
maximum = float(self.dlg_line_max_list[i_layer].text())
blend_mode = str(self.dlg_combo_blend_mode_list[i_layer].currentText())
opacity = int(self.dlg_scroll_opacity_list[i_layer].value())
if visualization != "None":
combination.create_layer(vis_method=visualization, normalization=norm, minimum=minimum, maximum=maximum,
blend_mode=blend_mode, opacity=opacity)
self.combination = combination
def check_dlg_comb_default_combs(self):
"""Checks if dlg blender combination values are same as any default combination or they
are Custom combination."""
self.load_dlg2combination()
if self.dlg.combo_combinations.currentText() == "enhanced Multi-Scale Topographic Position version 3" or \
self.dlg.combo_combinations.currentText() == "Archaeological combined (VAT combined)":
pass
else:
# find if dlg_combination has same attributes as one of the combinations
dlg_combination_name = self.default_blender_combinations.combination_in_combinations(self.combination)
if dlg_combination_name is not None:
self.dlg.combo_combinations.setCurrentText(dlg_combination_name)
else:
self.dlg.combo_combinations.setCurrentText("Custom")
def load_dlg2terrain(self):
self.load_dlg2default()
self.load_dlg2combination()
terrain_settings = rvt.blend.TerrainSettings()
terrain_settings.slp_output_units = self.default.slp_output_units
terrain_settings.hs_sun_azi = self.default.hs_sun_azi
terrain_settings.hs_sun_el = self.default.hs_sun_el
terrain_settings.mhs_nr_dir = self.default.mhs_nr_dir
terrain_settings.mhs_sun_el = self.default.mhs_sun_el
terrain_settings.slrm_rad_cell = self.default.slrm_rad_cell
terrain_settings.svf_n_dir = self.default.svf_n_dir
terrain_settings.svf_r_max = self.default.svf_r_max
terrain_settings.svf_noise = self.default.svf_noise
terrain_settings.asvf_dir = self.default.asvf_dir
terrain_settings.asvf_level = self.default.asvf_level
terrain_settings.sim_sky_mod = self.default.sim_sky_mod
terrain_settings.sim_nr_dir = self.default.sim_nr_dir
terrain_settings.sim_shadow_dist = self.default.sim_shadow_dist
terrain_settings.sim_shadow_az = self.default.sim_shadow_az
terrain_settings.sim_shadow_el = self.default.sim_shadow_el
terrain_settings.ld_min_rad = self.default.ld_min_rad
terrain_settings.ld_max_rad = self.default.ld_max_rad
terrain_settings.ld_rad_inc = self.default.ld_rad_inc
terrain_settings.ld_anglr_res = self.default.ld_anglr_res
terrain_settings.ld_observer_h = self.default.ld_observer_h
terrain_settings.msrm_feature_min = self.default.msrm_feature_min
terrain_settings.msrm_feature_max = self.default.msrm_feature_max
terrain_settings.msrm_scaling_factor = self.default.msrm_scaling_factor
terrain_settings.mstp_lightness = self.default.mstp_lightness
terrain_settings.mstp_local_scale = self.default.mstp_local_scale
terrain_settings.mstp_meso_scale = self.default.mstp_meso_scale
terrain_settings.mstp_broad_scale = self.default.mstp_broad_scale
for layer in self.combination.layers:
if layer.vis.lower() == "hillshade":
terrain_settings.hs_stretch = (layer.min, layer.max)
if layer.vis.lower() == "multiple directions hillshade":
terrain_settings.mhs_stretch = (layer.min, layer.max)
if layer.vis.lower() == "slope gradient":
terrain_settings.slp_stretch = (layer.min, layer.max)
if layer.vis.lower() == "simple local relief model":
terrain_settings.slrm_stretch = (layer.min, layer.max)
if layer.vis.lower() == "sky-view factor":
terrain_settings.svf_stretch = (layer.min, layer.max)
if layer.vis.lower() == "anisotropic sky-view factor":
terrain_settings.asvf_stretch = (layer.min, layer.max)
if layer.vis.lower() == "openness - positive":
terrain_settings.pos_opns_stretch = (layer.min, layer.max)
if layer.vis.lower() == "openness - negative":
terrain_settings.neg_opns_stretch = (layer.min, layer.max)
if layer.vis.lower() == "sky illumination":
terrain_settings.sim_stretch = (layer.min, layer.max)
if layer.vis.lower() == "local dominance":
terrain_settings.ld_stretch = (layer.min, layer.max)
if layer.vis.lower() == "multi-scale relief model":
terrain_settings.msrm_stretch = (layer.min, layer.max)
if layer.vis.lower() == "multi-scale topographic position":
terrain_settings.mstp_stretch = (layer.min, layer.max)
self.terrain_settings = terrain_settings
def combo_vis_check(self):
"""Check all layers, if layer visualization combo box is None then disable(lock) layer else enable(unlock),
also check which visualizations are present in blender and check their checkboxes in visualizations tab."""
self.deactivate_all_visualizations() # set all vis checkboxes to False
for i_layer in range(5):
if self.dlg_combo_vis_list[i_layer].currentText() == "None": # disable all dlg layer att when none
self.dlg_combo_norm_list[i_layer].setEnabled(False)
self.dlg_line_min_list[i_layer].setEnabled(False)
self.dlg_line_max_list[i_layer].setEnabled(False)
self.dlg_combo_blend_mode_list[i_layer].setEnabled(False)
self.dlg_scroll_opacity_list[i_layer].setEnabled(False)
self.dlg_label_opacity_list[i_layer].setEnabled(False)
else: # enable when not none
self.dlg_combo_norm_list[i_layer].setEnabled(True)
self.dlg_line_min_list[i_layer].setEnabled(True)
self.dlg_line_max_list[i_layer].setEnabled(True)
self.dlg_combo_blend_mode_list[i_layer].setEnabled(True)
self.dlg_scroll_opacity_list[i_layer].setEnabled(True)
self.dlg_label_opacity_list[i_layer].setEnabled(True)
# update vis checkboxes
if self.dlg_combo_vis_list[i_layer].currentText() == "Hillshade":
self.dlg.group_hillshade.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Shadow":
self.dlg.group_hillshade.setChecked(True)
self.dlg.check_hs_shadow.setChecked(True)
self.dlg.line_hs_sun_azi.setText(str(135))
self.dlg.line_hs_sun_el.setText(str(35))
if self.dlg_combo_vis_list[i_layer].currentText() == "Multiple directions hillshade":
self.dlg.group_hillshade_multiple.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Slope gradient":
self.dlg.group_slope.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Simple local relief model":
self.dlg.group_local_relief.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Sky-View Factor":
self.dlg.group_sky_view.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Anisotropic Sky-View Factor":
self.dlg.group_anisotropic.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Openness - Positive":
self.dlg.group_openess_pos.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Openness - Negative":
self.dlg.group_openess_neg.setChecked(True)
# if self.dlg_combo_vis_list[i_layer].currentText() == "Sky illumination":
# self.dlg.group_illumination.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Local dominance":
self.dlg.group_local_dominance.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Multi-scale relief model":
self.dlg.group_multi_reliefgroup_multi_relief.setChecked(True)
if self.dlg_combo_vis_list[i_layer].currentText() == "Multi-scale topographic position":
self.dlg.group_multi_scale_top_pos.setChecked(True)
def check_checkbox_float_8bit_change(self):
"""One of the checkboxes float or 8bit was clicked."""
self.dlg.check_hs_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_hs_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_mhs_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_mhs_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_slp_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_slp_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_slrm_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_slrm_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_svf_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_svf_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
# self.dlg.check_sim_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
# self.dlg.check_sim_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_ld_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_ld_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_msrm_float.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
self.dlg.check_msrm_8bit.stateChanged.connect(lambda: self.checkbox_float_8bit_check())
def check_fill_no_data_other_fill_method_combo_change(self):
self.dlg.combo_fill_method.currentTextChanged.connect(lambda: self.fill_no_data_other_fill_method_combo_check())
def fill_no_data_other_fill_method_combo_check(self):
"""Fill no data method additional parameters checks."""
if self.dlg.combo_fill_method.currentText() == "Inverse Distance Weighting":
self.dlg.label_fill_nan_rad.setEnabled(True)
self.dlg.line_fill_nan_rad.setEnabled(True)
self.dlg.label_fill_nan_scl.setEnabled(True)
self.dlg.line_fill_nan_scl.setEnabled(True)
else:
self.dlg.label_fill_nan_rad.setEnabled(False)
self.dlg.line_fill_nan_rad.setEnabled(False)
self.dlg.label_fill_nan_scl.setEnabled(False)
self.dlg.line_fill_nan_scl.setEnabled(False)
def check_blender_checkbox_float_8bit_change(self):
self.dlg.check_blender_save_float.stateChanged.connect(lambda: self.blender_checkbox_float_8bit_check())
self.dlg.check_blender_save_8bit.stateChanged.connect(lambda: self.blender_checkbox_float_8bit_check())
def checkbox_float_8bit_check(self):
"""Check all float and 8bit checkboxes, if both float and 8bit checkboxes are False for specific visualisation
then set them both to True. At least one of them has to be True!"""
if not self.dlg.check_hs_float.isChecked() and not self.dlg.check_hs_8bit.isChecked():
self.dlg.check_hs_float.setChecked(True)
self.dlg.check_hs_8bit.setChecked(True)
if not self.dlg.check_mhs_float.isChecked() and not self.dlg.check_mhs_8bit.isChecked():
self.dlg.check_mhs_float.setChecked(True)
self.dlg.check_mhs_8bit.setChecked(True)
if not self.dlg.check_slp_float.isChecked() and not self.dlg.check_slp_8bit.isChecked():
self.dlg.check_slp_float.setChecked(True)
self.dlg.check_slp_8bit.setChecked(True)
if not self.dlg.check_slrm_float.isChecked() and not self.dlg.check_slrm_8bit.isChecked():
self.dlg.check_slrm_float.setChecked(True)
self.dlg.check_slrm_8bit.setChecked(True)
if not self.dlg.check_svf_float.isChecked() and not self.dlg.check_svf_8bit.isChecked():
self.dlg.check_svf_float.setChecked(True)
self.dlg.check_svf_8bit.setChecked(True)
# if not self.dlg.check_sim_float.isChecked() and not self.dlg.check_sim_8bit.isChecked():
# self.dlg.check_sim_float.setChecked(True)
# self.dlg.check_sim_8bit.setChecked(True)
if not self.dlg.check_ld_float.isChecked() and not self.dlg.check_ld_8bit.isChecked():
self.dlg.check_ld_float.setChecked(True)
self.dlg.check_ld_8bit.setChecked(True)
if not self.dlg.check_msrm_float.isChecked() and not self.dlg.check_msrm_8bit.isChecked():
self.dlg.check_msrm_float.setChecked(True)
self.dlg.check_msrm_8bit.setChecked(True)
def blender_checkbox_float_8bit_check(self):
if not self.dlg.check_blender_save_float.isChecked() and not self.dlg.check_blender_save_8bit.isChecked():
self.dlg.check_blender_save_float.setChecked(True)
self.dlg.check_blender_save_8bit.setChecked(True)
def add_combination_clicked(self):
new_combination_name = str(self.dlg.line_combination_name.text()).strip()
existing_combinations = self.default_blender_combinations.combinations_names()
if new_combination_name not in existing_combinations and new_combination_name != "":
self.load_dlg2combination() # loads dlg to self.combination
self.combination.name = new_combination_name # apply new combination name
self.default_blender_combinations.add_combination(combination=self.combination) # add to combinations
self.default_blender_combinations.save_to_file(file_path=self.default_blender_combinations_path) # save
self.load_combinations2cb() # load new combinations to combobox
self.load_combination2dlg(combination=self.combination) # loads new combination
self.dlg.line_combination_name.setText("")
if new_combination_name == "":
self.iface.messageBar().pushMessage("RVT", "Combination name is empty!", level=Qgis.Warning)
def remove_combination_clicked(self):
selected_combination_name = str(self.dlg.combo_combinations.currentText())
if selected_combination_name != "Custom":
self.default_blender_combinations.remove_combination_by_name(name=selected_combination_name)
self.default_blender_combinations.save_to_file(file_path=self.default_blender_combinations_path)
self.load_combinations2cb()
def save_combination_to_clicked(self):
new_combination_name = str(self.dlg.line_combination_name.text()).strip()
if new_combination_name != "":
json_path = str(QFileDialog.getSaveFileName(self.dlg, caption='Save combination JSON',
filter="JSON (*.json)")[0])
if json_path != "":
try:
self.load_dlg2combination()
self.combination.name = new_combination_name
self.combination.save_to_file(json_path)
self.dlg.line_combination_name.setText("")
except:
self.iface.messageBar().pushMessage("RVT", "Can't save combination JSON file!", level=Qgis.Warning)
else:
self.iface.messageBar().pushMessage("RVT", "Combination name is empty!", level=Qgis.Warning)
def load_combination_from_clicked(self):
json_path = str(QFileDialog.getOpenFileName(self.dlg, caption="Load combination JSON",
filter="JSON (*.json)")[0])
if os.path.isfile(json_path):
try:
existing_combinations = self.default_blender_combinations.combinations_names()
combination = rvt.blend.BlenderCombination()
combination.read_from_file(json_path)
if combination.name not in existing_combinations and combination.name != "":
self.default_blender_combinations.add_combination(combination)
self.default_blender_combinations.save_to_file(self.default_blender_combinations_path)
self.load_combinations2cb()
self.load_combination2dlg(combination=combination)
self.combination = combination
except:
self.iface.messageBar().pushMessage("RVT", "Can't read combination JSON file!", level=Qgis.Warning)
def check_combination_change(self):
"""If blender combination combo box changes method triggers other methods."""
self.dlg.combo_combinations.currentTextChanged.connect(lambda: self.load_blender_combination())
def load_blender_combination(self):
"""Check which blender combination is selected, get that combination and fill blender dlg with
its values."""
selected_combination = str(self.dlg.combo_combinations.currentText())
combination = self.default_blender_combinations.select_combination_by_name(selected_combination)
if combination is not None:
self.combination = combination
self.load_combination2dlg(combination)
def load_combinations2cb(self, combinations=None):
"""Load combinations from self.default_blender_combinations to dlg.combo_combinations combobox."""
if combinations is None: # if combinations None it takes self.default_blender_combinations
combinations = self.default_blender_combinations
self.dlg.combo_combinations.clear()
comb_names = combinations.combinations_names()
for combination_name in comb_names:
self.dlg.combo_combinations.addItem(combination_name)
self.dlg.combo_combinations.addItem("Custom")
def load_combination2dlg(self, combination, terrain_bool=False):
"""Fill blender dlg parameters (combo boxes, line edits, scroll sliders) with values from combination."""
if not terrain_bool:
self.dlg.chech_terrain_preset.setCheckState(False)
nr_layers = len(combination.layers) # number of layers
self.combination = combination
for i_layer in range(5):
layer_number = i_layer + 1
if nr_layers >= layer_number:
layer = combination.layers[i_layer] # BlenderLayer
index_combo_vis = self.dlg_combo_vis_list[i_layer].findText(layer.vis)
if index_combo_vis >= 0:
self.dlg_combo_vis_list[i_layer].setCurrentIndex(index_combo_vis) # set vis
index_combo_norm = self.dlg_combo_norm_list[i_layer].findText(layer.normalization)
if index_combo_norm >= 0:
self.dlg_combo_norm_list[i_layer].setCurrentIndex(index_combo_norm) # set normalization
self.dlg_line_min_list[i_layer].setText(str(layer.min)) # set min
self.dlg_line_max_list[i_layer].setText(str(layer.max)) # set max
index_combo_blend_mode = self.dlg_combo_blend_mode_list[i_layer].findText(layer.blend_mode)
if index_combo_blend_mode >= 0:
self.dlg_combo_blend_mode_list[i_layer].setCurrentIndex(index_combo_blend_mode) # blend_mode
self.dlg_scroll_opacity_list[i_layer].setSliderPosition(layer.opacity) # set opacity
else:
self.set_dlg_layer_to_none(layer_number)
def set_dlg_layer_to_none(self, layer_number):
"""Set layer (layer_number) to none."""
i_layer = layer_number - 1
self.dlg_combo_vis_list[i_layer].setCurrentIndex(0)
self.dlg_combo_norm_list[i_layer].setCurrentIndex(0)
self.dlg_line_min_list[i_layer].setText("0.0000")
self.dlg_line_max_list[i_layer].setText("0.0000")
self.dlg_combo_blend_mode_list[i_layer].setCurrentIndex(0)
self.dlg_scroll_opacity_list[i_layer].setSliderPosition(100)
self.combo_vis_check()
def remove_layer_by_path(self, layer_path):
"""Remove layer with layer_path from Qgis."""
layer_path = os.path.abspath(layer_path)
for layer in QgsProject.instance().mapLayers().values():
if os.path.abspath(layer.dataProvider().dataSourceUri()) == layer_path:
QgsProject.instance().removeMapLayer(layer)
return 1
return 0
def fill_method_translate(self, fill_method):
"""Translates fill_method (no data interpolation method) string for function to text for combo box and
vice versa."""
if fill_method.split("_")[0] == "idw":
return "Inverse Distance Weighting"
elif fill_method == "Inverse Distance Weighting":
try:
radius = int(self.dlg.line_fill_nan_rad.text())
scale = float(self.dlg.line_fill_nan_scl.text())
return "idw_{}_{}".format(radius, scale)
except:
return "idw"
elif fill_method == "kd_tree":
return "K-D Tree"
elif fill_method == "K-D Tree":
return "kd_tree"
elif fill_method == "nearest_neighbour":
return "Nearest Neighbour"
elif fill_method == "Nearest Neighbour":
return "nearest_neighbour"
def load_default2dlg(self):
"""Reads default (rvt.defaul.DeafultValues()) from default_path and fill visualization dlg."""
self.dlg.check_overwrite.setChecked(bool(self.default.overwrite))
self.dlg.line_ve_factor.setText(str(self.default.ve_factor))
self.dlg.group_hillshade.setChecked(bool(self.default.hs_compute))
self.dlg.line_hs_sun_azi.setText(str(self.default.hs_sun_azi))
self.dlg.line_hs_sun_el.setText(str(self.default.hs_sun_el))
self.dlg.check_hs_shadow.setChecked(bool(self.default.hs_shadow))
self.dlg.group_hillshade_multiple.setChecked(bool(self.default.mhs_compute))
self.dlg.line_mhs_nr_dir.setText(str(self.default.mhs_nr_dir))
self.dlg.line_mhs_sun_el.setText(str(self.default.mhs_sun_el))
self.dlg.group_slope.setChecked(bool(self.default.slp_compute))
index_combo_slp_ou = self.dlg.combo_slp_output_units.findText(self.default.slp_output_units)
if index_combo_slp_ou >= 0:
self.dlg.combo_slp_output_units.setCurrentIndex(index_combo_slp_ou)
self.dlg.group_local_relief.setChecked(bool(self.default.slrm_compute))
self.dlg.line_slrm_rad_cell.setText(str(self.default.slrm_rad_cell))
self.dlg.group_sky_view.setChecked(bool(self.default.svf_compute))
index_combo_svf_n_dir = self.dlg.combo_svf_n_dir.findText(str(self.default.svf_n_dir))
if index_combo_svf_n_dir >= 0:
self.dlg.combo_svf_n_dir.setCurrentIndex(index_combo_svf_n_dir)
self.dlg.line_svf_r_max.setText(str(self.default.svf_r_max))
if self.default.svf_noise == 0:
self.dlg.check_svf_noise.setChecked(False)
else:
self.dlg.check_svf_noise.setChecked(True)
index_combo_svf_noise = 0
if self.default.svf_noise == 1:
index_combo_svf_noise = self.dlg.combo_svf_noise.findText("low")
elif self.default.svf_noise == 2:
index_combo_svf_noise = self.dlg.combo_svf_noise.findText("medium")
elif self.default.svf_noise == 3:
index_combo_svf_noise = self.dlg.combo_svf_noise.findText("high")
self.dlg.combo_svf_noise.setCurrentIndex(index_combo_svf_noise)
self.checkbox_svf_noise_check()
self.dlg.group_anisotropic.setChecked(bool(self.default.asvf_compute))
index_combo_asvf_level = self.dlg.combo_asvf_level.findText(str(self.default.asvf_level))
if index_combo_asvf_level >= 0:
self.dlg.combo_asvf_level.setCurrentIndex(index_combo_asvf_level)
self.dlg.line_asvf_dir.setText(str(self.default.asvf_dir))
self.dlg.group_openess_pos.setChecked(bool(self.default.pos_opns_compute))
self.dlg.group_openess_neg.setChecked(bool(self.default.neg_opns_compute))
# self.dlg.group_illumination.setChecked(bool(self.default.sim_compute))
# index_combo_sim_sky_mod = self.dlg.combo_sim_sky_mod.findText(self.default.sim_sky_mod)
# if index_combo_sim_sky_mod >= 0:
# self.dlg.combo_sim_sky_mod.setCurrentIndex(index_combo_sim_sky_mod)
# index_combo_sim_nr_dir = self.dlg.combo_sim_nr_dir.findText(str(self.default.sim_nr_dir))
# if index_combo_sim_nr_dir >= 0:
# self.dlg.combo_sim_nr_dir.setCurrentIndex(index_combo_sim_nr_dir)
# index_combo_sim_shadow_dist = self.dlg.combo_sim_shadow_dist.findText(str(self.default.sim_shadow_dist))
# if index_combo_sim_shadow_dist >= 0:
# self.dlg.combo_sim_shadow_dist.setCurrentIndex(index_combo_sim_shadow_dist)
self.dlg.group_local_dominance.setChecked(bool(self.default.ld_compute))
self.dlg.line_ld_min_rad.setText(str(self.default.ld_min_rad))
self.dlg.line_ld_max_rad.setText(str(self.default.ld_max_rad))
self.dlg.group_multi_relief.setChecked(bool(self.default.msrm_compute))
self.dlg.line_msrm_f_min.setText(str(self.default.msrm_feature_min))
self.dlg.line_msrm_f_max.setText(str(self.default.msrm_feature_max))
self.dlg.line_msrm_scale.setText(str(self.default.msrm_scaling_factor))
self.dlg.group_multi_scale_top_pos.setChecked(bool(self.default.mstp_compute))
self.dlg.line_mstp_loc_min.setText(str(self.default.mstp_local_scale[0]))
self.dlg.line_mstp_loc_max.setText(str(self.default.mstp_local_scale[1]))
self.dlg.line_mstp_loc_stp.setText(str(self.default.mstp_local_scale[2]))
self.dlg.line_mstp_meso_min.setText(str(self.default.mstp_meso_scale[0]))
self.dlg.line_mstp_meso_max.setText(str(self.default.mstp_meso_scale[1]))
self.dlg.line_mstp_meso_stp.setText(str(self.default.mstp_meso_scale[2]))
self.dlg.line_mstp_bro_min.setText(str(self.default.mstp_broad_scale[0]))
self.dlg.line_mstp_bro_max.setText(str(self.default.mstp_broad_scale[1]))
self.dlg.line_mstp_bro_stp.setText(str(self.default.mstp_broad_scale[2]))
self.dlg.line_mstp_light.setText(str(self.default.mstp_lightness))
self.dlg.check_hs_float.setChecked(bool(self.default.hs_save_float))
self.dlg.check_hs_8bit.setChecked(bool(self.default.hs_save_8bit))
self.dlg.check_mhs_float.setChecked(bool(self.default.mhs_save_float))
self.dlg.check_mhs_8bit.setChecked(bool(self.default.mhs_save_8bit))
self.dlg.check_slp_float.setChecked(bool(self.default.slp_save_float))
self.dlg.check_slp_8bit.setChecked(bool(self.default.slp_save_8bit))
self.dlg.check_slrm_float.setChecked(bool(self.default.slrm_save_float))
self.dlg.check_slrm_8bit.setChecked(bool(self.default.slrm_save_8bit))
self.dlg.check_svf_float.setChecked(bool(self.default.svf_save_float))
self.dlg.check_svf_8bit.setChecked(bool(self.default.svf_save_8bit))
# self.dlg.check_sim_float.setChecked(bool(self.default.sim_save_float))
# self.dlg.check_sim_8bit.setChecked(bool(self.default.sim_save_8bit))
self.dlg.check_ld_float.setChecked(bool(self.default.ld_save_float))
self.dlg.check_ld_8bit.setChecked(bool(self.default.ld_save_8bit))
self.dlg.check_msrm_float.setChecked(bool(self.default.msrm_save_float))
self.dlg.check_msrm_8bit.setChecked(bool(self.default.msrm_save_8bit))
self.dlg.check_mstp_float.setChecked(bool(self.default.mstp_save_float))
self.dlg.check_mstp_8bit.setChecked(bool(self.default.mstp_save_8bit))
def load_dlg2default(self):
"""Read Qgis plugin dialog visualization functions parameters and fill them to rvt.defaul.DeafultValues() ."""
self.default.overwrite = int(self.dlg.check_overwrite.isChecked())
self.default.ve_factor = float(self.dlg.line_ve_factor.text())
self.default.hs_compute = int(self.dlg.group_hillshade.isChecked())
self.default.hs_sun_azi = int(self.dlg.line_hs_sun_azi.text())
self.default.hs_sun_el = int(self.dlg.line_hs_sun_el.text())
self.default.hs_shadow = int(self.dlg.check_hs_shadow.isChecked())
self.default.mhs_compute = int(self.dlg.group_hillshade_multiple.isChecked())