ToolMap
Loading...
Searching...
No Matches
tmlayermanager.h
1/***************************************************************************
2 tmlayermanager.h
3 Central point for layer management
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#ifndef _TM_LAYERMANAGER_H_
17#define _TM_LAYERMANAGER_H_
18
19#include <wx/wxprec.h>
20
21#ifndef WX_PRECOMP
22#include <wx/wx.h>
23#endif
24
25#include <wx/regex.h>
26
27#include "tmdrawer.h" // for drawing into bitmaps
28#include "tocctrl.h" // class TOC ctrl
29#include "../database/database_tm.h" // class database
30#include "tmgisdata.h" // for GISdata
31#include "tmgisdatavectormysql.h" // for direct access to GIS mysql
32#include "tmrenderer.h" // for GIS rendering
33#include "tmscalectrl.h" // for combo box scale control
34#include "tmselecteddatamemory.h" // for storing selected data into memory
35#include "tmmanagerevent.h" // for shared event with other manager
36#include "tmmemoryzoom.h" // for storing previous zoom in memory.
37
38
39#define ID_MENU_UNLINK_SPATIAL_DATA 10023
40
41// forward declaration
42class tmGISLoadingDataThread;
43
45
46/***************************************************************************/
57class tmLayerManager : public wxEvtHandler {
58 private:
59 TocCtrl* m_TocCtrl;
60 tmRenderer* m_GISRenderer;
61 wxWindow* m_Parent;
62 DataBaseTM* m_DB;
63 tmGISScale m_Scale;
64 tmDrawer m_Drawer;
65 tmGISLoadingDataThread* m_Thread;
66 wxBitmap* m_Bitmap;
67 wxStatusBar* m_StatusBar;
68 tmScaleCtrlCombo* m_ScaleCtrl;
69 static bool m_LogOn;
70 tmSelectedDataMemory m_SelectedData;
71 bool m_BlockRefresh;
72 tmMemoryZoomManager m_ZoomManager;
73 PrjDefMemManage* m_MemoryPrjRef;
74 bool m_isUsingRAM;
75 long m_InternetRefreshTime;
76
77 // shared member data with thread
78 // tmTHREAD_STATUS m_Shared_ThreadStatus;
79 wxBitmap* m_ThreadBitmap;
80
81 // TOC specific functions
82 void FillTOCArray();
83
84 bool SaveTOCStatus(bool isClosing = false);
85
86 bool IsOK();
87
88 // rotation warning function
89 wxArrayString m_RotationName;
90 wxArrayShort m_RotationStatus;
91 wxArrayString m_RotationLayerNames;
92
93 // function called when view is updated
94 void _ZoomChanged();
95
96 bool _ReplaceLayer(const wxFileName& filename, const wxString& originalname);
97
98 void _BuildOverviewsIfNeeded(tmGISData* layer, const wxString& displayname);
99
100 // event functions
101 void OnZoomRectangleIn(wxCommandEvent& event);
102
103 void OnZoomRectangleOut(wxCommandEvent& event);
104
105 void OnZoomToFeature(wxCommandEvent& event);
106
107 void OnMoveToFeature(wxCommandEvent& event);
108
109 void OnPanFinished(wxCommandEvent& event);
110
111 void OnScrolled(wxCommandEvent& event);
112
113 void OnSelection(wxCommandEvent& event);
114
115 void OnRemoveLayers(wxCommandEvent& event);
116
117 void OnRotationWarning(wxCommandEvent& event);
118
119 void OnIncompatibleLayerWarning(wxCommandEvent& event);
120
121 // bitmap specific functions
122 void CreateEmptyBitmap(const wxSize& size);
123
124 // Reading all layers for extent or drawing
125 int ReadLayerExtent(bool loginfo = false, bool buildpyramids = false);
126
127 int ReadLayerDraw();
128
129 DECLARE_EVENT_TABLE()
130
131 public:
132 // ctor / dtor
133 tmLayerManager(wxWindow* parent, TocCtrl* tocctrl, tmRenderer* renderer, wxStatusBar* status,
134 tmScaleCtrlCombo* scalectrl);
135
137
138 // scale ctrl functions
139 void InitScaleCtrlList();
140
141 // Init layermanager
143
144 bool UnInitLayerManager();
145
146 void SetMemoryProject(PrjDefMemManage* memoryprj);
147
148 // layers operations
149 void RemoveLayer(wxCommandEvent& event);
150
151 void AddLayer(wxCommandEvent& event);
152
153 void AddWebLayer();
154
155 void GroupAdd(wxCommandEvent& event);
156
157 bool OpenLayer(const wxFileName& filename, bool replace = false, const wxString& originalname = wxEmptyString);
158
159 tmGISScale* GetScale() {
160 return &m_Scale;
161 }
162
163 bool ZoomToLayer(long layerid);
164
165 void ZoomToSelectedLayer();
166
167 void ZoomToFrameLayer();
168
169 // event operations
170 void OnSizeChange(wxCommandEvent& event);
171
172 void OnUpdateCoordinates(wxCommandEvent& event);
173
174 void OnUpdateAngle(wxCommandEvent& event);
175
176 void OnShowLayer(wxCommandEvent& event);
177
178 void OnScaleChanged(wxCommandEvent& event);
179
180 void OnDisplayProperties(wxCommandEvent& event);
181
182 void OnDisplayLabels(wxCommandEvent& event);
183
184 void OnTocEdited(wxCommandEvent& event);
185
186 // for logging (only one thread may acces the GUI.
187 static void EnableLogging(bool enable = true) {
188 m_LogOn = enable;
189 }
190
191 static bool IsLoggingEnabled() {
192 return m_LogOn;
193 }
194
195 // tool operations
196 void OnZoomToFit();
197
198 void OnZoomRectangle();
199
200 void OnPan();
201
202 void OnSelect();
203
204 bool ZoomPrevious();
205
206 bool HasZoomPrevious();
207
208 // selection function
209 bool SelectedSearch(const wxRect& rect, bool shiftdown = false);
210
211 bool SelectedClear();
212
213 bool SelectedInvert();
214
215 bool SelectByOid();
216
217 void CheckGeometryValidity();
218
219 void ExportSelectedGeometries(const wxFileName& file);
220
221 bool LoadProjectLayers();
222
223 bool ReloadProjectLayers(bool bFullExtent = TRUE, bool bInvalidateFullExt = TRUE);
224
225 tmSelectedDataMemory* GetSelectedDataMemory() {
226 return &m_SelectedData;
227 }
228
229 // blocking, unblocking the refresh process
230 void BlockRefreshProcess(bool block = true) {
231 m_BlockRefresh = block;
232 }
233
234 bool GetRefreshBlocked() {
235 return m_BlockRefresh;
236 }
237
238 void SetSelectionColour(const wxColour& col) {
239 m_SelectedData.SetSelectionColour(col);
240 }
241
242 void SetSelectionHalo(bool hashalo) {
243 m_SelectedData.SetSelectionHalo(hashalo);
244 }
245};
246
247#endif
Definition database_tm.h:80
Definition prjdefmemmanage.h:54
Definition tocctrl.h:30
In charge of all the drawing into bitmaps.
Definition tmdrawer.h:50
Main class for dealing with GIS data.
Definition tmgisdata.h:48
Definition tmgisscale.h:100
GIS class for dealing with layers.
Definition tmlayermanager.h:57
void OnScaleChanged(wxCommandEvent &event)
Called when user change scale.
Definition tmlayermanager.cpp:899
bool SelectedInvert()
Invert selected values.
Definition tmlayermanager.cpp:1112
bool UnInitLayerManager()
Un-Init the layer manager.
Definition tmlayermanager.cpp:145
void GroupAdd(wxCommandEvent &event)
Definition tmlayermanager.cpp:471
void OnZoomToFit()
Called when user press Zoom to fit.
Definition tmlayermanager.cpp:988
void OnDisplayProperties(wxCommandEvent &event)
Show properties dialog.
Definition tmlayermanager.cpp:919
void OnSizeChange(wxCommandEvent &event)
Called when windows size change.
Definition tmlayermanager.cpp:768
bool SelectedSearch(const wxRect &rect, bool shiftdown=false)
Searching data for selection.
Definition tmlayermanager.cpp:1016
bool InitLayerManager(DataBaseTM *db)
Init the layer manager with a project.
Definition tmlayermanager.cpp:112
void OnShowLayer(wxCommandEvent &event)
Called when showing or hiding a layer.
Definition tmlayermanager.cpp:887
bool LoadProjectLayers()
Load all layers (non threaded)
Definition tmlayermanager.cpp:1484
bool SelectedClear()
Clear all selected objects.
Definition tmlayermanager.cpp:1094
void AddLayer(wxCommandEvent &event)
Response to the event sent by the "Add Gis Data" menu.
Definition tmlayermanager.cpp:425
~tmLayerManager()
Destructor.
Definition tmlayermanager.cpp:98
void OnUpdateCoordinates(wxCommandEvent &event)
Respond to mouse mouve inside renderer area.
Definition tmlayermanager.cpp:807
void RemoveLayer(wxCommandEvent &event)
Response to the event sent by the #tmTOCCtrl.
Definition tmlayermanager.cpp:288
tmMemoryZoomManager
Definition tmmemoryzoom.h:60
Definition tmrenderer.h:99
Definition tmscalectrl.h:31
Store ID of selected data into memory.
Definition tmselecteddatamemory.h:43