OpenCPN Partial API docs
Loading...
Searching...
No Matches
select.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2013 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#ifndef _SELECT_H__
25#define _SELECT_H__
26
27#include "select_item.h"
28
29#include "model/track.h"
30#include "model/route.h"
31
32#define SELTYPE_UNKNOWN 0x0001
33#define SELTYPE_ROUTEPOINT 0x0002
34#define SELTYPE_ROUTESEGMENT 0x0004
35#define SELTYPE_TIDEPOINT 0x0008
36#define SELTYPE_CURRENTPOINT 0x0010
37#define SELTYPE_ROUTECREATE 0x0020
38#define SELTYPE_AISTARGET 0x0040
39#define SELTYPE_MARKPOINT 0x0080
40#define SELTYPE_TRACKSEGMENT 0x0100
41#define SELTYPE_DRAGHANDLE 0x0200
42
43class Select; // forward
44
45extern Select *pSelect;
46extern Select *pSelectTC;
47
48struct SelectCtx {
49 const bool show_nav_objects;
50 const double scale;
51 const double chart_scale;
52 SelectCtx(bool s, double _scale, double _chart_scale)
53 : show_nav_objects(s), scale(_scale), chart_scale(_chart_scale) {}
54};
55
56class Select {
57public:
58 Select();
59 ~Select();
60
61 void SetSelectPixelRadius(int radius) { pixelRadius = radius; }
62
63 bool IsSelectableRoutePointValid(RoutePoint *pRoutePoint);
64 bool AddSelectableRoutePoint(float slat, float slon,
65 RoutePoint *pRoutePointAdd);
66 bool AddSelectableRouteSegment(float slat1, float slon1, float slat2,
67 float slon2, RoutePoint *pRoutePointAdd1,
68 RoutePoint *pRoutePointAdd2, Route *pRoute);
69
70 bool AddSelectableTrackSegment(float slat1, float slon1, float slat2,
71 float slon2, TrackPoint *pTrackPointAdd1,
72 TrackPoint *pTrackPointAdd2, Track *pTrack);
73
74 SelectItem *FindSelection(SelectCtx &ctx, float slat, float slon,
75 int fseltype);
76 SelectableItemList FindSelectionList(SelectCtx &ctx, float slat, float slon,
77 int fseltype);
78
79 bool DeleteAllSelectableRouteSegments(Route *);
80 bool DeleteAllSelectableTrackSegments(Track *);
81 bool DeleteAllSelectableRoutePoints(Route *);
82 bool AddAllSelectableRouteSegments(Route *pr);
83 bool AddAllSelectableTrackSegments(Track *pr);
84 bool AddAllSelectableRoutePoints(Route *pr);
85 bool UpdateSelectableRouteSegments(RoutePoint *prp);
86 bool DeletePointSelectableTrackSegments(TrackPoint *pt);
87 bool IsSegmentSelected(float a, float b, float c, float d, float slat,
88 float slon);
89 bool IsSelectableSegmentSelected(SelectCtx &ctx, float slat, float slon,
90 SelectItem *pFindSel);
91
92 // Generic Point Support
93 // e.g. Tides/Currents and AIS Targets
94 SelectItem *AddSelectablePoint(float slat, float slon, const void *data,
95 int fseltype);
96 bool DeleteAllPoints(void);
97 bool DeleteSelectablePoint(void *data, int SeltypeToDelete);
98 bool ModifySelectablePoint(float slat, float slon, void *data, int fseltype);
99
100 // Delete all selectable points in list by type
101 bool DeleteAllSelectableTypePoints(int SeltypeToDelete);
102
103 bool DeleteSelectableRoutePoint(RoutePoint *prp);
104
105 // Accessors
106
107 SelectableItemList *GetSelectList() { return pSelectList; }
108
109private:
110 // FIXME (leamas?) this is not model stuff.
111 void CalcSelectRadius(SelectCtx &ctx);
112
113 SelectableItemList *pSelectList;
114 int pixelRadius;
115 float selectRadius;
116};
117
118#endif // _SELECT_H__
Represents a waypoint or mark within the navigation system.
Definition route_point.h:70
Represents a navigational route in the navigation system.
Definition route.h:98
Represents a single point in a track.
Definition track.h:56
Represents a track, which is a series of connected track points.
Definition track.h:114