OpenCPN Partial API docs
Loading...
Searching...
No Matches
nav_object_database.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2010 by David S. Register *
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, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 ***************************************************************************
23 */
24
25#ifndef _NAVOBJECTCOLLECTION_H__
26#define _NAVOBJECTCOLLECTION_H__
27
28#include <memory>
29#include <vector>
30
31#include <wx/checkbox.h>
32#include <wx/string.h>
33
34#include "pugixml.hpp"
35#include "bbox.h"
36#include "observable_evtvar.h"
37
38class Track;
39class TrackPoint;
40class RouteList;
41class RoutePointList;
42class Route;
43class RoutePoint;
44
45// Bitfield definition controlling the GPX nodes output for point objects
46#define OUT_TYPE 1 << 1 // Output point type
47#define OUT_TIME 1 << 2 // Output time as ISO string
48#define OUT_NAME 1 << 3 // Output point name if defined
49#define OUT_NAME_FORCE 1 << 4 // Output point name, even if empty
50#define OUT_DESC 1 << 5 // Output description if defined
51#define OUT_DESC_FORCE 1 << 6 // Output description, even if empty
52#define OUT_SYM_FORCE 1 << 7 // Output symbol name, using "empty" if undefined
53#define OUT_GUID 1 << 8 // Output GUID if defined
54#define OUT_VIZ 1 << 9 // Output point viz, if non-zero(true)
55#define OUT_VIZ_NAME 1 << 10 // Output point name viz, if non-zero(true)
56#define OUT_SHARED 1 << 11 // Output point shared state, if non-zero(true)
57#define OUT_AUTO_NAME \
58 1 << 12 // Output point auto_name state, if non-zero(true)
59#define OUT_HYPERLINKS 1 << 13 // Output point Hyperlinks, if present
60#define OUT_ACTION_ADD 1 << 14 // opencpn:action node support
61#define OUT_ACTION_DEL 1 << 15
62#define OUT_ACTION_UPD 1 << 16
63#define OUT_EXTENSION 1 << 17
64#define OUT_ARRIVAL_RADIUS 1 << 18
65#define OUT_WAYPOINT_RANGE_RINGS 1 << 19
66#define OUT_WAYPOINT_SCALE 1 << 20
67#define OUT_TIDE_STATION 1 << 21
68#define OUT_RTE_PROPERTIES 1 << 22
69
70#define OPT_TRACKPT OUT_TIME
71#define OPT_WPT \
72 (OUT_TYPE) + (OUT_TIME) + (OUT_NAME) + (OUT_DESC) + (OUT_SYM_FORCE) + \
73 (OUT_GUID) + (OUT_VIZ) + (OUT_VIZ_NAME) + (OUT_SHARED) + \
74 (OUT_AUTO_NAME) + (OUT_HYPERLINKS) + (OUT_ARRIVAL_RADIUS) + \
75 (OUT_WAYPOINT_RANGE_RINGS) + (OUT_WAYPOINT_SCALE) + (OUT_TIDE_STATION)
76#define OPT_ROUTEPT OPT_WPT + (OUT_RTE_PROPERTIES)
77
78// Bitfield definitions controlling the GPX nodes output for Route.Track
79// objects
80#define RT_OUT_ACTION_ADD 1 << 1 // opencpn:action node support
81#define RT_OUT_ACTION_DEL 1 << 2
82#define RT_OUT_ACTION_UPD 1 << 3
83#define RT_OUT_NO_RTPTS 1 << 4
84
85
86bool WptIsInRouteList(RoutePoint *pr);
87RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
88RoutePoint *WaypointExists(const wxString &guid);
89Route *RouteExists(const wxString &guid);
90Route *RouteExists(Route *pTentRoute);
91Track *TrackExists(const wxString &guid);
92
93Route *FindRouteContainingWaypoint(RoutePoint *pWP);
94
95class NavObjectCollection1 : public pugi::xml_document {
96public:
98 virtual ~NavObjectCollection1();
99
100 bool CreateNavObjGPXPoints(void);
101 bool CreateNavObjGPXRoutes(void);
102 bool CreateNavObjGPXTracks(void);
103
104 void AddGPXRoutesList(RouteList *pRoutes);
105 void AddGPXTracksList(std::vector<Track*> *pTracks);
106 bool AddGPXPointsList(RoutePointList *pRoutePoints);
107 bool AddGPXRoute(Route *pRoute);
108 bool AddGPXTrack(Track *pTrk);
109 bool AddGPXWaypoint(RoutePoint *pWP);
110
111 bool CreateAllGPXObjects();
112 bool LoadAllGPXObjects(bool b_full_viz, int &wpt_duplicates,
113 bool b_compute_bbox = false);
114 int LoadAllGPXObjectsAsLayer(int layer_id, bool b_layerviz,
115 wxCheckBoxState b_namesviz);
116
117 bool SaveFile(const wxString filename);
118
119 void SetRootGPXNode(void);
120 bool IsOpenCPN();
121 LLBBox &GetBBox() { return BBox; };
122
123 LLBBox BBox;
124 bool m_bSkipChangeSetUpdate;
125};
126
128friend class MyConfig;
129
130public:
131 static std::unique_ptr<NavObjectChanges> getTempInstance() {
132 return std::unique_ptr<NavObjectChanges>(new NavObjectChanges());
133 }
134
135 static NavObjectChanges* getInstance() {
136 static NavObjectChanges* instance = 0;
137 if (!instance) instance = new NavObjectChanges();
138 return instance;
139 }
140
141 void Init(const wxString& path) {
142 m_filename = path;
143 m_changes_file = fopen(m_filename.mb_str(), "a");
144 }
145
146 NavObjectChanges(const NavObjectChanges&) = delete;
147 void operator=(const NavObjectChanges&) = delete;
149
150 void AddRoute(Route *pr, const char *action); // support "changes" file set
151 void AddTrack(Track *pr, const char *action);
152 void AddWP(RoutePoint *pr, const char *action);
153 void AddTrackPoint(TrackPoint *pWP, const char *action,
154 const wxString &parent_GUID);
155
156 virtual void AddNewRoute(Route *pr);
157 virtual void UpdateRoute(Route *pr);
158 virtual void DeleteConfigRoute(Route *pr);
159
160 virtual void AddNewTrack(Track *pt);
161 virtual void UpdateTrack(Track *pt);
162 virtual void DeleteConfigTrack(Track *pt);
163
164 virtual void AddNewWayPoint(RoutePoint *pWP, int ConfigRouteNum = -1);
165 virtual void UpdateWayPoint(RoutePoint *pWP);
166 virtual void DeleteWayPoint(RoutePoint *pWP);
167 virtual void AddNewTrackPoint(TrackPoint *pWP, const wxString &parent_GUID);
168
169 bool ApplyChanges(void);
170 bool IsDirty() { return m_bdirty; }
171
182
183
184private:
186 m_changes_file = 0;
187 m_bdirty = false;
188 }
189 NavObjectChanges(wxString file_name);
190
191 wxString m_filename;
192 FILE *m_changes_file;
193 bool m_bdirty;
194};
195
196#endif // _NAVOBJECTCOLLECTION_H__
Generic event handling between between two parties like MVC Model and Controller using a shared Event...
EventVar evt_delete_track
Notified when Routeman (?) should delete a track.
EventVar evt_delete_route
Notified when Routeman (?) should delete a Route*.
Definition: route.h:70
Definition: track.h:79