我想使用该pst-optexp
包创建一个自定义组件。到目前为止,我已经知道如何制作一个显示内部结构的双端口自定义组件,但我不知道如何制作一个显示内部结构的三端口自定义组件。
也许解决方案是执行类似makeatletter
和 的操作makeatother
。我能够使用它来获取函数发生器的方波,但我没有足够的 LaTeX 魔法来在 \optdipolecomp 上施展这种魔法。
\documentclass[border=12pt]{standalone}
\usepackage{pstricks}
\usepackage{pst-optexp}
\usepackage{auto-pst-pdf}
\makeatletter
\def\elecsynthesizer@custom{%
\psline(-0.25,0)(-0.25,0.15)(0,.15)%
(0,-.15)(0.25,-.15)(.25,0)}
\makeatother
\begin{document}
\begin{pspicture}[showgrid](-2, 2)(12,-12)
\def\loopRadius{1}
\def\loopAngleOne{135}
\def\loopAngleTwo{45}
\pnode(5.5,-6){loopCenter}
\pnode([nodesep=\loopRadius,angle=135]loopCenter){loopTop}
\pnode([nodesep=\loopRadius,angle=-135]loopCenter){loopBottom}
\addtopsstyle{Fiber}{linecolor=red}
\psset{fiber=none}
\newpsstyle{OptCircArrow}{arrows=<-,unit=.6}
\def\phasemodulatorcomp{%
\psframe(-.7,-0.4)(.7,0.4)
\psline(-.7,0)(-.2,0)(.1,.3)(.7,.3)
\psline(-.2,0)(.1,-.3)(.7,-.3)}
%%%%%%%%%%%%%%%%%%% DOES NOT SHOW THE INTERNAL STRUCTURE, BUT HAS TWO PORTS
\newpsobject{mioc}{fiberbox}{fiberboxcount=1x2,fiberboxsize=1.5 0.8, extnode=b,showifcnodes }
%%%%%%%%%%%%%%%%%% SHOWS THE INTERNAL STRUCTURE, BUT ONLY HAS ONE PORT ON EACH SIDE
%\newpsobject{mioc}{optdipole}{optdipolesize=1.5 0.8,optdipolecomp={\phasemodulatorcomp}, extnode=b,showifcnodes }
\pnodes(3,0){A}(6,0){B}
\pnode(0,0){A}
\pnode([nodesep=5,angle=-90]A){B}
\pnode([nodesep=1,angle=-90]B){circ}
\pnode([nodesep=2,angle=0]circ){miocLoc}
\pnode([nodesep=3,angle=-90]circ){detectorLoc}
\optbox [position=start,compname=laser,labelref=relative,labeloffset=0](A)(B){laser}
\optisolator[position=.4,compname=isolator](A)(B)
\optbox [position=.8,extnode=b,compname=EOM,labelref=relative,labeloffset=0](A)(B){EOM}
\pnode(\oenodeExt{EOM}){pmr}
\pnode([nodesep=10,angle=0]pmr){E}
\optbox[compname=noiseGen,position=start,labeloffset=0,labelref=relative](E)(pmr){noise}
\optamp[position=.1,compname=preamp1](E)(pmr){+12 dB}
\optamp[position=.3,compname=preamp2](E)(pmr){+12 dB}
\optbox[position=.5,compname=attenuators](E)(pmr){-7 dB}
\optamp[position=.7,compname=preamp3](E)(pmr){+12 dB}
\optamp[position=.9,compname=amp](E)(pmr){+14 dB}
\drawwire{noiseGen}{preamp1}{preamp2}{attenuators}{preamp3}{amp}(pmr)
\optcirculator[optcircangle=180 0,compname=circulator](detectorLoc)(B)(miocLoc)
\drawfiber{laser}{isolator}{EOM}{circulator}
\mioc[position=end,compname=mioc,labeloffset=0](circ)(miocLoc){MIOC}
\drawfiber[startnode=2,fiberangleA=-90]{circulator}{mioc}
\drawfiber[startnode=2,fiberangleB=\loopAngleTwo]{mioc}(loopTop)
\drawfiber[startnode=3,fiberangleB=-\loopAngleTwo]{mioc}(loopBottom)
\psarc[linecolor=red]{-}(loopCenter){\loopRadius}{-\loopAngleOne}{\loopAngleOne}
\optdetector[compname=detector,dettype=diode,extnode=b](circ)(detectorLoc)
\pnode(\oenodeExt{detector}){detectorExit}
\pnode([nodesep=4,angle=0]detectorExit){liaLoc}
\optbox[position=end,compname=lia,extnode=t,labeloffset=0](detectorExit)(\oenodeExt{mioc}|liaLoc){LIA}
\elecsynthesizer[position=.5,synthtype=custom](\oenodeExt{mioc})(\oenodeExt{lia})
\drawwire(detectorExit){lia}
\drawfiber{circulator}{detector}
\pnode([nodesep=2,angle=0]liaLoc){output}
\cnodeput([nodesep=1,angle=0]output){output2}{output}
\drawwire[arrows=->]{lia}(output)
\end{pspicture}
%
\end{document}
答案1
为了绘制fiberbox
具有自定义内部结构的 ,您必须定义自己的宏以使用 进行调用\fiberbox
。\fiberbox@comp
内部宏fiberbox@comp
仅绘制光纤盒矩形。在这里,您已经可以访问使用 的光纤盒的输入和输出节点\oenode{1}{}
:
\documentclass[border=12pt]{standalone}
\usepackage{pst-optexp}
\usepackage{auto-pst-pdf}
\makeatletter
\def\phasemodulatorcomp{%
\pcdiag[angleB=180, arm=0.6](\oenode{1}{})(\oenode{2}{})
\pcdiag[angleB=180, arm=0.6](\oenode{1}{})(\oenode{N}{})}
\def\mioc{%
\let\fiberbox@comp@orig\fiberbox@comp
\def\fiberbox@comp{\fiberbox@comp@orig\phasemodulatorcomp}
\fiberbox}
\makeatother
\begin{document}
\begin{pspicture}(6,2)
\addtopsstyle{Fiber}{linecolor=red}
\pnode(0,1){In}
\pnode(2,1){Out}
\mioc[fiberboxcount=1x2, fiberboxsize=1.5 0.8, extnode=b,showifcnodes, position=end,compname=mioc](In)(Out){MIOC}
\drawfiber{}([Xnodesep=1, offset=0.4]\oenode{2}{})
\drawfiber{}([Xnodesep=1, offset=-0.4]\oenode{3}{})
\pccurve[style=Fiber, ncurv=1.2]([Xnodesep=1, offset=0.4]\oenode{2}{})([Xnodesep=1, offset=-0.4]\oenode{3}{})
\end{pspicture}
\end{document}
这让我想到添加一个参数fiberboxcomp
或类似的东西,这样你就可以用它的内部结构来定义“派生”光纤盒\newpsobject
。也许对 elecsynthesizer 也值得这样做。