ToolMap
Loading...
Searching...
No Matches
tmeditmanager.h
1/***************************************************************************
2 tmeditmanager.h
3 Deals with editing data in construction layers
4 -------------------
5 copyright : (C) 2007 CREALP Lucien Schreiber
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef _TM_EDIT_MANAGER_H_
18#define _TM_EDIT_MANAGER_H_
19
20#include <wx/wxprec.h>
21
22#ifndef WX_PRECOMP
23#include <wx/wx.h>
24#endif
25
26#include <wx/list.h> // for iterating lists
27#include <wx/notifmsg.h>
28
29#include "../core/bezierethz.h"
30#include "../core/tmsnappingmemory.h" // for snapping
31#include "../gis/tmattributiondataline.h" // for getting attribution (merging lines)
32#include "../gis/tmdraweredit.h" // for drawing line in modification
33#include "../gis/tmpointorientattrib.h" // for oriented points
34#include "../gui/beziersettings_dlg.h"
35#include "../gui/editvertex_dlg.h" // for editing vertex position
36#include "tmmanagerevent.h" // for shared event with other manager
37#include "tmselecteddatamemory.h" // for selection data
38#include "tocctrl.h" // for TOC ctrl
39
40const int tmEM_CONTEXTMENU_VERTEX_INSERT = 22200;
41const int tmEM_CONTEXTMENU_VERTEX_DELETE = 22201;
42const int tmEM_CONTEXTMENU_LINE_SAVE = 22202;
43const int tmEM_CONTEXTMENU_LINE_CANCEL = 22203;
44
45class ToolMapFrame;
46
47class DataBaseTM;
48
49class tmRenderer;
50
52 private:
53 long m_LineID;
54 int m_VertexID;
55 wxPoint m_CoordVertexPrevious;
56 wxPoint m_CoordVertex;
57
58 public:
59 tmSharedNodeEdit(long lineid, int vertexid, const wxPoint& coord, const wxPoint& coordprevious);
60
61 virtual ~tmSharedNodeEdit();
62
63 void DrawLine(wxClientDC* dc, wxPoint* point = nullptr);
64
65 long GetLineID() {
66 return m_LineID;
67 }
68
69 int GetVertexID() {
70 return m_VertexID;
71 }
72
73 void SetCoordVertex(const wxPoint& point) {
74 m_CoordVertex = point;
75 }
76};
77
78WX_DECLARE_OBJARRAY(tmSharedNodeEdit, tmArraySharedNodes);
79
80/***************************************************************************/
87class tmEditManager : public wxEvtHandler {
88 private:
89 // defined by ctor
90 ToolMapFrame* m_ParentEvt;
91 TocCtrl* m_TocCtrl;
92 tmSelectedDataMemory* m_SelectedData;
93 tmRenderer* m_Renderer;
94 bool m_EditStarted;
95 tmDrawerEditLine m_DrawLine;
96 int m_INSDELVertex;
97 wxRealPoint m_INSVertexPos;
98 tmPointOrientAttrib m_OrientedPt;
99 wxPoint m_LastMousePos;
100 tmArraySharedNodes m_SharedNodes;
101 wxOverlay m_OverlaySharedNodes;
102 wxColour m_SelectionColour;
103
104 DataBaseTM* m_pDB;
105 tmGISScale* m_Scale;
106
107 tmSnappingMemory* m_SnapMem;
108 bool m_SnappingShowOnMap;
109
110 wxRealPointList m_BezierPoints;
111 wxRealPointList m_BezierPointsControl;
112 wxArrayInt m_BezierSnappedPointsIndexes;
113 wxPoint m_BezierActualP1;
114 wxPoint m_BezierActualP2;
115 wxPoint m_BezierActualC1;
116 wxPoint m_BezierActualC2;
117 bool m_BezierDrawControlPoints;
118 wxRect m_BezierRefreshRect;
119 int m_BezierModifyIndexPoint;
120 int m_BezierModifyIndexControl;
121 bool m_BezierModifyControlInverted;
122 // double m_BezierApproximationScale;
123 BezierSettingsData m_BezierSettings;
124
125 wxRealPointList m_ArcPoints;
126 wxArrayLong m_ArcSnappedPointsIndexes;
127 wxPoint m_ArcActualPt;
128 wxRect m_ArcRefreshRect;
129 int m_ArcModifyIndexPoint;
130 long m_ArcOID;
131
132 // FUNCTIONS
133 void InitMemberValues();
134
135 // Extern EVENT function
136 void OnEditStart(wxCommandEvent& event);
137
138 void OnEditStop(wxCommandEvent& event);
139
140 void OnDrawFeatureValidate(wxCommandEvent& event);
141
142 void OnDrawFeatureEscape(wxCommandEvent& event);
143
144 void OnCutLines(wxCommandEvent& event);
145
146 void OnShowVertexPosition(wxCommandEvent& event);
147
148 void OnSetRenderFocus(wxCommandEvent& event);
149
150 void OnEditSharedDown(wxCommandEvent& event);
151
152 void OnEditSharedUp(wxCommandEvent& event);
153
154 void OnEditSharedMove(wxCommandEvent& event);
155
156 void OnOrientedPtsDown(wxCommandEvent& event);
157
158 void OnOrientedPtsMove(wxCommandEvent& event);
159
160 void OnOrientedPtsUp(wxCommandEvent& event);
161
162 void OnMenuInsertVertex(wxCommandEvent& event);
163
164 void OnMenuDeleteVertex(wxCommandEvent& event);
165
166 // internal verification
167 bool IsCorrectLayerSelected();
168
169 bool IsObjectSelected();
170
171 bool IsObjectMinNumberSelected(unsigned int iNumbermin = 1);
172
173 bool IsLayerTypeSelected(int layertype = LAYER_SPATIAL_LINE);
174
175 // snapping function
176 bool EMGetSnappingCoord(wxRealPoint& pt);
177
178 wxRealPoint* EMIterateAllSnappingLayers(const wxRealPoint& clickedpoint);
179
180 long _SaveToDatabase();
181
182 // checking
183 bool _LoadSnappingStatus();
184
185 wxArrayLong _GetErrorLines(wxArrayLong linetocheck);
186
187 void _ProcessChaikin();
188
189 DECLARE_EVENT_TABLE()
190 protected:
191 public:
192 // ctor - dtor
193 tmEditManager(ToolMapFrame* parent, TocCtrl* toc, tmSelectedDataMemory* seldata, tmRenderer* renderer,
194 tmGISScale* scale);
195
197
198 // If database is valid then project is open.
199 void SetDatabase(DataBaseTM* database) {
200 m_pDB = database;
201 }
202
203 void SetSnappingMemoryRef(tmSnappingMemory* snapping) {
204 m_SnapMem = snapping;
205 }
206
207 void SetSnappingShowOnMap(bool show) {
208 m_SnappingShowOnMap = show;
209 }
210
211 // change tool functions
212 void OnToolEdit();
213
214 void OnToolBezier();
215
216 void OnToolBezierModify();
217
218 void OnToolModify();
219
220 void OnToolEditShared();
221
222 void OnToolCutLines();
223
224 void OnToolOrientedPoint();
225
226 void OnToolVertexDelete();
227
228 void OnToolVertexInsert();
229
230 bool IsDrawingAllowed();
231
233
234 bool IsModificationBezierAllowed();
235
236 bool IsLayerSpatialType(int layerType = LAYER_SPATIAL_LINE);
237
238 bool IsMultipleModificationAllowed();
239
240 bool DeleteSelected(bool clearSelection = true);
241
242 bool UndoLastVertex();
243
244 bool HasLastVertex();
245
246 int GetSelectionCount();
247
248 bool SelectedSearch(const wxPoint& screenpt);
249
250 bool CreateIntersections();
251
252 bool EditVertexPosition();
253
254 bool MergeSelectedLines();
255
256 bool FlipLine();
257
258 bool SmoothLine();
259
260 void BezierClick(const wxPoint& mousepos);
261
262 void BezierMove(const wxPoint& mousepos);
263
264 void BezierDraw(wxGCDC* dc);
265
266 void BezierClear();
267
268 void BezierModifyDraw(wxGCDC* dc);
269
270 void BezierModifyClickDown(const wxPoint& mousepos);
271
272 void BezierModifyClickMove(const wxPoint& mousepos);
273
274 void BezierModifyClickUp(const wxPoint& mousepos);
275
276 bool BezierToLine(BezierSettingsData settings);
277
278 bool IsBezierToLinePreviewAllowed();
279
280 void SetBezierSettings(BezierSettingsData data, bool savetodb = false);
281
282 BezierSettingsData GetBezierSettings() {
283 return m_BezierSettings;
284 }
285
286 void ArcClick(const wxPoint& mousepos);
287
288 void ArcMove(const wxPoint& mousepos);
289
290 void ArcDraw(wxGCDC* dc);
291
292 void ArcClear();
293
294 void ArcModifyClickDown(const wxPoint& mousepos);
295
296 void ArcModifyClickMove(const wxPoint& mousepos);
297
298 void ArcModifyClickUp(const wxPoint& mousepos);
299
300 void ArcVertexInsertUp(const wxPoint& mousepos);
301
302 void ArcVertexDeleteUp(const wxPoint& mousePos);
303
304 void DrawSnappingCircle(wxGCDC* dc);
305};
306
307#endif
Definition beziersettings_dlg.h:31
Definition database_tm.h:80
Definition tocctrl.h:30
All frame's related stuff.
Definition toolmap.h:284
Definition tmdraweredit.h:34
Deals with editing data.
Definition tmeditmanager.h:87
bool MergeSelectedLines()
Merge selected lines.
Definition tmeditmanager.cpp:2037
int GetSelectionCount()
Number of selected features.
Definition tmeditmanager.cpp:1784
bool CreateIntersections()
Create intersections.
Definition tmeditmanager.cpp:1795
void OnToolModify()
User select modify tool.
Definition tmeditmanager.cpp:969
void OnToolCutLines()
Set tool to cut line tool.
Definition tmeditmanager.cpp:1073
bool DeleteSelected(bool clearSelection=true)
Delete the geometry and attribution of selected object.
Definition tmeditmanager.cpp:1685
bool SelectedSearch(const wxPoint &screenpt)
Search function.
Definition tmeditmanager.cpp:1566
~tmEditManager()
Destructor.
Definition tmeditmanager.cpp:99
void OnToolOrientedPoint()
Set oriented point tool.
Definition tmeditmanager.cpp:1083
bool EditVertexPosition()
Display a dialog for editing vertex position.
Definition tmeditmanager.cpp:1960
bool IsModificationAllowed()
Are we ready for drawing.
Definition tmeditmanager.cpp:1206
bool IsDrawingAllowed()
Are we ready for drawing.
Definition tmeditmanager.cpp:1193
void OnToolEdit()
User select edit tool.
Definition tmeditmanager.cpp:126
bool UndoLastVertex()
Remove the last vertex from memory.
Definition tmeditmanager.cpp:1731
Definition tmgisscale.h:100
Definition tmpointorientattrib.h:33
Definition tmrenderer.h:99
Store ID of selected data into memory.
Definition tmselecteddatamemory.h:43
Definition tmeditmanager.h:51
Store snapping status into memory.
Definition tmsnappingmemory.h:59