-
Notifications
You must be signed in to change notification settings - Fork 0
/
jaxaEarthApiPlugin.py
98 lines (85 loc) · 3.01 KB
/
jaxaEarthApiPlugin.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
"""
/***************************************************************************
JAXA Earth API Plugin
A QGIS plugin
QGIS Plugin for JAXA Earth API, easily get satellite datasets.
-------------------
begin : 2021-06-30
git sha : $Format:%H$
copyright : (C) 2021 by MIERUNE Inc.
email : [email protected]
license : GNU General Public License v2.0
***************************************************************************/
"""
import os
# QGIS-API
from PyQt5.QtCore import QSettings, QTranslator, QCoreApplication
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from qgis.core import *
from qgis.gui import *
from .jaxaEarthApiDialog import JaxaEarthApiDialog
PLUGIN_NAME = "JAXA Earth Api"
class JaxaEarthApiPlugin:
def __init__(self, iface):
self.iface = iface
self.win = self.iface.mainWindow()
self.plugin_dir = os.path.dirname(__file__)
self.actions = []
self.icon_path = os.path.join(self.plugin_dir, "imgs", "icon.png")
self.menu = PLUGIN_NAME
self.toolbar = self.iface.addToolBar(PLUGIN_NAME)
self.toolbar.setObjectName(PLUGIN_NAME)
self.dialog = None
self.action = None
# initialize locale
locale = QSettings().value("locale/userLocale")[0:2]
locale_path = os.path.join(
self.plugin_dir, "i18n", "jaxaEarthApi_{}.qm".format(locale)
)
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
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,
):
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:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToMenu(self.menu, action)
self.actions.append(action)
return action
def initGui(self):
# メニュー設定
self.add_action(
icon_path=os.path.join(self.plugin_dir, "imgs", "icon.png"),
text="JAXA Earth API Plugin",
callback=self.show_window,
parent=self.win,
)
self.dialog = JaxaEarthApiDialog()
def unload(self):
self.iface.removePluginMenu(PLUGIN_NAME, self.action)
self.iface.removeToolBarIcon(self.action)
self.action = None
del self.toolbar
def show_window(self):
self.dialog.show()