forked from Ermentrout/xppaut
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto_nox.c
executable file
·3017 lines (2613 loc) · 57.4 KB
/
auto_nox.c
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <string.h>
#include "parserslow.h"
#include "autevd.h"
#include "run_auto.h"
#include "auto_nox.h"
#include "auto_x11.h"
#include <libgen.h>
/* #include "f2c.h" */
#include "auto_f2c.h"
#include "auto_c.h"
#include "graf_par.h"
#include "load_eqn.h"
#include "read_dir.h"
#include "pp_shoot.h"
#include "read_dir.h"
/*#include "chunk.h"
*/
#include "kinescope.h"
#include "parserslow.h"
/*#include "graf_par.h"
*/
#include "ggets.h"
#include "init_conds.h"
#include "diagram.h"
#include "many_pops.h"
#include "browse.h"
#include "pop_list.h"
#include "menudrive.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#ifndef WCTYPE
#include <ctype.h>
#else
#include <wctype.h>
#endif
#include "axes2.h"
#include "graphics.h"
#include "xpplim.h"
#include "autlim.h"
#include "xAuto.h"
#define MAXLINELENGTH 100000
#define PACK_AUTO 0
#define PACK_LBF 1
#define PARAM_BOX 1
#define RUBBOX 0
#define RUBLINE 1
/* #define RIGHT 6
#define LEFT 2 */
#define ESC 27
#define TAB 10
#define BAD 0
#define FINE 13
#define UPT 6
#define SPT 7
#define OPEN_3 1
#define NO_OPEN_3 0
#define OVERWRITE 0
#define APPEND 1
/* calculation types */
int TypeOfCalc=0;
#define LPE2 1
#define LPP2 2
#define HB2 3
#define TR2 4
#define BR2 5
#define PD2 6
#define FP2 7
#define BV1 8
#define EQ1 9
#define PE1 10
#define DI1 11
#define HO2 12
#define STD_WID 460 /* golden mean */
#define STD_HGT 284
#define MAX_LEN_SBOX 25
#define HI_P 0 /* uhi vs par */
#define NR_P 1 /* norm vs par */
#define HL_P 2 /* Hi and Lo vs par periodic only */
#define PE_P 3 /* period vs par */
#define P_P 4 /* param vs param */
#define FR_P 10 /* freq vs par */
#define AV_P 11 /* ubar vs par */
#define SPECIAL 5
#define SPER 3
#define UPER 4
#define CSEQ 1
#define CUEQ 2
#define DISCRETE 0
extern XAUTO xAuto;
extern int leng[MAXODE];
extern int PS_Color;
extern double TOR_PERIOD;
extern float **storage;
extern int storind;
extern double constants[];
extern int PointType;
extern int xorfix;
extern int NoBreakLine;
extern char *auto_hint[],*aaxes_hint[],*afile_hint[],*arun_hint[],*no_hint[];
extern int BVP_FLAG;
extern int fp8_is_open;
extern FILE *fp8;
/*extern char *strdup(const char *s);
*/
extern int AutoRedrawFlag;
extern int FLOWK;
extern int mark_flag;
extern int mark_ibrs,mark_ibre;
extern int mark_ipts,mark_ipte;
int SEc=20;
int UEc=0;
int SPc=26;
int UPc=28;
int HBc=0;
int LPc=20;
/* two parameter colors need to do this
LP is 20 (red)
HB is 28 blue
TR is 26 (green)
PD is 24 (orange)
BR is 27 (turquoise)
FP is 25 (olive)
*/
int LPP_color=0;
int LPE_color=20;
int HB_color=28;
int TR_color=26;
int PD_color=23;
int BR_color=27;
int FP_color=25;
int HO_color=29;
int RestartLabel=0;
int auto_ntst=15,auto_nmx=200,auto_npr=50,auto_ncol=4;
double auto_ds=.02, auto_dsmax=.5, auto_dsmin=.001;
double auto_rl0=0.0,auto_rl1=2,auto_a0=0.0,auto_a1=1000.;
double auto_xmax=2.5, auto_xmin=-.5,auto_ymax=3.0,auto_ymin=-3.0;
double auto_epsl=1e-4,auto_epsu=1e-4,auto_epss=1e-4;
int auto_var=0;
int is_3_there=0;
int load_all_labeled_orbits=0;
ROTCHK blrtn;
GRABPT grabpt;
extern double MyData[MAXODE];
extern DIAGRAM *bifd;
extern int NBifs;
int AutoTwoParam=0;
int NAutoPar=8;
int Auto_index_to_array[8];
int AutoPar[8];
extern int TipsFlag;
extern unsigned int MyBackColor,MyForeColor,GrFore,GrBack;
void auto_scroll_window();
double atof();
double outperiod[20];
integer UzrPar[20];
int NAutoUzr;
char *get_first();
char *get_next();
/*extern char this_file[100];*/
extern char this_file[XPP_MAX_NAME];
char this_auto_file[200];
char fort3[200];
char fort7[200];
char fort8[200];
char fort9[200];
char TMPSWAP[200];
extern char uvar_names[MAXODE][12];
extern char upar_names[MAXPAR][11];
extern int NUPAR;
unsigned int DONT_XORCross=0;
double XfromAuto,YfromAuto;
int FromAutoFlag=0;
extern int NODE,NEQ;
extern int METHOD;
int HomoFlag=0;
int sparity=0;
double homo_l[100],homo_r[100];
double HOMO_SHIFT=0.0;
extern char uvar_names[MAXODE][12];
extern int storind;
extern int DCURX,DCURXs,DCURY,DCURYs,CURY_OFFs,CURY_OFF;
BIFUR Auto;
ADVAUTO aauto;
int NewPeriodFlag;
AUTOAX Old1p;
AUTOAX Old2p;
/* color plot stuff */
void colset(int type )
{
switch(type) {
case CSEQ:
autocol(SEc);
break;
case CUEQ:
autocol(UEc);
break;
case SPER:
autocol(SPc);
break;
case UPER:
autocol(UPc);
break;
}
}
void pscolset2(int flag2)
{
switch(flag2){
case LPE2:
set_linestyle(LPE_color-19);
break;
case LPP2:
set_linestyle(LPP_color);
break;
case HB2:
set_linestyle(HB_color-19);
break;
case TR2:
set_linestyle(TR_color-19);
break;
case BR2:
set_linestyle(BR_color-19);
break;
case PD2:
set_linestyle(PD_color-19);
break;
case FP2:
set_linestyle(FP_color-19);
break;
default:
set_linestyle(0);
}
}
void colset2(int flag2)
{
LineWidth(2);
switch(flag2){
case LPE2:
autocol(LPE_color);
break;
case LPP2:
autocol(LPP_color);
break;
case HB2:
autocol(HB_color);
break;
case TR2:
autocol(TR_color);
break;
case BR2:
autocol(BR_color);
break;
case PD2:
autocol(PD_color);
break;
case FP2:
autocol(FP_color);
break;
default:
autocol(0);
}
}
void storeautopoint(double x,double y)
{
if(Auto.plot==P_P){
XfromAuto=x;
YfromAuto=y;
FromAutoFlag=1;
}
}
void setautopoint()
{
if(FromAutoFlag)
{
FromAutoFlag=0;
set_val(upar_names[AutoPar[Auto.icp1]],XfromAuto);
set_val(upar_names[AutoPar[Auto.icp2]],YfromAuto);
evaluate_derived();
redraw_params();
}
}
void get_auto_str(xlabel,ylabel)
char *xlabel,*ylabel;
{
sprintf(xlabel,"%s",upar_names[AutoPar[Auto.icp1]]);
switch(Auto.plot){
case HI_P:
case HL_P:
sprintf(ylabel,"%s",uvar_names[Auto.var]);
break;
case NR_P:
sprintf(ylabel,"Norm");
break;
case PE_P:
sprintf(ylabel,"Period");
break;
case FR_P:
sprintf(ylabel,"Frequency");
break;
case P_P:
sprintf(ylabel,"%s",upar_names[AutoPar[Auto.icp2]]);
break;
case AV_P:
sprintf(ylabel,"%s_bar",uvar_names[Auto.var]);
break;
}
}
void draw_ps_axes()
{
char sx[20],sy[20];
set_scale(Auto.xmin,Auto.ymin,Auto.xmax,Auto.ymax);
get_auto_str(sx,sy);
Box_axis(Auto.xmin,Auto.xmax,Auto.ymin,Auto.ymax,sx,sy,0);
}
void draw_svg_axes()
{
char sx[20],sy[20];
set_scale(Auto.xmin,Auto.ymin,Auto.xmax,Auto.ymax);
get_auto_str(sx,sy);
Box_axis(Auto.xmin,Auto.xmax,Auto.ymin,Auto.ymax,sx,sy,0);
}
void draw_bif_axes()
{
int x0=Auto.x0,y0=Auto.y0,ii,i0;
int x1=x0+Auto.wid,y1=y0+Auto.hgt;
char junk[20],xlabel[20],ylabel[20];
clear_auto_plot();
ALINE(x0,y0,x1,y0);
ALINE(x1,y0,x1,y1);
ALINE(x1,y1,x0,y1);
ALINE(x0,y1,x0,y0);
sprintf(junk,"%g",Auto.xmin);
ATEXT(x0,y1+DCURYs+2,junk);
sprintf(junk,"%g",Auto.xmax);
ii=strlen(junk)*DCURXs;
ATEXT(x1-ii,y1+DCURYs+2,junk);
sprintf(junk,"%g",Auto.ymin);
ii=strlen(junk);
i0=9-ii;
if(i0<0)i0=0;
ATEXT(i0*DCURXs,y1,junk);
sprintf(junk,"%g",Auto.ymax);
ii=strlen(junk);
i0=9-ii;
if(i0<0)i0=0;
ATEXT(i0*DCURXs,y0+DCURYs,junk);
get_auto_str(xlabel,ylabel);
ATEXT((x0+x1)/2,y1+DCURYs+2,xlabel);
ATEXT(10*DCURXs,DCURYs,ylabel);
refreshdisplay();
}
int IXVal(x)
double x;
{
double temp=(double)Auto.wid*(x-Auto.xmin)/(Auto.xmax-Auto.xmin);
return ((int) temp+Auto.x0);
}
int IYVal(y)
double y;
{
double temp=(double)Auto.hgt*(y-Auto.ymin)/(Auto.ymax-Auto.ymin);
return(Auto.hgt-(int)temp+Auto.y0);
}
int chk_auto_bnds(int ix,int iy)
{
int x1=Auto.x0,x2=Auto.x0+Auto.wid;
int y1=Auto.y0,y2=Auto.y0+Auto.hgt;
if((ix>=x1)&&(ix<x2)&&(iy>=y1)&&(iy<y2))return 1;
return 0;
}
/* File manipulation stuff */
void renamef(old,new)
char *old,*new;
{
rename(old,new);
}
void cat_fp(fo)
FILE *fo;
{
int c;
rewind(fo);
while((c=getc(fo))!=EOF){
printf("%c",c);
}
}
void cat_file(f)
char *f;
{
FILE *fo;
int c;
printf(" cat %s \n", f);
fo=fopen(f,"r");
while((c=getc(fo))!=EOF){
printf("%c",c);
}
fclose(fo);
}
void copyf(old,new)
char *old,*new;
{
FILE *fo,*fn;
int c;
fo=fopen(old,"r");
fn=fopen(new,"w");
while((c=getc(fo))!=EOF){
putc(c,fn);
}
fclose(fo);
fclose(fn);
}
void appendf(old,new)
char *old,*new;
{
FILE *fo,*fn;
FILE *ft;
int c;
/* printf("Appending old=%s new=%s\n",old,new); */
fo=fopen(old,"r");
fn=fopen(new,"r");
if(fn==NULL){
fclose(fo);
copyf(old,new);
return;
}
ft=fopen(TMPSWAP,"w");
if(ft==NULL){
printf("Can't open %s \n",TMPSWAP);
return;
}
while((c=getc(fo))!= EOF)
putc(c,ft);
fclose(fo);
while((c=getc(fn))!=EOF)
putc(c,ft);
fclose(fn);
fclose(ft);
copyf(TMPSWAP,new);
deletef(TMPSWAP);
}
void deletef(old)
char *old;
{
remove(old);
}
void close_auto(flg) /* labels compatible with A2K */
int flg;
{
char string[1000];
/* if(fp8_is_open){
fclose(fp8);
fp8_is_open=0;
}
*/
if(flg==0) {/*Overwrite*/
sprintf(string,"%s.b",this_auto_file);
renamef(fort7,string);
sprintf(string,"%s.d",this_auto_file);
renamef(fort9,string);
sprintf(string,"%s.s",this_auto_file);
renamef(fort8,string);
}
else {/*APPEND*/
sprintf(string,"%s.b",this_auto_file);
appendf(fort7,string);
sprintf(string,"%s.d",this_auto_file);
appendf(fort9,string);
sprintf(string,"%s.s",this_auto_file);
appendf(fort8,string);
}
deletef(fort8);
fp8_is_open=0;
deletef(fort7);
deletef(fort9);
deletef(fort3);
}
void create_auto_file_name()
{
char string[200];
char *basec,*bname,*dirc,*dname;
basec = strdup(this_file);
dirc = strdup(this_file);
bname = (char*)basename(basec);
dname = (char*)dirname(dirc);
char* HOME = getenv("HOME");
if (HOME == NULL)
{
HOME = dname;
}
sprintf(this_auto_file,"%s/%s",HOME,bname);
}
void open_auto(flg) /* compatible with new auto */
int flg;
{
char string[200];
char *basec,*bname,*dirc,*dname;
basec = strdup(this_file);
dirc = strdup(this_file);
bname = (char*)basename(basec);
dname = (char*)dirname(dirc);
char* HOME = getenv("HOME");
if (HOME == NULL)
{
HOME = dname;
}
sprintf(this_auto_file,"%s/%s",HOME,bname);
sprintf(fort3,"%s/%s",HOME,"fort.3");
sprintf(fort7,"%s/%s",HOME,"fort.7");
sprintf(fort8,"%s/%s",HOME,"fort.8");
sprintf(fort9,"%s/%s",HOME,"fort.9");
sprintf(TMPSWAP,"%s/%s",HOME,"__tmp__");
is_3_there=flg;
if(flg==1){
sprintf(string,"%s.s",this_auto_file);
copyf(string,fort3);
}
}
/* MAIN Running routine Assumes that Auto structure is set up */
void do_auto(iold,isave,itp)
int iold,isave;
int itp;
{
redraw_auto_menus();
set_auto(); /* this sets up all the continuation initialization
it is equivalent to reading in auto parameters
and running init in auto
*/
open_auto(iold); /* this copies the relevant files .s to fort.3 */
go_go_auto(); /* this complets the initialization and calls the
main routines
*/
/* plintf("AUTO opened it==%d\n",itp); */
/* run_aut(Auto.nfpar,itp); THIS WILL CHANGE TO gogoauto stuff */
close_auto(isave); /* this copies fort.8 to the .s file and other
irrelevant stuff
*/
if(RestartLabel!=0){
printf("RestartLabel=%d itp=%d ips=%d nfpar=%d ilp=%d isw=%d isp=%d A2p=%d \n",RestartLabel,Auto.itp, Auto.ips,Auto.nfpar,Auto.ilp,Auto.isw,Auto.isp,AutoTwoParam);
Auto.irs=RestartLabel;
RestartLabel=0;
do_auto(iold,isave, Auto.itp);
}
ping();
redraw_params();
}
void set_auto() /* Caution - need to include NICP here */
{
NAutoUzr=Auto.nper;
init_auto(NODE,Auto.nfpar,Auto.nbc,Auto.ips,Auto.irs,Auto.ilp,Auto.ntst,Auto.isp,
Auto.isw,Auto.nmx,Auto.npr,Auto.ds,Auto.dsmin,
Auto.dsmax,Auto.rl0,Auto.rl1,Auto.a0,Auto.a1,Auto.icp1,
Auto.icp2,Auto.icp3,Auto.icp4,Auto.icp5,Auto.nper,Auto.epsl,Auto.epsu,Auto.epss,Auto.ncol);
}
int auto_name_to_index(s)
char *s;
{
int i,in;
find_variable(s,&in);
if(in==0)return(10);
in=find_user_name(PARAM_BOX,s);
for(i=0;i<NAutoPar;i++)
if(AutoPar[i]==in)return(i);
return(-1);
}
int auto_par_to_name(index,s)
int index;
char *s;
{
if(index==10){
sprintf(s,"T");
return(1);
}
if(index<0||index>8)return(0);
sprintf(s,"%s",upar_names[AutoPar[index]]);
return(1);
}
void auto_per_par()
{
static char *m[]={"0","1","2","3","4","5","6","7","8","9"};
static char key[]="0123456789";
char values[10][MAX_LEN_SBOX];
char bob[100],*ptr;
static char *n[]={"Uzr1","Uzr2","Uzr3","Uzr4","Uzr5",
"Uzr6","Uzr7","Uzr8","Uzr9"};
int status,i,in;
char ch;
ch=(char)auto_pop_up_list("Number",m,key,10,12,Auto.nper,10,10,no_hint,
Auto.hinttxt);
for(i=0;i<10;i++)
if(ch==key[i])Auto.nper=i;
NAutoUzr=Auto.nper;
if(Auto.nper>0){
for(i=0;i<9;i++){
auto_par_to_name(Auto.uzrpar[i],bob);
sprintf(values[i],"%s=%g",bob,Auto.period[i]);
}
status=do_string_box(9,5,2,"AutoPer",n,values,45);
if(status!=0)
for(i=0;i<9;i++){
ptr=get_first(values[i],"=");
in=auto_name_to_index(ptr);
if(in>=0){
Auto.uzrpar[i]=in;
ptr=get_next("@");
Auto.period[i]=atof(ptr);
}
}
}
for(i=0;i<9;i++){
outperiod[i]=Auto.period[i];
UzrPar[i]=Auto.uzrpar[i];
}
}
/* auto parameters are 1-8 (0-7) and since there are only 8, need to associate them
with real xpp parameters for which there may be many
*/
void auto_params()
{
static char *n[]={"*2Par1","*2Par2","*2Par3","*2Par4","*2Par5","*2Par6","*2Par7","*2Par8"};
int status,i,in;
char values[8][MAX_LEN_SBOX];
for(i=0;i<8;i++){
if(i<NAutoPar) sprintf(values[i],"%s",upar_names[AutoPar[i]]);
else values[i][0]='\0';/*sprintf(values[i],"");*/
}
status=do_string_box(8,8,1,"Parameters",n,values,38);
if(status!=0){
for(i=0;i<8;i++){
if(i<NAutoPar){
in=find_user_name(PARAM_BOX,values[i]);
if(in>=0){
AutoPar[i]=in;
in=get_param_index(values[i]);
Auto_index_to_array[i]=in;
/* printf("%d -> %d %s\n",i,in, values[i]); */
}
}
}
}
}
void auto_num_par()
{
static char *n[]={"Ntst","Nmax","NPr","Ds","Dsmin","Ncol","EPSL",
"Dsmax","Par Min","Par Max","Norm Min","Norm Max",
"EPSU","EPSS","IAD","MXBF","IID","ITMX","ITNW","NWTN","IADS"};
int status;
char values[21][MAX_LEN_SBOX];
sprintf(values[0],"%d",Auto.ntst);
sprintf(values[1],"%d",Auto.nmx);
sprintf(values[2],"%d",Auto.npr);
sprintf(values[3],"%g",Auto.ds);
sprintf(values[4],"%g",Auto.dsmin);
sprintf(values[7],"%g",Auto.dsmax);
sprintf(values[8],"%g",Auto.rl0);
sprintf(values[9],"%g",Auto.rl1);
sprintf(values[10],"%g",Auto.a0);
sprintf(values[11],"%g",Auto.a1);
sprintf(values[5],"%d",Auto.ncol);
sprintf(values[6],"%g",Auto.epsl);
sprintf(values[12],"%g",Auto.epsu);
sprintf(values[13],"%g",Auto.epss);
sprintf(values[14],"%d",aauto.iad);
sprintf(values[15],"%d",aauto.mxbf);
sprintf(values[16],"%d",aauto.iid);
sprintf(values[17],"%d",aauto.itmx);
sprintf(values[18],"%d",aauto.itnw);
sprintf(values[19],"%d",aauto.nwtn);
sprintf(values[20],"%d",aauto.iads);
status=do_string_box(21,7,3,"AutoNum",n,values,25);
if(status!=0){
Auto.ntst=atoi(values[0]);
Auto.nmx=atoi(values[1]);
Auto.npr=atoi(values[2]);
Auto.ds=atof(values[3]);
Auto.dsmin=atof(values[4]);
Auto.dsmax=atof(values[7]);
Auto.rl0=atof(values[8]);
Auto.rl1=atof(values[9]);
Auto.a0=atof(values[10]);
Auto.a1=atof(values[11]);
Auto.ncol=atoi(values[5]);
Auto.epsl=atof(values[6]);
Auto.epsu=atof(values[12]);
Auto.epss=atof(values[13]);
aauto.iad=atoi(values[14]);
aauto.mxbf=atoi(values[15]);
aauto.iid=atoi(values[16]);
aauto.itmx=atoi(values[17]);
aauto.itnw=atoi(values[18]);
aauto.nwtn=atoi(values[19]);
aauto.iads=atoi(values[20]);
}
}
void auto_plot_par()
{
static char *m[]={"Hi","Norm","hI-lo","Period","Two par","(Z)oom in","Zoom (O)ut",
"last 1 par", "last 2 par","Fit",
"fRequency","Average","Default","Scroll"};
static char key[]="hniptzo12frads";
char ch;
static char *n[]={"*1Y-axis","*2Main Parm", "*2Secnd Parm", "Xmin", "Ymin",
"Xmax", "Ymax"};
char values[7][MAX_LEN_SBOX];
int status,i;
int ii1,ii2,ji1,ji2;
int i1=Auto.var+1;
char n1[15];
ch=(char)auto_pop_up_list("Plot Type",m,key,14,10,Auto.plot,10,50,
aaxes_hint,Auto.hinttxt);
if(ch==ESC)
return;
for(i=0;i<5;i++)
if(ch==key[i])Auto.plot=i;
if(ch==key[10])Auto.plot=10;
if(ch==key[11])Auto.plot=11;
if(ch==key[5]){
if(auto_rubber(&ii1,&ji1,&ii2,&ji2,RUBBOX)!=0){
auto_zoom_in(ii1,ji1,ii2,ji2);
redraw_diagram();
}
return;
}
if(ch==key[6]){
if(auto_rubber(&ii1,&ji1,&ii2,&ji2,RUBBOX)!=0){
auto_zoom_out(ii1,ji1,ii2,ji2);
redraw_diagram();
}
return;
}
if(ch==key[7]){
load_last_plot(1);
draw_bif_axes();
return;
}
if(ch==key[8]){
load_last_plot(2);
draw_bif_axes();
return;
}
if(ch==key[9]){
auto_fit();
redraw_diagram();
return;
}
if(ch==key[12]){
auto_default();
redraw_diagram();
return;
}
if(ch==key[13]){
auto_scroll_window();
redraw_diagram();
/* printf("I am done scrolling!!"); */
return;
}
ind_to_sym(i1,n1);
sprintf(values[0],"%s",n1);
sprintf(values[1],"%s",upar_names[AutoPar[Auto.icp1]]);
sprintf(values[2],"%s",upar_names[AutoPar[Auto.icp2]]);
sprintf(values[3],"%g",Auto.xmin);
sprintf(values[4],"%g",Auto.ymin);
sprintf(values[5],"%g",Auto.xmax);
sprintf(values[6],"%g",Auto.ymax);
status=do_string_box(7,7,1,"AutoPlot",n,values,31);
if(status!=0){
/* get variable names */
find_variable(values[0],&i);
if(i>0)
Auto.var=i-1;
/* Now check the parameters */
i1=find_user_name(PARAM_BOX,values[1]);
if(i1>=0){
for(i=0;i<NAutoPar;i++){
if(i1==AutoPar[i]){
Auto.icp1=i;
}
}
}
i1=find_user_name(PARAM_BOX,values[2]);
if(i1>=0){
for(i=0;i<NAutoPar;i++){
if(i1==AutoPar[i]){
Auto.icp2=i;
}
}
}
Auto.xmin=atof(values[3]);
Auto.ymin=atof(values[4]);
Auto.xmax=atof(values[5]);
Auto.ymax=atof(values[6]);
draw_bif_axes();
if(Auto.plot<4)keep_last_plot(1);
if(Auto.plot==4)keep_last_plot(2);
}
}
void auto_default()
{
Auto.xmin=auto_xmin;
Auto.xmax=auto_xmax;
Auto.ymin=auto_ymin;
Auto.ymax=auto_ymax;
}
void auto_fit()
{
double xlo=Auto.xmin,xhi=Auto.xmax,ylo=Auto.ymin,yhi=Auto.ymax;
bound_diagram(&xlo,&xhi,&ylo,&yhi);
Auto.xmin=xlo;
Auto.xmax=xhi;
Auto.ymin=ylo;
Auto.ymax=yhi;
}
void auto_zoom_in(i1,j1,i2,j2)
int i1,j1,i2,j2;
{
double x1,y1,x2,y2;
int temp;
if(i1>i2){temp=i1;i1=i2;i2=temp;}
if(j2>j1){temp=j1;j1=j2;j2=temp;}
double dx = (Auto.xmax-Auto.xmin);
double dy = (Auto.ymax-Auto.ymin);
x1 = Auto.xmin+(double)(i1-Auto.x0)*(dx)/(double)Auto.wid;
x2 = Auto.xmin+(double)(i2-Auto.x0)*(dx)/(double)Auto.wid;
y1 = Auto.ymin+(double)(Auto.hgt+Auto.y0-j1)*(dy)/(double)Auto.hgt;
y2 = Auto.ymin+(double)(Auto.hgt+Auto.y0-j2)*(dy)/(double)Auto.hgt;
if((i1==i2)||(j1==j2))
{
if (dx < 0){dx=-dx;}
if (dy < 0){dy=-dy;}
dx = dx/2;
dy = dy/2;
/*Shrink by thirds and center (track) about the point clicked*/
Auto.xmin=x1-dx/2;
Auto.xmax=x1+dx/2;
Auto.ymin=y1-dy/2;
Auto.ymax=y1+dy/2;
}
else
{
Auto.xmin=x1;
Auto.ymin=y1;
Auto.xmax=x2;
Auto.ymax=y2;
}
}
void auto_zoom_out(i1,j1,i2,j2)
int i1,j1,i2,j2;
{
double x1=0.0,y1=0.0,x2=0.0,y2=0.0;
int temp;