diff --git a/README.md b/README.md index 414d760..1eb5e38 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,8 @@ -# qgis-plugin-template +# qgis-csmap-plugin -QGIS3.x プラグイン開発のひな形 +DEMからGeoTIFF形式のCS立体図を作成するQGISプラグインです。 +DEMの変換にはcsmap-pyを利用しています。 +It is a QGIS plugin that creates a GeoTIFF format CS topographic map from a DEM. +The DEM conversion process is based on [csmap-py](https://github.com/MIERUNE/csmap-py). -## Preparation - -### Windows - -- Windowsを利用する場合は、pyproject.tomlを開き、[packages]内のコメントアウトを削除し、プロジェクトに適したバージョンのQGIS内のPythonを参照してください。 - -``` -packages = [ - { include = "qgis", from = "C:\\Program Files\\QGIS 3.28.2\\apps\\qgis\\python" }, -] -``` - -1. install `Poetry` - - ```sh - pip install poetry - ``` - -2. install dependencies with Poetry - - ```sh - # QGIS内のPython実行ファイルを参照する(開発ターゲットのバージョンのQGIS) - # macOS, bash - poetry env use /Applications/QGIS.app/Contents/MacOS/bin/python3 - # Windows, Powershell - poetry env use "C:\Program Files\QGIS 3.28.2\apps\Python39\python.exe" - - poetry install - ``` - - 仮想環境がカレントディレクトリに作成されます。 - -3. (when VSCode) 仮想環境をVSCode上のPythonインタプリタとして選択 - - VSCodeはカレントディレクトリの仮想環境を検出しますが、手動で選択する必要がある場合もあります。 - - 1. [Cmd + Shift + P]でコマンドパレットを開く - 2. [Python: Select Interpreter]を見つけてクリック - 3. 利用可能なインタプリタ一覧が表示されるので、先ほど作成した仮想環境を選択(通常、リストの一番上に"Recommended"として表示される) +![image](./imgs/howtouse.png) \ No newline at end of file diff --git a/dem_to_csmap.py b/dem_to_csmap.py index 980f8d2..2757b93 100644 --- a/dem_to_csmap.py +++ b/dem_to_csmap.py @@ -2,7 +2,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog -from qgis.core import Qgis +from qgis.core import Qgis, QgsProject, QgsRasterLayer from qgis.gui import QgsFileWidget from qgis.PyQt import uic from qgis.utils import iface @@ -22,7 +22,7 @@ def __init__(self): # ウィンドウを常に全面に表示する self.setWindowFlags(Qt.WindowStaysOnTopHint) - + # 入力データの制限 self.ui.mQgsFileWidget_input.setFilter("*") @@ -75,7 +75,10 @@ def convert_dem_to_csmap(self): return # 出力結果をQGISに追加 - iface.addRasterLayer(output_path, os.path.basename(output_path)) + rlayer = QgsRasterLayer(output_path, os.path.basename(output_path)) + QgsProject.instance().addMapLayer(rlayer) + iface.setActiveLayer(rlayer) + iface.zoomToActiveLayer() # 処理終了後にウィンドウを閉じるオプション if self.ui.checkBox_closeAfterProcessing.isChecked(): diff --git a/dem_to_csmap.ui b/dem_to_csmap.ui index 6c0f65b..e6ca80c 100644 --- a/dem_to_csmap.ui +++ b/dem_to_csmap.ui @@ -6,625 +6,541 @@ 0 0 - 438 - 625 + 478 + 463 Dialog - - - - 12 - 12 - 63 - 16 - - - - 入力レイヤ - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - - 12 - 37 - 406 - 22 - - - - - - - 12 - 530 - 253 - 20 - - - - true - - - 処理終了後,自動でウィンドウを閉じる - - - - 20 - 20 - - - - - - - 12 - 69 - 63 - 16 - - - - 出力レイヤ - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - - 12 - 93 - 406 - 22 - - - - - - - 205 - 585 - 100 - 25 - - - - - 135 - 30 - - - - Cancel - - - false - - - - - - 12 - 125 - 230 - 391 - - - - Options - - - - - 10 - 25 - 150 - 20 - - - - - 0 - 0 - - - - gaussian filter size - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 150 - 25 - 70 - 20 - - - - Qt::LeftToRight - - - Qt::AlignCenter - - - 1 - - - 100 - - - 12 - - - - - - 150 - 55 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - 100 - - - 3 - - - - - - 10 - 55 - 150 - 20 - - - - gaussian filter sigma - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 10 - 85 - 150 - 20 - - - - curvature filter size - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 150 - 85 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - 100 - - - - - - 10 - 110 - 150 - 20 - - - - height scale - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 120 - 110 - 30 - 20 - - - - min - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 120 - 135 - 30 - 20 - - - - max - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 150 - 285 - 70 - 20 - - - - Qt::AlignCenter - - - 10000 - - - 256 - - - 1024 - - - - - - 10 - 285 - 150 - 20 - - - - chunk size as pixel - - - - - - 10 - 160 - 150 - 20 - - - - slope scale - - - - - - 120 - 160 - 50 - 20 - - - - - 0 - 0 - - - - - 50 - 20 - - - - min - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 120 - 185 - 50 - 20 - - - - - 0 - 0 - - - - - 50 - 20 - - - - max - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 150 - 160 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - 100.000000000000000 - - - 0.500000000000000 - - - - - - 150 - 185 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - 100.000000000000000 - - - 0.500000000000000 - - - 1.500000000000000 - - - - - - 10 - 210 - 150 - 20 - - - - curvature scale - - - - - - 120 - 210 - 30 - 20 - - - - min - - - - - - 120 - 235 - 30 - 20 - - - - max - - - - - - 150 - 210 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - -100.000000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - -0.100000000000000 - - - - - - 150 - 235 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - -100.000000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - 10 - 335 - 210 - 16 - - - - max workers for multiprocessing - - - - - - 150 - 360 - 70 - 20 - - - - Qt::AlignCenter - - - 1 - - - - - - 150 - 110 - 70 - 20 - - - - Qt::AlignCenter - - - 10000 - - - 100 - - - - - - 150 - 135 - 70 - 20 - - - - Qt::AlignCenter - - - 10000 - - - 100 - - - 1000 - - - - - - - 315 - 585 - 100 - 25 - - - - - 135 - 30 - - - - Run - - + + + + + + + + 0 + 0 + + + + 入力ファイル + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + + + 出力ファイル + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + + 0 + 0 + + + + 高度なオプション + + + true + + + false + + + + + + + 0 + 0 + + + + + 60 + 20 + + + + min + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + slope scale + + + + + + + + 80 + 16777215 + + + + Qt::AlignCenter + + + 10000 + + + 100 + + + 1000 + + + + + + + height scale + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + min + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 80 + 16777215 + + + + Qt::AlignCenter + + + 10000 + + + 100 + + + + + + + max + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignCenter + + + 2 + + + 100.000000000000000 + + + 0.500000000000000 + + + + + + + + 0 + 0 + + + + + 50 + 20 + + + + max + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignCenter + + + 2 + + + 100.000000000000000 + + + 0.500000000000000 + + + 1.500000000000000 + + + + + + + Qt::AlignCenter + + + 2 + + + -100.000000000000000 + + + 100.000000000000000 + + + 0.100000000000000 + + + -0.100000000000000 + + + + + + + + 70 + 0 + + + + Qt::AlignCenter + + + 2 + + + -100.000000000000000 + + + 100.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + curvature scale + + + + + + + + 70 + 0 + + + + min + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + max + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + max workers + + + + + + + Qt::AlignCenter + + + 1 + + + 64 + + + 1 + + + + + + + + 0 + 0 + + + + gaussian filter size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + gaussian filter sigma + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + curvature filter size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + chunk size + + + + + + + Qt::LeftToRight + + + Qt::AlignCenter + + + 1 + + + 100 + + + 12 + + + + + + + Qt::AlignCenter + + + 1 + + + 100 + + + 3 + + + + + + + Qt::AlignCenter + + + 1 + + + 100 + + + + + + + Qt::AlignCenter + + + 256 + + + 8192 + + + 256 + + + 1024 + + + + + + + + + + true + + + 処理終了後,自動でウィンドウを閉じる + + + + 20 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 80 + 0 + + + + + 100 + 30 + + + + キャンセル + + + false + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 30 + + + + 実行 + + + + + + diff --git a/imgs/howtouse.png b/imgs/howtouse.png new file mode 100644 index 0000000..61f1d15 Binary files /dev/null and b/imgs/howtouse.png differ