-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy path__init__.py
More file actions
167 lines (133 loc) · 5.16 KB
/
Copy path__init__.py
File metadata and controls
167 lines (133 loc) · 5.16 KB
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
# SemiAutomaticClassificationPlugin
# The Semi-Automatic Classification Plugin for QGIS allows for the supervised
# classification of remote sensing images, providing tools for the download,
# the preprocessing and postprocessing of images.
# begin: 2012-12-29
# Copyright (C) 2012-2026 by Luca Congedo.
# Author: Luca Congedo
# Email: ing.congedoluca@gmail.com
#
# This file is part of SemiAutomaticClassificationPlugin.
# SemiAutomaticClassificationPlugin 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 3 of the License, or (at your option) any later version.
# SemiAutomaticClassificationPlugin is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with SemiAutomaticClassificationPlugin.
# If not, see <https://www.gnu.org/licenses/>.
def name():
return 'Semi-Automatic Classification Plugin'
def description():
return (
'A plugin that integrates tools for easing the download, '
'the preprocessing, processing, and postprocessing of '
'remote sensing images.'
)
def version():
return 'Version 9.0.0'
def icon():
return 'semiautomaticclassificationplugin.png'
# noinspection PyPep8Naming
def qgisMinimumVersion():
return '3.99'
def author():
return 'Luca Congedo'
def email():
return 'ing.congedoluca@gmail.com'
def category():
return 'Raster'
# noinspection PyPep8Naming
def classFactory(iface):
# Easy-Install: fast filesystem check — never block QGIS
# (contributed by TerraLab — https://terra-lab.ai)
deps_ready = False
try:
from .core.venv_manager import (
_quick_check_packages, ensure_venv_packages_available,
)
is_ready, msg = _quick_check_packages()
if is_ready:
ensure_venv_packages_available()
deps_ready = True
except Exception as e:
try:
from qgis.core import QgsMessageLog, Qgis
QgsMessageLog.logMessage(
"SCP path setup error: {}".format(e),
"SCP", level=Qgis.Warning
)
except Exception:
pass
if deps_ready:
try:
from .semiautomaticclassificationplugin import (
SemiAutomaticClassificationPlugin
)
return SemiAutomaticClassificationPlugin(iface)
except Exception as e:
try:
from qgis.core import QgsMessageLog, Qgis
QgsMessageLog.logMessage(
"SCP import failed despite deps present: {}".format(e),
"SCP", level=Qgis.Warning
)
except Exception:
pass
# Dependencies missing or import failed — return lightweight stub
return _SCPStubPlugin(iface)
class _SCPStubPlugin:
"""Minimal QGIS plugin stub shown when dependencies are not installed.
Only uses PyQt6/qgis imports (always available). Does NOT import any
SCP core module that depends on scipy/torch/etc.
"""
def __init__(self, iface):
self._iface = iface
self._install_dialog = None
def initGui(self):
from PyQt6.QtCore import QTimer
QTimer.singleShot(3000, self._show_install_dialog)
def _show_install_dialog(self):
from .core.install_dialog import SCPInstallDialog
self._install_dialog = SCPInstallDialog(self._iface.mainWindow())
self._install_dialog.install_finished.connect(
self._on_install_finished
)
self._install_dialog.show()
def _on_install_finished(self, success, message):
from qgis.core import Qgis
if success:
self._iface.messageBar().pushMessage(
'Semi-Automatic Classification Plugin',
'Dependencies installed. Please restart QGIS.',
level=Qgis.Info, duration=0
)
else:
self._iface.messageBar().pushMessage(
'Semi-Automatic Classification Plugin',
'Dependency install failed. See log: View > Panels > '
'Log Messages > SCP',
level=Qgis.Warning, duration=0
)
def unload(self):
if self._install_dialog is not None:
try:
self._install_dialog.close()
except Exception:
pass
self._install_dialog = None
def homepage():
return (
'https://fromgistors.blogspot.com/p'
'/semi-automatic-classification-plugin.html')
def tracker():
return (
'https://github.com/semiautomaticgit/SemiAutomaticClassificationPlugin'
'/issues')
def repository():
return (
'https://github.com/semiautomaticgit/SemiAutomaticClassificationPlugin'
)