Mapper
move_area.c
Go to the documentation of this file.
1 
2 
3 #include "prototypes.h"
4 
5 void move_area(int win_x,int win_y,int qpf_flag)
6 
7 {
8 extern struct save save;
9 extern int spoint[2];
10 extern int npoint[2],zoom;
11 extern struct display_set display_set[4];
12 extern Display *display;
13 extern Window window;
14 extern GC gc;
15 extern int qmap[16];
16 extern struct abogus *bbogus[50];
17 extern Widget drawing_area;
18 Arg args[10];
19 int i,ox[3],oy[3],closed;
20 int x,y,firstx,firsty;
21 int MY=10;
22 Dimension width,height;
23 signed long XSIZE,YSIZE;
24 float xrat,yrat;
26 long lint1,lint2;
27 float dmult,cmult,mult;
28 struct abogus *cbogus;
29 struct abogus *nbogus;
30 struct abogus *pbogus;
31 struct abogus *xbogus;
32 struct abogus *zbogus;
33 
34 cbogus=bbogus[qpf_flag];
35 
36 closed=0;
37 
38 if(cbogus !=NULL){
39 
40  firstx=cbogus->x;
41  firsty=cbogus->y;
42 
43  for(;;) {
44 
45  if(cbogus->next==NULL) {
46 
47  if(firstx==cbogus->x &&
48  firsty==cbogus->y)
49  closed=1;
50  break;
51 
52  }
53 
54  xbogus=cbogus;
55  cbogus=cbogus->next;
56 
57  }
58 
59  }
60 
61 zbogus=cbogus;
62 
63 XSetFunction(display,gc,GXxor);
64 XSetForeground(display,gc,qmap[15]);
65 XSetBackground(display,gc,0);
66 
67 XtSetArg(args[0],XtNwidth,&width);
68 XtSetArg(args[1],XtNheight,&height);
69 XtGetValues(drawing_area,args,2);
70 
71 XSIZE=(long)width*10L;
72 YSIZE=(long)height*10L;
73 
74 xrat=(float)XSIZE/(float)12800;
75 yrat=(float)YSIZE/(float)9600;
76 
77 if(xrat < yrat)
78  mult=xrat;
79 
80 else
81  mult=yrat;
82 
83 display_flag=0;
84 h=0;
85 
93 
94 lint1=(long)npoint[0]*(long)MY;
95 lint2=(long)npoint[1]*(long)MY;
96 
98 
99 x=win_x;
100 y=win_y;
101 
102 if(zoom==1) {
103 
104  win_x=x*MY/mult;
105  win_y=y*MY/mult;
106 
107  }
108 
109 else {
110 
111 
112  win_x=((x*MY-xcen)/zoom + lint1)/mult;
113  win_y=((y*MY-ycen)/zoom + lint2)/mult;
114 
115  }
116 
117 /* first draw current area */
118 
119 cbogus=bbogus[qpf_flag];
120 
121 pbogus=NULL;
122 
123 if(cbogus !=NULL){
124 
125  for(;;) {
126 
127  if(cbogus->x == spoint[0] && cbogus->y==spoint[1])
128  break;
129 
130  if(cbogus->next==NULL)
131  return;
132 
133  pbogus=cbogus;
134  cbogus=cbogus->next;
135 
136  }
137 
138  }
139 
140 nbogus=cbogus->next;
141 
142 cbogus->x=win_x;
143 cbogus->y=win_y;
144 
145 if(pbogus==NULL && closed==1) {
146 
147 /*xbogus is the next to last point */
148 
149  pbogus=xbogus;
150 
151 /*zbogus is the last point */
152 
153  zbogus->x=win_x;
154  zbogus->y=win_y;
155 
156  /*point chosen was first and last point */
157 
158  }
159 
160 /* need to xor old points and lines */
161 
162 if(save.inuse==1) {
163 
164 for(i=0;i<3;i++) {
165 
166  if(zoom==1) {
167 
168  ox[i]=(xmin+(float)save.x[i] * cmult)/MY;
169  oy[i]=(xmin+(float)save.y[i] * cmult)/MY;
170 
171  }
172 
173  else {
174 
175  ox[i]=(((xmin+save.x[i]*cmult)-lint1)*zoom+xcen)/MY;
176  oy[i]=(((ymin+save.y[i]*cmult)-lint2)*zoom+ycen)/MY;
177 
178 
179  }
180 
181  if(i==1 && pbogus==NULL)
182  continue;
183 
184  if(i==2 && nbogus==NULL)
185  continue;
186 
187  if(i >= 1) {
188 
189  XDrawLine(display,window,gc,ox[i],oy[i],ox[i-1],oy[i-1]);
190 
191  }
192 
193 /* next Xor new points on to screen and pixmap */
194  }
195 
196 XDrawLine(display,window,gc,ox[1]-10,oy[1],ox[1]+10,oy[1]);
197 XDrawLine(display,window,gc,ox[1],oy[1]-10,ox[1],oy[1]+10);
198 
199 }
200 
201 if(pbogus!=NULL) {
202  save.x[0]=pbogus->x;
203  save.y[0]=pbogus->y;
204  }
205 
206 save.x[1]=cbogus->x;
207 save.y[1]=cbogus->y;
208 
209 if(nbogus != NULL) {
210  save.x[2]=nbogus->x;
211  save.y[2]=nbogus->y;
212  }
213 
214 
215 for(i=0;i<3;i++) {
216 
217  if(zoom==1) {
218 
219  ox[i]=(xmin+(float)save.x[i] * cmult)/MY;
220  oy[i]=(ymin+(float)save.y[i] * cmult)/MY;
221 
222  }
223 
224  else {
225 
226  ox[i]=(((xmin+save.x[i]*cmult)-lint1)*zoom+xcen)/MY;
227  oy[i]=(((ymin+save.y[i]*cmult)-lint2)*zoom+ycen)/MY;
228 
229 
230  }
231 
232 
233  if(i==1 && pbogus==NULL)
234  continue;
235 
236  if(i==2 && nbogus==NULL)
237  continue;
238 
239 
240  if(i >= 1) {
241 
242  XDrawLine(display,window,gc,ox[i],oy[i],ox[i-1],oy[i-1]);
243 
244  }
245 
246 }
247 
248 XDrawLine(display,window,gc,ox[1]-10,oy[1],ox[1]+10,oy[1]);
249 XDrawLine(display,window,gc,ox[1],oy[1]-10,ox[1],oy[1]+10);
250 
251 spoint[0]=cbogus->x;
252 spoint[1]=cbogus->y;
253 save.inuse=1;
254 
255 }
static int i
Display * display
Definition: mapper.c:159
float mult
Definition: edit_stations.c:6
int spoint[2]
Definition: mapper.c:70
unsigned long qmap[16]
Definition: mapper.c:116
Window window
Definition: mapper.c:190
int display_flag
Definition: mapper.c:100
void move_area(int win_x, int win_y, int qpf_flag)
Definition: move_area.c:5
float xrat
long xmax
float yrat
long ymax
long lint1
GC gc
Definition: mapper.c:163
float cmult
signed long xcen
Dimension height
signed long ycen
Dimension width
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
float dmult
Widget drawing_area
Definition: mapper.c:185
int npoint[2]
Definition: mapper.c:105
long ymin
unsigned long YSIZE
Definition: misc.h:330
short int x
Definition: misc.h:332
short int y
Definition: misc.h:333
struct abogus * next
Definition: misc.h:334
float dmult[4]
Definition: misc.h:613
long xmin[4]
Definition: misc.h:607
long xmax[4]
Definition: misc.h:609
long ymax[4]
Definition: misc.h:610
long ymin[4]
Definition: misc.h:608
long ycen[4]
Definition: misc.h:612
long xcen[4]
Definition: misc.h:611
Definition: misc.h:322
short int y[3]
Definition: misc.h:326
short int x[3]
Definition: misc.h:325
short int inuse
Definition: misc.h:324