Version: 0.6.0
vectorop.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: vector operations.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2011-2013 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/datasource/gdalinh.h"
24 #include "wxgis/datasource/spatialtree.h"
25 
26 #include "wx/event.h"
27 
28 class WXDLLIMPEXP_GIS_DS wxFeatureDSEvent;
29 
30 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_FEATURES_ADDED, wxFeatureDSEvent);
31 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_FEATURE_ADDED, wxFeatureDSEvent);
32 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_FEATURE_DELETED, wxFeatureDSEvent);
33 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_FEATURE_CHANGED, wxFeatureDSEvent);
34 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_CLOSED, wxFeatureDSEvent);
35 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_DS, wxDS_CHANGED, wxFeatureDSEvent);
36 
40 class WXDLLIMPEXP_GIS_DS wxFeatureDSEvent : public wxEvent
41 {
42 public:
43  wxFeatureDSEvent(wxEventType eventType = wxDS_FEATURES_ADDED, const wxGISSpatialTreeCursor &Cursor = wxNullSpatialTreeCursor) : wxEvent(0, eventType)
44  {
45  m_Cursor = Cursor;
46  m_nFid = wxNOT_FOUND;
47  }
48  wxFeatureDSEvent(wxEventType eventType, long nFid) : wxEvent(0, eventType)
49  {
50  m_Cursor = wxNullSpatialTreeCursor;
51  m_nFid = nFid;
52  }
53  wxFeatureDSEvent(const wxFeatureDSEvent& event) : wxEvent(event)
54  {
55  for (size_t i = 0; i < event.m_Cursor.GetCount(); ++i)
56  {
57  if (event.m_Cursor[i])
58  m_Cursor.Add(event.m_Cursor[i]->Clone());
59  }
60  m_nFid = event.m_nFid;
61  }
62 
63  void SetCursor(const wxGISSpatialTreeCursor &Cursor){m_Cursor = Cursor;};
64  wxGISSpatialTreeCursor GetCursor(void) const {return m_Cursor;};
65  long GetFID(void) const {return m_nFid;};
66 
67  virtual wxEvent *Clone() const { return new wxFeatureDSEvent(*this); }
68 
69 protected:
70  wxGISSpatialTreeCursor m_Cursor;
71  long m_nFid;
72 private:
73  DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFeatureDSEvent)
74 };
75 
76 typedef void (wxEvtHandler::*wxFeatureDSEventFunction)(wxFeatureDSEvent&);
77 
78 #define wxFeatureDSEventHandler(func) \
79  wxEVENT_HANDLER_CAST(wxFeatureDSEventFunction, func)
80 
81 #define EVT_DS_FEATURES_ADDED(func) wx__DECLARE_EVT0(wxDS_FEATURES_ADDED, wxFeatureDSEventHandler(func))
82 #define EVT_DS_FEATURE_ADDED(func) wx__DECLARE_EVT0(wxDS_FEATURE_ADDED, wxFeatureDSEventHandler(func))
83 #define EVT_DS_FEATURE_DELETED(func) wx__DECLARE_EVT0(wxDS_FEATURE_DELETED, wxFeatureDSEventHandler(func))
84 #define EVT_DS_FEATURE_CHANGED(func) wx__DECLARE_EVT0(wxDS_FEATURE_CHANGED, wxFeatureDSEventHandler(func))
85 #define EVT_DS_CLOSED(func) wx__DECLARE_EVT0(wxDS_CLOSED, wxFeatureDSEventHandler(func))
86 #define EVT_DS_CHANGED(func) wx__DECLARE_EVT0(wxDS_CHANGED, wxFeatureDSEventHandler(func))
87 
88 
89 WXDLLIMPEXP_GIS_DS void IncreaseEnvelope(OGREnvelope &Env, double dSize);
90 WXDLLIMPEXP_GIS_DS void SetEnvelopeRatio(OGREnvelope &Env, double dRatio);
91 WXDLLIMPEXP_GIS_DS void MoveEnvelope(OGREnvelope &MoveEnv, const OGREnvelope &Env);
92 
99 WXDLLIMPEXP_GIS_DS wxGISGeometry EnvelopeToGeometry(const OGREnvelope &Env, const wxGISSpatialReference &SpaRef = wxNullSpatialReference);
The FeatureDS class event.
Definition: vectorop.h:40
Definition: gdalinh.h:333
Definition: gdalinh.h:57