forked from rlabduke/mage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MUXMMAIN.c
1347 lines (1251 loc) · 47.4 KB
/
MUXMMAIN.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
/*MUX_MAIN.c*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
#define EXTERN /* as nothing, this file has the main() */
#include "MAGE.h"
#include "MAGELIST.h"
#include "MAGEDLOG.h"
#include "MAGEMENU.h"
#include "MAGEANGL.h"
#include "MAGETABL.h"
#include "MAGESYNC.h" /*sync and adjust: controls, sockets,...*/
#include "MAGEBBOX.h" /*121108 for adjustrock, etc... */
/****main()*******************************************************************/
int main(int argc, char** argv) /*121108 main is of type int !? */
{
XEvent report;
int Limages=0,Nimage=0; /*030725*/
/* setenv( "LANG", "C", 1 );*/ /* MGP: maybe needed for Redhat 8.0 ? */
/*printf("CurrentTime==%ld\n",CurrentTime);*/ /*keep so dcr remembers call*/
/*PEX stuff kept as guide for eventual openGL port*/
Lmagedone = 0; /*master flag, set true exits program */
mainsetup(&argc, argv); /*MUXMINIT.C*/
if(LGUI)
{/*LGUI*/
#ifdef _STDFONTCURSORS_
printf("defined: _STDFONTCURSORS_\n");
#endif
#ifdef UNIX_PEX
OpenPhigs(); /*MUXPHIG.c*/
#endif /*UNIX_PEX*/
while (!Lmagedone) /* until user wants to quit... */
{/*master event loop: while(!Lmagedone)*/
/*enter check-que only if not doing an auto update function*/
/*OR something has triggered the XtAppPending flag*/
/*like a keypress associated with drawing. */
if( (!Lmickeymouserun&&!Lmagetimerrunning)
|| Lpausemickeymouse
|| (XtAppPending(app_context)!=0)
)
{/*check event que*/
XtAppNextEvent(app_context,&report); /* get the next event */
#ifdef UNIX_PEX
if (report.type < LASTEvent)
#endif
{
if(report.type == KeyPress||report.type == KeyRelease )
{/*key press or release: need both to track ShiftKey state*/
/*if(!ACTIVE_DLOG && !Ltexteditable) */
if(!ACTIVE_DLOG)
{
if( Ltexteditable
&& ( (Window)(report.xkey).window == XtWindow(textwindow)
||(Window)(report.xkey).window == XtWindow(captwindow)))
{/*Ltexteditable, catch key in text and caption windows*/
XtDispatchEvent(&report);
}/*Ltexteditable, catch key in text and caption windows*/
else
{
fprintf(stderr," \010");/*print space+backspace to trick SGI*/
keypresseventhandler(&report);/*MUX_MAIN.c*/
}
}
else
{/*ACTIVE_DLOG*/
XtDispatchEvent(&report);
}
}/*key press or release*/
else
{
XtDispatchEvent(&report);
}
/*NOTE: mousedown event calls pick_CB as handler */
}
#ifdef UNIX_PEX
else
{
dospecialevent(&report); /*MUXPHIG.c*/
}
#endif /*UNIX_PEX*/
}/*check event que*/
if(Lpipeactive)
{/*controls for input from an active pipe*/
if(Lpipebufferloaded)
{
if(!Linhibiton)
{
/*does NOT come through here doing simulation from tail of active file!!!!*/
if(framenumber==0) Lappend = 0;
else Lappend = 1;
GetStuffFromFile(); /*MAGEINPT*/
}
}
else
{
readpipeintobuffer(1); /*up to #char before returning,____PIPE*/
}
}/*controls for input from an active pipe*/
if(Lsocketoutactive) /*more restrictive than Lsockets*/
{
syncsocketout(0); /* 0 for normal flow MAGESYNC.c*/
}
if(Lsocketoutextraactive) /*more restrictive than Lsockets*/
{
syncsocketoutextra(0); /* 0 for normal flow MAGESYNC.c*/
}
if(Lsockettrigger)
{/*commandline request for socket setup*/
setsockets(0); /*create socket for input*/
Lsockettrigger = 0;
#ifdef ALLATONCE
if(Lsocketsame == 1)
{/*mages must be initiated in reverse order, so 1-->2 and 1-->3*/
setsockets(Lsockets); /*-->2*/
setsockets(Lsockets); /*-->3*/
Lsocketreturn = 1; /*syncsocketout to request a return connection*/
Lsocketoutactive = 1;
}
#endif
}
if(Lmickeymouserun && !Lpausemickeymouse)
{/*LINUX does NOT provide a stream of interrupts, so rocking is spastic*/
/*however, checking for XtAppPending keeps things clicking*/
/*animatesteptime and rocksteptime floating point seconds*/
/*ticks are long integer 60ths of a second*/
if(Lautorock && theclocktickcount() > nextrocktick)
{
nextrocktick = theclocktickcount() + (long)(rocksteptime*60);
adjustrock(); /*MAGEBBOX.C*/
/*redrawvec() called by adjustrock()*/
}
if(Lautoanimate&&(nanimate > 1)&&(theclocktickcount() > nextanimatetick))
{
nextanimatetick = theclocktickcount() + (long)(animatesteptime*60);
adjustanimate(1); /*MAGEBBOX.C*/
if(Lautorock) adjustrock();
else redrawvec();
}
}
if(Ltestmode) /*magetimeticklimit*/
{
magetimercheck(); /*MAGEINIT.c 020816*/
}
if(Lsearched) /*NON-MODAL FIND DIALOG left unfinished business...030121*/
{
DoSearchDialog(); /*MUXMDLOG.c*/
}
if(LneedSetsinGrafWindow)
{
SetsinGrafWindow(); /*MAGEBBOX.c 030320*/
redrawvec(); /*040609 now not called by entry(), but needed here*/
}
if(Lreloadkinemage)
{
reloadkinemage(); /*060121*/
}
if(Lreplacemarkers)
{
replacemarkers(); /*061116*/
}
if(Lrescalekinemage)
{
rescalekinemage();
}
if(Lredrawvector)
{
redrawvec();
}
if(Lparamtriggeron) /*141006*/
{
Lparamtriggeron = 0;
DoNucleicAcidParameters();
}
}/*master event loop: while(!Lmagedone)*/
if(Lsockets)
{
syncsocketout(1); /*1 to close sockets*/
syncsocketoutextra(1); /*1 to close sockets*/
}
}/*LGUI*/
else
{/*NOT LGUI*/
if(Lpostscript)
{/*write eps file(s) of each animation*/
if(nanimate > 0) {Limages = nanimate;} /*030725*/
else {Limages = 1;} /*030725*/
Nimage = 1;
while(Limages > 0) /*030725*/
{
/*fpout = stdout;*/ /*NOT LGUI used to write to stdout*/
sprintf(OutStr,"%s.%d.eps",NameStr,Nimage);
fpout = fopen(OutStr,"w"); /*MAGEPOST closes fpout at end of kinemage*/
writepostscript(); /*writes postscript header stuff for NOT LGUI*/
drawvec(); /*draws the kinemage and writes postscript line-by-line*/
Limages--; /*030725*/
Nimage++; /*030725*/
if(Limages) {adjustanimate(1);} /*MAGEBBOX.C*/ /*030725*/
}
}/*write eps file(s) of each animation*/
else if(Lhelpstdout) { writehelptostdout(); /*MAGEHELP.c*/ }
else if(Lchangesstdout) { writechangestostdout(); /*MAGEINIT.c*/ }
else if(Lreportstderr) { writereporttostderr(); /*MAGEINIT.c 070901*/ }
}/*NOT LGUI*/
exit(0);
}
/*___main()_________________________________________________________________*/
/****keypresseventhandler()***************************************************/
void keypresseventhandler(XEvent* event)
{/*keyboard events*/
/*ref: Johnson&Reichard,2nd Ed,Motif,MIS Press,1993, pg 387*/
KeySym keysym;
XComposeStatus compose_status;
int length, size=9;
char string[10];
float factor;
/*keysym:*/
#define SPACEBAR 32
#define LARROW 65361
#define RARROW 65363
#define DARROW 65364
#define UARROW 65362
#define LSHIFT 65505
#define RSHIFT 65506
#define LCONTROLKEY 65507
#define RCONTROLKEY 65508
#define LALTKEY 65513
#define RALTKEY 65514
switch(event->type)
{
case KeyRelease: /*121108 disambiguate with () and clean code*/
length =
XLookupString((XKeyEvent *)event,string,size,&keysym,&compose_status);
if(keysym==SPACEBAR){ Lspacebar=0;}
if((keysym==LSHIFT) || (keysym==RSHIFT)){ Lshiftkey=0;}
if((keysym==LCONTROLKEY) || (keysym==RCONTROLKEY)){ Lctrlkey=0;}
if((keysym==LALTKEY) || (keysym==RALTKEY)){ Laltkey=0;}
/*
fprintf(stderr,"key: %s, l== %d, e->state== %u, ->code== %u, sym== %u, Lspace==%d, Lshift==%d, Lctrl==%d, Lalt==%d\n"
,string,length,((XKeyEvent *)event)->state,((XKeyEvent *)event)->keycode,keysym,Lspacebar,Lshiftkey,Lctrlkey,Laltkey);
*/
break;
case KeyPress:
length =
XLookupString((XKeyEvent *)event,string,size,&keysym,&compose_status);
if(keysym==SPACEBAR){ Lspacebar=1;}
if(keysym==LSHIFT || keysym==RSHIFT){ Lshiftkey=1;}
if(keysym==LCONTROLKEY || keysym==RCONTROLKEY){ Lctrlkey=1;}
if(keysym==LALTKEY || keysym==RALTKEY){ Laltkey=1;}
/*
fprintf(stderr,"key: %s, l== %d, e->state== %u, ->code== %u, sym== %u, Lspace==%d, Lshift==%d, Lctrl==%d, Lalt==%d\n"
,string,length,((XKeyEvent *)event)->state,((XKeyEvent *)event)->keycode,keysym,Lspacebar,Lshiftkey,Lctrlkey,Laltkey);
*/
/*drop through from special key-down logical state settings*/
if(length>0 && length<=9)
{
string[length] = '\0';
/*020718 control key forces all groups animate: for simulation file*/
if( ((string[0] == 'a') || (string[0] == 'A'))
&&((nanimate > 1)) )
{/* 'a' animation*/
adjustanimate(1); /*MAGEBBOX.c*/
redrawvec(); /*___DRAW.c*/
}
if( ((string[0] == 'b') || (string[0] == 'B'))
&&((nanimate > 1)) )
{/* 'b' 2animation*/
adjustanimate(2); /*MAGEBBOX.c*/
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='c')
{/* c toggles +,- stereo angle */
stereoangle = -stereoangle;
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='d')
{/* d toggles dragline pick-up/new */
Ladddrag = !Ladddrag;
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='e')
{/* e toggles between Lens on and Lens off */ /*971109*/
setLens(); /*MAGEMENU.C*/
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='f')
{/* f toggles scroll state, either xy rotations or xy tranlations */
setflat();
}
if(string[0]=='F' && Lkinfile)
{/* F invokes Find == search dialog */
Lshiftkey=0; /*drop no-longer-needed shift flag*/
DoSearchDialog(); /*MUXMDLOG*/
/*redrawvec();*/ /*___DRAW.c*/
}
if(string[0]=='g')
{/* g toggles white back-g-round */
setwhtbkg();
}
if(string[0]=='G' && Lkinfile)
{/* G invokes Find Again == search again for same strings */
Lshiftkey=0; /*drop no-longer-needed shift flag*/
DoSearchAgain(); /*MAGEUTIL*/
/*redrawvec();*/ /*___DRAW.c*/
}
if(string[0]=='h')
{/* h toggles maintain horizon state, only y rotation */
sethorizon();
}
if(string[0]=='H')
{/* Help : keyboard Shortcuts dialog*/
menuaboutsecrets(0);
}
if(string[0]=='i' && (NDIM > 3) )
{/* i toggles LNDpointsinfo 061115 */
LNDpointsinfo = !LNDpointsinfo;
if(LNDpointsinfo) {adjustSELECTINGlist(7);} /*MAGEDLOG*/
else {adjustSELECTINGlist(3);}
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='I' && (NDIM > 3) )
{/* I toggles LNDpickedinfo 061117 */
LNDpickedinfo = !LNDpickedinfo;
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='k')
{/* k toggles kaleidoscope==plotonly mode */
mycheckitem(kludgeMenu,plotonlyItem,Lplotonly=!Lplotonly);
/*___MENU.c*/
redrawvec(); /*___DRAW.c*/
}
if( string[0] == 'K' )
{ /* 'K' next Kinemage, re: meta-N on Mac */
Lshiftkey=0; /*drop no-longer-needed shift flag*/
Lgetnextkinemage = 1; /*971129*/
changecheckrouter(); /*MAGEINIT.c 020902*/
}
if(string[0]=='l')
{/* l toggles listcolor state, either color specified by list or point*/
setlistcolordominance();
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='L')
{/* L toggles listradius state, radius specified by list or point*/
setlistradiusdominance(); /*040402*/
redrawvec(); /*___DRAW.c*/
}
/* m blanks measures lines & dots, does not remove old values */
/*does disable measures operation, i.e. Lmeasureson==0, button==off*/
/*but potentiates a new measures sequence for a new Lmeasureson==1*/
/*effectively NOP if hit when measures button is off*/
/*971204*/
if(string[0]=='m')
{/* m blanks measures lines & dots*/
/*new 140518: errases ANGLE report: construct5 AngleBetweenLines*/
constructionstr[0] = '\0'; /*140518, tested in MAGEDRAW/redrawvec*/
monitorparamstr[0] = '\0'; /*140915, tested in MAGEDRAW/redrawvec*/
potentiateMeasures(); /*MAGEMENU.c note calls redrawvec 140518*/
}
if(string[0]=='n')
{/* n for +90 ninty*/ /*971104*/
getrot(0,0, 2); /*MAGEDRAW*/
redrawvec();
}
if(string[0]=='N')
{/* N for -90 Ninty*/ /*971104*/
Lshiftkey=0; /*drop no-longer-needed shift flag*/
getrot(0,0,-2); /*MAGEDRAW*/
redrawvec();
}
if( (string[0] == 'O')&&(!Ltestmode) ) /* 'O' open*/
{
Lshiftkey=0; /*drop no-longer-needed shift flag*/
Lappend = 0;
Lgetnewfile = 1; /*request to open-new-file */
ireturnflag = 0;
changecheckrouter(); /*MAGEINIT.c 020902*/
#ifdef OLDCODE
if(Lpruneactive||Ldrawactive||Lnewviewactive||Lnewstuffactive)
{/*check dialog sets ireturnflag*/
DoChangeCheckDialog();
}
else
{/*can go right to open-new-file stuff*/
OpenNewFile(); /*.*/
}
#endif
}
if(string[0]=='p')
{/* p toggles keepperspective */
/*Lkeepperspective = !Lkeepperspective;*/
/*if(Lkeepperspective) Lperspec = 1;*/
/*else Lperspec = 0;*/
Lperspec = !Lperspec; /*991130 like Mac 981114*/
resetmenuchecks(); /*___PMENU.c calls AdjustMenus();*/
redrawvec(); /*___DRAW.c*/
}
if( string[0] == 'P' ) /* 'P' */
{/* P Puts PointID into commandline string */
Lshiftkey=0; /*drop no-longer-needed shift flag*/
commandfrompointID(); /*MAGEOUT.c*/
}
if(string[0]=='q')
{/* q toggles double-sized markers, see 'w' */ /*000804*/
Lscalemarkers = !Lscalemarkers;
/*resetmenuchecks();no menu item yet*/
/*____MENU.C calls AdjustMenus();*/
rescalekinemage(); /*MAGEINPT*/
redrawvec(); /*MACDRAW.C*/
}
if( (string[0] == 'Q')&&(!Ltestmode) ) /* 'Q' quit*/
{
Lshiftkey=0; /*drop no-longer-needed shift flag*/
trytoquitMAGE(); /*____MENU.c*/
}
if( (string[0] == 'r') || (string[0] == ' '))/*i.e. Lspacebar*/
{/* r toggles mickeymouse autoanimate and autorock performance 010609*/
/* spacebar RUN/STOP once empowered by dialog makes sense*/
/* difference between stop and pause is kludgy*/
/*so use of r/R key is best compromise*/
if(Lmickeymouse==1)
{/*must be empowered by dialog before controled by keyboard*/
Lautorock = !Lautorock;
if(Lautorock || Lautoanimate)
{Lmickeymouserun = 1; /*some auto running*/ }
else {Lmickeymouserun = 0; /* no auto running*/ }
if(!Lautorock)
{/*reset current rotation matrix to current rocked state*/
a11 = r11; a12 = r12; a13 = r13;
a21 = r21; a22 = r22; a23 = r23;
a31 = r31; a32 = r32; a33 = r33;
}
else
{/*reset current rocked state to current rotation matrix*/
r11 = a11; r12 = a12; r13 = a13;
r21 = a21; r22 = a22; r23 = a23;
r31 = a31; r32 = a32; r33 = a33;
}
Lnewrock = 1; /*autorock to restart smoothly from mouse setting*/
redrawvec(); /*remove on-screen notification*/
}/*must be empowered by dialog before controled by keyboard*/
else
{
;/*NOP*/
}
}
/*subvert R so it no longer resets to view 1 010609*/
if( string[0] == 'R' ) /* R for autoanimate */
{
if(Lmickeymouse==1)
{/*must be empowered by dialog before controled by keyboard*/
Lautoanimate = !Lautoanimate;
if(Lautorock || Lautoanimate)
{Lmickeymouserun = 1; /*some auto running*/ }
else {Lmickeymouserun = 0; /* no auto running*/ }
redrawvec(); /*possible reset of on-screen notification*/
}
else
{
;/*NOP*/
}
}
if(string[0]=='s' && !Lcompareon)
{/* s toggles keepstereo */
Lkeepstereo = !Lkeepstereo;
if(Lkeepstereo) Lstereo = 1;
else Lstereo = 0;
adjuststereo(); /*MAGEMENU*/
}
if( string[0] == 'S' ) /* 'S' save whole kin as a kip*/
{
Lshiftkey=0; /*drop no-longer-needed shift flag*/
writeoutput(5);/*MUX_OUT.c*/ /*writes entire, possibly modified, kinemage*/
}
if(string[0]=='t')
{/* t toggles keepthinline */
Lkeepthinline=0; /*this keep stuff was a bad idea anyway*/
if(Lthin){Lthin=0;Lonewidth=1;Lmultiwidth=0;}
else if(Lonewidth){Lthin=0;Lonewidth=0;Lmultiwidth=1;}
else if(Lmultiwidth){Lthin=1;Lonewidth=0;Lmultiwidth=0;}
resetmenuchecks();/*___MENU.c calls AdjustMenus();*/
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='u' &&Lkinfile)
{/* u invokes general update Dialog */
if(Lkinfile) DoupdateDialog(); /*MAGEDLOG*/
}
if( string[0] == 'V' ) /* 'V' viewing parameters dialog*/
{
Lshiftkey=0; /*drop no-longer-needed shift flag*/
DostereoDialog(); /*which is still does as well*/
}
if(string[0]=='w')
{/* w toggles double-sized fonts, see 'q' */ /*010521*/
Lscalefonts = !Lscalefonts;
/*resetmenuchecks();no menu item yet*/ /*MACPMENU.C calls AdjustMenus();*/
rescalekinemage(); /*MAGEINPT*/
redrawvec(); /*MACDRAW.C*/
}
if(string[0]=='y')
{/* y toggles 5 depths vs 3 depths */ /*010927*/
L5depths = !L5depths;
if(L5depths) {L3depths=0;}
else {L3depths = 1;}
resetmenuchecks(); /*MAGEMENU.C calls AdjustMenus();*/
redrawvec(); /*____DRAW.C*/
}
if(Lztran)
{
factor = 0.0;
if(string[0]=='x') factor = -1.0;
/*press 'x' to do small step translate in -z*/
if(string[0]=='X') factor = -10.0;
/*press 'X' to do big step translate iz*/
if(string[0]=='z') factor = +1.0;
/*press 'z' to do small step translate in +z*/
if(string[0]=='Z') factor = +10.0;
/*press 'Z' to do big step translate in +z*/
if(factor > 0.01 || factor < -0.01)
{
fxcenternew = fxcenternew + (float)(factor*finestep*a13);
fycenternew = fycenternew + (float)(factor*finestep*a23);
fzcenternew = fzcenternew + (float)(factor*finestep*a33);
rescalekinemage(); /*MAGEINPT.c*/
redrawvec(); /*___DRAW.c*/
}
}
if(string[0]=='1')
{/* 1 zooms bigger by one unit*/
zoom = zoom +0.01;
if(zoom > 10.04) zoom = 10.04;/*maximum*/
adjustzoom(); /*MAGESYNC.c*/
}
if(string[0]=='2')
{/* 2 zooms bigger by ten units*/
zoom = zoom +0.1;
if(zoom > 10.04) zoom = 10.04;/*maximum*/
adjustzoom(); /*MAGESYNC.c*/
}
if(string[0]=='3')
{/* 3 zooms smaller by one unit*/
zoom = zoom -0.01;
if(zoom < .04) zoom = .04;/*minimum*/
adjustzoom(); /*MAGESYNC.c*/
}
if(string[0]=='4')
{/* 4 zooms smaller by ten units*/
zoom = zoom -0.1;
if(zoom < .04) zoom = .04;/*minimum*/
adjustzoom(); /*MAGESYNC.c*/
}
if(string[0]=='9')
{/* 9 augments TBstereo offset amount*/
TBYoffset++;
redrawvec();
}
if(string[0]=='0')
{/* 0 decrements TBstereo offset amount*/
TBYoffset--;
redrawvec();
}
if(string[0]==']') /* ] augments currentaspect*/
{
adjustcurrentaspect(+1);
}
if(string[0]=='[') /* [ decrements currentaspect*/
{
adjustcurrentaspect(-1);
}
if( ((string[0]=='+')||(string[0]=='=')) && (nanimate > 1) ) /*030111*/
{/* += accumulates animates*/
Laccumulate = 1;
adjustanimate(1); /*MAGEBBOX.c*/
Laccumulate = 0;
redrawvec(); /*___DRAW.c*/
}
if(string[0]=='/' && (NDIM > 3) )
{/* forward slash toggles LNDparallelaxes 061115 */
LNDparallelaxes = !LNDparallelaxes;
redrawvec(); /*___DRAW.c*/
}
}
else
{
if(nbondrot > 0 )
{/*arrow keys*/
/*<- one degree less of current bondrotation*/ /*970917*/
if(keysym==LARROW)
{
grafbondrotarrow(-1.0); /*MAGEANGL*/
}
/*-> one degree more of current bondrotation*/ /*970917*/
if(keysym==RARROW)
{
grafbondrotarrow(+1.0); /*MAGEANGL*/
}
if(keysym==DARROW && LbondrotHplot && LbondrotVplot)
{
dobondrotplotter(); /*MAGEANGL*/
}
if(keysym==UARROW && LbondrotHplot && LbondrotVplot)
{
dobondrotgrapher(); /*MAGEANGL*/
if(Lsocketout && Lsocketidsearch)
{
Lsocketoutactive = 1;
Lsocketoutgrapher = 1;
}
#ifdef TRYFORTHIRD
if(Lsocketoutextra && Lsocketidsearch)
{
Lsocketoutextraactive = 1;
Lsocketoutextragrapher = 1;
}
#endif
}
if(keysym==UARROW && NDIM>0) /*121208*/
{
dobondrotgrapherNDIMsuitefit(); /*MAGEANGL 121208,130116*/
}
}
}
break;
}
}
/*___keypresseventhandler()__________________________________________________*/
/****textcursor_CB()**********************************************************/
XtCallbackProc textcursor_CB(Widget w,XtPointer client_data,XtPointer call_data)
{
XmTextPosition textplace;
XmTextVerifyCallbackStruct *cbs =
(XmTextVerifyCallbackStruct *)call_data;
textplace = cbs->newInsert;
/*this is the index into the text buffer, hypertext?? */
DotextContentClick(textplace);
return(NULL);
}
/*___textcursor_CB()_________________________________________________________*/
/****captcursor_CB()**********************************************************/
XtCallbackProc captcursor_CB(Widget w,XtPointer client_data,XtPointer call_data)
{
XmTextPosition captplace;
XmTextVerifyCallbackStruct *cbs =
(XmTextVerifyCallbackStruct *)call_data;
captplace = cbs->newInsert;
/*this is the index into the capt buffer, hypercapt?? */
DocaptContentClick(captplace);
return(NULL);
}
/*___captcursor_CB()_________________________________________________________*/
/****pick_CB()****************************************************************/
XtCallbackProc pick_CB(Widget drawArea,caddr_t client_data,
XmDrawingAreaCallbackStruct *call_data)
{
/*equivalent to MPCMAIN/WMLButtonDown(), MACMAIN/DografContentClick() */
/*static int oldx,oldy;*/
/*Window *root, *child;*/
/*int *root_x,*root_y,*child_x,child_y;*/
/*unsigned int keys_buttons;*/
/*XEvent *report;*/
/*int idelx,idely;*/
int Nblank = 0; /*000410*/
XButtonPressedEvent *bpress = (XButtonPressedEvent *) call_data->event;
/*XPointerMovedEvent *mousemove = (XPointerMovedEvent *) call_data->event;*/
if (call_data->reason == XmCR_INPUT)
{/*call_data->reason == XmCR_INPUT*/
switch (call_data->event->type)
{/*switch call_data->event->type*/
case ButtonPress:
if(Lmickeymouserun)
{
Lpausemickeymouse=1;
if(Lautorock)
{/*reset current rotation matrix to current rocked state*/
a11 = r11; a12 = r12; a13 = r13;
a21 = r21; a22 = r22; a23 = r23;
a31 = r31; a32 = r32; a33 = r33;
Lnewrock = 1; /*autorock to restart smoothly from mouse setting*/
}
}
if (bpress->button == Button1)
{/*Button1*/
LmouseLdown = 1; /*so, for instance, Levelofdetail could be invoked*/
LmouseRdown = 0;
#ifdef UNIX_PEX
doxpick(call_data->window, bpress->x, bpress->y); /*MUXPHIG.c*/
#else /*NOT UNIX_PEX*/
/*updateratelimit = 10.0; */
/* updates per sec, default in MAGEINIT*/
updaterate = updateratelimit;
/*set rate so starts with a full update*/
/*and thus can evaluate what the */
/*full detail update rate really is */
fullupdaterate = updaterate;
ncountticks=theclocktickcount();/*___MAIN.C*/
mousex = bpress->x;
mousexold = bpress->x;
mousey = bpress->y;
mouseyold = bpress->y;
if( mousey > (GHEIGHT/6) ) { irotxy = 1; }
else { irotxy = 0; }
if(Lflat)
{/*flatland scrolling*/
makecursorflatland();
/*irotxy = 1; 030205 */
}
else
{/*3D rotations*/
if(irotxy==1) makecursorxyrot(); /*___MAIN.C*/
else makecursorzrot(); /*___MAIN.C*/
}
ipick = 2; /*flag for pick point recognition for button press*/
pickx = mousex;
picky = mousey;
/*flag nothing picked yet */
Lpick = 0;
Lpicknow = 0;
if(Ldraglineon || (Lnewlabelson&&!Ltestmode) /*991130*/
|| (Lnewballson&&!Ltestmode)) /*031127*/
{
Lnewdrag = 1;
Lnewmatrix = 1;
}
redrawvec();
Lcarry = 1;
totalrunticks = (theclocktickcount() - ncountticks); /*960809*/
if(totalrunticks != 0)
updaterate = (float)60/(float)totalrunticks;
else updaterate = 999;
if(Ldetail==1) fullupdaterate = updaterate;
while(Lpicknow) /*990211*/
{/*while Lpicknow*/
if(Ltablepickactive && Ltablegraphpicked) /*000327*/
{/*find corresponding cell in table to graphics picked point*/
getptIDstring(search1str, pickedpointptr);/*MAGELIST*/
for(isearch1=0;isearch1<256;isearch1++)
{
if(search1str[isearch1]==' ') Nblank++; /*000410*/
if(search1str[isearch1]=='\0') break;
}/*isearch1 is size of pointID str*/
if(isearch1 == Nblank) isearch1 = 0; /*000410*/
isearch2 = 0;
if(isearch1 > 0) /*000410*/
{
searchtablecells(0); /*MAGETABL.c: 0 == match {ptID}*/
Ltablegraphpicked = 0;
/*avoid coordinate matching in drawtable()*/
redrawtable();/*000324*/
removetablemarkpoints();
markfromtablecellsID(1);
/*MAGETABL.c flag==1 for ptID matching*/
}
}/*find corresponding cell in table to graphics picked point*/
Lpicknow = 0;
/* passes state between here and drawvec()*/
if(Lsuperpunchon) ipick = 2; /*990211*/
/*ipick==2 allows picking, so Lpicknow could become ==1 */
if(Lpickcenteron && Lztran)/*Lmouse ztran w Lpickcenteron 030709*/
{/*pickcenter so rezero ztran*/
iztran = 0;
resetgrafztranBar(iztran);
}
redrawvec(); /*MACDRAW.C*/
/*to move marker to picked atom if any near */
}/*while Lpicknow*/
/*if(Ltablepickactive && Ltablegraphpicked) redrawtable();*/ /*000324*/
mouseticks=theclocktickcount();/*____MAIN.C*/
/*set reference for timing mouse induced movements*/
#endif /*if---else NOT UNIX_PEX*/
if(Lpick)
{/*a pick is currently active*/
/*entered twice when last pick done for construction*/
if(Lconstruct4on && Lpoint==4)
{/*ACTIVE_DLOG filter protects dialog box creation*/
DoconstructDialog(); /*MUX_DLOG.c*/
/*this doesn't seem to need redrawvec() here ! */
/*141126 needed it at end of construct_OK_CB for years! */
}
else if(Lconstruct5on && Lpoint==5)
{
DoConstructFifthDialog(); /*MAGEDLOG.c*/
}
else if(Lconstruct6on && Lpoint==7)
{
DoConstructSixthDialog(); /*140912 MAGEDLOG.c*/
}
if(Lpickcoloron) DocolorshowDialog(); /*___DLOG.C*/
if(Lpickshowon) DopickshowDialog(); /*___DLOG.C*/
if(Lmovepointson) DopickpointsDialog(); /*___DLOG.C 061129*/
if(Lmeansigmason) DopickpointsDialog(); /*___DLOG.C 061129*/
if(Lsocketout)
{
Lsocketoutactive = 1;
if(Lsocketidsearch)
{
Lsocketoutidsearch = 1;
}
else if(Lpickcenteron)
{
Lsocketoutcenter = 1;
}
else
{
Lsocketoutpick = 1;
}
}
}/*a pick is currently active*/
break;
}/*Button1*/
else if (bpress->button == Button3)
{/*Button3 Right Button pickcenter*/
mousex = bpress->x; /*030405 any mouse button can reset these*/
mousexold = bpress->x; /*030405 any mouse button can reset these*/
mousey = bpress->y; /*030405 any mouse button can reset these*/
mouseyold = bpress->y; /*030405 any mouse button can reset these*/
LmouseRdown = 1;
LmouseLdown = 0;
Lpickcenteron = 1; /*forced for Right Button 030205*/
ipick = 2; /*flag for pick point recognition for button press*/
pickx = bpress->x;
picky = bpress->y;
/*flag nothing picked yet */
Lpick = 0;
Lpicknow = 0;
redrawvec();
if(Lpicknow) /*did a pick! */
{/*if Lpicknow*/
Lpick = 1; /*consistent w PC, but is this needed????*/
Lpicknow = 0;
if(Lztran && iztran != 0) /*Rmouse==pickcenter so rezero ztran*/
{
iztran = 0;
resetgrafztranBar(iztran);
redrawvec();
}
}/*if Lpicknow*/
if(Lpick)
{/*a pick is currently active*/
if(Lsocketout && !Lsocketidsearch)
{
Lsocketoutactive = 1;
Lsocketoutcenter = 1; /*since Lpickcenteron==1*/
}
}/*a pick is currently active*/
}/*Button3 Right Button pickcenter*/
else
{/*some other button pressed*/
;
#ifdef UNIX_PEX
doxprepick(call_data->window, bpress->x, bpress->y);/*MUXPHIG.c*/
#endif /*UNIX_PEX*/
}
break; /*from case ButtonPress */
case ButtonRelease:
if (bpress->button == Button1)
{/*Button1*/
makecursoractive(); /*___MAIN.C*/
Lcarry = 0;
if(LmouseLdown && Lmickeymouserun)
{/*reset current rocked state to current rotation matrix*/
r11 = a11; r12 = a12; r13 = a13;
r21 = a21; r22 = a22; r23 = a23;
r31 = a31; r32 = a32; r33 = a33;
Lnewrock = 1; /*autorock to restart smoothly from mouse setting*/
}
LmouseLdown = 0; /*so Levelofdetail not be invoked*/
if(Ldetail==0)
{
redrawvec(); /*restore detail*/
}
#ifdef UNIX_PEX
doxpickpredraw(); /*MUXPHIG.c*/
#endif /*UNIX_PEX*/
if(Lmickeymouserun) {Lpausemickeymouse=0;}
}/*Button1*/
if (bpress->button == Button3)
{/*Button3*/
LmouseRdown = 0;
}/*Button3*/
break; /*from case ButtonRelease*/
}/*switch call_data->event->type*/
}/*call_data->reason == XmCR_INPUT*/
return(NULL);
}
/*___pick_CB()_______________________________________________________________*/
/****fingerplacer()***********************************************************/
void fingerplacer(int irefresh)
{
/*places finger in mage-screen where mouse cursor is in X-window*/
/*put a finger on the local screen as ghost at remote cursor position*/
/*first: copy the offscreen image to the computer screen*/
/*if this is just a cursor motion without a redraw*/
if(irefresh) {copytoscreen();} /*121108 MUXMDRAW.c def in MAGEhdr.h*/
/*then: draw the finger image on top on it*/
XDrawLine( dpy, drawWindow, gc ,mousex,mousey,mousex+20,mousey);
XDrawLine( dpy, drawWindow, gc ,mousex,mousey,mousex+20,mousey+10);
XDrawLine( dpy, drawWindow, gc ,mousex,mousey,mousex+20,mousey-10);
Lfingerin = 0; /*fingerplacer called only when remote sends new fingerx,y*/
}
/*___fingerplacer()__________________________________________________________*/
/****motion_handler***********************************************************/
/*void motion_handler(Widget widget,caddr_t client_data,XEvent *event,Boolean *continue_to_dispatch)*/
void motion_handler(widget, client_data, event)
Widget widget;
caddr_t client_data;
register XPointerMovedEvent *event; /*Xlib.h*/ /*Vol 4, 218*/
/* Boolean *continue_to_dispatch; */
/*equivalent to MPCMAIN/WMMouseMove(), MACDRAW/Drawgraf( internal loop ) */
{
int idelx,idely;
long temptimeticks=0;
mousex = event->x;
mousey = event->y;
if(XtAppPending(app_context) == 0)
{/*no pending events*/ /*so caught up to latest mouse movement*/
if(!LmouseLdown)
{/*e.g. ctrl-down blocks mousedown signel but allows mouseup signel*/
mousexold = mousex;
mouseyold = mousey;
LmouseLdown = 1; /*should be only time when motion event possible*/
LmouseRdown = 0;
if( mousey > (GHEIGHT/6) ) { irotxy = 1; }
else { irotxy = 0; }
}
idelx = (mousex - mousexold);
idely = (mousey - mouseyold);
if(idelx!=0 || idely!=0)
{/*mouse has moved*/
mousexold = mousex;
mouseyold = mousey;
pickx = mousex; /*dragline needs this updated*/
picky = mousey;
if(LNDparallelaxes) /*subvert mouse drag for paraAX space 061117*/
{
paraAXtranx = paraAXtranx + idelx;
paraAXtrany = paraAXtrany + idely;
}
else
{/*regular moves in 3D space*/
/*labels can be dragged */ /*991130*/ /*but not in test mode*/
/*balls can be dragged 031127 like labels*/