1 /* WMGlobe 1.3 - All the Earth on a WMaker Icon
2 * copyright (C) 1998,99,2000,01 Jerome Dumonteil <jerome.dumonteil@linuxfr.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 ***************************************************************************/
18 /* it uses some functions of : Xglobe, Xearth, wmgeneral, wmaker/wrlib
19 ***************************************************************************/
26 #define MY_EXTERN extern
29 /* customization : see wmgoption.h */
38 #include <ctype.h> /*toupper */
41 #include <sys/timeb.h>
43 #include <sys/types.h>
46 #include <X11/Xutil.h>
47 #include <X11/extensions/shape.h>
49 #include <X11/Xatom.h>
53 #include "wmgoption.h"
58 #define MAX(x, y) ((x) < (y) ? (y) : (x))
59 #define MIN(x, y) ((x) > (y) ? (y) : (x))
60 #define ABS(a) ((a) < 0 ? -(a) : (a))
68 #define PI 3.141592653
79 #define MAX_MOUSE_REGION (8)
89 MY_EXTERN MOUSE_REGION mouse_region
[MAX_MOUSE_REGION
];
95 MY_EXTERN MPO
*md
[4], *mn
[4];
96 MY_EXTERN
double solu
[DIAMETRE
][DIAMETRE
][3];
97 MY_EXTERN
int tabsolu
[DIAMETRE
][DIAMETRE
];
98 MY_EXTERN
int solution
;
103 XpmAttributes attributes
;
106 MY_EXTERN Display
*dpy
;
107 MY_EXTERN
char *dayfile
, *nightfile
, *dpy_name
;
108 MY_EXTERN Pixmap pix
, pixmask
;
109 MY_EXTERN XEvent Event
;
110 MY_EXTERN RImage
*map
, *small
, *mapnight
;
111 MY_EXTERN XpmIcon screenpos
, scrdate
, scrdiv
, numpix
, txtpix
, wmg
;
112 MY_EXTERN Window iconwin
, win
;
114 MY_EXTERN
int onlyshape
, option_iw
;
115 MY_EXTERN GC NormalGC
;
117 /********* rendering********/
120 MY_EXTERN
double marker
[MAX_MARKERS
][3];
121 MY_EXTERN
int nb_marker
, sun_marker
, moon_marker
;
122 MY_EXTERN RColor sun_col
, moon_col
;
123 MY_EXTERN
double moon_lat
,moon_long
;
126 MY_EXTERN
double delay
, time_multi
;
128 * struct timeval delta_tim, last_tim, next_tim, render_tim, base_tim,
131 * time_t beg_time, ini_time,t1901;
133 MY_EXTERN
struct timeval tlast
, tnext
, trend
, tdelay
, tini
, tbase
;
134 MY_EXTERN
time_t tsunpos
;
136 MY_EXTERN
int sens
, fun
, funx
, funy
, oknimap
, mratiox
, mratioy
, gotoscr
;
138 MY_EXTERN
int typecadre
, p_type
, use_nightmap
,
139 use_default_nightmap
, use_nmap_ini
, firstTime
,
140 stoprand
, do_something
, iop
;
142 MY_EXTERN
double v_lat
, v_long
, old_dvlat
, old_dvlong
, dv_lat
, dv_long
;
143 MY_EXTERN
double dlat
, dlong
, addlat
, addlong
, ratiox
, ratioy
, dawn
;
144 MY_EXTERN
double sun_lat
;
145 MY_EXTERN
double sun_long
;
146 MY_EXTERN
double fov
;
147 MY_EXTERN
double radius
;
148 MY_EXTERN
double proj_dist
; /* distance to projection plane */
149 MY_EXTERN
double center_dist
; /* distance to center of earth */
150 MY_EXTERN
double ambient_light
; /* how dark is the dark side? */
151 MY_EXTERN
double light_x
, light_y
, light_z
; /* vector of sunlight with lengt 1 */
152 MY_EXTERN
double c_coef
, b_coef
;
153 MY_EXTERN
double zoom
;
154 MY_EXTERN
int radius_proj
, aml
; /* radius of sphere on screen */
156 MY_EXTERN RColor noir
;
158 MY_EXTERN
double minhz
;
161 MY_EXTERN
int stable
;
163 /****************************************************************/
164 /* Function Prototypes */
165 /****************************************************************/
166 int main(int argc
, char *argv
[]);
168 void AddMouseRegion(unsigned index
, int left
, int top
, int right
, int bottom
);
169 int CheckMouseRegion(int x
, int y
);
170 void RedrawWindowXYWH(int x
, int y
, int w
, int h
);
172 void loadxpm(Window drawable
);
173 void cmdline(int argc
, char *argv
[]);
175 void rotation_terre(int x
, int y
, int lat_flag
);
176 void zooming(int facto
);
177 struct timeval
diftimev(struct timeval t1
, struct timeval t2
);
178 struct timeval
addtimev(struct timeval t1
, struct timeval t2
);
179 struct timeval
getimev();
181 void setZoom(double z
);
184 void initmyconvert();
185 int myRConvertImage(RContext
* context
, RImage
* image
, Pixmap
* pixmap
);
186 RContext
*myRCreateContext
187 (Display
* dpy
, int screen_number
, RContextAttributes
* attribs
);
188 void setTime(struct timeval t
);
189 void recalc(int calme
);
190 void sun_position(time_t ssue
, double *lat
, double *lon
);
191 void moon_position(time_t ssue
, double *lat
, double *lon
);
192 void transform_marker(int m
);
193 void setViewPos(double lat
, double lon
);
194 int ripalpha(RImage
* image
);
196 RScaleImage(RImage
*image
, unsigned new_width
, unsigned new_height
);
198 RReleaseImage(RImage
*image
);