Skip to content

Commit

Permalink
入力レイヤ・出力レイヤを選択するuiを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
KeiTa4446 committed Jun 6, 2024
1 parent 268158d commit f5cb67e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
26 changes: 15 additions & 11 deletions dem_to_csmap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os

from PyQt5.QtWidgets import QDialog, QMessageBox
from PyQt5.QtWidgets import QDialog
from qgis.PyQt import uic
from qgis.gui import QgsFileWidget

Check failure on line 5 in dem_to_csmap.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

dem_to_csmap.py:5:22: F401 `qgis.gui.QgsFileWidget` imported but unused

from csmap_py.csmap import process

Expand All @@ -13,22 +14,25 @@ def __init__(self):
os.path.join(os.path.dirname(__file__), "dem_to_csmap.ui"), self
)

# ウィンドウタイトル
self.setWindowTitle("CSMap Plugin")
# ラスタデータのみ選択(現状tifのみにしています)
self.ui.mQgsFileWidget.setFilter('*.tif')
# 出力先をフォルダに指定
self.ui.mQgsFileWidget_.setStorageMode(1)

self.ui.pushButton_run.clicked.connect(self.get_and_show_input_text)
self.ui.pushButton_cancel.clicked.connect(self.close)

def get_and_show_input_text(self):
# テキストボックス値取得
text_value = self.ui.lineEdit.text()
# テキストボックス値をメッセージ表示
QMessageBox.information(None, "ウィンドウ名", text_value)

# 試しにCSMapの処理を実行:ちゃんと入力・出力をUIから参照しよう
params = process.CsmapParams()
input_path = "/Users/kanahiro/Downloads/dem.tif"
output_path = "/Users/kanahiro/Downloads/out.tif"

# 入力・出力をUIで操作
input_path = self.ui.mQgsFileWidget.filePath()
output_path = self.ui.mQgsFileWidget_.filePath()
process.process(
input_path,
output_path,
256,
output_path=os.path.join(output_path, 'csmap.tif'),
chunk_size=256,
params=params,
)
37 changes: 27 additions & 10 deletions dem_to_csmap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,61 @@
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>68</height>
<width>357</width>
<height>168</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
<widget class="QLabel" name="label">
<property name="text">
<string>入力レイヤ</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFileWidget" name="mQgsFileWidget"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>出力レイヤ</string>
</property>
</widget>
</item>
<item>
<widget class="QgsFileWidget" name="mQgsFileWidget_"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_run">
<property name="text">
<string>OK</string>
<string>Run</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<property name="text">
<string>キャンセル</string>
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsFileWidget</class>
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit f5cb67e

Please sign in to comment.