File: NavObjectCollection.h

package info (click to toggle)
opencpn 5.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 101,540 kB
  • sloc: ansic: 414,598; cpp: 253,008; xml: 83,748; sh: 409; python: 353; makefile: 110; javascript: 87; perl: 83
file content (144 lines) | stat: -rw-r--r-- 6,011 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/******************************************************************************
 *
 * Project:  OpenCPN
 *
 ***************************************************************************
 *   Copyright (C) 2010 by David S. Register                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,  USA.         *
 ***************************************************************************
 */

#ifndef __NAVOBJECTCOLLECTION_H__
#define __NAVOBJECTCOLLECTION_H__

#include "pugixml.hpp"
#include <wx/string.h>
#include <wx/checkbox.h>
#include "bbox.h"

class Track;
class TrackList;
class TrackPoint;
class RouteList;
class RoutePointList;
class Route;
class RoutePoint;

//      Bitfield definition controlling the GPX nodes output for point objects
#define         OUT_TYPE        1 << 1          //  Output point type
#define         OUT_TIME        1 << 2          //  Output time as ISO string
#define         OUT_NAME        1 << 3          //  Output point name if defined
#define         OUT_NAME_FORCE  1 << 4          //  Output point name, even if empty
#define         OUT_DESC        1 << 5          //  Output description if defined
#define         OUT_DESC_FORCE  1 << 6          //  Output description, even if empty
#define         OUT_SYM_FORCE   1 << 7          //  Output symbol name, using "empty" if undefined
#define         OUT_GUID        1 << 8          //  Output GUID if defined
#define         OUT_VIZ         1 << 9          //  Output point viz, if non-zero(true)
#define         OUT_VIZ_NAME    1 << 10         //  Output point name viz, if non-zero(true)
#define         OUT_SHARED      1 << 11         //  Output point shared state, if non-zero(true)
#define         OUT_AUTO_NAME   1 << 12         //  Output point auto_name state, if non-zero(true)
#define         OUT_HYPERLINKS  1 << 13         //  Output point Hyperlinks, if present
#define         OUT_ACTION_ADD  1 << 14         //  opencpn:action node support
#define         OUT_ACTION_DEL  1 << 15
#define         OUT_ACTION_UPD  1 << 16
#define         OUT_EXTENSION   1 << 17
#define         OUT_ARRIVAL_RADIUS 1 << 18
#define         OUT_WAYPOINT_RANGE_RINGS 1 << 19
#define         OUT_WAYPOINT_SCALE 1 << 20
#define         OUT_TIDE_STATION 1 << 21
#define         OUT_RTE_PROPERTIES 1 << 22

#define  OPT_TRACKPT    OUT_TIME
#define  OPT_WPT        (OUT_TYPE) +\
                        (OUT_TIME) +\
                        (OUT_NAME) +\
                        (OUT_DESC) +\
                        (OUT_SYM_FORCE) +\
                        (OUT_GUID) +\
                        (OUT_VIZ) +\
                        (OUT_VIZ_NAME) +\
                        (OUT_SHARED) +\
                        (OUT_AUTO_NAME) +\
                        (OUT_HYPERLINKS) +\
                        (OUT_ARRIVAL_RADIUS) +\
                        (OUT_WAYPOINT_RANGE_RINGS) +\
                        (OUT_WAYPOINT_SCALE) +\
                        (OUT_TIDE_STATION)
#define OPT_ROUTEPT     OPT_WPT +\
                        (OUT_RTE_PROPERTIES)

//      Bitfield definitions controlling the GPX nodes output for Route.Track objects
#define         RT_OUT_ACTION_ADD         1 << 1          //  opencpn:action node support
#define         RT_OUT_ACTION_DEL         1 << 2
#define         RT_OUT_ACTION_UPD         1 << 3
#define         RT_OUT_NO_RTPTS           1 << 4


class NavObjectCollection1 : public pugi::xml_document
{
public:
    NavObjectCollection1();
    ~NavObjectCollection1();
    
    bool CreateNavObjGPXPoints(void);
    bool CreateNavObjGPXRoutes(void);
    bool CreateNavObjGPXTracks(void);
 
    void AddGPXRoutesList( RouteList *pRoutes );
    void AddGPXTracksList( TrackList *pTracks );
    bool AddGPXPointsList( RoutePointList *pRoutePoints );
    bool AddGPXRoute(Route *pRoute);
    bool AddGPXTrack(Track *pTrk);
    bool AddGPXWaypoint(RoutePoint *pWP );
    
    bool CreateAllGPXObjects();
    bool LoadAllGPXObjects( bool b_full_viz, int &wpt_duplicates, bool b_compute_bbox = false);
    int LoadAllGPXObjectsAsLayer(int layer_id, bool b_layerviz, wxCheckBoxState b_namesviz);
    
    bool SaveFile( const wxString filename );

    void SetRootGPXNode(void);
    bool IsOpenCPN();
    LLBBox &GetBBox( ) { return BBox;};
    
    LLBBox     BBox;
    pugi::xml_node      m_gpx_root;
};


class NavObjectChanges : public NavObjectCollection1
{
public:
    NavObjectChanges();
    NavObjectChanges( wxString file_name );
    ~NavObjectChanges();
    
    void AddRoute( Route *pr, const char *action );           // support "changes" file set
    void AddTrack( Track *pr, const char *action );
    void AddWP( RoutePoint *pr, const char *action );
    void AddTrackPoint( TrackPoint *pWP, const char *action, const wxString& parent_GUID );
    
    bool ApplyChanges(void);
    
    wxString    m_filename;
    FILE *      m_changes_file;
    bool        m_bdirty;
 
};


#endif