1 /* WMGlobe 1.3 - All the Earth on a WMaker Icon 2 * copyright (C) 1998,99,2000,01 Jerome Dumonteil <jerome.dumonteil@linuxfr.org> 3 * 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. 8 * 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. 13 * 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 ***************************************************************************/ 20 21 22 #ifndef WMG_HEADER_H 23 #define WMG_HEADER_H 24 25 /* customization : see wmgoption.h */ 26 27 #include <stdlib.h> 28 #include <stdio.h> 29 #include <string.h> 30 #include <unistd.h> 31 #include <fcntl.h> 32 #include <math.h> 33 #include <limits.h> 34 #include <ctype.h> /*toupper */ 35 #include <stdarg.h> 36 #include <time.h> 37 #include <sys/time.h> 38 #include <sys/types.h> 39 #include <X11/Xlib.h> 40 #include <X11/xpm.h> 41 #include <X11/Xutil.h> 42 #include <X11/extensions/shape.h> 43 #include <assert.h> 44 #include <X11/Xatom.h> 45 #include <locale.h> 46 47 #include "wraster.h" 48 49 #include "wmgoption.h" 50 51 #define FALSE 0 52 #define TRUE 1 53 #define STRONG 2 54 #define MAX(x, y) ((x) < (y) ? (y) : (x)) 55 #define MIN(x, y) ((x) > (y) ? (y) : (x)) 56 #define ABS(a) ((a) < 0 ? -(a) : (a)) 57 58 #define PTFIXED 1 59 #define PTSUN 2 60 #define PTRANDOM 3 61 #define PTMOON 4 62 63 #ifndef PI 64 #define PI 3.141592653 65 #endif 66 67 /* 68 * wmglobe 69 * variables globales 70 */ 71 72 /************/ 73 /* Typedefs */ 74 /************/ 75 #define MAX_MOUSE_REGION (8) 76 77 typedef struct { 78 int enable; 79 int top; 80 int bottom; 81 int left; 82 int right; 83 } MOUSE_REGION; 84 85 extern MOUSE_REGION mouse_region[MAX_MOUSE_REGION]; 86 87 typedef struct MPO { 88 int r, g, b; 89 } MPO; 90 91 extern MPO *md[4], *mn[4]; 92 93 extern double solu[DIAMETRE][DIAMETRE][3]; 94 extern int tabsolu[DIAMETRE][DIAMETRE]; 95 extern int solution; 96 97 typedef struct { 98 Pixmap pixmap; 99 Pixmap mask; 100 XpmAttributes attributes; 101 } XpmIcon; 102 103 104 extern Display *dpy; 105 106 extern char *dayfile, *nightfile, *dpy_name; 107 108 extern Pixmap pix, pixmask; 109 110 extern XEvent Event; 111 112 extern RImage *map, *small, *mapnight; 113 114 extern XpmIcon screenpos, scrdate, scrdiv, numpix, txtpix, wmg; 115 116 extern Window iconwin, win; 117 extern int onlyshape, option_iw; 118 extern GC NormalGC; 119 120 /********* rendering********/ 121 122 #if WITH_MARKERS 123 extern double marker[MAX_MARKERS][3]; 124 extern int nb_marker, sun_marker, moon_marker; 125 extern RColor sun_col, moon_col; 126 extern double moon_lat,moon_long; 127 #endif 128 129 extern double delay, time_multi; 130 /* 131 * struct timeval delta_tim, last_tim, next_tim, render_tim, base_tim, 132 * vec_tim; 133 * 134 * time_t beg_time, ini_time,t1901; 135 */ 136 extern struct timeval tlast, tnext, trend, tdelay, tini, tbase; 137 extern time_t tsunpos; 138 139 extern int sens, fun, funx, funy, oknimap, mratiox, mratioy, gotoscr; 140 141 extern int typecadre, p_type, use_nightmap, use_default_nightmap, 142 use_nmap_ini, firstTime, stoprand, do_something, iop; 143 144 extern double v_lat, v_long, old_dvlat, old_dvlong, dv_lat, dv_long; 145 extern double dlat, dlong, addlat, addlong, ratiox, ratioy, dawn; 146 147 extern double sun_lat; 148 extern double sun_long; 149 150 extern double fov; 151 extern double radius; 152 extern double proj_dist; /* distance to projection plane */ 153 154 extern double center_dist; /* distance to center of earth */ 155 156 extern double ambient_light; /* how dark is the dark side? */ 157 158 extern double light_x, light_y, light_z; /* vector of sunlight with lengt 1 */ 159 160 extern double c_coef, b_coef; 161 extern double zoom; 162 extern int radius_proj, aml; /* radius of sphere on screen */ 163 164 extern RColor noir; 165 #ifdef DEBUG 166 extern double minhz; 167 #endif 168 169 extern int stable; 170 171 /****************************************************************/ 172 /* Function Prototypes */ 173 /****************************************************************/ 174 int main(int argc, char *argv[]); 175 176 177 void AddMouseRegion(int index, int left, int top, int right, int bottom); 178 int CheckMouseRegion(int x, int y); 179 void RedrawWindowXYWH(int x, int y, int w, int h); 180 void set_defaults(); 181 void loadxpm(Window drawable); 182 void cmdline(int argc, char *argv[]); 183 void screen_back(); 184 void rotation_terre(int x, int y, int lat_flag); 185 void zooming(int facto); 186 struct timeval diftimev(struct timeval t1, struct timeval t2); 187 struct timeval addtimev(struct timeval t1, struct timeval t2); 188 struct timeval getimev(); 189 190 191 void setZoom(double z); 192 void calcDistance(); 193 void renderFrame(); 194 void initmyconvert(); 195 int myRConvertImage(RContext * context, RImage * image, Pixmap * pixmap); 196 RContext *myRCreateContext 197 (Display * dpy, int screen_number, RContextAttributes * attribs); 198 void setTime(struct timeval t); 199 void recalc(int calme); 200 void sun_position(time_t ssue, double *lat, double *lon); 201 void moon_position(time_t ssue, double *lat, double *lon); 202 void transform_marker(int m); 203 void setViewPos(double lat, double lon); 204 int ripalpha(RImage * image); 205 RImage* 206 RScaleImage(RImage *image, unsigned new_width, unsigned new_height); 207 void 208 RReleaseImage(RImage *image); 209 210 #endif 211