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 "SelectItem.h" 28 29 #define SELTYPE_UNKNOWN 0x0001 30 #define SELTYPE_ROUTEPOINT 0x0002 31 #define SELTYPE_ROUTESEGMENT 0x0004 32 #define SELTYPE_TIDEPOINT 0x0008 33 #define SELTYPE_CURRENTPOINT 0x0010 34 #define SELTYPE_ROUTECREATE 0x0020 35 #define SELTYPE_AISTARGET 0x0040 36 #define SELTYPE_MARKPOINT 0x0080 37 #define SELTYPE_TRACKSEGMENT 0x0100 38 #define SELTYPE_DRAGHANDLE 0x0200 39 40 class TrackPoint; 41 class Track; 42 class Route; 43 class RoutePoint; 44 class ChartCanvas; 45 46 class Select 47 { 48 public: 49 Select(); 50 ~Select(); 51 SetSelectPixelRadius(int radius)52 void SetSelectPixelRadius(int radius){ pixelRadius = radius; } 53 54 bool IsSelectableRoutePointValid(RoutePoint *pRoutePoint ); 55 bool AddSelectableRoutePoint( float slat, float slon, RoutePoint *pRoutePointAdd ); 56 bool AddSelectableRouteSegment( float slat1, float slon1, float slat2, float slon2, 57 RoutePoint *pRoutePointAdd1, RoutePoint *pRoutePointAdd2, Route *pRoute ); 58 59 bool AddSelectableTrackSegment( float slat1, float slon1, float slat2, float slon2, 60 TrackPoint *pTrackPointAdd1, TrackPoint *pTrackPointAdd2, Track *pTrack ); 61 62 SelectItem *FindSelection( ChartCanvas *cc, float slat, float slon, int fseltype ); 63 SelectableItemList FindSelectionList( ChartCanvas *cc, float slat, float slon, int fseltype ); 64 65 bool DeleteAllSelectableRouteSegments( Route * ); 66 bool DeleteAllSelectableTrackSegments( Track * ); 67 bool DeleteAllSelectableRoutePoints( Route * ); 68 bool AddAllSelectableRouteSegments( Route *pr ); 69 bool AddAllSelectableTrackSegments( Track *pr ); 70 bool AddAllSelectableRoutePoints( Route *pr ); 71 bool UpdateSelectableRouteSegments( RoutePoint *prp ); 72 bool DeletePointSelectableTrackSegments( TrackPoint *pt ); 73 bool IsSegmentSelected( float a, float b, float c, float d, float slat, float slon ); 74 bool IsSelectableSegmentSelected( ChartCanvas *cc, float slat, float slon, SelectItem *pFindSel ); 75 76 // Generic Point Support 77 // e.g. Tides/Currents and AIS Targets 78 SelectItem *AddSelectablePoint(float slat, float slon, const void *data, int fseltype); 79 bool DeleteAllPoints( void ); 80 bool DeleteSelectablePoint( void *data, int SeltypeToDelete ); 81 bool ModifySelectablePoint( float slat, float slon, void *data, int fseltype ); 82 83 // Delete all selectable points in list by type 84 bool DeleteAllSelectableTypePoints( int SeltypeToDelete ); 85 86 bool DeleteSelectableRoutePoint( RoutePoint *prp ); 87 88 // Accessors 89 GetSelectList()90 SelectableItemList *GetSelectList() 91 { 92 return pSelectList; 93 } 94 95 private: 96 void CalcSelectRadius(ChartCanvas *cc); 97 98 SelectableItemList *pSelectList; 99 int pixelRadius; 100 float selectRadius; 101 }; 102 103 #endif 104