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