File: map.h

package info (click to toggle)
xtide 2.6.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,996 kB
  • ctags: 2,617
  • sloc: cpp: 26,266; ansic: 8,105; makefile: 152; yacc: 113; sh: 54; lex: 54
file content (163 lines) | stat: -rw-r--r-- 4,119 bytes parent folder | download | duplicates (2)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* $Id: map.h,v 1.3 2003/07/02 20:05:45 flaterco Exp $ */

/*  Map class definition.  */

/*****************************************************************************\

    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., 675 Mass Ave, Cambridge, MA 02139, USA.

\*****************************************************************************/


#ifndef MAP_H
#define MAP_H

/* RWL the following ifdef removes a templates error when compiling with MSVC (Known bug) */

#ifdef WIN32
#include <math.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <qapplication.h>
#include <qevent.h>
#include <qpainter.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qstatusbar.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qmessagebox.h>
#include <qtooltip.h>
#include <qrect.h>
#include <qpoint.h>
#include <qcolordialog.h>
#include <qfiledialog.h>
#include <qcursor.h>
#include <qimage.h>
#include <qstrlist.h>
#include <qintdict.h>
#include <qwhatsthis.h>
#include <qaction.h>
#include <qmainwindow.h>
#include <qrangecontrol.h>
#include <qpen.h>
#include <qpoint.h>
#include <qpixmap.h>
#include <qwidget.h>
#include <qstring.h>
#include <qpointarray.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <qlistbox.h>


#define MAX_ZOOM_LEVEL   5
#define MAP_X_SIZE       1000
#define MAP_Y_SIZE       500
#define MAP_LEFT         0
#define MAP_UP           1
#define MAP_RIGHT        2
#define MAP_DOWN         3
#define BORDER           5


class QMouseEvent;
class QResizeEvent;
class QPaintEvent;


class Map:public QWidget
{
    Q_OBJECT 


  public:

    Map (QWidget * parent = 0, const char *name = 0);

    void setPenColor (const QColor & c)
    {
        pen.setColor (c);
    }

    QColor penColor ()
    {
        return pen.color ();
    }

    void setZoomLevel (int level);
    void setExtents (int zoom, double slat, double nlat, double wlon, 
                     double elon);
    int getExtents (double *slat, double *nlat, double *wlon, double *elon,
                    double *full_slat, double *full_nlat, double *full_wlon,
                    double *full_elon);
    void setRedrawZeroLevel ();
    void moveMap (int direction);
    void moveMap (double center_lat, double center_lon);
    void redrawMap ();
    void clearScreen ();
    void drawLine (int x1, int y1, int x2, int y2);
    void drawCircle (int x, int y, int h, int w, int r, QColor color);
    void drawRectangle (int x, int y, int h, int w);
    int translateCoordinates (double lat, double lon, int *x, int *y);
    void untranslateCoordinates (double *lat, double *lon, int x, int y);


  signals:

    void leftMouseSignal (QMouseEvent *e);
    void midMouseSignal (QMouseEvent * e);
    void rightMouseSignal (QMouseEvent * e);
    void moveMouseSignal (QMouseEvent * e);
    void redrawSignal ();


  protected:

    void mousePressEvent (QMouseEvent * e);
    void mouseReleaseEvent (QMouseEvent * e);
    void mouseMoveEvent (QMouseEvent * e);
    void resizeEvent (QResizeEvent * e);
    void paintEvent (QPaintEvent * e);

    QPen pen;
    QPointArray polyline;

    QPixmap buffer, savemap;


    typedef struct
    {
        double slat;
        double nlat;
        double wlon;
        double elon;
    }
    BOUNDS;

    BOUNDS bounds[MAX_ZOOM_LEVEL + 1];

    double center_longitude, range, move_inc;
    int zoom_level, redraw_zero_level;
    int border;
    int last_x, last_y;
    int draw_width, draw_height;
};

#endif