1 // $Id: xxMap.hh 3636 2010-04-06 23:59:23Z flaterco $
2 
3 /*  xxMap   Location chooser using Cylindrical Equidistant projection.
4 
5     There is some duplicated code between xxGlobe and xxMap.  However,
6     they are sufficiently different that I think complete
7     encapsulation is the cleanest approach.  -- DWF
8 
9     Copyright (C) 2002  David Flater.
10 
11     This program is free software: you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
15 
16     This program is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19     GNU General Public License for more details.
20 
21     You should have received a copy of the GNU General Public License
22     along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 class xxMap: public xxWindow {
26 public:
27   xxMap (const xxWidget &shell);
28   ~xxMap ();
29 
30   void listAll();
31   void zoomOut();
32   void keyboard (KeySym key);
33   void mouseMove (const XMotionEvent *xme);
34   void mouseButton (const XButtonEvent *xbe);
35   void globalRedraw();
36 
37 protected:
38   Pixmap mapPixmap;
39   Pixmap topPixmap;
40   const StationIndex &stationIndex;
41   std::auto_ptr<xxWidget> picture, dismissButton, listAllButton, helpButton,
42                           zoomOutButton, latitudeLabel, longitudeLabel,
43                           roundButton;
44   std::auto_ptr<xxLocationList> locationList;
45   int xBlast, yBlast, xLast, yLast;
46   unsigned zoomLevel;
47   bool blastFlag, redrawZeroLevel;
48   Dimension internalHeight, internalWidth;
49   double centerLongitude;
50   Coordinates currentPosition; // from GPS
51 
52   static const unsigned maxZoomLevel = 8U;
53 
54   struct Bounds {
55     double slat;
56     double nlat;
57     double wlon;
58     double elon;
59   };
60 
61   // For reasons known only to Jan, when you zoom out, it remembers
62   // where you were when you zoomed in and goes back there instead of
63   // zooming out from the present position.
64   Bounds bounds[maxZoomLevel + 1];
65 
66   // Returns true if coordinates are in the window or close to it.
67   const bool translateCoordinates (const Coordinates &coordinates,
68 				   int &x_out,
69 				   int &y_out);
70   const bool translateCoordinates (double lat,
71 				   double lng,
72 				   int &x_out,
73 				   int &y_out);
74 
75   void untranslateCoordinates (double &lat_out,
76                                double &lng_out,
77                                int x,
78                                int y);
79 
80   void updatePosition (int x, int y);
81   void blast (int x, int y);
82   void redrawMap ();
83   void drawCurrentPosition ();
84   void zoomBounds (const double lat, const double lon);
85 };
86 
87 // Cleanup2006 Done
88