본문으로 건너뛰기
로딩중...
검색중...
일치하는것 없음
MapTool.h
1#pragma once
2
3#include "gdkqt/GdkQtForward.h"
4#include "maptools/MapOverlayModel.h"
5#include "maptools/MapToolTypes.h"
6
7#include "gdk_dll/maptools/glsMapToolTypes.h"
8
9#include <QRect>
10#include <QString>
11#include <QVector>
12
13#include <functional>
14
15class QKeyEvent;
16class QMenu;
17class QWidget;
18
19namespace GdkQt {
20
21// 우클릭 컨텍스트 메뉴가 호출하는 앱 수준 명령 모음.
22// 위젯(GdkMapWidget) 생성 시점 이후 MainWindowComposition 에서 한 번 와이어링된다.
23// 비어 있는(빈 std::function) 항목은 해당 기능을 사용할 수 없음을 의미하므로
24// 호출 전에 항상 유효성을 검사한다.
33 // 선택 / 편집
37 std::function<bool()> hasSelection;
42 std::function<bool()> hasSelectionLayerSelection;
44 std::function<void()> clearSelection;
46 std::function<void()> zoomToSelection;
48 std::function<void()> deleteSelection;
50 std::function<bool()> canEditSelection;
51 // 식별
53 std::function<void()> zoomToIdentified;
55 std::function<void()> openInfoPanel;
56 // 편집 세션
58 std::function<void()> saveEdits;
60 std::function<void()> cancelEdits;
62 std::function<bool()> isEditing;
63};
64
74 QWidget* widget = nullptr;
75 GdkQtSession* session = nullptr;
77 std::function<GDK::glsMapView*()> mapView;
79 std::function<void()> syncViewport;
81 std::function<void()> notifyViewChanged;
83 std::function<void()> requestUpdate;
85 std::function<void()> requestOverlayUpdate;
87 std::function<void(const QPointF&)> identifyClicked;
92 std::function<void(const GDK::glsMapToolSelectionRequest&)> executeSelection;
94 std::function<void(const QRectF&)> identifyRect;
98 std::function<void(const QRect&)> dragRectChanged;
100 std::function<SnapSettings()> snapSettings;
102 std::function<QString()> snapTargetLayerId;
106 std::function<void(MapToolMode, const QVector<GDK::glsMapPoint>&)> createFeatureGeometry;
111 std::function<GDK::glsMapToolEditTargetResult(const GDK::glsMapToolSelectionRequest&)> selectEditTarget;
116 std::function<bool(const QString&)> canEditGeometry;
121 std::function<bool(const QString&)> beginGeometryEdit;
126 std::function<void(const QString&, int)> endGeometryEdit;
128 std::function<void(const QString&)> showStatus;
131};
132
141class MapTool {
142public:
145 explicit MapTool(MapToolHost* host) : m_host(host) {}
147 virtual ~MapTool() = default;
148
150 virtual void activate() {}
152 virtual void deactivate() {}
154 virtual void viewChanged() {}
155
159 virtual bool mousePress(const MapMouseEvent& event) = 0;
163 virtual bool mouseMove(const MapMouseEvent& event) = 0;
167 virtual bool mouseRelease(const MapMouseEvent& event) = 0;
171 virtual bool mouseDoubleClick(const MapMouseEvent& event) { return false; }
175 virtual bool keyPress(QKeyEvent* event) { return false; }
176
177 // 현재 도구에 맞는 모드별 우클릭 메뉴 항목을 menu 에 추가한다.
178 // 기본 구현은 아무 것도 추가하지 않는다. ev 는 우클릭이 발생한 지점.
182 virtual void buildContextMenu(QMenu& menu, const MapMouseEvent& event) {}
183
184 // ── Undo integration (EditWorkflowController::undo) ─────────────────
187 virtual bool hasUndoableStep() const { return false; }
190 virtual bool undoStep() { return false; }
193 virtual bool blocksEditHistory() const { return false; }
197 virtual void editStateChanged() {}
198
203 virtual Qt::CursorShape defaultCursorShape() const { return Qt::ArrowCursor; }
204
205protected:
209 {
210 static const MapCommandSink kEmpty;
211 return m_host ? m_host->commands : kEmpty;
212 }
213
216 GDK::glsMapView* mapView() const
217 {
218 return m_host && m_host->mapView ? m_host->mapView() : nullptr;
219 }
220
222 void syncViewport() const
223 {
224 if (m_host && m_host->syncViewport) {
226 }
227 }
228
230 void notifyViewChanged() const
231 {
234 }
235 }
236
238 void requestUpdate() const
239 {
240 if (m_host && m_host->requestUpdate) {
242 }
243 }
244
247 {
250 }
251 }
252
255 void showStatus(const QString& message) const
256 {
257 if (m_host && m_host->showStatus) {
258 m_host->showStatus(message);
259 }
260 }
261
264 MapOverlayModel* overlay() const { return m_host ? m_host->overlay : nullptr; }
267 QWidget* widget() const { return m_host ? m_host->widget : nullptr; }
269 MapToolHost* m_host = nullptr;
270};
271
272} // namespace GdkQt
273
워크스페이스를 소유하고 지도와 데이터 작업을 Qt 형식으로 제공하는 세션입니다.
정의 GdkQtSession.h:39
const MapCommandSink & commands() const
호스트의 응용 프로그램 명령 모음을 돌려줍니다.
정의 MapTool.h:208
virtual bool hasUndoableStep() const
도구 자체의 되돌릴 단계(예: 스케치 정점)가 있는지 돌려줍니다.
정의 MapTool.h:187
void showStatus(const QString &message) const
호스트의 showStatus 콜백으로 상태 메시지를 표시합니다.
정의 MapTool.h:255
virtual bool undoStep()
도구 자체의 마지막 단계를 되돌립니다.
정의 MapTool.h:190
void syncViewport() const
호스트의 syncViewport 콜백을 부릅니다. 호스트나 콜백이 없으면 아무것도 하지 않습니다.
정의 MapTool.h:222
virtual bool mouseDoubleClick(const MapMouseEvent &event)
마우스 두 번 클릭을 처리합니다.
정의 MapTool.h:171
virtual void editStateChanged()
대기 중인 편집이 도구 밖에서(실행 취소·다시 실행으로) 바뀌었을 때 불립니다.
정의 MapTool.h:197
GDK::glsMapView * mapView() const
현재 지도 뷰를 빌려 줍니다.
정의 MapTool.h:216
virtual void deactivate()
이 도구가 다른 도구로 바뀌거나 파괴되기 전에 불립니다.
정의 MapTool.h:152
void requestOverlayUpdate() const
호스트의 requestOverlayUpdate 콜백으로 오버레이 다시 그리기를 요청합니다. 호스트나 콜백이 없으면 아무것도 하지 않습니다.
정의 MapTool.h:246
MapTool(MapToolHost *host)
도구를 만듭니다.
정의 MapTool.h:145
virtual bool mouseRelease(const MapMouseEvent &event)=0
마우스 놓기를 처리합니다.
MapToolHost * m_host
생성자에서 받은 호스트입니다. 빌린 포인터이며 소유하지 않습니다.
정의 MapTool.h:269
QWidget * widget() const
지도 위젯을 빌려 줍니다.
정의 MapTool.h:267
virtual bool blocksEditHistory() const
진행 중인 조작이 대기 중인 편집의 변경을 견딜 수 없는 동안(예: 정점 드래그 중) true를 돌려줍니다.
정의 MapTool.h:193
virtual Qt::CursorShape defaultCursorShape() const
이 도구가 활성인 동안 쓸 커서입니다(C# GdkMapTool.DefaultCursor에 대응).
정의 MapTool.h:203
virtual ~MapTool()=default
도구를 해제합니다.
virtual bool mouseMove(const MapMouseEvent &event)=0
마우스 이동을 처리합니다.
void requestUpdate() const
호스트의 requestUpdate 콜백으로 지도 전체 다시 그리기를 요청합니다. 호스트나 콜백이 없으면 아무것도 하지 않습니다.
정의 MapTool.h:238
virtual void viewChanged()
지도 뷰가 바뀐 뒤 불립니다. 오버레이를 다시 계산해야 할 수 있습니다.
정의 MapTool.h:154
MapOverlayModel * overlay() const
GdkMapWidget가 소유한 오버레이 모델을 빌려 줍니다.
정의 MapTool.h:264
virtual void buildContextMenu(QMenu &menu, const MapMouseEvent &event)
이벤트 위치에 맞는 도구 고유의 오른쪽 클릭 메뉴 항목을 menu에 추가합니다.
정의 MapTool.h:182
virtual bool keyPress(QKeyEvent *event)
키 누름을 처리합니다.
정의 MapTool.h:175
virtual void activate()
이 도구가 활성 도구가 될 때 불립니다. 이전 도구의 deactivate() 뒤에 불립니다.
정의 MapTool.h:150
virtual bool mousePress(const MapMouseEvent &event)=0
마우스 누름을 처리합니다.
void notifyViewChanged() const
호스트의 notifyViewChanged 콜백을 부릅니다. 도구가 지도 뷰를 바꾼 뒤 부르며, 호스트나 콜백이 없으면 아무것도 하지 않습니다.
정의 MapTool.h:230
glsGdkQt의 공개 형식과 함수가 있는 네임스페이스입니다.
정의 AppSettings.h:15
지도 도구와 오른쪽 클릭 메뉴에 노출하는 선택적 응용 프로그램 명령 모음입니다.
정의 MapTool.h:32
std::function< void()> saveEdits
편집 내용을 저장합니다. 편집 중이고 이 함수가 있을 때 메뉴에 표시합니다.
정의 MapTool.h:58
std::function< bool()> canEditSelection
선택 피처를 지금 삭제할 수 있는지 돌려줍니다. false이면 삭제 메뉴를 비활성으로 표시하고, 비어 있으면 활성으로 봅니다.
정의 MapTool.h:50
std::function< void()> clearSelection
모든 레이어의 선택을 해제합니다. 비어 있으면 선택 해제 메뉴를 표시하지 않습니다.
정의 MapTool.h:44
std::function< bool()> hasSelectionLayerSelection
선택을 가진 레이어(네이티브 GetSelectedLayerId)에 선택이 있는지 돌려줍니다.
정의 MapTool.h:42
std::function< bool()> hasSelection
보이고 선택 가능한 레이어 중 하나라도 선택이 있는지 돌려줍니다(모든 레이어 대상).
정의 MapTool.h:37
std::function< void()> zoomToIdentified
식별한 피처로 확대합니다. 비어 있으면 해당 메뉴를 표시하지 않습니다.
정의 MapTool.h:53
std::function< void()> cancelEdits
편집 내용을 취소합니다. 편집 중이고 이 함수가 있을 때 메뉴에 표시합니다.
정의 MapTool.h:60
std::function< void()> zoomToSelection
선택 피처의 범위로 확대합니다. 비어 있으면 해당 메뉴를 표시하지 않습니다.
정의 MapTool.h:46
std::function< bool()> isEditing
편집 모드인지 돌려줍니다. 비어 있으면 편집 중으로 봅니다.
정의 MapTool.h:62
std::function< void()> openInfoPanel
정보(피처 속성) 패널을 엽니다. 비어 있으면 해당 메뉴를 표시하지 않습니다.
정의 MapTool.h:55
std::function< void()> deleteSelection
선택 레이어의 선택 피처를 삭제합니다. 비어 있으면 삭제 메뉴를 표시하지 않습니다.
정의 MapTool.h:48
GdkMapWidget이 지도 도구에 전달하는 정규화된 마우스 이벤트입니다.
정의 MapToolTypes.h:71
지도 위젯이 지도 위에 그리는 지도 도구 오버레이 상태입니다.
정의 MapOverlayModel.h:48
GdkMapWidget가 지도 도구에 빌려 주는 의존 객체와 콜백 모음입니다.
정의 MapTool.h:73
MapOverlayModel * overlay
GdkMapWidget가 소유한 오버레이 모델입니다. 도구가 내용을 바꾼 뒤 requestOverlayUpdate를 부릅니다.
정의 MapTool.h:129
std::function< SnapSettings()> snapSettings
현재 스냅 설정을 돌려줍니다. 비어 있으면 스냅하지 않습니다.
정의 MapTool.h:100
std::function< GDK::glsMapToolEditTargetResult(const GDK::glsMapToolSelectionRequest &)> selectEditTarget
네이티브 ObjectMove·VertexEdit 도구가 클릭 위치의 편집 대상 하나를 선택하도록 요청합니다.
정의 MapTool.h:111
std::function< void(const QRect &)> dragRectChanged
Info 드래그 사각형(기기 픽셀)이 바뀌었음을 알립니다.
정의 MapTool.h:98
std::function< void(const QPointF &)> identifyClicked
Info 클릭 위치(기기 픽셀)의 피처 식별을 요청합니다. GdkMapWidget는 mapClicked() 시그널로 전달합니다.
정의 MapTool.h:87
std::function< void(const QString &)> showStatus
도구의 상태 메시지(번역된 문구)를 표시합니다.
정의 MapTool.h:128
std::function< bool(const QString &)> beginGeometryEdit
편집 도구가 레이어 ID의 지오메트리를 기록하기 직전에 허용 여부를 묻습니다.
정의 MapTool.h:121
MapCommandSink commands
응용 프로그램 명령 모음입니다. GdkMapWidget::setMapCommandSink()로 설정합니다.
정의 MapTool.h:130
std::function< void()> notifyViewChanged
도구가 지도 뷰를 바꿨음을 알립니다. GdkMapWidget는 viewChanged() 시그널을 냅니다.
정의 MapTool.h:81
std::function< void()> requestOverlayUpdate
오버레이 영역만 다시 그리도록 요청합니다. overlay를 바꾼 뒤 부릅니다.
정의 MapTool.h:85
std::function< QString()> snapTargetLayerId
그리기·스냅 대상 레이어 ID를 돌려줍니다. 대상이 없으면 빈 문자열입니다.
정의 MapTool.h:102
std::function< void(MapToolMode, const QVector< GDK::glsMapPoint > &)> createFeatureGeometry
생성 도구가 완성한 지오메트리로 피처 생성을 요청합니다.
정의 MapTool.h:106
std::function< bool(const QString &)> canEditGeometry
네이티브 편집 도구가 레이어 ID의 지오메트리를 편집할 수 있는지 돌려줍니다.
정의 MapTool.h:116
GdkQtSession * session
세션입니다.
정의 MapTool.h:75
std::function< void(const QString &, int)> endGeometryEdit
beginGeometryEdit()이 허용한 기록이 끝났음을 알립니다.
정의 MapTool.h:126
std::function< GDK::glsMapView *()> mapView
현재 지도 뷰를 돌려줍니다. 빌린 포인터이며 지도 뷰가 없으면 null입니다.
정의 MapTool.h:77
QWidget * widget
지도 위젯입니다. 포인터 캡처와 기기 픽셀 비율 계산에 씁니다.
정의 MapTool.h:74
std::function< void()> syncViewport
지도 뷰의 크기와 DPI를 위젯의 기기 픽셀 크기에 맞춥니다. 내장 Pan 도구가 드래그로 뷰를 움직이기 전에 부릅니다.
정의 MapTool.h:79
std::function< void(const QRectF &)> identifyRect
Info 드래그 사각형(기기 픽셀, 정규화됨)의 피처 식별을 요청합니다. GdkMapWidget는 mapDragSelected() 시그널로 전달합니다.
정의 MapTool.h:94
std::function< void()> requestUpdate
지도 위젯 전체를 다시 그리도록 요청합니다.
정의 MapTool.h:83
std::function< void(const GDK::glsMapToolSelectionRequest &)> executeSelection
네이티브 내장 선택 도구의 선택 실행을 요청합니다.
정의 MapTool.h:92
지도 도구가 쓰는 스냅 설정입니다.
정의 SnapTypes.h:48