File: Select.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 (103 lines) | stat: -rw-r--r-- 4,337 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
/***************************************************************************
 *
 * Project:  OpenCPN
 *
 ***************************************************************************
 *   Copyright (C) 2013 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 __SELECT_H__
#define __SELECT_H__

#include "SelectItem.h"

#define SELTYPE_UNKNOWN              0x0001
#define SELTYPE_ROUTEPOINT           0x0002
#define SELTYPE_ROUTESEGMENT         0x0004
#define SELTYPE_TIDEPOINT            0x0008
#define SELTYPE_CURRENTPOINT         0x0010
#define SELTYPE_ROUTECREATE          0x0020
#define SELTYPE_AISTARGET            0x0040
#define SELTYPE_MARKPOINT            0x0080
#define SELTYPE_TRACKSEGMENT         0x0100
#define SELTYPE_DRAGHANDLE           0x0200

class TrackPoint;
class Track;
class Route;
class RoutePoint;
class ChartCanvas;

class Select
{
public:
    Select();
    ~Select();

    void SetSelectPixelRadius(int radius){ pixelRadius = radius; }

    bool IsSelectableRoutePointValid(RoutePoint *pRoutePoint );
    bool AddSelectableRoutePoint( float slat, float slon, RoutePoint *pRoutePointAdd );
    bool AddSelectableRouteSegment( float slat1, float slon1, float slat2, float slon2,
            RoutePoint *pRoutePointAdd1, RoutePoint *pRoutePointAdd2, Route *pRoute );

    bool AddSelectableTrackSegment( float slat1, float slon1, float slat2, float slon2,
                                    TrackPoint *pTrackPointAdd1, TrackPoint *pTrackPointAdd2, Track *pTrack );

    SelectItem *FindSelection( ChartCanvas *cc, float slat, float slon, int fseltype );
    SelectableItemList FindSelectionList( ChartCanvas *cc, float slat, float slon, int fseltype );

    bool DeleteAllSelectableRouteSegments( Route * );
    bool DeleteAllSelectableTrackSegments( Track * );
    bool DeleteAllSelectableRoutePoints( Route * );
    bool AddAllSelectableRouteSegments( Route *pr );
    bool AddAllSelectableTrackSegments( Track *pr );
    bool AddAllSelectableRoutePoints( Route *pr );
    bool UpdateSelectableRouteSegments( RoutePoint *prp );
    bool DeletePointSelectableTrackSegments( TrackPoint *pt );
    bool IsSegmentSelected( float a, float b, float c, float d, float slat, float slon );
    bool IsSelectableSegmentSelected( ChartCanvas *cc, float slat, float slon, SelectItem *pFindSel );

    //    Generic Point Support
    //      e.g. Tides/Currents and AIS Targets
    SelectItem *AddSelectablePoint(float slat, float slon, const void *data, int fseltype);
    bool DeleteAllPoints( void );
    bool DeleteSelectablePoint( void *data, int SeltypeToDelete );
    bool ModifySelectablePoint( float slat, float slon, void *data, int fseltype );

    //    Delete all selectable points in list by type
    bool DeleteAllSelectableTypePoints( int SeltypeToDelete );

    bool DeleteSelectableRoutePoint( RoutePoint *prp );
    
    //  Accessors

    SelectableItemList *GetSelectList()
    {
        return pSelectList;
    }

private:
    void CalcSelectRadius(ChartCanvas *cc);

    SelectableItemList *pSelectList;
    int pixelRadius;
    float selectRadius;
};

#endif