-
Notifications
You must be signed in to change notification settings - Fork 2
/
sseqdrawing.code.tex
1459 lines (1378 loc) · 56 KB
/
sseqdrawing.code.tex
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
%%
%% Package: spectralsequences v1.2.0 2017-09-16 2017-09-16
%% Author: Hood Chatham
%% Email: [email protected]
%% Date: 2017-12-10
%% License: Latex Project Public License
%%
%% File: sseqdrawing.code.tex
%%
%% Defines the macros that draw the features of the spectral sequence (at least, those that aren't drawn by tikz).
%% Everything here has to be super optimized, because like 90% of the execution time is in these functions.
%% In particular, tikz is a horrible performance hole that must be avoided at all costs. For example, the code
%% the code to produce the axis ticks used to use the tikz \node command, and in the file example_KF3n.tex drawing
%% the axes ticks was taking about 1/3 of the compile time (a little under 1s out of a 3.2)
%%
% Only for integer valued coordinates...
\def\sseq@qpointxy#1#2{\pgfqpointxy{\numexpr#1+\sseq@xoffset\relax}{\numexpr#2+\sseq@yoffset\relax}}
\def\sseq@transform@xymirror{
\pgfsetxvec{\pgfqpoint{1cm}{0cm}}
\pgfsetyvec{\pgfqpoint{0cm}{1cm}}
\pgftransformcm{0}{1}{1}{0}{\pgfpointxy{\sseq@xoffset*\sseq@xscale }{\sseq@yoffset*\sseq@yscale}} % Reflect x and y axes,
\pgftransformshift{\pgfpointxy{-\sseq@xoffset*\sseq@yscale}{-\sseq@yoffset*\sseq@xscale}} % but we need to conjugate by a shift of (xoffset,yoffset)
\pgfsetyvec{\pgfqpoint{0cm}{\sseq@xscale cm}}
\pgfsetxvec{\pgfqpoint{\sseq@yscale cm}{0cm}}
}
\def\sseq@setlayoutparameter#1#2{\@xp\let\csname sseq@#1\@xp\endcsname\csname sseq@#1@#2\endcsname}
\def\sseq@setlayoutparameters{
\sseq@setlayoutparameter{yaxisorigin}{x\sseq@xaxistype}
\sseq@setlayoutparameter{drawyaxis}{x\sseq@xaxistype}
\sseq@setlayoutparameter{yaxisstartoffset}{x\sseq@xaxistype}
\sseq@setlayoutparameter{yaxisendoffset}{x\sseq@xaxistype}
\sseq@setlayoutparameter{bottomgridpadding}{x\sseq@xaxistype}
\sseq@setlayoutparameter{topgridpadding}{x\sseq@xaxistype}
\sseq@setlayoutparameter{bottomclippadding}{x\sseq@xaxistype}
\sseq@setlayoutparameter{topclippadding}{x\sseq@xaxistype}
\sseq@setlayoutparameter{xlabelposition}{x\sseq@xaxistype}
%
\sseq@setlayoutparameter{xaxisorigin}{y\sseq@yaxistype}
\sseq@setlayoutparameter{drawxaxis}{y\sseq@xaxistype}
\sseq@setlayoutparameter{xaxisstartoffset}{y\sseq@yaxistype}
\sseq@setlayoutparameter{xaxisendoffset}{y\sseq@yaxistype}
\sseq@setlayoutparameter{leftgridpadding}{y\sseq@yaxistype}
\sseq@setlayoutparameter{rightgridpadding}{y\sseq@yaxistype}
\sseq@setlayoutparameter{leftclippadding}{y\sseq@yaxistype}
\sseq@setlayoutparameter{rightclippadding}{y\sseq@yaxistype}
\sseq@setlayoutparameter{ylabelposition}{y\sseq@xaxistype}
}
% The appropriate one of these is chosen by the "axis type" keys in sseqkeys.
% Used to determine axis and ticks placement
\def\sseq@xaxisorigin@yborder{\sseq@xmin}
\def\sseq@xaxisorigin@yframe{\sseq@xmin}
\def\sseq@xaxisorigin@ycenter{\sseq@xaxisorigin@center@}
\def\sseq@yaxisorigin@xborder{\sseq@ymin}
\def\sseq@yaxisorigin@xframe{\sseq@ymin}
\def\sseq@yaxisorigin@xcenter{\sseq@yaxisorigin@center@}
% Used to determine clipping and grid boundaries
\def\sseq@leftgridpadding@yborder{\dimexpr\sseq@yaxisgap-\sseq@yclip@axisgap\relax}
\def\sseq@rightgridpadding@yborder{\sseq@xaxis@end@extend}
\def\sseq@leftgridpadding@ycenter{\sseq@xaxis@start@extend}
\def\sseq@rightgridpadding@ycenter{\sseq@xaxis@end@extend}
\def\sseq@leftgridpadding@yframe{\dimexpr\sseq@yaxisgap-\sseq@yclip@axisgap\relax}
\def\sseq@rightgridpadding@yframe{5cm} % Just make it big enough to push off the end of the clip
\def\sseq@leftgridpadding@ynone{\sseq@yaxisgap}
\def\sseq@rightgridpadding@ynone{\sseq@yaxisgap}
\def\sseq@bottomgridpadding@xborder{\dimexpr\sseq@xaxisgap-\sseq@xclip@axisgap\relax}
\def\sseq@topgridpadding@xborder{\sseq@yaxis@end@extend}
\def\sseq@bottomgridpadding@xcenter{\sseq@yaxis@start@extend}
\def\sseq@topgridpadding@xcenter{\sseq@yaxis@end@extend}
\def\sseq@bottomgridpadding@xframe{\dimexpr\sseq@xaxisgap-\sseq@xclip@axisgap\relax}
\def\sseq@topgridpadding@xframe{5cm}
\def\sseq@bottomgridpadding@xnone{\sseqxaxisgap}
\def\sseq@topgridpadding@xnone{\sseq@xaxisgap}
\def\sseq@leftclippadding@yborder{\dimexpr-\sseq@yaxisgap+\sseq@yclip@axisgap\relax}
\def\sseq@rightclippadding@yborder{\dimexpr\sseq@xaxis@end@extend+\sseq@clip@padding@right\relax}
\def\sseq@leftclippadding@ycenter{\dimexpr-\sseq@xaxis@start@extend-\sseq@clip@padding@left\relax}
\def\sseq@rightclippadding@ycenter{\dimexpr\sseq@xaxis@end@extend+\sseq@clip@padding@right\relax}
\def\sseq@leftclippadding@yframe{\dimexpr-\sseq@yaxisgap+\sseq@yclip@axisgap\relax}
\def\sseq@rightclippadding@yframe{\dimexpr\sseq@yaxisgap-\sseq@yclip@axisgap\relax}
\def\sseq@leftclippadding@ynone{\dimexpr-\sseq@yaxisgap-\sseq@clip@padding@left\relax}
\def\sseq@rightclippadding@ynone{\dimexpr\sseq@yaxisgap+\sseq@clip@padding@right\relax}
\def\sseq@bottomclippadding@xborder{\dimexpr-\sseq@xaxisgap+\sseq@xclip@axisgap\relax}
\def\sseq@topclippadding@xborder{\dimexpr\sseq@yaxis@end@extend+\sseq@clip@padding@top\relax}
\def\sseq@bottomclippadding@xcenter{\dimexpr-\sseq@yaxis@start@extend-\sseq@clip@padding@bottom\relax}
\def\sseq@topclippadding@xcenter{\dimexpr\sseq@yaxis@end@extend+\sseq@clip@padding@top\relax}
\def\sseq@bottomclippadding@xframe{\dimexpr-\sseq@xaxisgap+\sseq@xclip@axisgap\relax}
\def\sseq@topclippadding@xframe{\dimexpr\sseq@xaxisgap-\sseq@xclip@axisgap\relax}
\def\sseq@bottomclippadding@xnone{\dimexpr-\sseq@xaxisgap-\sseq@clip@padding@bottom\relax}
\def\sseq@topclippadding@xnone{\dimexpr\sseq@xaxisgap+\sseq@clip@padding@top\relax}
% Used to figure out how much further beyond (min -- max) to draw axes
\def\sseq@xaxisstartoffset@yborder{\dimexpr\sseq@xaxis@tail+\sseq@yaxisgap\relax}
\def\sseq@xaxisendoffset@yborder{\sseq@xaxis@end@extend}
\def\sseq@xaxisstartoffset@ycenter{\sseq@xaxis@start@extend}
\def\sseq@xaxisendoffset@ycenter{\sseq@xaxis@end@extend}
\def\sseq@xaxisstartoffset@yframe{\sseq@yaxisgap}
\def\sseq@xaxisendoffset@yframe{\sseq@yaxisgap}
\def\sseq@yaxisstartoffset@xborder{\dimexpr\sseq@yaxis@tail+\sseq@xaxisgap\relax}
\def\sseq@yaxisendoffset@xborder{\sseq@yaxis@end@extend}
\def\sseq@yaxisstartoffset@xcenter{\sseq@yaxis@start@extend}
\def\sseq@yaxisendoffset@xcenter{\sseq@yaxis@end@extend}
\def\sseq@yaxisstartoffset@xframe{\sseq@xaxisgap}
\def\sseq@yaxisendoffset@xframe{\sseq@xaxisgap}
\def\sseq@xlabelposition@xborder{(0,-\sseq@xaxisstartoffset)}
\def\sseq@xlabelposition@xcenter{(-\sseq@yaxisgap,-\sseq@xaxisstartoffset-5pt)}
\def\sseq@xlabelposition@xframe{(0,-\sseq@xaxisgap-\sseq@xlabelgap-10pt)}
\def\sseq@xlabelposition@xnone{(0,0)}
\def\sseq@ylabelposition@yborder{(0,\sseq@yaxisstartoffset)}
\def\sseq@ylabelposition@ycenter{(-\sseq@xaxisgap,\sseq@yaxisstartoffset+5pt)}
\def\sseq@ylabelposition@yframe{(0,\sseq@yaxisgap+\sseq@ylabelgap+10pt)}
\def\sseq@ylabelposition@ynone{(0,0)}
%%%
%%% Draw axes and clip
%%%
\def\sseq@handlexaxis{
\bgroup
\sseq@drawxaxis
\ifsseq@drawxaxisticks
\sseq@drawxticks
\fi
\egroup
}
\def\sseq@handleyaxis{
\bgroup
\sseq@drawyaxis
\ifsseq@drawyaxisticks
\sseq@drawyticks
\fi
\egroup
}
% Draws an x axis. Use with \sseq@transform@xymirror to draw y axis.
% #1 -- horizontal start offset
% #2 -- horizontal end offset
% #3 -- vertical offset
% #4 -- start value
% #5 -- end value
% #6 -- vertical value
\def\sseq@drawaxis@generic#1#2#3#4#5#6{
\bgroup
\pgftransformshift{\pgfqpoint{#2}{#3}}
\pgfpathmoveto{\sseq@qpointxy{#5}{#6}}
\egroup
%
\bgroup
\pgftransformshift{\pgfqpoint{#1}{#3}}
\pgfpathlineto{\sseq@qpointxy{#4}{#6}}
\egroup
}
\def\sseq@drawxaxis@ynone{
\sseq@drawxaxisticksfalse
}
\def\sseq@drawyaxis@xnone{
\sseq@drawyaxisticksfalse
}
\def\sseq@drawxaxis@yborder{
\sseq@drawaxis@generic{-\sseq@xaxisstartoffset}{\sseq@xaxisendoffset}{-\sseq@xaxisgap}{\sseq@xmin}{\sseq@xmax}{\sseq@yaxisorigin}
\pgfusepath{stroke}
}
\let\sseq@drawxaxis@ycenter\sseq@drawxaxis@yborder
\def\sseq@drawxaxis@yframe{
\sseq@drawaxis@generic{-\sseq@xaxisstartoffset}{\sseq@xaxisendoffset}{-\sseq@xaxisgap}{\sseq@xmin}{\sseq@xmax}{\sseq@ymin}
\sseq@drawaxis@generic{-\sseq@xaxisstartoffset}{\sseq@xaxisendoffset}{ \sseq@xaxisgap}{\sseq@xmin}{\sseq@xmax}{\sseq@ymax}
\pgfusepath{stroke}
}
\def\sseq@drawyaxis@xborder{
\bgroup
\sseq@transform@xymirror
\sseq@drawaxis@generic{-\sseq@yaxisstartoffset}{\sseq@yaxisendoffset}{-\sseq@yaxisgap}{\sseq@ymin}{\sseq@ymax}{\sseq@xaxisorigin}
\pgfusepath{stroke}%
\egroup
}
\let\sseq@drawyaxis@xcenter\sseq@drawyaxis@xborder
\def\sseq@drawyaxis@xframe{
\bgroup
\sseq@transform@xymirror
\sseq@drawaxis@generic{-\sseq@yaxisstartoffset}{\sseq@yaxisendoffset}{-\sseq@yaxisgap}{\sseq@ymin}{\sseq@ymax}{\sseq@xmin}
\sseq@drawaxis@generic{-\sseq@yaxisstartoffset}{\sseq@yaxisendoffset}{ \sseq@yaxisgap}{\sseq@ymin}{\sseq@ymax}{\sseq@xmax}
\pgfusepath{stroke}%
\egroup
}
\ExplSyntaxOn
\def\sseq@intdivceiling#1#2{%
\ifnum#1>\z@ % \int_div_truncate:nn rounds towards 0. We want \int_div_ceiling
\int_div_truncate:nn{#1+#2-1}{#2} % if positive, use ceil(p/q)=floor((p+q-1)/q) for p,q integers
\else
\int_div_truncate:nn{#1}{#2} % if we are negative, towards 0 is ceiling
\fi
}
\def\sseq@intdivfloor#1#2{%
\ifnum#1<\z@ % \int_div_truncate:nn rounds towards 0. We want \int_div_floor
\int_div_truncate:nn{#1-#2+1}{#2} % if we are negative, use floor(p/q) = ceil(p-q+1/q) for p,q integers
\else
\int_div_truncate:nn{#1}{#2} % if positive, towards 0 is floor
\fi
}
\ExplSyntaxOff
% #1 -- xmin
% #2 -- xmax
% #3 -- step
% #4 -- offset
% #5 -- ymin
% #6 -- xaxisgap
% #7 -- code
\def\sseq@tickloop@generic#1#2#3#4#5#6#7{
\sseq@tempx=\numexpr % min
\sseq@intdivceiling{#1}{#3} * #3
-
\sseq@intdivceiling{#4}{#3} * #3 + #4
\relax
\ifnum\sseq@tempx<#1\relax
\advance\sseq@tempx#3\relax
\fi
\sseq@tempxb=\numexpr#2+1\relax % max
\loop
\bgroup
\pgftransformshift{\sseq@qpointxy{\sseq@tempx}{#5}}%
\pgftransformshift{\pgfqpoint{0pt}{#6}}
#7
\egroup
\advance\sseq@tempx#3\relax
\ifnum\sseq@tempx<\sseq@tempxb\repeat
}
\def\sseq@drawxticks{%
\sseq@tickloop@generic{\sseq@xmin}{\sseq@xmax}{\sseq@xtickstep}{\sseq@xtickstepoffset}{\sseq@yaxisorigin}{-\sseq@xaxisgap}{
\pgftransformshift{\pgfqpoint{0pt}{-\sseq@xlabelgap}}
\pgftransformresetnontranslations
%\@xp\tikzset\@xp{\sseq@xtickstyle}
%\pgftext{\tikz@options\tikz@textfont\hbox{$\sseq@xtickfn{\the\sseq@tempx}$}}%
\@xp\node\@xp[\sseq@xtickstyle]{\hbox{$\sseq@xtickfn{\the\sseq@tempx}$}};
}
\ifnum\sseq@xmajortickstep>\z@
\sseq@tickloop@generic{\sseq@xmin}{\sseq@xmax}{\sseq@xmajortickstep}{\sseq@xtickstepoffset}{\sseq@yaxisorigin}{-\sseq@xaxisgap}{
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{-0.4*\sseq@xaxisgap}}
}
\fi
\ifnum\sseq@xminortickstep>\z@
\sseq@tickloop@generic{\sseq@xmin}{\sseq@xmax}{\sseq@xminortickstep}{\sseq@xtickstepoffset}{\sseq@yaxisorigin}{-\sseq@xaxisgap}{
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{-0.2*\sseq@xaxisgap}}
}
\fi
\pgfusepath{stroke}
}
\def\sseq@drawyticks{%
\sseq@transform@xymirror
\sseq@tickloop@generic{\sseq@ymin}{\sseq@ymax}{\sseq@ytickstep}{\sseq@ytickstepoffset}{\sseq@xaxisorigin}{-\sseq@yaxisgap}{
\pgftransformshift{\pgfqpoint{0pt}{-\sseq@ylabelgap}}
\pgftransformresetnontranslations
%\@xp\tikzset\@xp{\sseq@ytickstyle}
%\pgftext{\tikz@options\tikz@textfont\hbox{$\sseq@ytickfn{\the\sseq@tempx}$}}%
\@xp\node\@xp[\sseq@ytickstyle]{\hbox{$\sseq@ytickfn{\the\sseq@tempy}$}};
}
\ifnum\sseq@ymajortickstep>\z@
\sseq@tickloop@generic{\sseq@ymin}{\sseq@ymax}{\sseq@ymajortickstep}{\sseq@ytickstepoffset}{\sseq@xaxisorigin}{-\sseq@yaxisgap}{
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{-0.4*\sseq@yaxisgap}}
}
\fi
\ifnum\sseq@yminortickstep>\z@
\sseq@tickloop@generic{\sseq@ymin}{\sseq@ymax}{\sseq@yminortickstep}{\sseq@ytickstepoffset}{\sseq@xaxisorigin}{-\sseq@yaxisgap}{
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{0}{-0.2*\sseq@yaxisgap}}
}
\fi
\pgfusepath{stroke}
}
\def\sseq@setupclip{
%\clip(\[email protected],\[email protected]) rectangle (\sseq@xmax+0.5,\sseq@ymax+0.5);%
\ifsseq@clip
\ifx\sseq@customclip\pgfutil@empty
\bgroup
\def\xmin{\pgftransformshift{\pgfqpoint{\sseq@leftclippadding}{0pt}}}
\def\ymin{\pgftransformshift{\pgfqpoint{0pt}{\sseq@bottomclippadding}}}
\def\xmax{\pgftransformshift{\pgfqpoint{\sseq@rightclippadding}{0pt}}}
\def\ymax{\pgftransformshift{\pgfqpoint{0pt}{\sseq@topclippadding}}}
\bgroup
\xmin\ymin
\pgfpathmoveto{\pgfqpointxy{\numexpr\sseq@xmin+\sseq@xoffset\relax}{\numexpr\sseq@ymin+\sseq@yoffset\relax}}
\egroup
\bgroup
\xmin\ymax
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmin+\sseq@xoffset\relax}{\numexpr\sseq@ymax+\sseq@yoffset\relax}}
\egroup
\bgroup
\xmax\ymax
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmax+\sseq@xoffset\relax}{\numexpr\sseq@ymax+\sseq@yoffset\relax}}
\egroup
\bgroup
\xmax\ymin
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmax+\sseq@xoffset\relax}{\numexpr\sseq@ymin+\sseq@yoffset\relax}}
\egroup
\egroup
\pgfpathclose
\pgfgetpath\sseq@theclippath % This stores the clipping so I can apply it later
\pgfusepath{discard}% This has to be after the egroup or else the clipping gets screwed up
%
\bgroup
\pgfpathmoveto{\pgfqpointxy{\numexpr\sseq@xmin+\sseq@xoffset\relax}{\numexpr\sseq@ymin+\sseq@yoffset\relax}}
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmin+\sseq@xoffset\relax}{\numexpr\sseq@ymax+\sseq@yoffset\relax}}
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmax+\sseq@xoffset\relax}{\numexpr\sseq@ymax+\sseq@yoffset\relax}}
\pgfpathlineto{\pgfqpointxy{\numexpr\sseq@xmax+\sseq@xoffset\relax}{\numexpr\sseq@ymin+\sseq@yoffset\relax}}
\pgfpathclose
\egroup
\pgfgetpath\sseq@therangepath % Only for deciding whether to draw "tricky edges"
\pgfusepath{discard}
\else
\def\sseq@temp{\path[name path=temp]}
\@xptwo\sseq@temp\@xp\@gobble\sseq@customclip
\pgfgetpath\sseq@theclippath
\let\sseq@theclippath\tikz@intersect@path@name@temp
\fi
\else
\let\sseq@theclippath\relax
\fi
}
\def\sseq@useclip{\ifx\sseq@theclippath\relax\else\pgfsetpath\sseq@theclippath\pgfusepath{clip}\fi}
% sets \pgf@xa and \pgf@ya equal to the coordinates of (1,1), sets \pgf@xb and \pgf@xb equal to (x grid step, y grid step)
\def\sseq@grid@setstepandgridstep{
\pgf@process{\pgfqpointxy{1}{1}}
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\pgf@process{\pgfqpointxy{\sseq@xgridstep}{\sseq@ygridstep}}
\pgf@xb=\pgf@x
\pgf@yb=\pgf@y
}
% #1 -- macro to store result in
% #2 -- "x" or "y" as appropriate
% #3 -- length (with units)
% #4 -- fraction of gridstep
% If #2 is x, then it either sets #1 to #3/(x scale) or xgridstep*#4, whichever is smaller
% The output is intended for use with \pgfpointxy.
\def\sseq@grid@atmostgridstep#1#2#3#4{
\ifdim#3<\dimexpr\csname pgf@#2b\endcsname*#4\relax
\pgfmathparse{#3/\csname pgf@#2a\endcsname}
\let#1\pgfmathresult
\else
\edef#1{\csname sseq@#2gridstep\endcsname*#4}
\fi
}
% This grid was a huge pain in the ass to get right...
\def\sseq@grid@chess{
\bgroup
\pgfscope
% Pad on the right and top by either the grid padding, or the remaining piece of the checkerboard before it would start a new square
% (it looks ugly to have a tiny sliver). Annoyingly, mod returns its result with the same sign as its input, so in order to reduce mod
% \sseq@xgridstep and get a positive result, we have to do it twice. The 0.5cm*scale here matches the -0.5 in the \pgfpathgrid call.
\pgfmathsetmacro\sseq@rightpadding{min(
\sseq@rightgridpadding,
1cm* mod(mod(-\sseq@xmax,\sseq@xgridstep)+\sseq@xgridstep,\sseq@xgridstep)+0.5cm*\[email protected]
)}
\pgfmathsetmacro\sseq@toppadding{min(
\sseq@topgridpadding,
1cm * mod(mod(-\sseq@ymax,\sseq@ygridstep)+\sseq@ygridstep,\sseq@ygridstep)+0.5cm*\[email protected]
)}
% Because of complicated aliasing issues that arise when misusing the \pgfgrid command in this way,
% it's more convenient to add a clip than to actually stop things in the right place.
\clip (\sseq@xmin-\sseq@xoffset,\sseq@ymin-\sseq@yoffset) ++ (-0.48, -0.48)
rectangle ([shift={(\sseq@rightpadding pt,\sseq@toppadding pt)}]\sseq@xmax,\sseq@ymax);
%
\sseq@useclip
\pgfsetcolor{\sseq@gridcolor}
\pgfsetstrokeopacity{0.3} % We don't set low opacity for the other grids, but this one is visible even if it is very faint.
\sseq@grid@setstepandgridstep
%
% Use ifdim with cm to compare real scalars b/c tex is dumb.
% okay, now we need to be careful in order to avoid overflows. The hack we are using requires that the xvec and the yvec are equal
% because we can't apply these via lowlevelsynccm. However, xvec and yvec are the things that prevent overflows.
% What we need to do is set them both equal to the smaller value. Now the scale factor determines the size of the squares,
% so we mix in the grid steps. We also need to scale the larger scaled coordinate by the ratio of the two scales.
\ifdim\sseq@xscale cm<\sseq@yscale cm\relax
% x is smaller so set both x and y vecs to \sseq@xscale cm.
\pgfsetxvec{\pgfpoint{\sseq@xscale cm}{0cm}}
\pgfsetyvec{\pgfpoint{0cm}{\sseq@xscale cm}}
\def\sseq@xadjustscale{\sseq@xgridstep}
\def\sseq@yadjustscale{\sseq@yscale/\sseq@xscale*\sseq@ygridstep}
\def\sseq@stepscale{\sseq@xscale}
\else
\pgfsetxvec{\pgfpoint{\sseq@yscale cm}{0cm}}
\pgfsetyvec{\pgfpoint{0cm}{\sseq@yscale cm}}
\def\sseq@xadjustscale{(\sseq@xscale/\sseq@yscale*\sseq@xgridstep)}
\def\sseq@yadjustscale{\sseq@ygridstep}
\def\sseq@stepscale{\sseq@yscale}
\fi
\pgftransformxscale{\sseq@xadjustscale}
\pgftransformyscale{\sseq@yadjustscale}
% Now we have to put in some ridiculously complicated shift in order to get the bottom corner in the right place.
% I found this formula mostly by trial and error.
% The basic idea that we should be making something divisible by twice the grid step (which is the actual period of our grid)
% is reasonable enough, but what the heck are these other two terms for? I don't know either, thank god it works.
\pgftransformshift{\pgfpointxy{
floor((\sseq@xgridstep-1)/2)/\sseq@xgridstep
+ \ifodd\sseq@xgridstep\space 0 \else 0.5/\sseq@xgridstep\fi
+ mod(1+\sseq@xmin/\sseq@xgridstep,2*\sseq@xgridstep)
}{
floor((\sseq@ygridstep-1)/2)/\sseq@ygridstep
+ \ifodd\sseq@ygridstep\space 0\else 0.5/\sseq@ygridstep\fi
+ mod(1+\sseq@ymin/\sseq@ygridstep,2*\sseq@ygridstep)
}
}
% We use lowlevelsynccm to make the scale adjust the line width. Normally scaling doesn't affect line width, text size, etc, which is sensible.
% When you apply \pgflowlevelsynccm, pgf loses track of the coordinate matrix and it gets indiscriminately applied to everything.
% This is good for us, because we're doing this absurd thing where we make a checkerboard by drawing a really really fat line.
\pgflowlevelsynccm
\pgfsetlinewidth{1cm*\sseq@stepscale}
\pgfsetdash{{1cm*\sseq@stepscale}{1cm*\sseq@stepscale}}{1cm*\sseq@stepscale}
%
% Naturally some trial and error occurred here too.
% Note the huge multiples of \sseq@xgridstep I added in -- they probably aren't necessary, but I don't understand what's going on so whatever.
% The basic idea is that things need to be divisible by twice the grid step. The part I added in the shift above
% was the remainder when you divide \sseq@xmin by twice the grid step, now we need to add in the multiple of twice the grid step.
% The -0.5 is ensuring that the checkerboard boundaries lie at half-integer coordinates (I think).
\pgfpathgrid[stepx= 2cm*\sseq@stepscale,stepy=2cm*\sseq@stepscale]
{ \pgfpointxy
{ -0.5 + \sseq@intdivfloor{\numexpr\sseq@xmin - \sseq@xgridstep\relax}{2*\sseq@xgridstep}*2*\sseq@xgridstep + \sseq@xoffset - 50*\sseq@xgridstep }
{ -0.5 + \sseq@intdivfloor{\numexpr\sseq@ymin - \sseq@ygridstep\relax}{2*\sseq@ygridstep}*2*\sseq@ygridstep + \sseq@yoffset - 50*\sseq@ygridstep}
}{ \pgfpointxy
{ \sseq@xmax + \sseq@xoffset + 50*\sseq@xgridstep }
{ \sseq@ymax + \sseq@yoffset + 50*\sseq@ygridstep }
}
\pgfusepath{stroke}
\endpgfscope
\egroup
}
\def\sseq@grid@crossword{
\bgroup
\pgfscope
\sseq@useclip
\pgfsetcolor{\sseq@gridcolor}
\pgfsetlinewidth{\the\sseq@gridstrokethickness}
\sseq@grid@setstepandgridstep
%
% We don't want the grid to end with an extra line, so extend it by one half the step distance or
% \sseq@---gridpadding, whichever is shorter.
\sseq@grid@atmostgridstep\sseq@xminpadding{x}{\sseq@leftgridpadding}{1/2}
\sseq@grid@atmostgridstep\sseq@xmaxpadding{x}{\sseq@rightgridpadding}{1/2}
\sseq@grid@atmostgridstep\sseq@yminpadding{y}{\sseq@bottomgridpadding}{1/2}
\sseq@grid@atmostgridstep\sseq@ymaxpadding{y}{\sseq@topgridpadding}{1/2}
%
\pgftransformshift{\pgfpointxy{-\sseq@xgridstep/2}{-\sseq@ygridstep/2}}
\pgfpathgrid[stepx=\pgf@xb,stepy=\pgf@yb]
{ \pgfpointxy
{ \sseq@xmin - \sseq@xminpadding + 0.01 + \sseq@xoffset + \sseq@xgridstep/2 }
{ \sseq@ymin - \sseq@yminpadding + 0.01 + \sseq@yoffset + \sseq@ygridstep/2 } }
{ \pgfpointxy
{ \sseq@xmax + \sseq@xmaxpadding - 0.01 + \sseq@xoffset + \sseq@xgridstep/2 }
{ \sseq@ymax + \sseq@ymaxpadding - 0.01 + \sseq@yoffset + \sseq@ygridstep/2 } }
\pgfusepath{stroke}
\endpgfscope
\egroup
}
\def\sseq@grid@go{
\bgroup
\pgfscope
\sseq@useclip
\pgfsetcolor{\sseq@gridcolor}
\pgfsetlinewidth{\the\sseq@gridstrokethickness}
\sseq@grid@setstepandgridstep
%
% We don't want the grid to end with an extra line, so extend it by one step distance or
% \sseq@---gridpadding, whichever is shorter.
\sseq@grid@atmostgridstep\sseq@xminpadding{x}{\sseq@leftgridpadding}{1}
\sseq@grid@atmostgridstep\sseq@xmaxpadding{x}{\sseq@rightgridpadding}{1}
\sseq@grid@atmostgridstep\sseq@yminpadding{y}{\sseq@bottomgridpadding}{1}
\sseq@grid@atmostgridstep\sseq@ymaxpadding{y}{\sseq@topgridpadding}{1}
%
\pgfpathgrid[stepx=\pgf@xb,stepy=\pgf@yb]
{ \pgfpointxy
{ \sseq@xmin - \sseq@xminpadding + 0.01 + \sseq@xoffset }
{ \sseq@ymin - \sseq@yminpadding + 0.01 + \sseq@yoffset } }
{ \pgfpointxy
{ \sseq@xmax + \sseq@xmaxpadding - 0.01 + \sseq@xoffset }
{ \sseq@ymax + \sseq@ymaxpadding - 0.01 + \sseq@yoffset }
}
\pgfusepath{stroke}
\endpgfscope
\egroup
}
\def\sseq@grid@none{}
\def\sseq@grid@dots{
\bgroup
\pgfscope
\pgfgettransform\sseq@savetransform
\pgfgettransformentries{\sseq@a}{\sseq@b}{\sseq@c}{\sseq@d}{\sseq@u}{\sseq@v}
\pgfsettransform\sseq@savetransform
\sseq@useclip
\pgftransformshift{\pgfqpoint{-1.5cm}{-0.5cm}}
\pgfsetdash{{1pt}{\sseq@a*1cm-1pt}}{0.5cm+.5pt}
\pgfsetlinewidth{1pt}
\sseq@tempy=\sseq@ymin\relax
\advance\sseq@tempy\m@ne
\loop
\advance\sseq@tempy\@ne
\pgfpathmoveto{\pgfpointxy{\sseq@xmin + 0.5/\sseq@a}{\the\sseq@tempy}}
\pgfpathlineto{\pgfpointxy{\sseq@xmax + 1.01 }{\the\sseq@tempy}}
\ifnum\sseq@tempy<\sseq@ymax\repeat
%\pgfpathgrid[stepx=1cm,stepy=1cm]{\pgfpoint{-0.5cm}{-0.5cm}}{\pgfpoint{\xmax cm-0.5cm}{\ymax cm-0.5cm}}
\pgfusepath{stroke}
\endpgfscope
\egroup
}
%%%
%%% Draw Classes
%%%
%%% Class offsets
\sseqnewclasspattern{standard}{
(0,0);
(-0.13,0)(0.13,0);
(-0.2,0)(0,0)(0.2,0);
(-0.13,-0.13)(0.13,-0.13)(-0.13,0.13)(0.13,0.13);
(-0.16,-0.16)(0.16,-0.16)(-0.16,0.16)(0.16,0.16)(0,0);
(-0.13,-0.2)(-0.13,0)(-0.13,0.2)(0.13,-0.2)(0.13,0)(0.13,0.2);
}
\sseqnewclasspattern{linear}{
(0,0);
(-0.13,0)(0.13,0);
(-0.2,0)(0,0)(0.2,0);
(-0.3,0)(-0.1,0)(0.1,0)(0.3,0);
(-0.4,0)(-0.2,0)(0,0)(0.2,0)(0.4,0);
(-0.5,0)(-0.3,0)(-0.1,0)(0.1,0)(0.3,0)(0.5,0);
}
\def\sseq@offset#1#2{
\sseq@eval{\@nx\pgftransformshift{
\@nx\pgfqpointxy
{ \csname sseq@\sseq@classpattern xoffset#1/#2\endcsname }
{ \csname sseq@\sseq@classpattern yoffset#1/#2\endcsname }
}}
}
\def\sseq@class@getparts#1(#2,#3,#4)[#5].{
\sseq@seterrorannotation@drawing{#1}{#2}{#3}{#4}{#5}
\def\sseq@thisclassname{class.(#2,#3,#4)}
\def\sseq@thisnodename{sseq{#2,#3,#4}}
\def\sseq@thispos{(#2,#3)}
\edef\sseq@thisposnum{\sseq@obj{class.(#2,#3,#4).n}}
\def\sseq@thisclassnum{#5}
\sseq@tempx=#2\relax
\sseq@tempy=#3\relax
}
\def\sseq@tooltip@wrapper#1#2{%
\edef\temp{\detokenize\@xpthree{#2}}%
\edef\temp{\@xp\sseqtooltip@replaceslashes\@xp{\temp}}%
\sseq@eval{\@nx\pdftooltip{\unexpanded{#1}}{\temp}}%
}
\bgroup\lccode`\!=`\\\lowercase{\egroup
\def\sseqtooltip@replaceslashes#1{\sseqtooltip@replaceslashes@#1!\sseq@nil}
\def\sseqtooltip@replaceslashes@#1!#2{%
#1%
\ifx\sseq@nil#2\@xp\@gobble\else
\@nx\@nx\@nx\textbackslash
\@xp\sseqtooltip@replaceslashes@
\fi#2%
}
}
% #1 -- the name of the node object
% Someday I should document this horrible mess of code here
\newif\ifsseq@permanentcycle
\newcount\sseq@totalclassesdrawn
\AtEndDocument{\message{Total classes: \the\sseq@totalclassesdrawn}}
\def\sseq@class@drawnode#1{%
\global\advance\sseq@totalclassesdrawn\@ne
\begingroup
\sseq@class@getparts#1.
\sseq@needstikzfalse
\sseq@options@firstpassmode
\sseq@thesseqstyle
\sseq@theclassstyle
\ifnum\sseq@obj{#1.page}=\sseq@infinitycount
\sseq@thepermanentcyclestyle
\else
\sseq@thetransientcyclestyle
\ifsseq@thispage
\sseq@thethispagecyclestyle
\fi
\fi
\the\sseq@scope@toks
\sseq@obj{#1.needstikz}
%
\sseq@outofrangetrue\relax % Mysterious that we need this \relax here...
\ifnum\sseq@tempx<\sseq@xmaxpp\relax\ifnum\sseq@tempx>\sseq@xminmm\relax\ifnum\sseq@tempy<\sseq@ymaxpp\relax\ifnum\sseq@tempy>\sseq@yminmm\relax
\sseq@outofrangefalse
\pgfscope
\let\tikz@options\pgfutil@empty
\let\tikz@alias=\pgfutil@empty
\def\pgfkeysdefaultpath{/sseqpages/class/}
\sseq@options@secondpassmode
\sseq@thesseqstyle
\sseq@theclassstyle
\ifnum\sseq@obj{#1.page}=\sseq@infinitycount
\sseq@permanentcycletrue % This is to communicate with family style code...
\sseq@thepermanentcyclestyle
\else
\sseq@permanentcyclefalse
\sseq@thetransientcyclestyle
\ifsseq@thispage
\sseq@thethispagecyclestyle
\fi
\fi
\def\sseq@collections@featuretype{class}
\the\sseq@scope@toks
\sseq@obj{#1.options}
\pgftransformshift{\pgfqpointxy{\numexpr\sseq@tempx +\sseq@xoffset-\sseq@x\relax}{\numexpr\sseq@tempy + \sseq@yoffset-\sseq@y\relax}}
\iftikz@fullytransformed\pgfgettransform{\savetransform}\fi
\pgftransformresetnontranslations
\sseq@globalrotatetransform
\sseq@classplacementtransform
\sseq@obj@ifdef{#1.offset}{\sseq@obj{#1.offset}}{%
\sseq@offset{\sseq@thisposnum}{\sseq@obj{partcoord.\[email protected]}}%
}%
\iftikz@fullytransformed\pgfsettransform{\savetransform}\else\pgftransformresetnontranslations\ifsseq@rotatelabels\sseq@globalrotatetransform\fi\fi
\tikz@options
% the value of \sseq@class@showname comes from styles. If there was a local option with showname, it's stored in #1.showname.
% local value takes priority.
\let\sseq@classlabelnodes\pgfutil@empty
\edef\sseq@classnodetextoptions{\sseq@obj@ifdef{#1.nodetext.options}{\@xptwo\@nx\sseq@obj{#1.nodetext.options}}{}}
\edef\sseq@classnodetext{\sseq@obj@ifdef{#1.nodetext}{\@xptwo\@nx\sseq@obj{#1.nodetext}}{}}
\sseq@obj@ifdef{#1.showname}{\sseq@lettoobj\sseq@class@showname{#1.showname}}{}
\ifcsname sseq@class@showname\endcsname
\sseq@obj@ifdef{#1.name}{
\sseq@eval{\@nx\sseq@handleclassquotes@inner{\sseq@obj{#1.name}}{\sseq@class@showname}}
}{}
\fi
\ifsseq@needstikz
\let\sseq@mode\tikz@mode
\tikzset{every text node part/.code/.expand once={\sseq@globalrotatetransform\sseq@classnodetextoptions{}}}%
\sseq@eval{%
\@nx\node[/utils/exec={\let\@nx\tikz@mode\@nx\sseq@mode},
/handlers/first char syntax/the character "/.initial=\@nx\sseq@handlequote
] (\sseq@thisnodename) {\unexpanded\@xp{\sseq@classnodetext}}
[every text node part/.code={}];
}%
\else
\tikz@node@textfont
\sseq@setnodetext{\sseq@classnodetext}{\sseq@classnodetextoptions}
\let\tikz@fig@name\sseq@thisnodename
\pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{\sseq@drawnode}%
\tikz@alias
\fi
\sseq@obj{#1.labelnodes}
\sseq@classlabelnodes % classlabelnodes comes from show name
\sseq@obj@ifdef{#1.tooltip}{
\pgfpointanchor{\sseq@thisnodename}{west}
\pgf@xa=\pgf@x
\pgfpointanchor{\sseq@thisnodename}{south}
\pgf@ya=\pgf@y
%
\pgf@process{\pgfpointdiff{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{west}}}{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{east}}}}
\pgf@xb=\pgf@x
\pgf@process{\pgfpointdiff{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{south}}}{\pgfpointtransformed{\pgfpointanchor{\sseq@thisnodename}{north}}}}
\pgf@yb=\pgf@y
%
\setbox\tikz@tempbox=\hbox{
\pgfinterruptpicture
\sseqtooltip{\rule{\pgf@xb}{0pt}\rule{0pt}{\pgf@yb}}{\sseq@obj{#1.tooltip}}
\endpgfinterruptpicture
}
{%
\pgftransformshift{\pgfqpoint{\pgf@xa}{\pgf@ya}}%
\pgfapproximatenonlineartransformation%
\pgfqboxsynced{\tikz@tempbox}%
}%
}{}
\endpgfscope
\fi\fi\fi\fi
\ifsseq@outofrange
\sseq@eval{\@nx\pgftransformshift{\@nx\pgfqpointxy{\numexpr\sseq@tempx+\sseq@xoffset-\sseq@x\relax}{\numexpr\sseq@tempy+\sseq@yoffset-\sseq@y\relax}}}%
\pgftransformresetnontranslations
\sseq@globalrotatetransform
\sseq@classplacementtransform
\sseq@offset{\sseq@thisposnum}{\sseq@obj{partcoord.\[email protected]}}
\pgfcoordinate{\sseq@thisnodename}{\pgfpointorigin}%
\fi
\endgroup
}
% #1 -- label text
% #2 -- options
\def\sseq@setnodetext#1#2{%
\setbox\pgfnodeparttextbox=\hbox{%
\pgfscope%
#2
\tikzset{every text node part/.try}%
\ifx\tikz@textopacity\pgfutil@empty%
\else%
\pgfsetfillopacity{\tikz@textopacity}%
\pgfsetstrokeopacity{\tikz@textopacity}%
\fi%
\pgfinterruptpicture
\ifx\tikz@text@width\pgfutil@empty%
\tikz@textfont%
\else%
\begingroup%
\pgfmathsetlength{\pgf@x}{\tikz@text@width}%
\pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}%
\tikz@textfont%
\tikz@text@action%
\fi%
\ifx\tikz@textcolor\pgfutil@empty%
\else%
\pgfutil@colorlet{.}{\tikz@textcolor}%
\fi%
\pgfsetcolor{.}%
\tikz@atbegin@node%
#1%
\tikz@atend@node%
\ifx\tikz@text@width\pgfutil@empty%
\else%
\pgfutil@endminipage%
\endgroup%
\fi%
\endpgfinterruptpicture
\endpgfscope%
}%
\ifx\tikz@text@width\pgfutil@empty%
\else%
\pgfmathsetlength{\pgf@x}{\tikz@text@width}%
\wd\pgfnodeparttextbox=\pgf@x%
\fi%
\ifx\tikz@text@height\pgfutil@empty%
\else%
\pgfmathsetlength{\pgf@x}{\tikz@text@height}%
\ht\pgfnodeparttextbox=\pgf@x%
\fi%
\ifx\tikz@text@depth\pgfutil@empty%
\else%
\pgfmathsetlength{\pgf@x}{\tikz@text@depth}%
\dp\pgfnodeparttextbox=\pgf@x%
\fi%
}
\def\sseq@drawnode{%
\pgfutil@tempdima=\pgflinewidth%
{%
\tikz@mode%
%\iftikz@mode@clip \sseq@error@internal{Clip shouldn't happen here, but this error should be caught earlier}{}\fi %
\iftikz@mode@draw%
\iftikz@mode@double%
% Change line width
\begingroup%
\pgfsys@beginscope%
\tikz@double@setup%
\fi%
\fi%
%
% Step 10: Do stroke/fill as needed
%
\sseq@eval{\noexpand\pgfusepath{%
\iftikz@mode@fill fill,\fi%
\iftikz@mode@draw draw,\fi%
}}%
%
% Step 11: Double stroke, if necessary
%
\iftikz@mode@draw%
\iftikz@mode@double%
\pgfsys@endscope%
\endgroup%
\fi%
\fi
}%
\global\pgflinewidth=\pgfutil@tempdima%
}
%%% Labels
% #1 -- label text
% #2 -- options
\def\sseq@drawlabel#1#2{
\bgroup\pgfscope
\def\tikz@mode{}
\let\sseq@tikz@transform@save\tikz@transform
\pgfkeyssetvalue{/pgf/inner xsep}{2pt}
\pgfkeyssetvalue{/pgf/inner ysep}{2pt}
\def\tikz@shape{rectangle}
\let\tikz@transform\empty % The next line was set up to fix the classlabelstyle glitch
\sseq@options@secondpassmode
\sseq@thesseqstyle\sseq@thelabelstyle\sseq@theclasslabelstyle#2
\tikz@options
\pgftransformreset
\pgftransformshift{\tikz@node@at}
\tikz@lib@pos@call
\tikz@transform
\tikz@mode
\let\tikz@transform\sseq@tikz@transform@save
\sseq@setnodetext{\sseq@labeltextfn{#1}}{}
\pgfmultipartnode{\tikz@shape}{\tikz@anchor}{label}{\sseq@drawnode}%
\ifsseq@pin
\def\sseq@pinoptions{}
\let\tikz@options\empty
\let\tikz@mode\empty
\sseq@thepinstyle
#2
\sseq@pinoptions
\tikz@options
\tikz@mode
\sseq@drawedge@findsourcetarget{\tikz@fig@name}{}{label}{}
\pgfpathmoveto{\sseq@sourcecoord}%
\pgfpathlineto{\sseq@targetcoord}%
\sseq@eval{\noexpand\pgfusepath{%
draw
\iftikz@mode@fill fill,\fi
\iftikz@mode@draw draw,\fi
}}%
\fi
\endpgfscope\egroup
}
%%%
%%% Drawing edges
%%%
\def\sseq@ifinrange(#1){\sseq@ifinrange@#1,\sseq@nil}
\def\sseq@ifinrange@#1,#2,#3\sseq@nil{%
\sseq@tempx=#1\relax\sseq@tempy=#2\relax
\sseq@outofrangetrue
\ifnum\sseq@tempx<\sseq@xmaxpp\relax\ifnum\sseq@tempx>\sseq@xminmm\relax\ifnum\sseq@tempy<\sseq@ymaxpp\relax\ifnum\sseq@tempy>\sseq@yminmm\relax
\sseq@outofrangefalse
\fi\fi\fi\fi
\ifsseq@outofrange
\@xp\pgfutil@secondoftwo
\else
\@xp\pgfutil@firstoftwo
\fi
}
% #1 -- source node
% #2 -- source anchor
% #3 -- target node
% #4 -- target anchor
% Calculate actual start and end of the edge (node borders), return the results stored in \sseq@sourcecoord, \sseq@targetcoord
\def\sseq@drawedge@findsourcetarget#1#2#3#4{
\edef\sseq@edgesourceanchor{#2}
\edef\sseq@edgetargetanchor{#4}
\let\tempaf\pgfutil@empty
\ifx\sseq@edgesourceanchor\pgfutil@empty % Check that the source doesn't have a specified anchor
\def\tempa{\pgfpointanchor{#1}{center}}% if so, start by taking the center of that coordinate
\else
\edef\tempa{\@nx\pgfpointanchor{#1}{\sseq@edgesourceanchor}} % If it has an anchor, use that
\let\tempaf\tempa
\fi
\ifx\sseq@edgetargetanchor\pgfutil@empty % check that the target doesn't have a specified anchor
\def\tempb{\pgfpointshapeborder{#3}{\tempa}}% if so, our end point is the point on the boundary of node b that is in the direction of our initial start coordinate
\else
\edef\tempb{\@nx\pgfpointanchor{#3}{\sseq@edgetargetanchor}}% If it has a specified anchor, use that
\fi
\let\tempbf\tempb
\ifx\tempaf\pgfutil@empty%
\def\tempaf{\pgfpointshapeborder{#1}{\tempb}}%
\fi
\let\sseq@sourcecoord\tempaf
\let\sseq@targetcoord\tempbf
}
\def\sseq@fullcoord@to@partialcoord(#1){\sseq@fullcoord@to@partialcoord@#1,\@nil}
\def\sseq@fullcoord@to@partialcoord@#1,#2,#3\@nil{{#1cm}{#2cm}}
% #1 -- source (full)
% #2 -- target (full)
% #3 -- which type of edge (either "structline" or "differential")
% #4 -- options
\def\sseq@drawedge(#1)(#2)#3#4{%
\begingroup\pgfscope
% If either class is part of a family we aren't drawing, don't draw the edge either.
\expandafter\ifx\csname pgf@sh@pi@sseq{#1}\endcsname\pgfpictureid\else
\@xp\sseq@break
\fi
\expandafter\ifx\csname pgf@sh@pi@sseq{#2}\endcsname\pgfpictureid\else
\@xp\sseq@break
\fi
\def\sseq@edgetype{#3}
\let\sseq@collections@featuretype\sseq@edgetype
\let\sseq@edgesourceanchor\pgfutil@empty
\let\sseq@edgetargetanchor\pgfutil@empty
%
\sseq@needstikzfalse
\def\pgfkeysdefaultpath{/sseqpages/#3/}%
\sseq@options@bothpassmode
\sseq@thesseqstyle
\sseq@theedgestyle\csname sseq@the#3style\endcsname\the\sseq@scope@toks
#4%
\csname sseq@collections@#3@hook\endcsname
\pgftransformshift{\pgfqpointxy{-\the\sseq@x}{-\the\sseq@y}}%
% puts results into \sseq@sourcecoord and \sseq@targetcoord
\sseq@drawedge@findsourcetarget{sseq{#1}}{\sseq@edgesourceanchor}{sseq{#2}}{\sseq@edgetargetanchor}
%
\tikz@options
\tikz@mode
\def\temparrowstartspec{}%
\def\temparrowendspec{}%
\pgfcoordinate{tempa}{\sseq@sourcecoord}%
\pgfcoordinate{tempb}{\sseq@targetcoord}%
\pgftransformreset
\sseq@outofrangefalse
\sseq@ifinrange(#1){}{
\edef\temparrowstartspec{\@nx\pgfsetarrowsstart{\csname sseq@runoffarrow@start@#3@spec\endcsname}}
\sseq@outofrangetrue
}%
\sseq@ifinrange(#2){}{
\edef\temparrowendspec{\@nx\pgfsetarrowsend{\csname sseq@runoffarrow@end@#3@spec\endcsname}}
\sseq@outofrangetrue
}
\ifsseq@outofrange
\sseq@handleoffpageedge{#1}{#2}%
\fi
\ifsseq@drawedge
% TODO: should some sort of transformation manipulation be here? Maybe allow user to specify preference?
% Don't draw dots on very short segments
\pgfpointdiff{\sseq@targetcoord}{\sseq@sourcecoord}
\pgfmathveclen{\pgf@x}{\pgf@y}%
\@xp\pgfmathint\@xp{\pgfmathresult}%
\ifnum\pgfmathresult<10\relax%%17? % TODO: Fix this predicate
\tikzset{every text node part/.append code={\pgfsetcolor{white}}}% I wonder why this is here...
\ifx\temparrowstartspec\pgfutil@empty
\else
\def\temparrowstartspec{\pgfsetarrowsstart{}}%
\fi
\ifx\temparrowendspec\pgfutil@empty
\else
\def\temparrowendspec{\pgfsetarrowsend{}}%
\fi
\fi
\ifsseq@needstikz
\draw[/sseqpages,
/utils/exec={\sseq@thesseqstyle\sseq@theedgestyle\csname sseq@the#3style\endcsname\the\sseq@scope@toks
\temparrowstartspec\temparrowendspec #4}%
] (tempa) to (tempb);%
\else
\temparrowstartspec
\temparrowendspec
\pgfpathmoveto{\pgfpointanchor{tempa}{center}}%
\pgfpathlineto{\pgfpointanchor{tempb}{center}}%
\sseq@eval{\noexpand\pgfusepath{%
\iftikz@mode@fill fill,\fi
\iftikz@mode@draw draw,\fi
}}%
\fi
\fi
\sseq@breakpoint
\endpgfscope\endgroup
}
% TODO: this macro is super expensive. Make it faster
\def\sseq@handleoffpageedge#1#2{
\pgfpathmoveto{\sseq@sourcecoord}%
\pgfpathlineto{\sseq@targetcoord}%
\pgfgetpath\thispath
\pgfusepath{discard}%
\pgfintersectionofpaths{\pgfsetpath\sseq@theclippath}{\pgfsetpath\thispath}%
\ifcase\pgfintersectionsolutions\relax
% No intersections, but one or both endpoints may be out of range but still in clipping region due to scaling. Add ellipses as appropriate.
\sseq@ifinrange(#1){% If the first endpoint is in range, the second must be out of range b/c sseq@outofrange is true.
%\edef\temparrowendspec{\@nx\pgfsetarrowsend{\csname sseq@runoffarrow@end@#3@spec\endcsname}}
}{%
\sseq@ifinrange(#2){}{\sseq@drawedge@handletrickyedge}% uh-oh, both ends are out of range
}%
\or
\sseq@ifinrange(#1){% If the startpoint is in range, the intersection must be the end.
\def\sseq@targetcoord{\pgfpointintersectionsolution{1}}
\pgfcoordinate{tempb}{\sseq@targetcoord}
}{%
\sseq@ifinrange(#2){% If the startpoint is out of range and the endpoint is in range, the intersection must be the start
\def\sseq@sourcecoord{\pgfpointintersectionsolution{1}}%
\pgfcoordinate{tempa}{\sseq@sourcecoord}%
}{\sseq@drawedge@handletrickyedge}% Uh-oh, both ends are out of range.
}
\or% an orphan
\ifsseq@draworphanedges
\sseq@drawedge@handleorphan
\else
\sseq@drawedgefalse % Don't draw "orphaned edges"
\fi
\else