summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/smartdiagram/smartdiagram.sty
blob: de6878aedcdfe0251bfd4934baf5c0999fa3b21b (plain)
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
%%
%% This is file `smartdiagram.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% smartdiagram.dtx  (with options: `package')
%% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
%% smartdiagram --- Automatic creation of smart diagrams from lists of items.
%% E-mail: claudio.fiandrino@gmail.com
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{smartdiagram}[2013/03/09 v0.2 Automatic creation of smart diagrams from lists of items.]

\RequirePackage{tikz}

\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{xstring}

\usetikzlibrary{backgrounds,
   calc,
   fadings,
   shadows,
   shapes.arrows,
   shapes.symbols
}
\pgfdeclarelayer{smart diagram arrow back}
\pgfsetlayers{background,smart diagram arrow back,main}
\@namedef{color@1}{red!40}
\@namedef{color@2}{cyan!40}
\@namedef{color@3}{blue!40}
\@namedef{color@4}{green!40}
\@namedef{color@5}{orange!40}
\@namedef{color@6}{yellow!40}
\@namedef{color@7}{magenta!40}
\@namedef{color@8}{brown!40}
\@namedef{color@9}{violet!40}
\@namedef{color@10}{teal!40}
\tikzset{rnd rectangle/.style={rectangle,rounded corners}
}

\def\CalcHeight(#1,#2)#3{%
\pgfpointdiff{\pgfpointanchor{#1}{south west}}{\pgfpointanchor{#2}{north west}}
\pgfmathsetmacro{\myheight}{veclen(\pgf@x,\pgf@y)}
\global\expandafter\edef\csname #3\endcsname{\myheight}
}
\pgfkeys{/smart diagram/.cd, module minimum width/.initial=2cm,
   module minimum height/.initial={1cm},
   module y sep/.initial={1.65},
   module x sep/.initial={2.75},
   descriptive items y sep/.initial={1.75},
   text width/.initial={1.5cm},
   description title width/.initial={1.5cm},
   description text width/.initial={5cm},
   description title text width/.initial={1.25cm},
   description title font/.initial={\small},
   description font/.initial={\small},
   description width/.initial={5.5cm},
   font/.initial={\small},
   border color/.initial={gray},
   circular distance/.initial={2.75cm},
   arrow line width/.initial={0.1cm},
   module shape/.initial={rnd rectangle},
   insert decoration/.initial={},
   arrow tip/.initial={stealth},
   arrow color/.initial={gray},
   bubble center node size/.initial={4cm},
   bubble center node font/.initial={\large},
   bubble center node color/.initial={lightgray!60},
   distance center/other bubbles/.initial=0.8cm,
   distance text center bubble/.initial={0.5cm},
   bubble fill opacity/.initial={0.5},
   bubble node size/.initial={2.5cm},
   bubble text opacity/.initial={0.8},
   bubble node font/.initial={\normalfont},
   planet size/.initial={2.5cm},
   planet color/.initial={lightgray!60},
   planet font/.initial={\large},
   distance planet-connection/.initial={0.1cm},
   distance planet-text/.initial={0.5cm},
   planet text width/.initial={1.75cm},
   satellite size/.initial={1.75cm},
   satellite font/.initial={\normalfont},
   satellite fill opacity/.initial={0.5},
   satellite text opacity/.initial={0.8},
   satellite text width/.initial={1.5cm},
   distance satellite-connection/.initial={0.075cm},
   connection line width/.initial={0.1cm},
   connection color/.initial={gray},
   distance planet-satellite/.initial={3.5cm},
   priority arrow width/.initial={1.5cm},
   priority arrow head extend/.initial={0.15cm},
   priority tick size/.initial={5pt},
   priority arrow height advance/.initial={2cm},
   sequence item height/.initial={1cm},
   sequence item width/.initial={2cm},
   sequence item border color/.initial={gray},
   sequence item border size/.initial={1.75\pgflinewidth},
   sequence item font size/.initial={\normalfont},
   sequence item fill opacity/.initial={1},
   sequence item text opacity/.initial={1},
   sequence item text width/.initial={1.9cm},
   sequence item text color/.initial={black},
   sequence item uniform color/.initial={gray!60!black},
}%

\pgfkeys{/smart diagram/.cd, module minimum width/.get=\modulewidth,
   module minimum height/.get=\moduleheight,
   module y sep/.get=\moduleysep,
   module x sep/.get=\modulexsep,
   descriptive items y sep/.get=\descriptiveitemsysep,
   text width/.get=\moduletextwidth,
   description title width/.get=\descriptiontitlewidth,
   description text width/.get=\descriptiontextwidth,
   description title text width/.get=\descriptiontitletextwidth,
   description title font/.get=\descriptiontitlefontsize,
   description font/.get=\descriptionfontsize,
   description width/.get=\descriptionwidth,
   font/.get=\modulefontsize,
   border color/.get=\bordercolor,
   circular distance/.get=\circulardistance,
   arrow line width/.get=\arrowlinewidth,
   module shape/.get=\moduleshape,
   insert decoration/.get=\borderdecoration,
   arrow tip/.get=\arrowtip,
   arrow color/.get=\arrowcolor,
   bubble center node size/.get=\bubblecenternodesize,
   bubble center node font/.get=\bubblecenternodefont,
   bubble center node color/.get=\bubblecenternodecolor,
   distance center/other bubbles/.get=\distancecenterotherbubbles,
   distance text center bubble/.get=\distancetextcenterbubble,
   bubble fill opacity/.get=\bubblefillopacity,
   bubble node size/.get=\bubblenodesize,
   bubble text opacity/.get=\bubbletextopacity,
   bubble node font/.get=\bubblenodefont,
   planet size/.get=\planetminimumsize,
   planet color/.get=\planetcolor,
   planet font/.get=\planetfont,
   distance planet-connection/.get=\planetoutersep,
   distance planet-text/.get=\planetinnersep,
   planet text width/.get=\planettextwidth,
   satellite size/.get=\satelliteminimumsize,
   satellite font/.get=\satellitefont,
   satellite fill opacity/.get=\satellitefillopacity,
   satellite text opacity/.get=\satellitetextopacity,
   satellite text width/.get=\satellitetextwidth,
   distance satellite-connection/.get=\satelliteoutersep,
   connection line width/.get=\connectionlinewidth,
   connection color/.get=\connectioncolor,
   distance planet-satellite/.get=\distanceplanetsatellite,
   priority arrow width/.get=\priorityarrowwidth,
   priority arrow head extend/.get=\priorityarrowheadextend,
   priority tick size/.get=\prioritytick,
   priority arrow height advance/.get=\priorityarrowheightadvance,
   sequence item height/.get=\seqitemheight,
   sequence item width/.get=\seqitemwidth,
   sequence item border color/.get=\seqitembordercolor,
   sequence item border size/.get=\seqlinewidth,
   sequence item font size/.get=\seqitemfont,
   sequence item fill opacity/.get=\seqitemfillopacity,
   sequence item text opacity/.get=\seqitemtextopacity,
   sequence item text width/.get=\seqitemtextwidth,
   sequence item text color/.get=\seqitemtextcolor,
   sequence item uniform color/.get=\seqitemuniformcol,
}%


\pgfkeys{/smart diagram/.cd, set color list/.code={
      \foreach \listitem [count=\i] in {#1}{
         \global\@namedef{color@\i\expandafter}\expandafter{\listitem}
      }
   }
}

\pgfkeys{/smart diagram/.cd, use predefined color list/.code={
      \@namedef{color@1}{red!30}
      \@namedef{color@2}{cyan!30}
      \@namedef{color@3}{blue!30}
      \@namedef{color@4}{green!30}
      \@namedef{color@5}{orange!30}
      \@namedef{color@6}{yellow!30}
      \@namedef{color@7}{magenta!30}
      \@namedef{color@8}{brown!30}
      \@namedef{color@9}{violet!30}
      \@namedef{color@10}{teal!30}
   }
}


\newif\ifbackarrowdisabled
\pgfkeys{/smart diagram/.cd,
  back arrow disabled/.is if=backarrowdisabled,
  back arrow disabled=false,
}


\NewDocumentCommand{\smartdiagramset}{m}{%
  \pgfkeys{/smart diagram/.cd,#1}%
  \pgfkeys{/smart diagram/.cd, module minimum width/.get=\modulewidth,
   module minimum height/.get=\moduleheight,
   module y sep/.get=\moduleysep,
   module x sep/.get=\modulexsep,
   descriptive items y sep/.get=\descriptiveitemsysep,
   text width/.get=\moduletextwidth,
   description title width/.get=\descriptiontitlewidth,
   description text width/.get=\descriptiontextwidth,
   description title text width/.get=\descriptiontitletextwidth,
   description title font/.get=\descriptiontitlefontsize,
   description font/.get=\descriptionfontsize,
   description width/.get=\descriptionwidth,
   font/.get=\modulefontsize,
   border color/.get=\bordercolor,
   circular distance/.get=\circulardistance,
   arrow line width/.get=\arrowlinewidth,
   module shape/.get=\moduleshape,
   insert decoration/.get=\borderdecoration,
   arrow tip/.get=\arrowtip,
   arrow color/.get=\arrowcolor,
   bubble center node size/.get=\bubblecenternodesize,
   bubble center node font/.get=\bubblecenternodefont,
   bubble center node color/.get=\bubblecenternodecolor,
   distance center/other bubbles/.get=\distancecenterotherbubbles,
   distance text center bubble/.get=\distancetextcenterbubble,
   bubble fill opacity/.get=\bubblefillopacity,
   bubble node size/.get=\bubblenodesize,
   bubble text opacity/.get=\bubbletextopacity,
   bubble node font/.get=\bubblenodefont,
   planet size/.get=\planetminimumsize,
   planet color/.get=\planetcolor,
   planet font/.get=\planetfont,
   distance planet-connection/.get=\planetoutersep,
   distance planet-text/.get=\planetinnersep,
   planet text width/.get=\planettextwidth,
   satellite size/.get=\satelliteminimumsize,
   satellite font/.get=\satellitefont,
   satellite fill opacity/.get=\satellitefillopacity,
   satellite text opacity/.get=\satellitetextopacity,
   satellite text width/.get=\satellitetextwidth,
   distance satellite-connection/.get=\satelliteoutersep,
   connection line width/.get=\connectionlinewidth,
   connection color/.get=\connectioncolor,
   distance planet-satellite/.get=\distanceplanetsatellite,
   priority arrow width/.get=\priorityarrowwidth,
   priority arrow head extend/.get=\priorityarrowheadextend,
   priority tick size/.get=\prioritytick,
   priority arrow height advance/.get=\priorityarrowheightadvance,
   sequence item height/.get=\seqitemheight,
   sequence item width/.get=\seqitemwidth,
   sequence item border color/.get=\seqitembordercolor,
   sequence item border size/.get=\seqlinewidth,
   sequence item font size/.get=\seqitemfont,
   sequence item fill opacity/.get=\seqitemfillopacity,
   sequence item text opacity/.get=\seqitemtextopacity,
   sequence item text width/.get=\seqitemtextwidth,
   sequence item text color/.get=\seqitemtextcolor,
   sequence item uniform color/.get=\seqitemuniformcol,
  }%
}%
\tikzfading[name=priorityarrowfading,
  bottom color=transparent!5,
  top color=transparent!80
]
\tikzset{priority arrow fill/.style={
  fill=gray,
  path fading=priorityarrowfading
  }
}

\tikzset{module/.style={
      \pgfkeysvalueof{/smart diagram/module shape},
      thick,
      draw=\bordercolor,
      top color=white,
      bottom color=\col,
      text width=\moduletextwidth,
      minimum width=\modulewidth,
      minimum height=\moduleheight,
      font=\modulefontsize,
      \borderdecoration
   },
   diagram arrow type/.style={
      >=\arrowtip,line width=\arrowlinewidth,\col
   },
}

\pgfkeys{/smart diagram/.cd,%
      uniform arrow color/.is choice,%
      uniform arrow color/true/.code={%
        \tikzset{diagram arrow type/.append style={
           \arrowcolor
           },
        }
      },%
      uniform arrow color/false/.style={diagram arrow type},%
    uniform arrow color/.default=false,
}%

\tikzset{description title/.style={
      circle,
      draw=\bordercolor,
      minimum width=\descriptiontitlewidth,
      anchor=east,
      bottom color=\col,
      top color=white!80!\col,
      font=\descriptiontitlefontsize,
      text width=\descriptiontitletextwidth,
      \borderdecoration,
   },
   description/.style={
      \pgfkeysvalueof{/smart diagram/module shape},
      text width=\descriptiontextwidth,
      draw=\bordercolor,
      anchor=west,
      minimum height=\moduleheight,
      minimum width=\descriptionwidth,
      bottom color=\col,
      top color=white!80!\col,
      font=\descriptionfontsize,
      \borderdecoration,
   }
}
\tikzset{priority arrow/.style={
      draw=\bordercolor,
      single arrow,
      minimum height=\distancemodules,
      minimum width=\priorityarrowwidth,
      priority arrow fill,
      rotate=90,
      single arrow head extend=\priorityarrowheadextend,
      anchor=west,
   }
}
\tikzset{bubble center node/.style={
      minimum size=\bubblecenternodesize,
      circle,
      fill=\bubblecenternodecolor,
      font=\bubblecenternodefont,
      outer sep=\distancecenterotherbubbles,
      inner sep=\distancetextcenterbubble,
   },
   bubble node/.style={
      minimum size=\bubblenodesize,
      circle,
   ultra thick,
   font=\bubblenodefont,
   draw=white,
   fill opacity=\bubblefillopacity,
   fill=\col,
   text opacity=\bubbletextopacity,
   }
}
\tikzset{planet/.style={
      minimum size=\planetminimumsize,
      circle,
      fill=\planetcolor,
      font=\planetfont,
      outer sep=\planetoutersep,
      inner sep=\planetinnersep,
      text width=\planettextwidth,
   },
   satellite/.style={
      minimum size=\satelliteminimumsize,
      circle,
    font=\satellitefont,
    fill opacity=\satellitefillopacity,
    fill=\col,
    text opacity=\satellitetextopacity,
    text width=\satellitetextwidth,
    outer sep=\satelliteoutersep,
   },
   connection planet satellite/.style={
   line width=\connectionlinewidth,
   >=\arrowtip,
   \col,
   }
}

\tikzset{sequence item/.style={
      minimum height=\seqitemheight,
      minimum width=\seqitemwidth,
      signal,
      signal from=west,
      signal to=east,
      draw=\seqitembordercolor,
      line width=\seqlinewidth,
    font=\seqitemfont,
    fill opacity=\seqitemfillopacity,
    fill=\col,
    text opacity=\seqitemtextopacity,
    text width=\seqitemtextwidth,
      text=\seqitemtextcolor,
  }
}

\pgfkeys{/smart diagram/.cd,%
      uniform sequence color/.is choice,%
      uniform sequence color/true/.code={%
        \tikzset{sequence item/.append style={
           fill=\seqitemuniformcol,
           },
        }
      },%
      uniform sequence color/false/.style={sequence item},%
    uniform sequence color/.default=false,
}%

\pgfkeys{/smart diagram/.cd,%
      uniform connection color/.is choice,%
      uniform connection color/true/.code={%
        \tikzset{connection planet satellite/.append style={
           \connectioncolor
           },
        }
      },%
      uniform connection color/false/.style={connection planet satellite},%
    uniform connection color/.default=false,
}%
\NewDocumentCommand{\smartdiagram}{r[] m}{%
   \StrCut{#1}{:}\diagramtype\option
   \IfNoValueTF{#1}{% true-no value 1
      \PackageError{smartdiagram}%
      {Type of the diagram not inserted. Please insert it}%
      {Example: \protect\smartdiagram[flow diagram]}}
   {%false-no value 1
   \IfStrEq{\diagramtype}{}{%
      \PackageError{smartdiagram}{Type of the diagram not inserted. Please insert it}
      {Example: \protect\smartdiagram[flow diagram]}
   }{}
   \IfStrEq{\diagramtype}{circular diagram}{% true-circular diagram
   \begin{tikzpicture}[every node/.style={align=center}]

   \foreach \smitem [count=\xi] in {#2}  {\global\let\maxsmitem\xi}

   \foreach \smitem [count=\xi] in {#2}{%
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
     \pgfmathtruncatemacro{\angle}{180+360/\maxsmitem*\xi}
   }{% false-clockwise-circular diagram
     \pgfmathtruncatemacro{\angle}{360/\maxsmitem*\xi}
   }
   \edef\col{\@nameuse{color@\xi}}
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
     \node[module,drop shadow] (module\xi)
      at (-\angle:\circulardistance) {\smitem };
   }{% false-clockwise-circular diagram
     \node[module,drop shadow] (module\xi)
      at (\angle:\circulardistance) {\smitem };
   }
   }%

   \foreach \smitem [count=\xi] in {#2}{%
   \pgfmathtruncatemacro{\xj}{mod(\xi, \maxsmitem) + 1)}
   \edef\col{\@nameuse{color@\xj}}
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
     \draw[<-,diagram arrow type,shorten <=0.3cm,shorten >=0.3cm]
   (module\xj) to[bend right] (module\xi);
   }{% false-clockwise-circular diagram
     \draw[<-,diagram arrow type,shorten <=0.3cm,shorten >=0.3cm]
   (module\xj) to[bend left] (module\xi);
   }
   }%
   \end{tikzpicture}
   }{}% end-circular diagram
   \IfStrEq{\diagramtype}{flow diagram}{% true-flow diagram
   \begin{tikzpicture}[every node/.style={align=center}]

   \foreach \smitem [count=\xi] in {#2}  {\global\let\maxsmitem\xi}

   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
   \IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
     \path let \n1 = {int(0-\xi)}, \n2={0+\xi*\modulexsep} in
         node[module,drop shadow] (module\xi) at +(\n2,0) {\smitem};
   }{% false-horizontal-flow diagram
     \path let \n1 = {int(0-\xi)}, \n2={0-\xi*\moduleysep} in
         node[module,drop shadow] (module\xi) at +(0,\n2) {\smitem};
   }
   }%

   \foreach \smitem [count=\xi] in {#2}{%
   \pgfmathtruncatemacro{\xj}{mod(\xi, \maxsmitem) + 1)}
   \edef\col{\@nameuse{color@\xj}}
   \ifnum\xi<\maxsmitem
   \begin{pgfonlayer}{smart diagram arrow back}
   \draw[<-,diagram arrow type] (module\xj) -- (module\xi);
   \end{pgfonlayer}
   \fi
   % last arrow - not display it in background - check if disabled
   \ifbackarrowdisabled
     \relax
   \else
     \ifnum\xi=\maxsmitem
       \IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
         \tikzset{square arrow/.style={
            to path={-- ++(0,0.5) -| (\tikztotarget)}
            }
         }
         \draw[<-,diagram arrow type, square arrow]
          (module\xj.north) to (module\xi.north);
       }{% false-horizontal-flow diagram
         \tikzset{square arrow/.style={
            to path={-- ++(0.5,0) |- (\tikztotarget)}
            }
         }
         \draw[<-,diagram arrow type,square arrow]
           (module\xj.east) to (module\xi);
       }
     \fi
   \fi
   }%
   \end{tikzpicture}
   }{}% end-flow diagram
   \IfStrEq{\diagramtype}{descriptive diagram}{% true-descr. diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
   \foreach \subitem [count=\xii] in \smitem{%
   \ifnumequal{\xii}{1}{% true
   \node[description title,drop shadow]
    (module-title\xi) at (0,0-\xi*\descriptiveitemsysep) {\subitem};
   }{}
   \ifnumequal{\xii}{2}{% true
   \node[description,drop shadow](module\xi)
    at (0,0-\xi*\descriptiveitemsysep) {\subitem};
   }{}
   }%
   }%
   \end{tikzpicture}
   }{}% end-descr. diagram
   \IfStrEq{\diagramtype}{bubble diagram}{% true-bubble diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[bubble center node](center bubble){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[bubble node] (module\xi)
       at (center bubble.\angle) {\smitem };
   }%
   }%
   \end{tikzpicture}
   }{}%end-bubble diagram
   \IfStrEq{\diagramtype}{constellation diagram}{% true-const diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[planet](planet){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[satellite] (satellite\xi)
       at (\angle:\distanceplanetsatellite) {\smitem };
   \draw[->,connection planet satellite] (planet) -- (satellite\xi);
   }%
   }%
   \end{tikzpicture}
   }{}%end-const diagram
   \IfStrEq{\diagramtype}{connected constellation diagram}{% true-conn const diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[planet](planet){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[satellite] (satellite\xj)
        at (\angle:\distanceplanetsatellite) {\smitem };
   }%
   }%
   \foreach \smitem [count=\xi] in {#2}{%
      \ifnumgreater{\xi}{1}{ %true
      \pgfmathtruncatemacro{\xj}{\xi-1}
      \edef\col{\@nameuse{color@\xj}}
      \pgfmathtruncatemacro{\xk}{mod(\xj,\actualnumitem) +1}
      \path[connection planet satellite]
         (satellite\xj) edge[bend right] (satellite\xk);
   }{}
   }%
   \end{tikzpicture}
   }{}%end-connected constellation diagram
   \IfStrEq{\diagramtype}{priority descriptive diagram}{% true-priority descriptive diagram
   \pgfmathparse{subtract(\priorityarrowwidth,\priorityarrowheadextend)}
   \pgfmathsetmacro\priorityticksize{\pgfmathresult/2}
   \pgfmathsetmacro\arrowtickxshift{(\priorityarrowwidth-\priorityticksize)/2}
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
    \node[description,drop shadow](module\xi)
    at (0,0+\xi*\descriptiveitemsysep) {\smitem};
\draw[line width=\prioritytick,\col]
      ([xshift=-\arrowtickxshift pt]module\xi.base west)--
 ($([xshift=-\arrowtickxshift pt]module\xi.base west)-(\priorityticksize pt,0)$);
   }%
   \coordinate (A) at (module1);
   \coordinate (B) at (module\maxsmitem);
   \CalcHeight(A,B){heightmodules}
   \pgfmathadd{\heightmodules}{\priorityarrowheightadvance}
   \pgfmathsetmacro{\distancemodules}{\pgfmathresult}
   \pgfmathsetmacro\arrowxshift{\priorityarrowwidth/2}
   \begin{pgfonlayer}{background}
   \node[priority arrow] at ([xshift=-\arrowxshift pt]module1.south west){};
   \end{pgfonlayer}
   \end{tikzpicture}
   }{}% end-priority descriptive diagram
   \IfStrEq{\diagramtype}{sequence diagram}{% true-sequence diagram
   \begin{tikzpicture}[every node/.style={align=center}]
 \foreach \x[count=\xi, count=\prevx from 0] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
\ifnum\xi=1
  \node[sequence item] (x-\xi) {\x};
\else
  \node[sequence item,anchor=west] (x-\xi) at (x-\prevx.east) {\x};
\fi
 }
   \end{tikzpicture}
   }{}% end-sequence diagram
}% end-no value 1
}% end-command
\tikzset{
   sminvisible/.style={opacity=0,text opacity=0},
   smvisible on/.style={smalt=#1{}{sminvisible}},
   smalt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
   },
}

\NewDocumentCommand{\smartdiagramanimated}{r[] m}{%
   \StrCut{#1}{:}\diagramtype\option
   \IfNoValueTF{#1}{% true-no value 1
      \PackageError{smartdiagram}{Type of the diagram not inserted. Please insert it}
      {Example: \protect\smartdiagram[flow diagram]}}
   {%false-no value 1
   \IfStrEq{\diagramtype}{}{%
      \PackageError{smartdiagram}{Type of the diagram not inserted. Please insert it}
      {Example: \protect\smartdiagram[flow diagram]}
   }{}
   \IfStrEq{\diagramtype}{circular diagram}{% true-circular diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}  {\global\let\maxsmitem\xi}
   \foreach \smitem [count=\xi] in {#2}{%
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
     \pgfmathtruncatemacro{\angle}{180+360/\maxsmitem*\xi}
   }{% false-clockwise-circular diagram
     \pgfmathtruncatemacro{\angle}{360/\maxsmitem*\xi}
   }
   \edef\col{\@nameuse{color@\xi}}
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
      \node[module,
        drop shadow={smvisible on=<\xi->},
        smvisible on=<\xi->] (module\xi)
       at (-\angle:\circulardistance) {\smitem};
   }{% false-clockwise-circular diagram
      \node[module,
        drop shadow={smvisible on=<\xi->},
        smvisible on=<\xi->] (module\xi)
       at (\angle:\circulardistance) {\smitem};
   }
   }%
   \foreach \smitem [count=\xi] in {#2}
   {%
   \pgfmathtruncatemacro{\xj}{mod(\xi, \maxsmitem) + 1)}
   \pgfmathtruncatemacro{\adv}{\xi + 1)}
   \edef\col{\@nameuse{color@\xi}}
   \IfStrEq{\option}{clockwise}{% true-clockwise-circular diagram
     \draw[<-,diagram arrow type,shorten <=0.3cm,shorten >=0.3cm,
   smvisible on=<\adv->] (module\xj) to[bend right] (module\xi);
   }{% false-clockwise-circular diagram
     \draw[<-,diagram arrow type,shorten <=0.3cm,shorten >=0.3cm,
   smvisible on=<\adv->] (module\xj) to[bend left] (module\xi);
   }
   }%
   \end{tikzpicture}
   }{}% end-circular diagram
   \IfStrEq{\diagramtype}{flow diagram}{% true-flow diagram
   \begin{tikzpicture}[every node/.style={align=center}]

   \foreach \smitem [count=\xi] in {#2}  {\global\let\maxsmitem\xi}

   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
   \IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
     \path let \n1 = {int(0-\xi)}, \n2={0+\xi*\modulexsep}
        in node[module,drop shadow={smvisible on=<\xi->},
        smvisible on=<\xi->] (module\xi) at +(\n2,0) {\smitem};
   }{% false-horizontal-flow diagram
     \path let \n1 = {int(0-\xi)}, \n2={0-\xi*\moduleysep}
        in node[module,drop shadow={smvisible on=<\xi->},
        smvisible on=<\xi->] (module\xi) at +(0,\n2) {\smitem};
   }
   }%

   \foreach \smitem [count=\xi] in {#2}{%
   \pgfmathtruncatemacro{\xj}{mod(\xi, \maxsmitem) + 1)}
   \edef\col{\@nameuse{color@\xj}}
   \ifnum\xi<\maxsmitem
   \begin{pgfonlayer}{smart diagram arrow back}
   \draw[<-,diagram arrow type,smvisible on=<\xi->]
     (module\xj) -- (module\xi);
   \end{pgfonlayer}
   \fi
   % last arrow - not display it in background - check if disabled
   \ifbackarrowdisabled
     \relax
   \else
     \ifnum\xi=\maxsmitem
       \IfStrEq{\option}{horizontal}{% true-horizontal-flow diagram
         \tikzset{square arrow/.style={
           to path={-- ++(0,0.5) -| (\tikztotarget)}
           }
         }
         \draw[<-,diagram arrow type, square arrow,smvisible on=<\xi->]
          (module\xj.north) to (module\xi.north);
       }{% false-horizontal-flow diagram
         \tikzset{square arrow/.style={
           to path={-- ++(0.5,0) |- (\tikztotarget)}
           }
         }
         \draw[<-,diagram arrow type,square arrow,smvisible on=<\xi->]
           (module\xj.east) to (module\xi);
       }
     \fi
   \fi
   }%
   \end{tikzpicture}
   }{}% end-flow diagram
   \IfStrEq{\diagramtype}{descriptive diagram}{% true-descriptive diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}

   \foreach \subitem [count=\xii] in \smitem{%
      \pgfmathtruncatemacro\subitemvisible{\xi}
   \ifnumequal{\xii}{1}{% true
   \node[description title,drop shadow, smvisible on=<\subitemvisible->]
   (module-title\xi) at (0,0-\xi*\descriptiveitemsysep) {\subitem};\pause
   }{}
   \ifnumequal{\xii}{2}{% true
   \node[description,drop shadow,smvisible on=<\subitemvisible->]
   (module\xi)at (0,0-\xi*\descriptiveitemsysep) {\subitem};\pause
   }{}
   }%
   }%
   \end{tikzpicture}
   }{}% end-descriptive diagram
   \IfStrEq{\diagramtype}{bubble diagram}{% true-bubble diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[bubble center node, smvisible on=<\xi->](center bubble){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[bubble node, smvisible on=<\xi->](module\xi)
        at (center bubble.\angle) {\smitem };
   }%
   }%
   \end{tikzpicture}
   }{}%end-bubble diagram
   \IfStrEq{\diagramtype}{constellation diagram}{% true-const diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[planet, smvisible on=<\xi->](planet){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[satellite, smvisible on=<\xi->] (satellite\xi)
    at (\angle:\distanceplanetsatellite) {\smitem };
   \draw[->,connection planet satellite, smvisible on=<\xi->]
    (planet) -- (satellite\xi);
 }%
   }%
   \end{tikzpicture}
   }{}%end-constellation diagram
   \IfStrEq{\diagramtype}{connected constellation diagram}{% true-conn const diagram
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \pgfmathtruncatemacro\actualnumitem{\maxsmitem-1}
   \foreach \smitem [count=\xi] in {#2}{%
   \ifnumequal{\xi}{1}{ %true
   \node[planet,smvisible on=<\xi->](planet){\smitem};
   }{%false
   \pgfmathtruncatemacro{\xj}{\xi-1}
   \pgfmathtruncatemacro{\angle}{360/\actualnumitem*\xj}
   \edef\col{\@nameuse{color@\xj}}
   \node[satellite,smvisible on=<\xi->] (satellite\xj)
    at (\angle:\distanceplanetsatellite) {\smitem };
   }%
   }%
   \foreach \smitem [count=\xi] in {#2}{%
      \ifnumgreater{\xi}{1}{ %true
      \pgfmathtruncatemacro{\xj}{\xi-1}
      \edef\col{\@nameuse{color@\xj}}
      \pgfmathtruncatemacro{\xk}{mod(\xj,\actualnumitem) +1}
      \pgfmathtruncatemacro{\smvisible}{\xi+1}
      \path[connection planet satellite,smvisible on=<\smvisible->]
       (satellite\xj) edge[bend right] (satellite\xk);
   }{}
   }%
   \end{tikzpicture}
   }{}%end-connected constellation diagram
   \IfStrEq{\diagramtype}{priority descriptive diagram}{% true-priority descriptive diagram
   \pgfmathparse{subtract(\priorityarrowwidth,\priorityarrowheadextend)}
   \pgfmathsetmacro\priorityticksize{\pgfmathresult/2}
   \pgfmathsetmacro\arrowtickxshift{(\priorityarrowwidth-\priorityticksize)/2}
   \begin{tikzpicture}[every node/.style={align=center}]
   \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
   \foreach \smitem [count=\xi] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
   \pgfmathtruncatemacro\smvisible{\xi+1}
   \node[description,drop shadow={smvisible on=<\smvisible->},smvisible on=<\smvisible->]
    (module\xi) at (0,0+\xi*\descriptiveitemsysep) {\smitem};
\draw[line width=\prioritytick,\col,smvisible on=<\smvisible->]
 ([xshift=-\arrowtickxshift pt]module\xi.base west)--
 ($([xshift=-\arrowtickxshift pt]module\xi.base west)-(\priorityticksize pt,0)$);
   }%
   \coordinate (A) at (module1);
   \coordinate (B) at (module\maxsmitem);
   \CalcHeight(A,B){heightmodules}
   \pgfmathadd{\heightmodules}{\priorityarrowheightadvance}
   \pgfmathsetmacro{\distancemodules}{\pgfmathresult}
   \pgfmathsetmacro\arrowxshift{\priorityarrowwidth/2}
   \begin{pgfonlayer}{background}
   \node[priority arrow] at ([xshift=-\arrowxshift pt]module1.south west){};
   \end{pgfonlayer}
   \end{tikzpicture}
   }{}% end-priority descriptive diagram
   \IfStrEq{\diagramtype}{sequence diagram}{% true-sequence diagram
   \begin{tikzpicture}[every node/.style={align=center}]
 \foreach \x[count=\xi, count=\prevx from 0] in {#2}{%
   \edef\col{\@nameuse{color@\xi}}
\ifnum\xi=1
  \node[sequence item,smvisible on=<\xi->] (x-\xi) {\x};
\else
  \node[sequence item,anchor=west,smvisible on=<\xi->]
       (x-\xi) at (x-\prevx.east) {\x};
\fi
 }
   \end{tikzpicture}
   }{}% end-sequence diagram
   }% end-no value 1
}% end-command

%% 
%% Copyright (C) 2012-2013 by Claudio Fiandrino <claudio.fiandrino@gmail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% Claudio Fiandrino.
%% 
%% This work consists of the file  smartdiagram.dtx
%% and the derived files           smartdiagram.ins,
%%                                 smartdiagram.pdf, and
%%                                 smartdiagram.sty.
%% 
%%
%% End of file `smartdiagram.sty'.