-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGRDBASE.CPP
298 lines (283 loc) · 7.04 KB
/
GRDBASE.CPP
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* MODUL ZALEZNY OD BIBLIOTEKI GRAFICZNEJ - NIEPRZENOSNY */
#include <graphics.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <alloc.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include "pipek.hpp"
#include "patt2dat.h"
#include "grreadst.h"
extern char datname[256];
extern char inputname[256];
extern char sciezka[256];
extern char ext[10];
extern float skala;
extern float epsilonapr;
extern int gdriver , gmode, changeany,mx,my,sx,sy,maxcol,textband,bandband,text,bacg,bands,donebands,stand,patt,paper;
extern int krok; /* Wspolna dla wszystkich procedur tego modulu */
extern int Transform; /* Flaga stasowania odwrotnej Approxymacji dla "x" w opcji view */
extern pipek dbase,flip;
static char BaseName[128]="*.cut ?";
static char Description[128]="/ No data base";
extern void (*OutOfMem)(int);
void CRTOutOfMem(int);
void GROutOfMem(int);
void TITLE();
void view(int WithSize , int stand, int bands , int patt );
void opis();
void repaintdesktop();
char* GetDescription(char* BaseName,char* Description);/* stringi minimum po 80 zmakow ! */
void MakeNewDBase(char* BaseName,char* Description);
void Searchlane(char* BaseName,int l);
void laneToDBase(char* BaseName,int l);
void gr_dbase()
{
char iobuf[156];
int onefive=(mx-textband)/5;
int serX=0,serY=0,i=-1,lnum=-1;
pipek search,save,Name,NewDb,pipESC,laneNum,comm;
Name.set(textband+3 ,my-199,onefive*5-3,17,(maxcol>1?text:1),bacg);
Name.InstallText(BaseName,'\\',1);
laneNum.set(textband+3 ,my-179,onefive*2.5-3,17,(maxcol>4?stand:0),maxcol);
laneNum.InstallText("laNe ?",'n',1);
search.set(textband+3 ,my-100,onefive*5-3,17,donebands,bacg);
search.InstallText("Search in d.base",'s',1);
save.set(textband+3 ,my-40 ,onefive*3-3,17,donebands,bacg);
save.InstallText("Lane to d.base",'l',1);
NewDb.set(textband+4 ,my-20 ,onefive*3-3,17,donebands,bacg);
NewDb.InstallText("new d.bAse",'a',1);
comm.set(textband+4 ,my-60 ,onefive*5-3,17,(maxcol>1?text:1),bacg);
comm.InstallText(Description,'/',1);
pipESC.set(textband+onefive*3+6,my-40 ,onefive*2-6,35,donebands,(maxcol>1?stand:0));
pipESC.InstallText("ESC",27,1);
/* miejsce na nowe przyciski */
opis();
Interface::VisCursor();
do{
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
Interface::UnVisCursor();
Name.put();
laneNum.put();
dbase.put();
flip.put();
search.put();
comm.put();
save.put();
NewDb.put();
pipESC.put();
Interface::VisCursor();
while(!kbhit()&&(!Interface::CheckClik()))
;
if( (serX=Interface::GetMosX())<textband && Interface::GetClik()!=0)
{
if(serX<0) serX=0;/* Gdy nie ma myszy to moze byc -1 */
if(serX<bandband)
{
sprintf(iobuf,"lane:%3d",(lnum=(serX/krok+1)));
laneNum.InstallText(iobuf,'y',1);
serY=Interface::GetMosY();
Interface::SetCursor(serX,serY);
}
goto END_LOOP;
}
Interface::UnVisCursor();
/* obsluga bazy */
if(wherex()>50 || wherey()>19 )
{
changeany=0;
repaintdesktop();
}
if(laneNum.DoIt())
{
laneNum.invers();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,512,"lane: ? ",sx/2,sy,25,donebands);
if(*iobuf=='\0')
goto END_LOOP;
if((i=atoi(iobuf))<0)
i=1;/* obcinanie */
if(i==0) goto END_LOOP;
serX=(i-1)*krok+krok/2;
if(serX<bandband)
sprintf(iobuf,"lane:%3d",(lnum=(serX/krok+1)));
else
{
if(serX>textband) strcpy(iobuf,"MENU");
else strcpy(iobuf,"EMPTY");
lnum=0;
}
laneNum.InstallText(iobuf,'y',1);
Interface::SetCursor(serX,serY);
goto END_LOOP;
}
if(dbase.DoIt() || Name.DoIt())
{
dbase.invers();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,128,"Base name (*.cut):",sx/4,sy,64,donebands);
if(*iobuf!='\0')
{
*BaseName='\0';
if(strchr(iobuf,'\\')==NULL)
{
strcpy(BaseName,sciezka);
strcat(BaseName,"\\");
}
strcat(BaseName,iobuf);
if(strchr(iobuf,'.')==NULL)
strcat(BaseName,".cut");
Name.InstallText(BaseName,'\\',1);
comm.InstallText("/ ???",'/',1);
}
goto END_LOOP;
}
if(comm.DoIt())
{
comm.invers();
if(gdriver!=HERCMONO)
comm.InstallText(GetDescription(BaseName,Description),'/',1);
else
{
restorecrtmode();
OutOfMem=CRTOutOfMem;
TITLE();
comm.InstallText(GetDescription(BaseName,Description),'/',1);
PAUSE;
setgraphmode(gmode);
OutOfMem=GROutOfMem;
Interface::MousePresent(); /* Long time running */
repaintdesktop();
}
goto END_LOOP;
}
if(search.DoIt())
{
search.invers();
if(lnum>0 && lnum<=lanenum)
{
if(lanes[lnum-1].fresh && !lanes[lnum-1].stand)
{
(putchar)('\7');
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,12,"ERROR: Fresh or modified lane! "PENTER,sx/4,sy,45,stand);
goto END_LOOP;
}
restorecrtmode();
OutOfMem=CRTOutOfMem;
linenum=0;
TITLE();
Searchlane(BaseName,lnum-1);
changeany=1;
PAUSE;
setgraphmode(gmode);
OutOfMem=GROutOfMem;
if(gdriver==HERCMONO)
Interface::MousePresent(); /* Long time running */
repaintdesktop();
}
else
{
(putchar)('\7');
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,12,"ERROR: Invalid lane number!"PENTER,sx/4,sy,40,stand);
}
goto END_LOOP;
}
if(save.DoIt())
{
save.invers();
if(lnum>0 && lnum<=lanenum)
{
if(lanes[lnum-1].fresh && !lanes[lnum-1].stand)
{
(putchar)('\7');
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,12,"ERROR: Fresh or modified lane! "PENTER,sx/4,sy,45,stand);
goto END_LOOP;
}
else
{
if(gdriver!=HERCMONO)
{
laneToDBase(BaseName,(lnum-1));
changeany=1;
}
else
{
restorecrtmode();
OutOfMem=CRTOutOfMem;
TITLE();
laneToDBase(BaseName,(lnum-1));
changeany=1;
PAUSE;
setgraphmode(gmode);
OutOfMem=GROutOfMem;
Interface::MousePresent(); /* Long time running */
repaintdesktop();
}
}
}
else
{
(putchar)('\7');
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,12,"ERROR: Invalid lane number!"PENTER,sx/4,sy,40,stand);
}
goto END_LOOP;
}
if(NewDb.DoIt())
{
NewDb.invers();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
grreadstr(iobuf,128,"Description:",sx/4,sy,64,donebands);
if(*iobuf!='\0')
if(gdriver!=HERCMONO)
{
strcpy(Description,iobuf);
MakeNewDBase(BaseName,Description);
changeany=1;
}
else
{
restorecrtmode();
OutOfMem=CRTOutOfMem;
TITLE();
strcpy(Description,iobuf);
MakeNewDBase(BaseName,Description);
changeany=1;
PAUSE;
setgraphmode(gmode);
OutOfMem=GROutOfMem;
Interface::MousePresent(); /* Long time running */
repaintdesktop();
}
}
if( flip.DoIt())
{
flip.invers();
viewsize();
changeany=0;
goto END_LOOP;
};
/* Wyjscie */
if(pipESC.DoIt())
{
pipESC.invers();
Interface::WaitForDrop();
pipek::clear();
break;
}
END_LOOP:
Interface::VisCursor();
Interface::WaitForDrop();
pipek::clear();
HTEST;
}while(1);
/* sprzatanie */
repaintdesktop();
}