ToolMap
Loading...
Searching...
No Matches
tmrenderer.h
1/***************************************************************************
2 tmrenderer.h
3 Deals with the main renderer windows
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_GISRENDERER_H_
18#define _TM_GISRENDERER_H_
19
20#include <wx/wxprec.h>
21
22#ifndef WX_PRECOMP
23#include <wx/wx.h>
24#endif
25
26#include <wx/dcbuffer.h>
27#include <wx/dcgraph.h>
28#include <wx/overlay.h>
29#include <wx/scrolwin.h> // for scrolled window base
30
31#include "../core/tmarraysize.h" // for array of wxSize items
32#include "tmgisscale.h" // for number of division;
33
34const wxString TMRENDERER_WINDOW_NAME = wxTRANSLATE("TMRENDERER_WINDOW");
35
36class vrRubberBand;
37
38// EVENT FOR GIS RENDERER CTRL
39DECLARE_EVENT_TYPE(tmEVT_LM_SIZE_CHANGED, -1)
40DECLARE_EVENT_TYPE(tmEVT_LM_MOUSE_MOVED, -1)
41DECLARE_EVENT_TYPE(tmEVT_LM_ZOOM_RECTANGLE_OUT, -1)
42DECLARE_EVENT_TYPE(tmEVT_LM_ZOOM_RECTANGLE_IN, -1)
43DECLARE_EVENT_TYPE(tmEVT_LM_PAN_ENDED, -1)
44DECLARE_EVENT_TYPE(tmEVT_LM_SELECTION, -1)
45DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_CLICK, -1)
46DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_ENTER, -1)
47DECLARE_EVENT_TYPE(tmEVT_EM_CUT_LINE, -1)
48DECLARE_EVENT_TYPE(tmEVT_AM_SHORTCUT_PRESSED, -1)
49DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_MOVED, -1)
50DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_UP, -1)
51DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_CLICK, -1)
52DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_MOVE, -1)
53DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_DOWN, -1)
54DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_ESC, -1)
55DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_MENU, -1)
56DECLARE_EVENT_TYPE(tmEVT_TM_UPDATE_TOOL_VIEW, -1)
57DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_ORIENT_DOWN, -1)
58DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_ORIENT_MOVE, -1)
59DECLARE_EVENT_TYPE(tmEVT_EM_DRAW_ORIENT_UP, -1)
60DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_SHARED_DOWN, -1)
61DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_SHARED_UP, -1)
62DECLARE_EVENT_TYPE(tmEVT_EM_MODIFY_SHARED_MOVE, -1)
63
64enum tmGIS_TOOL {
65 tmTOOL_SELECT = 0,
66 tmTOOL_ZOOM_RECTANGLE_IN,
67 tmTOOL_ZOOM_RECTANGLE_OUT,
68 tmTOOL_PAN,
69 tmTOOL_DRAW,
70 tmTOOL_DRAW_BEZIER,
71 tmTOOL_MODIFY,
72 tmTOOL_MODIFY_BEZIER,
73 tmTOOL_CUT_LINES,
74 tmTOOL_ORIENTED_POINTS,
75 tmTOOL_MODIFY_SHARED,
76 tmTOOL_VERTEX_DELETE,
77 tmTOOL_VERTEX_INSERT,
78 tmTOOL_ZOOM_RECTANGLE = tmTOOL_ZOOM_RECTANGLE_IN
79};
80
81enum tmGIS_CURSOR {
82 tmCURSOR_ZOOM_IN,
83 tmCURSOR_ZOOM_OUT,
84 tmCURSOR_HAND,
85 tmCURSOR_EDIT,
86 tmCURSOR_ORIENTED,
87 tmCURSOR_VERTEX_ADD,
88 tmCURSOR_VERTEX_REMOVE
89};
90
91// parameter : size of selection in pixels
92// sould be able to divide it by two
93const int tmSELECTION_DIAMETER = 10;
94
95class tmEditManager;
96
97class tmToolManager;
98
99class tmRenderer : public wxScrolledWindow {
100 private:
101 wxBitmap* m_bmp;
102 tmGIS_TOOL m_ActualTool;
103 tmGIS_CURSOR m_ActualNotStockCursor;
104
105 tmEditManager* m_EditManager;
106 tmToolManager* m_ToolManager;
107
108 wxSize m_OldSize;
109
110 // rubber band
111 wxPoint m_StartCoord;
112 wxBitmap* m_PanBmp;
113 vrRubberBand* m_Rubber;
114 wxOverlay m_Overlay;
115
116 bool m_ShiftDown;
117
118 bool m_ModifyCalled;
119 bool m_DrawCalled;
120
121 int m_WheelRotation;
122 wxPoint m_WheelPosition;
123 wxTimer m_WheelTimer;
124
125 // changing cursors
126 wxCursor LoadCursorFromBitmap(tmGIS_CURSOR cursor);
127
128 void ChangeCursor(const tmGIS_TOOL& selected_tool);
129
130 // mouse event function
131 void OnMouseDown(wxMouseEvent& event);
132
133 // void OnMouseRightDown (wxMouseEvent & event);
134 void OnMouseMove(wxMouseEvent& event);
135
136 void OnMouseUp(wxMouseEvent& event);
137
138 void OnMouseCaptureLost(wxMouseEvent& event);
139
140 void OnMouseDClick(wxMouseEvent& event);
141
142 void OnMouseWheel(wxMouseEvent& event);
143
144 void OnShiftDown(wxKeyEvent& event);
145
146 void OnShiftUp(wxKeyEvent& event);
147
148 void OnKey(wxKeyEvent& event);
149
150 void OnWheelTimer(wxTimerEvent& event);
151
152 void OnAvoidFlickering(wxEraseEvent& event);
153
154 // bitmap functions
155 bool BitmapUpdateSize();
156
157 bool BitmapSetToWhite();
158
159 bool BitmapCopyInto(wxBitmap* bmp);
160
161 bool m_isPanning;
162 DECLARE_EVENT_TABLE()
163
164 protected:
165 // rubber band functions
166 void ZoomStart(const wxPoint& mousepos);
167
168 void ZoomUpdate(wxMouseEvent& event);
169
170 void ZoomStop(const wxPoint& mousepos);
171
172 // selecting function
173 void SelectStart(const wxPoint& mousepos);
174
175 void SelectUpdate(wxMouseEvent& event);
176
177 void SelectStop(const wxPoint& mousepos);
178
179 // panning function
180 void PanStart(const wxPoint& mousepos);
181
182 void PanUpdate(const wxPoint& mousepos);
183
184 void PanStop(const wxPoint& mousepos);
185
186 void PanDClick(wxMouseEvent& event);
187
188 // oriented pts functions
189 void OrientedPtsStart(const wxPoint& mousepos);
190
191 void OrientedPtsMove(const wxPoint& mousepos);
192
193 void OrientedPtsStop(const wxPoint& mousepos);
194
195 // modify shared function
196 void ModifySharedStart(const wxPoint& mousepos);
197
198 void ModifySharedStop(const wxPoint& mousepos);
199
200 void ModifySharedUpdate(const wxPoint& mousepos);
201
202 void CutLineClick(const wxPoint& mousepos);
203
204 public:
205 tmRenderer(wxWindow* parent, wxWindowID id);
206
207 ~tmRenderer();
208
209 void OnSizeChange(wxSizeEvent& event);
210
211 void InitSize();
212
213 void OnPaint(wxPaintEvent& event);
214
215 void SetBitmapStatus(wxBitmap* bmp = nullptr); //{m_bmp = bmp;}
216
217 void SetTool(tmGIS_TOOL selected_tool);
218
219 tmGIS_TOOL GetTool() {
220 return m_ActualTool;
221 }
222
223 // get bitmap
224 wxBitmap* GetBitmap() {
225 return m_bmp;
226 }
227
228 // drawing
229 void DrawCircleVideoInverse(wxPoint pt, int radius);
230
231 void DrawCircleVideoInverseClean();
232
233 // editing
234 void StopModifyEvent() {
235 m_ModifyCalled = false;
236 }
237
238 void SetEditManagerRef(tmEditManager* manager) {
239 m_EditManager = manager;
240 }
241
242 void SetToolManagerRef(tmToolManager* manager) {
243 m_ToolManager = manager;
244 }
245};
246
247#endif
Deals with editing data.
Definition tmeditmanager.h:87
Definition tmrenderer.h:99
void PanStop(const wxPoint &mousepos)
Refresh screen after pan.
Definition tmrenderer.cpp:763
void OnSizeChange(wxSizeEvent &event)
Respond to a Size message.
Definition tmrenderer.cpp:157
void PanStart(const wxPoint &mousepos)
Start the pan.
Definition tmrenderer.cpp:691
void CutLineClick(const wxPoint &mousepos)
Click up with cut line tool.
Definition tmrenderer.cpp:860
void SelectStart(const wxPoint &mousepos)
Called when selection start (mouse down)
Definition tmrenderer.cpp:628
~tmRenderer()
Destructor.
Definition tmrenderer.cpp:145
void PanUpdate(const wxPoint &mousepos)
Update the pan image during mouse move.
Definition tmrenderer.cpp:729
void DrawCircleVideoInverse(wxPoint pt, int radius)
Draw a circle using inverse video.
Definition tmrenderer.cpp:874
void SelectStop(const wxPoint &mousepos)
Called when selection finished (mouse up)
Definition tmrenderer.cpp:658
void SelectUpdate(wxMouseEvent &event)
Called when selection is updated (mouse move)
Definition tmrenderer.cpp:641
Definition tmtoolmanager.h:34
Definition vrrubberband.h:26