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;
46
47struct SelectCtx {
48 const bool show_nav_objects;
49 const double scale;
50 const double chart_scale;
51 SelectCtx(bool s, double _scale, double _chart_scale)
52 : show_nav_objects(s), scale(_scale), chart_scale(_chart_scale) {}
53};
54
55class Select {
56public:
57 Select();
58 ~Select();
59
60 void SetSelectPixelRadius(int radius) { pixelRadius = radius; }
61
62 bool IsSelectableRoutePointValid(RoutePoint *pRoutePoint);
63 bool AddSelectableRoutePoint(float slat, float slon,
64 RoutePoint *pRoutePointAdd);
65 bool AddSelectableRouteSegment(float slat1, float slon1, float slat2,
66 float slon2, RoutePoint *pRoutePointAdd1,
67 RoutePoint *pRoutePointAdd2, Route *pRoute);
68
69 bool AddSelectableTrackSegment(float slat1, float slon1, float slat2,
70 float slon2, TrackPoint *pTrackPointAdd1,
71 TrackPoint *pTrackPointAdd2, Track *pTrack);
72
73 SelectItem *FindSelection(SelectCtx &ctx, float slat, float slon,
74 int fseltype);
75 SelectableItemList FindSelectionList(SelectCtx &ctx, float slat, float slon,
76 int fseltype);
77
78 bool DeleteAllSelectableRouteSegments(Route *);
79 bool DeleteAllSelectableTrackSegments(Track *);
80 bool DeleteAllSelectableRoutePoints(Route *);
81 bool AddAllSelectableRouteSegments(Route *pr);
82 bool AddAllSelectableTrackSegments(Track *pr);
83 bool AddAllSelectableRoutePoints(Route *pr);
84 bool UpdateSelectableRouteSegments(RoutePoint *prp);
85 bool DeletePointSelectableTrackSegments(TrackPoint *pt);
86 bool IsSegmentSelected(float a, float b, float c, float d, float slat,
87 float slon);
88 bool IsSelectableSegmentSelected(SelectCtx &ctx, float slat, float slon,
89 SelectItem *pFindSel);
90
91 // Generic Point Support
92 // e.g. Tides/Currents and AIS Targets
93 SelectItem *AddSelectablePoint(float slat, float slon, const void *data,
94 int fseltype);
95 bool DeleteAllPoints(void);
96 bool DeleteSelectablePoint(void *data, int SeltypeToDelete);
97 bool ModifySelectablePoint(float slat, float slon, void *data, int fseltype);
98
99 // Delete all selectable points in list by type
100 bool DeleteAllSelectableTypePoints(int SeltypeToDelete);
101
102 bool DeleteSelectableRoutePoint(RoutePoint *prp);
103
104 // Accessors
105
106 SelectableItemList *GetSelectList() { return pSelectList; }
107
108private:
109 // FIXME (leamas?) this is not model stuff.
110 void CalcSelectRadius(SelectCtx &ctx);
111
112 SelectableItemList *pSelectList;
113 int pixelRadius;
114 float selectRadius;
115};
116
117#endif // _SELECT_H__
Definition route.h:75
Represents a single point in a track.
Definition track.h:52
Represents a track, which is a series of connected track points.
Definition track.h:78