summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pst-optexp/pst-optexp-doc.tex
blob: bbab17d1c817c1d8291cd0f52446561a4684281b (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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
%\documentclass[headinclude,DIV12]{scrartcl}
\documentclass[11pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,smallheadings,
    headexclude,footexclude,oneside]{pst-doc}

\usepackage[latin1]{inputenc}
%
\usepackage{pst-func}
\usepackage{pst-optexp}
\let\verPstOptExp\fileversion
\let\datePstOptExp\filedate
\usepackage{pst-circ}
\usepackage{nicefrac}
\usepackage{longtable}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{float}
%
\newfloat{LTXexampleFloat}{H}{expl}
\floatname{LTXexampleFloat}{Listing}
%
% New commands
%
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\newcommand{\OptExpPackage}{\textsf{`pst-optexp'}}
\newcommand{\parameter}[1]{\texttt{#1}}
\newcommand{\nodename}[1]{\emph{#1}}
\newcommand{\param}[1]{\normalfont\texttt{#1}}
\newcommand{\paramvalue}[1]{\texttt{#1}}
\newcommand{\defaultparam}[1]{\emph{default:} \paramvalue{#1}}
\newcommand{\paramitem}[3]{\item[\param{#1}:] \paramvalue{#2} (\defaultparam{#3})}
\newcommand{\styleitem}[2]{\item[\param{#1}:] \paramvalue{#2}}
\newcommand{\styleshape}[1]{\texttt{#1}}
\newcolumntype{T}{>{\ttfamily}l}
\newcolumntype{B}{>{\bfseries}l}
\newcommand{\refstringexplanation}[0]{%
  A \paramvalue{<ref string>} is any combination of \paramvalue{c}
  (center), \paramvalue{t} (top), \paramvalue{b} (bottom), \paramvalue{l}
  (left), \paramvalue{r} (right)}
%
% Settings
%\setkomafont{sectioning}{\normalfont\normalcolor\bfseries}
%
\makeatletter
\renewenvironment{description}
  {\list{}{\labelwidth\z@ \itemindent-0.5\leftmargin
    \itemsep0pt \parsep0pt
    \let\makelabel\descriptionlabel}}
  {\endlist}
\makeatother
%
%\clearscrheadfoot
%\setheadsepline{0.4pt}
%\ihead{\OptExpPackage}\ohead{A PSTricks package to draw optical experimental setups}
%\ofoot{\pagemark}
%\pagestyle{scrheadings}

\psset{usefiberstyle=true}
\addtopsstyle{Fiber}{linecolor=red,linewidth=1.5\pslinewidth}
\addtopsstyle{Beam}{linewidth=1.5\pslinewidth}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\title{\texttt{pstricks-add}\\additionals Macros for \texttt{pstricks}%
%\thanks{%
%    This document was written with \texttt{Kile: 1.7 (Qt: 3.1.1; KDE: 3.3;}
%    \url{http://sourceforge.net/projects/kile/}) and the PDF output
%    was build with VTeX/Free (\url{http://www.micropress-inc.com/linux})}
\\
    \small v.\verPstOptExp}
 \title{\texttt{pst-optexp}\\ A PSTricks package to draw optical experimental setups}
 \author{Christoph Bersch}
 \date{\datePstOptExp}
\maketitle

\clearpage
\tableofcontents
\clearpage

\section{Introduction}
The package \nxLPack{pst-optexp} is a collection of optical components
that facilitate easy sketching of optical experimental
setups. Mechanisms for proper alignment of different components are
provided internally. This way the user does not have to care for proper
orientation of the elements. Macros for convenient definition of new 
user-defined components are also provided.

\section{Concept and General Behavior}\label{sec:general}

This section introduces into the basic concepts of the package design and
explains the parameters and commands which are supported by most optical
objects.

\subsection{Concept}

The objects provided by \nxLPack{pst-optexp} can be differentiated into
two different categories: free-ray and fiber-optical objects.

The free-ray units are subdivided in two different kinds: dipoles which
require two reference points for alignment and do not alter the
direction of passing light beams (e.g. lenses and retardation plates)
and tripoles which work in reflection and require three reference points
(mirrors, gratings, beamsplitters etc.).

For free-ray setups one usually has a few straight light paths in which
several different objects are to be arranged. In this case it is very
convenient to define only two nodes for each light path. The objects are
placed on this light path using the different positioning parameters
(see Sec.~\ref{sec:positioning}) of the package. After having arranged
everything, the beams themselves are drawn. If objects with multiple
internal reflections (e.g. prisms, see Sections \ref{sec:doveprism},
\ref{sec:prism} -- \ref{sec:ppprism}) or objects without internal beams
(e.g. optical diodes, see Sec.~\ref{sec:optdiode}) are involved. The
different possibilities are explained in Sec.~\ref{sec:connecting}.

The fiber-optical objects can be classified as dipoles, tripoles and
quadrupoles which have a corresponding number of fiber
connections. Their handling differs in some aspects from the free-ray
objects. The fiber optics are directly connected to the reference
nodes. Every input and output fiber can be flexibly customized for each
object (see Sec.~\ref{sec:styles}). Positioning of the fiber dipoles is
handled equivalently to the free-ray dipoles. Tripoles and quadrupoles
can be found only as different coupler types. Their positioning
mechanisms are a bit more involved and explained in
Sec.~\ref{sec:coupler}.

Some hybrid dipoles (optbox, detector etc.) can be used both as
fiber-optical or free-ray elements. The way they are treated regarding
the connections to the reference points can be controlled by the
parameters explained in Sec.~\ref{sec:connecting}.

\subsection{General Settings}

\begin{description}
\paramitem{angle}{<degree>}{0}
\paramitem{compshift}{<num>}{0}
\paramitem{optional}{<boolean>}{false}
\paramitem{showoptdots}{<boolean>}{false}

\end{description}

\parameter{optional} can be used with every object and marks it as
optional. The style of an optional element can be configured by changing
the psstyle \styleshape{OptionalStyle}.

\parameter{showoptdots} draws some internal nodes which are used to
place the object and the label. The black points are used for
positioning, the red points mark the label references.

\medskip

\begin{LTXexample}[pos=t, vsep=0.8cm]
\begin{pspicture}[showgrid=true](8,2)
\psset{beam}
\lens[optional](0,1)(3,1){L}
\mirror[showoptdots](4,1)(7,1)(7,0){mirror}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Using PSStyles}\label{sec:styles}

\begin{description}
\styleitem{OptionalStyle}{<psstyle>}
\paramitem{addtoOptComp}{<psstyle>}{}
\paramitem{newOptComp}{<psstyle>}{}
\styleitem{OptComp}{<psstyle>}
\end{description}

\styleshape{OptComp} affects only the appearence of the optical
components. This was introduced, because using only the standard
graphics parameters changes also the connections that are drawn within
the component.

\medskip

\begin{LTXexample}[pos=t, vsep=0.8cm]
\begin{pspicture}[showgrid=true](8,2)
  \psset{beam}
  \addtopsstyle{OptComp}{linestyle=dashed, dash=2pt 2pt}
  % wrong, also beam width is changed
  \mirror[linewidth=3\pslinewidth](0,1)(3,1)(3,0){mirror}
  % correct result
  \mirror[addtoOptComp={linewidth=3\pslinewidth}](5,1)(7,1)(7,0){mirror}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Positioning}\label{sec:positioning}

\begin{description}
\paramitem{position}{<num>}{\{\}}
\paramitem{abspos}{<num>}{\{\}}
\end{description}

\noindent\parameter{position} is equivalent to the \parameter{npos}
parameter of \cs{ncput} (can be any number from 0 to 1) and controls the
relative position of object between the two reference points. It is only
not available for the free-ray tripoles.

The parameter \parameter{abspos} allows absolute positioning between the
two reference nodes. Its value is given in psunits.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2) 
  \lens[beam, position=0.8](0,1.2)(3,1.2){L}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2) 
  \lens[beam, abspos=1](0,1.2)(3,1.2){L}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Labels}\label{sec:labels}

\begin{description}
\paramitem{labeloffset}{<num>}{0.8}
\paramitem{labelangle}{<num>}{0}
\paramitem{labelstyle}{<macro>}{\cs{small}}
\paramitem{labelalign}{<ref string>\footnote{\refstringexplanation}}{c}
\paramitem{labelref}{relative|relgrav|global}{relgrav}
\paramitem{label}{<offset> <angle> <ref string> <labelref>}{}
\end{description}

\noindent\parameter{labeloffset} specifies the offset from the label 
reference node of the object which is mostly the center. 
\parameter{labelstyle} defines the textstyle that is used to typeset 
the label and \parameter{labelalign} corresponds to the refpoint of 
\cs{rput}. The parameter \parameter{labelref} sets the reference 
coordinate system for the \parameter{labelangle} and the orientation of
the label text. The detailed behaviour is best illustrated looking at
the following three examples.

\medskip

\begin{LTXexample}[width=5cm]
\begin{pspicture}(-2,-2)(2.5,2)
   \multido{\i=0+45}{8}{%
      \optbox[endbox,
              labelref=relative,
              labeloffset=0,
              optboxwidth=1,
              optboxheight=0.6](0,0)(1;\i){\i}
   }
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=5cm]
\begin{pspicture}(-2,-2)(2.5,2)
   \multido{\i=0+72}{5}{%
      \optbox[endbox,
              labelref=relgrav,
              optboxwidth=1,
              optboxheight=0.6](0,0)(1;\i){\i}
   }
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=5cm]
\begin{pspicture}(-2,-2)(2.5,2)
   \multido{\i=0+72}{5}{%
      \optbox[endbox,
              labelref=global,
              optboxwidth=1,
              optboxheight=0.6](0,0)(1;\i){\i}
   }
\end{pspicture}
\end{LTXexample}

\medskip

\parameter{label} simplifies the simultaneous change of more than one label-related parameter. It takes up to four space-separated arguments. Unchanged arguments may be specified with a dot.

\medskip

\begin{LTXexample}[width=5cm]
  \begin{pspicture}[showgrid=true](0,0)(3,3)
    \psset{endbox, beam}
    \optbox[label=1 -45](1,0)(2,1){label}
    \optbox[label=0 . . relative](0.6,0.6)(0.6,1.6){label}
  \end{pspicture}
\end{LTXexample}

\medskip

\subsection{Named Objects}\label{sec:namedobj}

\begin{description}
  \paramitem{compname}{<string>}{\{\}}
\end{description}

\noindent Every \nxLPack{pst-optexp} object of an experimental setup can
be assigned a name that is unique within one pspicture environment. The
name is defined with the parameter \parameter{compname} which is
defineable only directly within a \nxLPack{pst-optexp} object: \medskip

\begin{lstlisting}
\optbox[compname=MyBox](A)(B){Box} % valid use of 'compname'
\psset{compname=MyName}            % not valid, gives an error
\end{lstlisting}

\medskip

\noindent With this naming mechanisms one can access some special nodes of the
component at any time after its definition:

\begin{table}[H]
  \centering
  \addtolength{\extrarowheight}{1.5mm}
  \begin{tabularx}{.8\linewidth}{TX}
    \toprule
    \multicolumn{1}{l}{node name} & description\\
    \midrule
    <compname>ExtNode & Node for external connections (\emph{external node})\\
    <compname>Intern1 & Node which should be connected to the first reference node. 
       In the text we refer to this node as \emph{left outer node} \\
    <compname>Intern2 & First internal node. As the nodes with higher numbers it 
       is only available for objects with multiple internal beams (e.g. dove prism, 
       see Sec.~\ref{sec:doveprism}). They are called \emph{internal nodes}.\\
    \multicolumn{1}{c}{\vdots} & \\
    <compname>InternN & Node which should be connected to the second reference node. 
       In the text this node is referred to as \emph{right outer node}\\
    \bottomrule
  \end{tabularx}
  \caption{Naming conventions for special nodes which are created by named objects and can be 
    accessed by the user after definition of the object.}
\end{table}

If \parameter{compname} is empty, the external node has the name
\nodename{ExtNode} and will be overwritten by any following object. The
outer nodes are not accessible to the user and will also be overwritten
by following object. The internal nodes are deleted after the object's
definition.

These named objects are used to create permanent external nodes (see
Sec.~\ref{sec:extnode}) and to connect objects after their definition
(see Sec.~\ref{sec:connecting}).


\subsection{Nodes For External Usage}\label{sec:extnode}

\begin{description}
\paramitem{extnode}{<ref string>\footnote{\refstringexplanation}}{\{\}}
\end{description}

\noindent Some of the objects can provide a supplementary node for additional
connections. A laser diode may be connected for example to a frequency synthesizer
(use package \nxLPack{pst-circ}) or a detector to a computer.

\parameter{extnode} controls the position of the additional node and
takes a \paramvalue{<ref string>} as its argument. By default this
parameter is empty (\paramvalue{\{\}}) and no node is created.

The name of the new node depends on the \parameter{compname} parameter
(see Sec.~\ref{sec:namedobj} for naming conventions). If \parameter{compname} is empty
the new node is named \nodename{ExtNode} by default and overwritten by
following objects.

Table.~\ref{tab:nodes} shows all objects which provide an external
node. Some allow any possible \paramvalue{<ref string>} for \parameter{extnode}, others have
only one reasonable possibility (e.g. piezo mirror, see
Sec.~\ref{sec:mirror}) which does not depend on the actual value of \parameter{extnode}.

\bigskip

\begin{LTXexample}[pos=t, vsep=8mm]
\begin{pspicture}[showgrid=true](11,3) 
   \psset{conn=o-o, labelangle=-90, labeloffset=0.3}
   \optbox[extnode=tl](0,2.5)(3,2.5){\texttt{tl}}\psdot(ExtNode)
   \optbox[extnode=l](0,1.5)(3,1.5){\texttt{l}}\psdot(ExtNode)
   \optbox[extnode=bl](0,0.5)(3,0.5){\texttt{bl}}\psdot(ExtNode)
   \optbox[extnode=t](4,2.5)(7,2.5){\texttt{t}}\psdot(ExtNode)
   \optbox[extnode=c](4,1.5)(7,1.5){\texttt{c}}\psdot(ExtNode)
   \optbox[extnode=b](4,0.5)(7,0.5){\texttt{b}}\psdot(ExtNode)
   \optbox[extnode=tr](8,2.5)(11,2.5){\texttt{tr}}\psdot(ExtNode)
   \optbox[extnode=r](8,1.5)(11,1.5){\texttt{r}}\psdot(ExtNode)
   \optbox[extnode=br](8,0.5)(11,0.5){\texttt{br}}\psdot(ExtNode)
\end{pspicture}
\end{LTXexample}

\begin{table}[H]
\centering
  \begin{tabular}{llc}
    \toprule
    Object & possible extnode positions &\\
    \midrule
    %
    \cs{optbox} & 
    all (any combination of \paramvalue{t}, \paramvalue{r}, \paramvalue{l} and \paramvalue{b}) &
    \begin{pspicture}[shift=-0.3](0,-0.4)(1,0.4)
       \psframe(0,-0.25)(1,0.25)
       \psdot(0,-0.25)\psdot(0.5,-0.25)\psdot(1,-0.25)
       \psdot(0,0)\psdot(0.5,0)\psdot(1,0)
       \psdot(0,0.25)\psdot(0.5,0.25)\psdot(1,0.25)
    \end{pspicture}\\
    %
    \cs{mirror} & 
    one fixed position (only for \parameter{mirrortype=piezo}) &
    \begin{pspicture}[shift=-0.3](1,0.8)
       \mirror[mirrortype=piezo,extnode=t](0,0.4)(0.5,0.4)(0.5,0){}\psdot(ExtNode)
    \end{pspicture}\\
    %
    \cs{optdetector} & 
    one (for \parameter{dettype=round}) &
    \begin{pspicture}[shift=-0.3](1,0.8)
       \optdetector[detsize=0.6, extnode=r](0,0.4)(0.5,0.4){}
       \psdot(ExtNode)
    \end{pspicture}\\
    %
    & all (for \parameter{dettype=diode})& see \cs{optbox}\\
    \cs{optmzm} & all& see \cs{optbox}\\
    \cs{optfilter} & all & see \cs{optbox}\\
    \cs{optswitch} & all & see \cs{optbox}\\
    \cs{fiberdelayline} & all & see \cs{optbox}\\
    \bottomrule
  \end{tabular}
  \caption{The objects which may provide an external node when parameter
    \parameter{extnode} is not empty. Some allow different positions of the
    node and for some only a fixed node makes sense.}\label{tab:nodes}
\end{table}

\subsection{Connecting Objects}\label{sec:connecting}

\begin{description}
\paramitem{conn}{<conn definition>}{-}
\item[\param{fiber}:] alias for \parameter{conn=f-f}
\item[\param{beam}:] alias for \parameter{conn=o-i}
\paramitem{connjoin}{<int>}{1}
\end{description}

\noindent Simple experimental setups with a few objects can usually be
realized by defining some nodes, arranging the object in between and
drawing the beams at the end. If, however, objects with changed internal
optical path (all the prisms) or without visible internal beam (optical
diode) are involved, this simple method is not applicable anymore.

For this case several different possibilities of connecting objects are
available: \parameter{conn} specifies the kind of connections in front of and
behind the object. Its syntax is analogous to the PSTricks
\parameter{arrows} parameter. By default it is set to \paramvalue{-} and no
connections are drawn. Tab.~\ref{tab:conn} lists all possible values and
their scope for the \paramvalue{<conn definition>}.

\begin{table}\centering
\addtolength{\extrarowheight}{1.5mm}
\begin{tabularx}{0.9\textwidth}{TXl}
  \toprule
  \multicolumn{1}{l}{conn style} & description & scope\\
  \midrule
  i & Draw beam from the first reference node to its assigned outer node 
      and then through all internal nodes and end at the other 
      outer node. & \multirow{3}{*}{optexp objects}\\
  o & Draw beam from the first reference node to its assigned outer node.  & \\
  f & Draw fiber from the first reference node to its assigned outer node. & \\
  \midrule
  a & Left outer node & \multirow{4}{*}{\cs{drawbeam} macro}\\
  A & Connect left outer node to all internal nodes and then to the right outer node & \\
  b & Right outer node & \\
  B & Connect right outer node to all internal nodes and then to the left outer node & \\
  \bottomrule
\end{tabularx}
\caption{All possible values for the \paramvalue{<conn definition>}, their detailed description and scope.}\label{tab:conn}
\end{table}

The first letter (before the dash) in the \paramvalue{<conn definition>}
refers to which object node the first reference node should be connected
to, the second letter (after the dash) affects the connection from the
object to the second reference node. Tab.~\ref{tab:conn} lists all
possibilities for \parameter{conn} within an object: \paramvalue{f} draws
a fiber connection and \paramvalue{o} a beam connection to the
appropriate outer node. \paramvalue{i} draws a beam connection to the
appropriate outer node and then through all internal nodes and end at
the other outer node. The boolean parameter \parameter{beam} is an alias
for \parameter{conn=o-i}. The beam style is controlled by the
psstyle \styleshape{Beam} which can be changed
using \cs{newpsstyle} and \cs{addtopsstyle}.

All fiber-optical units define \parameter{conn=f-f} which means that
input and output connections are \paramvalue{f}ibers. The boolean
parameter \parameter{fiber} is an alias for \parameter{conn=f-f}. The
fiber connection style can be changed by adapting the \styleshape{Fiber*}
styles (see Sec.~\ref{sec:fiberstyles}).

The way how to really use this kind of connections should become more
clear after looking at the following examples in this section.

\medskip

\begin{LTXexample}[width=4.5cm]
\begin{pspicture}[showgrid=true](4,5)
  \addtopsstyle{Beam}{arrows=->, arrowscale=1.5}
  \psset{labeloffset=0}
  \doveprism[conn=o-](0,4.5)(4,4.5){\texttt{o-}}
  \doveprism[conn=i-](0,3.5)(4,3.5){\texttt{i-}}
  \doveprism[conn=-o](0,2.5)(4,2.5){\texttt{-o}}
  \doveprism[conn=-i](0,1.5)(4,1.5){\texttt{-i}}
  \optbox[conn=-f](0,0.5)(4,0.5){\texttt{-f}}
\end{pspicture}
\end{LTXexample}

\medskip 

The following example shows how this \parameter{conn} parameter can be used in some kinds
of experimental setups using objects with changed internal optical path (here a
penta prism). Instead of drawing the beam at the end with a \cs{psline},
the beams are created at definition time of the respective object.

\begin{LTXexampleFloat}
\begin{LTXexample}[width=4.5cm]
\begin{pspicture}[showgrid=true](4,5)
   \pnode(1,1){A}\pnode(1,4){G}\pnode(3,4){B}
   \optbox[endbox, labelref=relative, labeloffset=0, optboxwidth=1](G)(A){Laser}
   \lens[lens=0.5 0.5 0.5, abspos=0.3](A)(G){}
   \pinhole[abspos=0.5](A)(G){}
   \lens[lens=2, abspos=0.8](A)(G){}
   \lens[abspos=2, labelangle=180](A)(G){L}
   \optplate[abspos=1.5, labeloffset=1](A)(G){SLM}
   \lens[abspos=1](G)(B){L}
   \optbox[endbox, labeloffset=0, optboxwidth=1](G)(B){CCD}
   \pentaprism[beam, labeloffset=1](A)(G)(B){PP}
\end{pspicture}
\end{LTXexample}
\caption{Code example on how to use the \parameter{conn} parameter in experimental setups.}\label{lst:conn}
\end{LTXexampleFloat}

This method works unless objects without internal beams (e.g. an optical
diode, Sec.~\ref{sec:optdiode}) or with internal reflections (e.g. a
Dove prism, Sec.~\ref{sec:doveprism}) are used in the straight light
paths of the setup. One possibility would be to create additional nodes,
but this may be not very comfortable. Therefore, \nxLPack{pst-optexp}
provides a macro \cs{drawbeam} which connects a named object
(Sec.~\ref{sec:namedobj}) to another named object or a node.

\medskip

\begin{lstlisting}
\drawbeam[conn=...]{<from>}{<to>}
\end{lstlisting}

\medskip

\noindent If \paramvalue{<from>} or \paramvalue{<to>} is a node, it must be written
including the round braces. The call

\medskip

\begin{lstlisting}
\drawbeam{Obj}{(1;45)}
\end{lstlisting}

\medskip\noindent connects the named object \nodename{Obj} to the node.

The type of beam connection which \cs{drawbeam} draws is again
controlled by the parameter \parameter{conn}. Almost every optical
object does not have distinguished inputs and outputs and can be used in
either directions. Therefore, it does not make sense to speak about
`input` and `output` when referring to the object nodes, but rather
about node A (\nodename{left outer node}) and node B (\nodename{right outer
  node}). Consequently, the two letters of parameter \parameter{conn}
can take the values \paramvalue{a}, \paramvalue{A}, \paramvalue{b}
or \paramvalue{B} when used together with \cs{drawbeam}. The detailed
descriptions of the individual possibilities are listed in
Tab.~\ref{tab:conn}. The letter before the dash in \parameter{conn}
refers to the \paramvalue{<from>} object, the other one to
the \paramvalue{<to>} object. Again, the next examples should clearify
how to apply the \cs{drawbeam} macro together with the
different \parameter{conn} settings.

\begin{LTXexampleFloat}
  \begin{LTXexample}[width=4.5cm]
    \begin{pspicture}[showgrid=true](4,6) \psset{labeloffset=0.6}
      \addtopsstyle{Beam}{arrows=->, arrowscale=1.5}
      \doveprism[compname=Dove1](0,0.8)(3,0.8){Dove1}
      \drawbeam[conn=b-]{Dove1}{(3,0.8)}
      \doveprism[compname=Dove2](0,2.3)(3,2.3){Dove2}
      \drawbeam[conn=B-]{Dove2}{(3,2.3)}
      \doveprism[compname=Dove3](0,3.8)(3,3.8){Dove3}
      \drawbeam[conn=-a]{(0,3.8)}{Dove3}
      \doveprism[compname=Dove4](0,5.3)(3,5.3){Dove4}
      \drawbeam[conn=-A]{(0,5.3)}{Dove4}
    \end{pspicture}
  \end{LTXexample}
\end{LTXexampleFloat}

With the help of the \cs{drawbeam} macro we can adapt
Listing~\ref{lst:conn} to use an optical diode before the beam clearing
and connect it to the other components. In order to illustrate the beams
that are drawn by the different mechanisms, they are colorcoded in the
resulting Listing~\ref{lst:conn2}: \emph{green} is the direct connecting
of the optical diode, \emph{red} is the \cs{drawbeam} connection and
\emph{blue} the direct connecting of the penta prism.

\begin{LTXexampleFloat}
\begin{LTXexample}[width=4.5cm]
\begin{pspicture}[showgrid=true](4,6)
   \pnode(1,1){A}\pnode(1,5){G}\pnode(3,5){B}
   \optbox[endbox, labelref=relative, labeloffset=0, optboxwidth=1](G)(A){Laser}
   \lens[lens=0.5 0.5 0.5, abspos=1.5](A)(G){}
   \pinhole[abspos=1.7](A)(G){}
   \lens[lens=2, abspos=2](A)(G){}
   \lens[abspos=3, labelangle=180](A)(G){L}
   \optplate[abspos=2.5, labeloffset=1](A)(G){SLM}
   \lens[abspos=1](G)(B){L}
   \optbox[endbox, labeloffset=0, optboxwidth=1](G)(B){CCD}
   \optdiode[abspos=0.8, conn=o-, compname=OD](A)(G){OD}
   \addtopsstyle{Beam}{linecolor=blue}
   \pentaprism[conn=-i, labeloffset=1, compname=PP](A)(G)(B){PP}
   \addtopsstyle{Beam}{linecolor=red}
   \drawbeam[conn=b-a]{OD}{PP}
\end{pspicture}
\end{LTXexample}
\caption{More soffisticated code example which employs both connecting
  methods. The beam connections are colorcoded: \emph{green} is the
  direct connecting of the optical diode, \emph{red} is the
  \cs{drawbeam} connection and \emph{blue} the direct connecting of the
  penta prism.}\label{lst:conn2}
\end{LTXexampleFloat}

\newpage

\section{Free-Ray Objects}

The general appearance of all objects can be customized using the
standard PSTricks parameter like \parameter{linewidth}
or \parameter{fillstyle}. Some components allow changing a special part
(e.g. for a piezo mirror) for which they use certain psstyles. For the
automatic beam connections the \styleshape{Beam} style is used.

\subsection{Lens}\label{sec:lens}

\begin{description}
\paramitem{lensheight}{<num>}{1}
\paramitem{lenswidth}{<num>}{0.2}
\paramitem{lensradius}{<num> [<num>]}{\{\}}
\paramitem{lensradiusleft}{<num>}{1}
\paramitem{lensradiusright}{<num>}{1}
\paramitem{lens}{<num> [<num> [<num> [<num>]]]}{\{\}}
\paramitem{thicklens}{<boolean>}{false}
\end{description}

\medskip 

\begin{LTXexample}[width=5.5cm]
\begin{pspicture}[showgrid=true](5,6)
  % concave lenses
  \pnode(0,5){A}\pnode(5,5){B}
  \psline[style=Beam](A)(B)
  \lens[position=0.2](A)(B){L}
  \lens[lensradius=-1,position=0.5](A)(B){L}
  \lens[lens=-1.5 1,position=0.7](A)(B){L}
  % convex lenses
  \pnode(0,3){A}\pnode(5,3){B}
  \psline[style=Beam](A)(B)
  \lens[position=0.2,lens=1 -1](A)(B){L}
  \lens[lens=0 -1](A)(B){L}
  \lens[lens=1 0,position=0.7](A)(B){L}
  % thick lenses
  \pnode(0,1){A}\pnode(5,1){B}
  \psline[style=Beam](A)(B)
  \lens[position=0.3, lens=-1.5 1 1 0.5, thicklens](A)(B){thicklens}
  \lens[lens=0 -1, position=0.7, fillstyle=solid, fillcolor=blue!30!white](A)(B){lens}
\end{pspicture}
\end{LTXexample}

\medskip

The shape of a lens is defined by its two surface radii. A negative
radius gives a concave, a positive radius a convex and a radius of
\texttt{0} a plain surface. The parameters \parameter{lensradiusleft}
and \parameter{lensradiusright} allow to define independent values for
both surfaces. \parameter{lensradius} sets both curvatures to the same
value. Usually only \parameter{lensheight} and the two radii are used to
construct the lens. The thickness (or width) is determined
automatically. Manually controlling the thickness of the lens can be
achived by setting \parameter{thicklens}
to \paramvalue{true}. Then \parameter{lenswidth} is used as width of the
lens at its waist. Finally, the parameter \parameter{lens} allows the
definition of all relevant lens parameters at once. It consists of one
up to four space-separated numbers. The first one gives the left
radius. If no further value is set, the right radius will be set to the
same value and all other parameters are left unchanged. Using two
numbers defines two different radii. The third optional value defines
the \parameter{lensheight} and the fourth one the \parameter{lenswidth}
which is use only if \parameter{thicklens} is set to \parameter{true}.

\textbf{Compatibility:} The whole implementation of the lens was
changed in version 1.2. It allows a much more flexible definition of different lens
types. However, I could not get full compatibility with the older way to
define lens using only \parameter{lensheight} and \parameter{lenswidth}. To use
this old behaviour, you have to set the \parameter{lenstype} explicitly, but
then you have no access to the new features! All users are encouraged to
adapt their code to use the new parameters, as the old code will be
removed in future versions.

\medskip
\subsection{Optical Plate}

\begin{description}
\paramitem{plateheight}{<num>}{1}
\paramitem{platelinewidth}{<num>}{2\cs{pslinewidth}}
\paramitem{angle}{<degree>}{0}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optplate[beam](0,1.2)(3,1.2){filter}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optplate[angle=10, beam](0,1.2)(3,1.2){glass plate}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Retardation Plate}

\begin{description}
\paramitem{plateheight}{<num>}{1}
\paramitem{platewidth}{<num>}{0.1}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,1.2){A}
  \pnode(3,1.2){B}
  \optretplate[beam](A)(B){$\nicefrac{\lambda}{2}$}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Pinhole}

\begin{description}
\paramitem{outerheight}{<num>}{1}
\paramitem{innerheight}{<num>}{0.1}
\paramitem{phlinewidth}{<num>}{2\cs{pslinewidth}}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,1.2){A}
  \pnode(3,1.2){B}
  \pinhole[beam](A)(B){PH}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Crystal}\label{sec:crystal}

\begin{description}
\paramitem{crystalwidth}{<num>}{1.4}
\paramitem{crystalheight}{<num>}{0.6}
\paramitem{caxislength}{<num>}{0.6}
\paramitem{caxisinv}{<boolean>}{false}
\paramitem{voltage}{<boolean>}{false}
\paramitem{lamp}{<boolean>}{false}
\paramitem{lampscale}{<num>}{0.3}
\paramitem{angle}{<degree>}{0}
\paramitem{rotateref}{<ref string>}{c}
\end{description}

\noindent For a discussion of the \parameter{angle} and \parameter{rotateref}
parameters see Sec.~\ref{sec:box} about boxes.  \medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,1.2){A}
  \pnode(3,1.2){B}
  \crystal[fillstyle=solid, fillcolor=yellow!90!black, labelangle=-45, labeloffset=1.2, voltage, lamp, beam](A)(B){SBN:Ce}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Box}\label{sec:box}

\begin{description}
\paramitem{optboxheight}{<num>}{0.8}
\paramitem{optboxwidth}{<num>}{1.4}
\paramitem{endbox}{<boolean>}{false}
\paramitem{angle}{<degree>}{0}
\paramitem{rotateref}{<ref string>\footnote{\refstringexplanation}}{c}
\paramitem{refractiveindex}{<num>}{\{\}}
\end{description}

\medskip 

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optbox[beam](0,0)(3,2){box}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optbox[beam, endbox](0,0)(1.7,1){box}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,0){A}
  \pnode(1.7,1){B}
  \optbox[beam, endbox, labelref=relative, labeloffset=0](A)(B){box}
\end{pspicture}
\end{LTXexample}

\medskip

\noindent The parameter \parameter{angle} describes the tilt of the box
relative to the reference line defined by the two reference nodes. The
reference point for the rotation can be defined
with \parameter{rotateref} which can take any combination
of \paramvalue{c}, \paramvalue{t}, \paramvalue{b}, \paramvalue{l}
and \paramvalue{r} (compare with \parameter{extnode} in
Sec.~\ref{sec:extnode}). Note, that all connection-related nodes are
also rotate, while the label is not affected.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optbox[angle=20, beam, rotateref=l, labeloffset=0.5](0,1)(3,1){box}
\end{pspicture}
\end{LTXexample}

\medskip

\noindent Together with the parameter \parameter{refractiveindex} this
can be exploited to sketch the refraction through a tilted homogeneous
medium (e.g. a glass plate). Then, however, the reference nodes for the
beam connection must be corrected which is rather easy using the outer
nodes of the object as coordinate references and the \texttt{|} node
operator.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,1){A}
  \pnode(3,1){B}
  \optbox[labeloffset=0.7, optboxwidth=0.5, optboxheight=1, angle=20, refractiveindex=2.3, compname=Box](A)(B){glass plate}
  \drawbeam[conn=-a]{(A|BoxIntern1)}{Box}
  \drawbeam[conn=B-]{Box}{(B|BoxInternN)}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Detector}

\begin{description}
\paramitem{detsize}{<num>}{0.8}
\paramitem{dettype}{round|diode}{round}
\end{description}

With \nxLPack{pst-optexp} version 2.0 the name for the detector was
changed to \cs{optdetector} as the package \nxLPack{pst-circ} also
provides a \cs{detector} macro. For compatibility reasons the old
\cs{detector} macro is available when \nxLPack{pst-circ} is not loaded
before \nxLPack{pst-optexp}.


  \medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,0){A}
  \pnode(1.7,1){B}
  \optdetector[beam](A)(B){detector}
\end{pspicture}
\end{LTXexample}

\bigskip 

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,0){A}
  \pnode(1.7,1){B}
  \optdetector[beam, dettype=diode](A)(B){detector}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Optical Diode}\label{sec:optdiode}

\begin{description}
\paramitem{optdiodesize}{<num>}{0.8}
\end{description}

\medskip 

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \optdiode[conn=o-o](0,1)(3,1){Diode}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Dove Prism}\label{sec:doveprism}
\begin{description}
  \paramitem{doveprismsize}{<num>}{0.6}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \doveprism[beam](0,1)(3,1){Dove}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Polarization}

\begin{description}
\paramitem{poltype}{parallel|perp|misc|lcirc|rcirc}{parallel}
\paramitem{polsize}{<num>}{0.6}
\paramitem{pollinewidth}{<num>}{0.7\cs{pslinewidth}}
\end{description}

\medskip

\begin{LTXexample}[width=3.4cm]
\begin{pspicture}[showgrid=true](3,5)
  \pnode(0,0.5){A1}\pnode(3,0.5){B1}\pnode(0,1.5){A2}
  \pnode(3,1.5){B2}\pnode(0,2.5){A3}\pnode(3,2.5){B3}
  \pnode(0,3.5){A4}\pnode(3,3.5){B4}\pnode(0,4.5){A5}
  \pnode(3,4.5){B5}\psset{style=Beam}
  \multido{\i=1+1}{5}{\psline(A\i)(B\i)}
  \psset{linecolor=black}
  \polarization[poltype=misc,position=0.2](A5)(B5)
  \polarization[poltype=perp,position=0.35](A4)(B4)
  \polarization[poltype=parallel,position=0.5](A3)(B3)
  \polarization[poltype=rcirc,position=0.65](A2)(B2)
  \polarization[poltype=lcirc,position=0.8](A1)(B1)
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Mirror}\label{sec:mirror}

\begin{description}
\paramitem{mirrorwidth}{<num>}{1}
\paramitem{mirrorradius}{<num>}{0}
\paramitem{mirrorlinewidth}{<num>}{2\cs{pslinewidth}}
\paramitem{mirrortype}{normal|piezo|extended}{normal}
\paramitem{mirrordepth}{<num>}{0.1}
\paramitem{variable}{<num>}{false}
\styleitem{ExtendedMirror}{<psstyle>}
\styleitem{PiezoMirror}{<psstyle>}
\end{description}

\noindent The parameter \parameter{mirrorradius} defines the curvature
of the mirror. A value of \paramvalue{0} is for a plain mirror, a
negative radius is for a concave mirror and a positive radius gives you
a convex mirror. The style of the extended mirror is defined as a
psstyle \styleshape{ExtendedMirror} and can be changed using
\cs{newpsstyle} or \cs{addtopsstyle}. The appearence of the piezo mirror
likewise can be changed by adapting the psstyle
\styleshape{PiezoMirror}. Note, when using \parameter{extnode} with a
piezo mirror, the default piece of wire is omitted.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}
  \pnode(1.8,2.2){G}
  \pnode(0,3){B}
  \mirror[beam](A)(G)(B){mirror}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}
  \pnode(1.8,2.2){G}
  \pnode(0,3){B}
  \mirror[beam, variable](A)(G)(B){M$_\mathrm{var}$}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}
  \pnode(1.8,2.2){G}
  \pnode(0,3){B}
  \mirror[beam, mirrortype=piezo,labelangle=-90](A)(G)(B){piezo}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}
  \pnode(1.8,2.2){G}
  \pnode(0,3){B}
  \mirror[beam, mirrortype=extended](A)(G)(B){M$_\mathrm{ext}$}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}\pnode(1,2){G1}
  \pnode(1.8,1){G2}\pnode(2.5,3){B}
  \psset{labeloffset=0.5}
  \psline[style=Beam](A)(G1)(G2)(B)
  \mirror[mirrortype=extended, mirrorradius=1](A)(G1)(G2){M$_{\mathrm{concave}}$}
  \mirror[mirrorradius=-1](G1)(G2)(B){M$_{\mathrm{convex}}$}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Beamsplitter}

\begin{description}
\paramitem{bssize}{<num>}{0.8}
\paramitem{bsstyle}{cube|plate}{cube}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,2){A}
  \pnode(2,2){G}
  \pnode(3,0){B}
  \beamsplitter[beam](A)(G)(B){BS}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,2){A}
  \pnode(2,2){G}
  \pnode(3,0){B}
  \beamsplitter[bsstyle=plate, beam](A)(G)(B){BS}
\end{pspicture}
\end{LTXexample}

\medskip


\subsection{Optical Grid}

\begin{description}
\paramitem{optgridcount}{<integer>}{10}
\paramitem{optgridwidth}{<num>}{1}
\paramitem{optgridheight}{<num>}{0.1}
\paramitem{optgriddepth}{<num>}{0.05}
\paramitem{optgridtype}{blazed|binary}{blazed}
\paramitem{optgridlinewidth}{<num>}{0.7\cs{pslinewidth}}
\paramitem{reverse}{<boolean>}{false}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,3){A}
  \pnode(1.8,2.2){G}
  \pnode(0,0){B}
  \optgrid[beam](A)(G)(B){grid}
\end{pspicture}
\end{LTXexample}

\bigskip


\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,3){A}
  \pnode(1.8,2.2){G}
  \pnode(0,0){B}
  \optgrid[beam, reverse](A)(G)(B){grid}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,3){A}
  \pnode(1.8,2.2){G}
  \pnode(0,0){B}
  \optgrid[beam,%
           optgridcount=6,%
           optgriddepth=0.2,%
           optgridheight=0.3](A)(G)(B){grid}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,3){A}
  \pnode(1.8,2.2){G}
  \pnode(0,0){B}
  \optgrid[beam, optgridtype=binary](A)(G)(B){grid}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Prism}\label{sec:prism}
\begin{description}
  \paramitem{prismsize}{<num>}{1}
  \paramitem{prismangle}{<num>}{60}
\end{description}

The prism has always a symmetric refraction independent of the beams and
the \parameter{prismangle}.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,2.5){A}
  \pnode(2,2){G}
  \pnode(3,0){B}
  \optprism[beam](A)(G)(B){Prism}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Right-Angle Prism}\label{sec:raprism}
\begin{description}
  \paramitem{raprismsize}{<num>}{1.5}
\end{description}

The right-angle prisms is constructed such that the two incoming beams
are parallel and the middle reference node is vertically centered in the
prism.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \pnode(0,1.5){A}
  \pnode(1.8,0.8){G}
  \pnode(0,0.5){B}
  \rightangleprism[beam, showoptdots](A)(G)(B){RA}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Penta Prism}\label{sec:ppprism}
\begin{description}
  \paramitem{pentaprismsize}{<num>}{0.7}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,2){A}
  \pnode(2,2){G}
  \pnode(2,0){B}
  \pentaprism[beam](A)(G)(B){PP}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Custom Components}\label{sec:custom}
The macros \cs{optdipole} and \cs{opttripole} allow using everything as
optical component. If you want to use a certain component several times,
you should define it as a new component. For details on how to define
your own components see Sec.~\ref{sec:newobj}.

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,2){A}
  \pnode(3,1){B}
  \optdipole[labeloffset=1, beam](A)(B){%
    \rput(0,0){%
      \includegraphics[scale=0.25]{parque-nacional}
    }
  }{label}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
  \pnode(0,0){A}
  \pnode(1.5,2){G}
  \pnode(3,1.5){B}
  \opttripole[beam](B)(G)(A){\rput[b](0,0){text}}{label}
\end{pspicture}
\end{LTXexample}

\medskip

\section{Fiber-Optical Objects}

\begin{description}
\paramitem{usefiberstyle}{<boolean>}{false}
\end{description}

Fiber-optical objects are automatically connected to the reference
nodes. The style of all fiber connections can be configured
independently (see Sec.~\ref{sec:fiberstyles}).

For some components it might me nice to highlight some
internals. If \parameter{usefiberstyle} is enabled, for examples the
passing parts of the optical filter are drawn with the \styleshape{Fiber}
style. In the documentation this parameter is enabled to show the parts
which would be highlighted.

\subsection{Fiber}
\begin{description}
\paramitem{fiberloops}{<integer>}{3}
\paramitem{fiberloopradius}{<num>}{0.4}
\paramitem{fiberloopsep}{<num>}{0.3}
\end{description}
\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optfiber[labeloffset=0.4](0,1)(3,1){SSMF}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Amplifier}
\begin{description}
\paramitem{optampsize}{<num>}{0.8}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optamp(0,1)(3,1){EDFA}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Mach-Zehnder Modulator}
\begin{description}
\paramitem{optmzmsize}{<num>}{0.8}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optmzm(0,1)(3,1){MZM}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Filter}
\begin{description}
\paramitem{filtersize}{<num>}{0.8}
\paramitem{filtertype}{bandpass|bandstop}{bandpass}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optfilter(0,1)(3,1){bandpass}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optfilter[filtertype=bandstop](0,1)(3,1){bandstop}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Polarization Controller}
\begin{description}
\paramitem{polcontrolsize}{<num>}{0.15}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \polcontrol(0,1)(3,1){PC}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Isolator}
\begin{description}
\paramitem{isolatorsize}{<num>}{0.6}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optisolator(0,1)(3,1){}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Optical Switch}
\begin{description}
\paramitem{switchsize}{<num>}{0.8}
\paramitem{switchstyle}{opened|closed}{opened}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optswitch(0,1)(3,1){Opened switch}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optswitch[switchstyle=closed](0,1)(3,1){Closed switch}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Fiber Delay Line}

\begin{description}
  \paramitem{fdlsize}{<num>}{0.6}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \fiberdelayline(0,1)(3,1){Delay line}
\end{pspicture}
\end{LTXexample}

\medskip


\subsection{Fiber Polarizer}

\begin{description}
  \paramitem{fiberpolsize}{<num>}{0.6}
\end{description}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optfiberpolarizer(0,1)(3,1){polarizer}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Fiber Collimator}

\begin{description}
\paramitem{fibercolsize}{<num>}{0.3}
\end{description}

The connection type for the fiber collimator is fixed
to \parameter{conn=o-f}. The component can be use with two, three or
four nodes. With more than two points, the fiber is drawn as a
\cs{psbezier} curve. In the case of three nodes, the middle one is used
twice. Positioning parameters can still be used to shift the component
between the first two nodes.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \fibercollimator(0.5,1)(2.5,1){FC}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \fibercollimator(0,1)(2,1)(3,2){FC}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \fibercollimator(0.5,1)(2.5,1)(2.5,2){FC}
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \fibercollimator[position=0.2](0.5,1)(2.5,1)(2.5,2)(0.5,2){FC}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Coupler}\label{sec:coupler}
\begin{description}
\paramitem{couplersize}{<num>}{0.2}
\paramitem{couplersep}{<num>}{0.1}
\paramitem{couplertype}{none|elliptic}{elliptic}
\paramitem{align}{top|bottom|center}{center}
\end{description}

\subsubsection{\texorpdfstring{$2\times 2$}{2x2} Coupler}

\medskip 

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optcoupler(0.5,2)(0,0.5)(3,1.5)(2.5,0){Coupler}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optcoupler[align=top](0.5,2)(0,0.5)(3,1.5)(2.5,0){Coupler}
\end{pspicture}
\end{LTXexample}

\bigskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \optcoupler[align=bottom, couplertype=none](0.5,2)(0,0.5)(3,1.5)(2.5,0){Coupler}
\end{pspicture}
\end{LTXexample}

\medskip

\subsubsection{WDM Coupler}

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \wdmcoupler[labeloffset=0.5](0,1.5)(0,0.5)(3,1){WDM}
\end{pspicture}
\end{LTXexample}

\medskip

\subsubsection{WDM Splitter}
\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
  \newpsstyle{FiberOut2}{style=Fiber, arrows=->}
  \wdmsplitter[align=top, labeloffset=0.5](0,1.5)(3,1.5)(3,0.5){}
\end{pspicture}
\end{LTXexample}

\medskip

\subsection{Fiber Styles}\label{sec:fiberstyles}

\begin{description}
\styleitem{Fiber}{<psstyle>}%{linecolor=red}
\styleitem{FiberIn}{<psstyle>}%{style=Fiber}
\styleitem{FiberIn1}{<psstyle>}%{style=FiberIn}
\styleitem{FiberIn2}{<psstyle>}%{style=FiberIn}
\styleitem{FiberOut}{<psstyle>}%{style=Fiber}
\styleitem{FiberOut1}{<psstyle>}%{style=FiberOut}
\styleitem{FiberOut2}{<psstyle>}%{style=FiberOut}
\end{description}

All these psstyles control the appearence of the fiber parts before and
after each object. The styles can be redefined with \cs{newpsstyle} or
changed with \cs{addtopsstyle}.  For optical systems it is not possible
to define a unique input and a unique output as most components can be
used bidirectionally. Therefore, I refer to the input as the connections
on the left of the object and to the output the ones on the right side.

The basic style is \styleshape{Fiber} which is the parent of all other
styles. \styleshape{FiberIn} inherits from \styleshape{Fiber} and defines
the style of the input fiber. Analogously \styleshape{FiberOut} controls
the style of the output fiber. If you want to change the input and
output fiber styles you should use \cs{addtopsstyle} as then the
inheritance from the parent style \styleshape{Fiber} remains.

The other psstyles are used only by the various fiber couplers
(\cs{optcoupler}, \cs{wdmcoupler} and
\cs{wdmsplitter}). \styleshape{FiberIn1} affects the upper input fiber,
\styleshape{FiberIn2} the lower input fiber, \styleshape{FiberOut1} the
upper output fiber and \styleshape{FiberOut2} the lower output fiber. If
the object has only one input (e.g. \cs{wdmsplitter}),
\styleshape{FiberIn} is used. All fiber connections are drawn as
\cs{pccurve} which means that also the curvature and the input and
output angles of each connection can be changed as you will see in a
following code example.

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,3)
   \addtopsstyle{FiberIn}{ArrowInside=->, arrowscale=1.2}
   \addtopsstyle{FiberOut2}{linecolor=blue}
   \optcoupler(0,2.5)(0,0.5)(3,2.5)(3,0.5){50~\%}
\end{pspicture}
\end{LTXexample}

\medskip

In addition to the psstyles there exist
corresponding \parameter{newFiber\ldots} and \parameter{addtoFiber\ldots}
parameter keys for each of them.

\medskip

\begin{lstlisting}
\psset{addtoFiberIn={arrows=->, arrowscale=1.3}}
\end{lstlisting}

\medskip

\noindent is equivalent to 

\medskip

\begin{lstlisting}
\addtopsstyle{FiberIn}{arrows=->, arrowscale=1.3}
\end{lstlisting}

\medskip

\noindent Accordingly \parameter{newFiberIn} corresponds to \cs{newpsstyle\{FiberIn\}\{\ldots\}}.

At first glance these keys make no sense. The reason why I
introduced them was to be able to define special couplers with
\cs{newpsobject}. This is only possible if all modifications can be
expressed as parameter keys. Consider for example a WDM splitter which
only couples out a certain spectral range of the input and you want to
mark the output with an arrow:

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \newpsobject{mywdmsplitter}{wdmsplitter}{addtoFiberOut1={arrows=->, arrowscale=1.3, linecolor=blue}, labelangle=180, align=bottom}
   \mywdmsplitter(0,0.5)(3,1.5)(3,0.5){blue band}
\end{pspicture}
\end{LTXexample}

\medskip

Or if you need a coupler with a particular input angle you can do it be extending the appropriate fiber style:

\medskip

\begin{LTXexample}[width=3.5cm]
\begin{pspicture}[showgrid=true](3,2)
   \newpsobject{mycoupler}{optcoupler}{addtoFiberIn2={angleA=90}, align=top}
   \mycoupler(0.5,1.5)(0.5,0.5)(2.5,1.5)(2.5,0.5){}
\end{pspicture}
\end{LTXexample}

\medskip

\section{Defining New Objects}

\subsection{Customized Versions of Existing Macros}

The easiest way to define your own components is to use the
\cs{newpsobject} macro. With this you can define a new component using
predefined objects with a set of options. These options serve only as
default values and can be overridden when calling the macro. The
following examples defines a new object \cs{sbn} for the special crystal
used in Sec.~\ref{sec:crystal}.

\medskip

\begin{LTXexample}[width=3.5cm]
\newpsobject{sbn}{crystal}{voltage, lamp, labelangle=45, labeloffset=1.2, fillstyle=solid, fillcolor=yellow!90!black}
\begin{pspicture}[showgrid=true](3,2) 
   \sbn(0,1)(3,1){SBN:Ce}
   \psline[style=Beam](0,1)(3,1)
\end{pspicture}
\end{LTXexample}

\medskip

\begin{LTXexample}[width=3.5cm]
\newpsobject{pumpcoupler}{wdmcoupler}{align=top, labelangle=180, labeloffset=0.5,addtoFiberIn2={ArrowInside=->, arrowscale=2}}
\begin{pspicture}[showgrid=true](3,2) 
   \pumpcoupler(0,1)(0,0)(3,1){Pumpcoupler}
\end{pspicture}
\end{LTXexample}

\medskip

Or if you need more than one type of lenses several times in your setup
it is very cumbersome to specify all parameters every time.

\medskip

\begin{LTXexample}[width=5.5cm]
\newpsobject{MOLensIn}{lens}{lens=0.5 0.5 0.5}
\newpsobject{MOLensOut}{lens}{lens=1.5 1.5 1.5}
\begin{pspicture}[showgrid=true](5,2) 
   \pnode(0,1){A}\pnode(5,1){B}
   \MOLensIn[abspos=0.5](A)(B){}
   \MOLensOut[abspos=1](A)(B){}
   \MOLensOut[abspos=4](A)(B){}
   \MOLensIn[abspos=4.5](A)(B){}
   \psline[style=Beam](A)(B)
\end{pspicture}
\end{LTXexample}
\medskip

\subsection{Defining New Objects}\label{sec:newobj}

Since version 1.2 \nxLPack{pst-optexp} provides some high-level macros to
allow very convenient definition of completely new components. The macro
\cs{newOptexpDipole} generates all organizing code for a new free-ray
component. All you have to do is to define a new `drawing' macro
\cs{mycomponent@iii} which contains all drawing code. Analogously
\cs{newOptexpDipoleNolabel} defines a new free-ray object without label
(like \cs{polarization}) and \cs{newOptexpTripole} defines a new
reflective component. 

New fiber-optical components can be defined using
\cs{newOptexpFiberDipole}. This macro differs from its free-ray
analogous only in that it presets \parameter{fiber} and hence directly
connects the component with its reference nodes. The first node in the
parameter list gets connected with a node \nodename{tempNode@A@}, the
second node with a node \nodename{tempNode@B@}. These two internal
nodes are preset to \paramvalue{(0,0)} and can be overwritten within the
drawing macro.

The syntax of the macros is
\begin{lstlisting}
\newOptexpDipole[fixed options]{name}{default options}
\newOptexpDipoleNolabel[fixed options]{name}{default options}
\newOptexpTripole[fixed options]{name}{default options}
\newOptexpFiberDipole[fixed options]{name}{default options}
\end{lstlisting}
The \texttt{default options} are simply a list of PSTricks parameters
which are taken as defaults for the new component. The optional argument
allows setting of parameters which cannot be overridden later.

This is illustrate a bit more in the next code snippet, which also shows
how the coordinate system is handled within the \cs{mycomponent@iii}
macro.

\medskip

\begin{LTXexample}[width=4.5cm]
\newOptexpTripole{mygrid}{subgriddiv=5, griddots=0, subgridwidth=\pslinewidth, gridwidth=2\pslinewidth}
\makeatletter
\def\mygrid@iii{% put here all PSTricks drawing code
  \psgrid(-1,0)(1,1)
}%
\makeatother
\begin{pspicture}[showgrid=true](4,4) 
   \pnode(0,1){A}\pnode(2,2){G}\pnode(3,0){B}
   \mygrid[gridcolor=red,labeloffset=1.5](A)(G)(B){myGrid}
   \psline[style=Beam](A)(G)(B)
\end{pspicture}
\end{LTXexample}
\medskip

The default position of the label reference point is (0,0). If you want
to change this, you have to define a new pnode named
\nodename{tempNode@Label} in the \cs{mycomponent@iii} macro.

If you create a new component, please send it to me then I can
incorporate this in a new released version.

\newpage

\section{Examples}
\begin{LTXexample}[pos=t,vsep=8mm]
\begin{pspicture}(10,2)
\psset{optboxwidth=1}\addtopsstyle{Beam}{linewidth=2\pslinewidth}
\pnode(1,1){Start}\pnode(9,1){CCD}\optbox[endbox, labeloffset=0](CCD)(Start){Laser}
\optbox[endbox,labeloffset=0,beam](Start)(CCD){CCD}
\polarization[poltype=perp,abspos=0.5](Start)(CCD)
\optretplate[abspos=1](Start)(CCD){$\nicefrac{\lambda}{2}$}
\lens[lens=0.4 0.4 0.5,abspos=2](Start)(CCD){$L_1$}\lens[abspos=4](Start)(CCD){$L_2$}
\optplate[abspos=6,platelinewidth=3\pslinewidth](Start)(CCD){SLM}
\optplate[abspos=6.5,labelangle=180](Start)(CCD){PF}
\polarization[abspos=6.7](Start)(CCD)\lens[abspos=7](Start)(CCD){$L_3$}
\end{pspicture}
\end{LTXexample}

\vspace{\fill}

\begin{LTXexample}[pos=t,vsep=8mm]
\begin{pspicture}(-4,-1)(3,3)
\addtopsstyle{Beam}{linewidth=2\pslinewidth, linecolor=red!90!black}
\psset{labeloffset=0.5}
\pnode(-2,0){LaserOut}\pnode(0,0){Grat}
\pnode(4;45){Out}\pnode(2.5;67.5){Mvar}
\optbox[optboxwidth=2,labeloffset=0, endbox](Grat)(LaserOut){diode laser}
\mirror[variable,conn=o-](Grid)(Mvar)(Grid){M$_\mathrm{var}$}
\optgrid[beam](LaserOut)(Grat)(Out){grating}
\optretplate[position=0.3,labeloffset=0.8]%
  (LaserOut)(Grat){$\nicefrac{\lambda}{4}$}
\rput[l](-3,2){Littman setup}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t, vsep=8mm]
\begin{pspicture}(8.5,1.6)
    \addtopsstyle{Beam}{linecolor=green!90!black}
    \pnode(1.6,1){Laser}\pnode(7.6,1){Diode}
    \optbox[endbox,labeloffset=0](Diode)(Laser){Laser}%
    \optbox[abspos=4, optboxwidth=1, optboxheight=0.6, labeloffset=1, compname=PC, conn=o-, angle=-10, rotateref=l, refractiveindex=2.3](Laser)(Diode){Photonic Crystal}
    \optdetector[dettype=diode, conn=o-](PCInternN)(Diode|PCInternN){PD}
    \defShiftedNode(PCIntern1)(2;170){Angle1}
    \psline[linestyle=dashed](PCIntern1)(Angle1)
    \psarc{<->}(PCIntern1){1.3}{330}{30}
    \psarc[arcsep=1pt]{<->}(PCIntern1){2}{170}{180}
    \uput{2.1}[175](PCIntern1){\small $\varphi$}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t, vsep=8mm]
\begin{pspicture}(6.4,3.2)
\addtopsstyle{Fiber}{linecolor=red}
\pnode(2.3,2.3){Lin}\pnode([Xnodesep=0.5]Lin){Lout}
\pnode([Xnodesep=1.5]Lout){EAMout}
\pnode([Xnodesep=1.5]EAMout){Det}
\optbox[fiber, labeloffset=-0.2, endbox, compname=L, extnode=b](Lout)(Lin){%
    \psGauss[yunit=0.03,sigma=0.03]{-0.5}{0.5}}
\optbox[fiber, labeloffset=0, optboxwidth=1, compname=EAM, extnode=b](Lout)(EAMout){EAM}
\optfiber[labeloffset=0.3](EAMout)(Det){fibre}
\optdetector(EAMout)(Det){OSA}
\pnode([Xnodesep=-1,offset=-1]LExtNode){Osc}
\pnode(LExtNode|Osc){PSin}\pnode(EAMExtNode|Osc){PSout}
\oscillator[output=right](Osc){10\,GHz}{}
\phaseshifter[labeloffset=-0.7](PSin)(PSout){$\tau$}
\wire(LExtNode)(PSin)\wire(EAMExtNode)(PSout)
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t, vsep=8mm]
\begin{pspicture}(0.9,0.9)(10.4,5.9)
  \psset{arrowscale=1.5, arrowinset=0}
  \addtopsstyle{Fiber}{linewidth=2\pslinewidth}
  \pnode(2,5){PC1in}\pnode(4,5){PC1out}\pnode(6,5){PC2in}
  \pnode(8,5){PC2out}\pnode(2,2){CplSig}\pnode(5,2){CplIn}
  \pnode(2,1){CplOut}\pnode(10,4.5){Pump}\pnode(8,2){PumpSig}
  \optisolator[compshift=0.8, addtoFiberIn={angleA=180}, addtoFiberOut={angleB=180}, labelref=relative, labeloffset=0.6](CplSig)(PC1in){isolator}
  \polcontrol[addtoFiberIn={arrows=|-}](PC1in)(PC1out){}
  \optfiberpolarizer[labeloffset=0.6](PC1out)(PC2in){polarizer}
  \polcontrol[addtoFiberOut={arrows=-|}](PC2in)(PC2out){}
  \wdmsplitter[labeloffset=0.3, align=bottom, addtoFiberIn={arrows=|-}, addtoFiberOut1={arrows=->}, addtoFiberOut2={arrows=-|}](CplIn)(CplOut)(CplSig){95/5}
  \wdmcoupler[addtoFiberIn1={ArrowInside=->}, addtoFiberIn2={angleA=0}, addtoFiberOut={angleB=0,arrows=-|}, ncurv=0.9, align=bottom, compshift=0.8](Pump)(PC2out)(PumpSig){Pump}
  \optbox[endbox,labeloffset=0,labelref=relative]([offset=-0.1]Pump)(Pump){980~nm}
  \optfiber[fiberloops=2, labeloffset=0.4](CplIn)(PumpSig){Er$^+$-doped}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t, vsep=8mm]
\makeatletter
\def\LCLV@iii{%
  \psframe[fillstyle=solid,fillcolor=black,dimen=outer](-0.12,-0.5)(0,0.5)
  \psframe[fillstyle=solid,fillcolor=gray!50,dimen=outer](0,-0.5)(0.15,0.5)
  \pnode(-0.12,0){\optexp@nodeA}\pnode(0.15,0){\optexp@nodeB}}
\makeatother
\begin{pspicture}(9,5)
\newOptexpDipole{LCLV}{}\psset{lens=1.2 0 1}
\pnode(2.4,1){BS1}\pnode([offset=3]BS1){M1}\pnode([Xnodesep=5.5]M1){PP}\pnode(PP|BS1){BS2}
\LCLV[position=0.2, compname=LCLV](BS1)(BS2){LCLV}\beamsplitter[compname=BS](BS2)(BS1)(M1){BS}
\optretplate(BS1)(M1){P}\mirror[conn=i-](BS1)(M1)(PP){M}\lens[position=0.2](M1)(PP){L}
\pinhole(M1)(PP){}\lens[position=0.2](PP)(M1){L}\pentaprism[beam](M1)(PP)(BS2){PP}
\beamsplitter(PP)(BS2)(BS1){BS}\lens(BS2)(BS1){L}
\doveprism[compname=Dove,conn=i-,position=0.27](BS2)(BS1){D}
\drawbeam[conn=b-b]{Dove}{LCLV}\drawbeam[conn=b-a]{BS}{LCLV}
\psline[arrowscale=1.3, style=Beam]{->}(BS2)([offset=-1]BS2)
\addtopsstyle{Beam}{arrowscale=1.3, ArrowInside=-<}
\optbox[labeloffset=0, endbox, conn=o-](BS1)([Xnodesep=-1]BS1){Nd:YAG}
\end{pspicture}
\end{LTXexample}

\begin{LTXexample}[pos=t,vsep=8mm]
\begin{pspicture}(0,-0.4)(9,6)
  \addtopsstyle{Beam}{linewidth=2\pslinewidth}
  \pnode(1.5,5){Laser}\pnode(4,5){PBS}\pnode(6.5,5){PBS2}
  \pnode(6.5,5.7){piezo}\pnode(4,2){BSFwd}\pnode(6.5,2){BSBwd}
  \pnode(2,2){BS4f}\pnode(2,0.5){M4f3}\pnode(8,2){M4f1}
  \pnode(8,0.5){M4f2}\pnode(1,2){CCD}
  \psline[style=Beam](Laser)(PBS2)(piezo)(BSBwd)(M4f1)(M4f2)(M4f3)(BS4f)(CCD)
  \psline[style=Beam](PBS)(BSFwd)(BS4f)
  \psset{mirrorwidth=0.6, plateheight=0.7, outerheight=0.7, labeloffset=0.7, labelstyle=\scriptsize, lens=1.2 1.2 0.8, bssize=0.5} 
  \optbox[endbox,optboxwidth=1.5, optboxheight=0.7,labeloffset=0]%
     (PBS)(Laser){\parbox{1.5cm}{\centering Nd:YAG\\ 532\,nm}}
  \lens[lensheight=0.5, position=0.2](Laser)(PBS){MO}
  \pinhole[position=0.3,labelangle=180](Laser)(PBS){PH}
  \lens[position=0.5](Laser)(PBS){L}
  \optretplate[position=0.8](Laser)(PBS){$\nicefrac{\lambda}{2}$}
  \beamsplitter(Laser)(PBS)(BSFwd){PBS}
  \optretplate[position=0.4](PBS)(BSFwd){$\nicefrac{\lambda}{2}$}
  \polarization(PBS)(BSFwd)\polarization(PBS2)(BSBwd)
  \lens[position=0.8](PBS)(BSFwd){L}
  \optretplate(PBS)(PBS2){$\nicefrac{\lambda}{2}$}
  \beamsplitter(PBS)(PBS2)(piezo){PBS}
  \optretplate[abspos=0.5](PBS2)(piezo){$\nicefrac{\lambda}{4}$}
  \mirror[mirrortype=piezo,labelangle=90](PBS2)(piezo)(PBS2){PZ}
  \lens[position=0.8,labelangle=180](PBS2)(BSBwd){L}
  \crystal[crystalwidth=1, crystalheight=0.5, voltage, lamp, fillstyle=solid, fillcolor=yellow!90!black, labeloffset=0.8, beam](BSFwd)(BSBwd){SBN:Ce}
  \beamsplitter(PBS)(BSFwd)(BSBwd){BS}
  \beamsplitter[labelangle=-90](PBS2)(BSBwd)(BSFwd){BS}
  \mirror(BSBwd)(M4f1)(M4f2){M}\mirror(M4f1)(M4f2)(M4f3){M}
  \lens[labelangle=180](M4f2)(M4f3){L}\mirror(M4f2)(M4f3)(BS4f){M}
  \beamsplitter(M4f3)(BS4f)(CCD){BS}\optbox[endbox,labeloffset=0, optboxwidth=1](BS4f)(CCD){CCD}
  \lens[abspos=0.7](BS4f)(BSFwd){L}\lens[abspos=0.7](BSBwd)(M4f1){L}
\end{pspicture}
\end{LTXexample}

\psset{unit=0.8cm,labelstyle=\footnotesize}
\begin{LTXexample}[pos=t]
\begin{pspicture}(0.5,4)(13.2,10.5)
  \addtopsstyle{Fiber}{linecolor=red!90!black}\psset{usefiberstyle, optboxwidth=1}
  \pnode(2,10){LD}\pnode([Xnodesep=5.5]LD){CPLin1}
  \pnode([offset=-2]CPLin1){CPLin2}\pnode([Xnodesep=1.5]CPLin1){CPLout1}
  \pnode([Xnodesep=1.5]CPLin2){CPLout2}
  \optbox[endbox, labeloffset=0, fiber]([Xnodesep=0.1]LD)(LD){LD}
  \optmzm([Xnodesep=0.1]LD)([Xnodesep=1.5]LD){MZM}
  \optamp([Xnodesep=1.5]LD)([Xnodesep=2.5]LD){EDFA}
  \optfilter([Xnodesep=2.5]LD)([Xnodesep=3.5]LD){BPF}
  \optswitch([Xnodesep=3.5]LD)([Xnodesep=4.5]LD){SW}
  \polcontrol([Xnodesep=4.5]LD)(CPLin1){}
  \optcoupler[couplertype=none](CPLin1)(CPLin2)(CPLout1)(CPLout2){}
  \optamp(CPLout1)([Xnodesep=1.5]CPLout1){EDFA}
  \optfilter([Xnodesep=1.5]CPLout1)([Xnodesep=3]CPLout1){BPF}
  \optbox[endbox, labeloffset=0, conn=f-f]([Xnodesep=3]CPLout1)([Xnodesep=3.1]CPLout1){RX}
  \pnode([Xnodesep=2]CPLout2){LoopRU}\pnode([offset=-3.5]LoopRU){LoopRL}
  \pnode([Xnodesep=-5]CPLin2){LoopLU}\pnode([offset=-3.5]LoopLU){LoopLL}
  \optamp(CPLout2)(LoopRU){EDFA}
  \psline[linearc=1,style=Fiber](LoopRU)([Xnodesep=1]LoopRU)([Xnodesep=1,offset=-2]LoopRU)
  \psline[linearc=1,style=Fiber]([Xnodesep=1,offset=1.5]LoopRL)%
                                ([Xnodesep=1]LoopRL)(LoopRL)
  \optfiber[labelalign=b, labeloffset=-1, position=0.8]([Xnodesep=-2]LoopRL)(LoopRL){\begin{tabular}{c}conventional\\fibre 89.8~km\end{tabular}}
  \optamp([Xnodesep=-2]LoopRL)([Xnodesep=-3]LoopRL){EDFA}
  \optfilter([Xnodesep=-3]LoopRL)([Xnodesep=-4.5]LoopRL){BPF}
  \optfiber[fiberloops=1, labeloffset=-1, labelalign=b]([Xnodesep=-7]LoopRL)([Xnodesep=-4.5]LoopRL){DCF 16.2~km}
  \optamp([Xnodesep=1.5]LoopLL)(LoopLL){EDFA}
  \psline[style=Fiber,linearc=1](LoopLL)([Xnodesep=-1]LoopLL)%
                                ([Xnodesep=-1,offset=3.5]LoopLL)(LoopLU)
  \optfilter(LoopLU)([Xnodesep=1.5]LoopLU){BPF}
  \optswitch([Xnodesep=1.5]LoopLU)([Xnodesep=3.5]LoopLU){SW}
  \polcontrol([Xnodesep=3.5]LoopLU)(CPLin2){}
\end{pspicture}
\end{LTXexample}

\section{Complete List of Parameters}
\begin{longtable}{TTT}
\toprule \multicolumn{1}{l}{parameter} & \multicolumn{1}{l}{allowed values} & \multicolumn{1}{l}{default}\\\midrule\endhead
\bottomrule\endfoot
abspos & <num> & \{\}\\
addtoBeam & <psstyle> & \\
addtoFiber* & <psstyle> & \\
addtoOptComp & <psstyle> & \\
align & top|bottom|center & center\\
angle & <degree> & 0\\
beam & \multicolumn{2}{l}{alias for \parameter{conn=o-i}}\\
bssize & <num> & 0.8\\
bsstyle & cube|plate & cube\\
caxisinv & <boolean> & false\\
caxislength & <num> & 0.6\\
compname & <string> & \{\}\\
compshift & <num> & 0\\
conn & <conn definition> & -\\
connjoin & <int> & 1\\
couplersep & <num> & 0.1\\
couplersize & <num> & 0.2\\
couplertype & none|elliptic & elliptic\\
crystalheight & <num> & 0.6\\
crystalwidth & <num> & 1.4\\
detsize & <num> & 0.8\\
dettype & round|diode & round\\
doveprismsize & <num> & 0.6\\
endbox & <boolean> & false\\
extnode & <ref string> & \{\}\\
fdlsize & <num> & 0.6\\
fiber & \multicolumn{2}{l}{alias for \parameter{conn=f-f}}\\
fibercolsize & <num> & 0.3\\
fiberloopradius & <num> & 0.4\\
fiberloops & <integer> & 3\\
fiberloopsep & <num> & 0.3\\
fiberpolsize & <num> & 0.6\\
filtersize & <num> & 0.8\\
filtertype & bandpass|bandstop & bandpass\\
innerheight & <num> & 0.1\\
isolatorsize & <num> & 0.6\\
label & <offset> <angle> <ref> <labelref> & \\
labelalign & <ref string> & c\\
labelangle & <num> & 0\\
labeloffset & <num> & 0.8\\
labelref & relative|relgrav|global & relgrav\\
labelstyle & <macro> & \cs{small}\\
lamp & <boolean> & false\\
lampscale & <num> & 0.3\\
lens & <num> [<num> [<num> [<num>]]] & \{\}\\
lensheight & <num> & 1\\
lensradius & <num> [<num>] & \{\}\\
lensradiusleft & <num> & 1\\
lensradiusright & <num> & 1\\
lenswidth & <num> & 0.2\\
mirrordepth & <num> & 0.1\\
mirrorlinewidth & <num> & 2\cs{pslinewidth}\\
mirrorradius & <num> & 0\\
mirrortype & normal|piezo|extended & normal\\
mirrorwidth & <num> & 1\\
newBeam & <psstyle> & \\
newFiber* & <psstyle> & \\
newOptComp & <psstyle> & \\
optampsize & <num> & 0.8\\
optboxheight & <num> & 0.8\\
optboxwidth & <num> & 1.4\\
optdiodesize & <num> & 0.8\\
optgridcount & <integer> & 10\\
optgriddepth & <num> & 0.05\\
optgridheight & <num> & 0.1\\
optgridlinewidth & <num> & 0.7\cs{pslinewidth}\\
optgridtype & blazed|binary & blazed\\
optgridwidth & <num> & 1\\
optional & <boolean> & false\\
optmzmsize & <num> & 0.8\\
outerheight & <num> & 1\\
pentaprismsize & <num> & 0.7\\
phlinewidth & <num> & 2\cs{pslinewidth}\\
plateheight & <num> & 1\\
platelinewidth & <num> & 2\cs{pslinewidth}\\
platewidth & <num> & 0.1\\
polcontrolsize & <num> & 0.15\\
pollinewidth & <num> & 0.7\cs{pslinewidth}\\
polsize & <num> & 0.6\\
poltype & parallel|perp|misc|lcirc|rcirc & parallel\\
position & <num> & \{\}\\
prismangle & <num> & 60\\
prismsize & <num> & 1\\
raprismsize & <num> & 1.5\\
refractiveindex & <num> & \{\}\\
reverse & <boolean> & false\\
rotateref & <ref string> & c\\
showoptdots & <boolean> & false\\
switchsize & <num> & 0.8\\
switchstyle & opened|closed & opened\\
thicklens & <boolean> & false\\
usefiberstyle & <boolean> & false\\
variable & <num> & false\\
voltage & <boolean> & false\\
\end{longtable}

\section{Complete List of Styles}

\begin{table}[H]
\addtolength{\extrarowheight}{1.5mm}
\begin{tabularx}{\linewidth}{BX}
\toprule
\multicolumn{1}{l}{style} & \multicolumn{1}{l}{description}\\
\midrule
Beam           & All automatic free-ray connections are drawn using this style\\
ExtendedMirror & Affects the additional part for \parameter{mirrortype=extended}\\
Fiber          & Parent style for all fiber connections. For a detailed discussion see Sec.~\ref{sec:fiberstyles}\\
FiberIn        & Left fiber style if only one connection to be drawn (inherits from \styleshape{Fiber})\\
FiberIn1       & Upper left connection (used for couplers only, inherits from \styleshape{FiberIn})\\
FiberIn2       & Lower left connection (used for couplers only, inherits from \styleshape{FiberIn})\\
FiberOut       & Right fiber style if only one connection to be drawn (inherits from \styleshape{Fiber})\\
FiberOut1      & Upper right connection (used for couplers only, inherits from \styleshape{FiberOut})\\
FiberOut2      & Lower right connection (used for couplers only, inherits from \styleshape{FiberOut})\\
OptComp        & Affects only the appearance of optical components without changing connections that may be drawn inside the component \\
OptionalStyle  & Used for objects with parameter \parameter{optional} set to \paramvalue{true}\\
PiezoMirror    & Affects the additional part for \parameter{mirrortype=piezo}\\
\bottomrule
\end{tabularx}
\end{table}

\section{Requirements}

\nxLPack{pst-optexp} version 2.1 requires at least version 2.87 of
\nxLPack{pstricks-add} and \LaTeX. It does not work with plain \TeX.

\section{Todo}

\begin{itemize}
\item Automatic sizing of optboxes (like a \cs{psframebox}
\item Even more soffisticated beam drawing (draw beam before object contours)
\item Drawing of extended beams with focusing and so on could be integrated to
some extent in future versions. But as the topic is rather difficult if
you want to do it properly (components should be placed above the beam,
but the new nodes are available only when the component is drawn) it
could take very long until this feature will be implemented.
\end{itemize}
\section{Acknowledgements}

I thank all the people of the PSTricks mailinglist for the continuous help, especially Herbert Voß.

\end{document}