%%=========================================
%% This is file 'pst-sigsys.sty'
%% It provides the pst-sigsys package.
%% ------------------------------------
%% Author: Farshid Delgosha
%% E-mail: fdelgosha@gmail.com
%%=========================================

\ProvidesPackage{pst-sigsys}[2009/01/15 by Farshid Delgosha]

\csname PSTsigsysLoaded\endcsname
\def\fileversion{1.00}
\def\filedate{2008/01/15}
\message{`PST-sigsys' v\fileversion, \filedate\space (Farshid Delgosha)}

\ifx\PSTricksLoaded\endinput\else\input pstricks \fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node \fi
\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi



\newif\if@elegant \@eleganttrue
\newif\if@pstadd \@pstaddfalse

\DeclareOption{notelegant}{\@elegantfalse}
\DeclareOption{pstadd}{\@pstaddtrue}

\ExecuteOptions{}
\ProcessOptions*

\if@elegant
\AtBeginDocument{\psset{framesep=.125,framearc=.25,linearc=.1}}
\fi


\SpecialCoor




%--- internal macros -------------------------------------
\newdimen\ss@zerowidth
\newdimen\ss@zeroradius
\newdimen\ss@zeroradiusinc
\newdimen\ss@polewidth
\newdimen\ss@polelength
\newdimen\ss@oplength
\newdimen\ss@opwidth
\newdimen\ss@opsep
\newdimen\ss@ldotssep
\newdimen\ss@ldotssize
%
\newdimen\ss@temp@dimA
\newdimen\ss@temp@dimB
\newdimen\ss@temp@dimC
\newcount\ss@temp@cnt
\def\ss@temp{}
\def\ss@temp@choice{}
%
\def\pst@scale#1{\pssetlength{#1}{\ss@scale#1}}
%
\def\ss@LW{}
\newdimen\ss@LW@dim
\def\pst@scaleLW#1#2{%
\pssetlength{\ss@LW@dim}{#1\pslinewidth}%
\pst@dimtonum{\ss@LW@dim}{\ss@LW}%
\let#2\ss@LW%
}
%
\newdimen\ss@cross@dim
\def\ss@cross@angle{}
\def\ss@cross@temp{}
\def\pst@cross(#1;#2)#3{%
\pssetlength{\ss@cross@dim}{#2}%
\psaddtolength{\ss@cross@dim}{90}%
\pst@divide{\ss@cross@dim}{\psunit}\ss@cross@temp%
\psline[linewidth=#3,arrows=-](-#1;#2)(#1;#2)%
\psline[linewidth=#3,arrows=-](-#1;\ss@cross@temp)(#1;\ss@cross@temp)%
}
%--- end internal macros ---------------------------------


%--- new pstricks styles ---------------------------------
\newpsstyle{ArrowLen}{arrowsize=1.55mm,arrowlength=1.25,arrowinset=.25}
\newpsstyle{Arrow}{arrows=->,style=ArrowLen}
\newpsstyle{Dash}{linestyle=dashed,dash=.15 .08}
\newpsstyle{Graph}{linewidth=1.25pt,linearc=0}
\newpsstyle{Stem}{linewidth=1.25pt,linestyle=solid,stemhead=*}
%--- end new pstricks styles -----------------------------


%--- new pstricks-add styles -----------------------------
\if@pstadd
\newpsstyle{ArrowIn}{ArrowInside=->,style=ArrowLen}
\newpsstyle{DashDot}{linestyle=dashed,dash=.15 .055 .04 .055}
\newpsstyle{Brace}{braceWidth=.02,braceWidthInner=.115,braceWidthOuter=.115,ref=C}
\newpsstyle{BraceUp}{style=Brace,rot=-90,nodesepB=-\pslabelsep}
\newpsstyle{BraceDown}{style=Brace,rot=90,nodesepB=\pslabelsep}
\newpsstyle{BraceRight}{style=Brace,rot=-90,nodesepA=\pslabelsep}
\newpsstyle{BraceLeft}{style=Brace,rot=-90,nodesepA=-\pslabelsep}
\fi
%--- end new pstricks-add styles -------------------------


%--- keys ------------------------------------------------
\define@key[psset]{pst-sigsys}{scale}{\def\ss@scale{#1}}
\define@choicekey*[psset]{pst-sigsys}{xlpos}[\val\ss@temp@choice]{b,t}{%
  \ifcase\ss@temp@choice\relax
     \def\ss@xlpos{b}
  \or
     \def\ss@xlpos{t}
  \fi
}
\define@choicekey*[psset]{pst-sigsys}{ylpos}[\val\ss@temp@choice]{r,l}{%
  \ifcase\ss@temp@choice\relax
     \def\ss@ylpos{r}
  \or
     \def\ss@ylpos{l}
  \fi
}
\define@key[psset]{pst-sigsys}{stemhead}[]{\def\ss@stemhead{#1}}
\define@boolkey[psset]{pst-sigsys}[ss@]{stemtag}[true]{}
\define@key[psset]{pst-sigsys}{stemtagformat}[]{\def\ss@stemtagformat{#1}}
\define@key[psset]{pst-sigsys}{order}{\def\ss@order{#1}}
\define@key[psset]{pst-sigsys}{zerowidth}{\pssetlength{\ss@zerowidth}{#1}}
\define@key[psset]{pst-sigsys}{zeroradius}{\pssetlength{\ss@zeroradius}{#1}}
\define@key[psset]{pst-sigsys}{zeroradiusinc}{\pssetlength{\ss@zeroradiusinc}{#1}}
\define@key[psset]{pst-sigsys}{polewidth}{\pssetlength{\ss@polewidth}{#1}}
\define@key[psset]{pst-sigsys}{polelength}{\pssetlength{\ss@polelength}{#1}}
\define@key[psset]{pst-sigsys}{opwidth}{\pssetlength{\ss@opwidth}{#1}}
\define@key[psset]{pst-sigsys}{oplength}{\pssetlength{\ss@oplength}{#1}}
\define@key[psset]{pst-sigsys}{opsep}{\pssetlength{\ss@opsep}{#1}}
\define@choicekey*[psset]{pst-sigsys}{operation}[\val\ss@temp@choice]{plus,times}{%
  \ifcase\ss@temp@choice\relax
     \def\ss@angle{0}
  \or
     \def\ss@angle{45}
  \fi
}
\define@key[psset]{pst-sigsys}{angle}{\def\ss@angle{#1}}
\define@key[psset]{pst-sigsys}{ldotssize}{\pssetlength{\ss@ldotssize}{#1}}
\define@key[psset]{pst-sigsys}{ldotssep}{\pssetlength{\ss@ldotssep}{#1}}
%--- end keys --------------------------------------------


%--- default key values ----------------------------------
\psset[pst-sigsys]{scale=1}%   global
\psset[pst-sigsys]{xlpos=b,ylpos=r}%  psaxeslabels
\psset[pst-sigsys]{stemhead=*,stemtag=false,stemtagformat=\scriptstyle}%   psstem
\psset[pst-sigsys]{zerowidth=.7pt,zeroradius=.08,zeroradiusinc=.07,order=1}%   pszero
\psset[pst-sigsys]{polewidth=.7pt,polelength=.12}%   pspole
\psset[pst-sigsys]{opwidth=.7pt,oplength=.125,opsep=.1,operation=plus}%   pscircleop and psframeop
\psset[pst-sigsys]{ldotssize=.05,ldotssep=.15,angle=0}%   psldots
%--- end default key values ------------------------------

\pst@addfams{pst-sigsys}


%--- some new commands -----------------------------------
\providecommand{\RE}{\ensuremath{\mathcal{R}\mathrm{e}}}
\providecommand{\IM}{\ensuremath{\mathcal{I}\mathrm{m}}}
\providecommand{\sRE}{\ensuremath{\scriptstyle\mathcal{R}\mathrm{e}}}
\providecommand{\sIM}{\ensuremath{\scriptstyle\mathcal{I}\mathrm{m}}}
%---------------------------------------------------------


%--- psaxeslabels ----------------------------------------
\def\psaxeslabels{\def\pst@par{}\pst@object{psaxeslabels}}
\def\psaxeslabels@i{\pst@getarrows\psaxeslabels@ii}
\def\psaxeslabels@ii(#1,#2)(#3,#4)(#5,#6)#7#8{{%
\use@par%
\psline(#3,#2)(#5,#2)%
\psline(#1,#4)(#1,#6)%
%
\if\ss@xlpos t%
\rput(#5,#2){\rput[rb](0,\pslabelsep){#7}}%
\else%
\rput(#5,#2){\rput[rt](0,-\pslabelsep){#7}}%
\fi%
%
\if\ss@ylpos l%
\rput(#1,#6){\rput[tr](-\pslabelsep,0){#8}}%
\else%
\rput(#1,#6){\rput[tl](\pslabelsep,0){#8}}%
\fi%
}\ignorespaces}
%--- end psaxeslabels ------------------------------------


%--- psstem ----------------------------------------------
\def\psstem{\def\pst@par{}\pst@object{psstem}}
\def\psstem@i{\@ifnextchar({\psstem@ii}{\psstem@ii(0,1)}}
\def\psstem@ii(#1,#2)#3{{%
\use@par%
\ss@temp@cnt=#1%
\@for\ss@for@ind:=#3\do{%
\psline{-\ss@stemhead}(\ss@temp@cnt,0)(\ss@temp@cnt,\ss@for@ind)%
%
\ifss@stemtag%
\pssetlength{\ss@temp@dimA}{\ss@for@ind}%
\ifdim\ss@temp@dimA<\z@%
\rput[b](\ss@temp@cnt,\pslabelsep){$\ss@stemtagformat\the\ss@temp@cnt$}%
\else%
\rput[t](\ss@temp@cnt,-\pslabelsep){$\ss@stemtagformat\the\ss@temp@cnt$}%
\fi\fi%
%
\advance\ss@temp@cnt#2}%
}\ignorespaces}
%--- end psstem ------------------------------------------


%--- pszero ----------------------------------------------
\def\pszero{\def\pst@par{}\pst@object{pszero}}
\def\pszero@i(#1)#2{{%
\use@par%
\pst@scale{\ss@zerowidth}%
\pst@scale{\ss@zeroradius}%
\pst@scale{\ss@zeroradiusinc}%
\pssetlength{\ss@temp@dimA}{\ss@zeroradius}%
\ss@temp@cnt=\ss@order%
\loop%
\cnode[linewidth=\ss@zerowidth](#1){\ss@temp@dimA}{#2}%
\psaddtolength{\ss@temp@dimA}{\ss@zeroradiusinc}%
\ifnum\ss@temp@cnt>\@ne%
\advance\ss@temp@cnt-\@ne%
\repeat%
}\ignorespaces}
%--- end pszero ------------------------------------------


%--- pspole ----------------------------------------------
% The main part of this code is borrowed from pst-node
%
\def\pspole{\def\pst@par{}\pst@object{pspole}}
\def\pspole@i(#1)#2{%
\leavevmode%
\hbox{%
\use@par%
\pst@scale{\ss@polelength}%
\pst@scale{\ss@polewidth}%
\pst@@getcoor{#1}%
\pssetlength\pst@dimc{\ss@polelength}%
\pst@dimg=\psk@dimen\pslinewidth%
\advance\pst@dimc-\pst@dimg%
\advance\pst@dimc.5\pslinewidth%
\ifnodealign%
\kern\pst@dimc%
\vrule width\z@ height \pst@dimc depth \pst@dimc%
\fi%
\rput(#1){\pst@cross(\ss@polelength;45){\ss@polewidth}}%
\pst@newnode{#2}{11}{\pst@coor \pst@number\pst@dimc}{\tx@InitCnode}%
\ifnodealign\kern\pst@dimc\fi%
}\ignorespaces}
%--- end pspole ------------------------------------------


%--- pscircleop ------------------------------------------
\def\pscircleop{\def\pst@par{}\pst@object{pscircleop}}
\def\pscircleop@i(#1)#2{{%
\use@par%
\pst@scale{\ss@oplength}%
\pst@scale{\ss@opsep}%
\pst@scale{\ss@opwidth}%
\pst@scale{\pslinewidth}%
\rput(#1){\pst@cross(\ss@oplength;\ss@angle){\ss@opwidth}}%
\pssetlength{\ss@temp@dimA}{\ss@oplength}%
\psaddtolength{\ss@temp@dimA}{\ss@opsep}%
\cnode(#1){\ss@temp@dimA}{#2}%
}\ignorespaces}
%--- end pscircleop --------------------------------------


%--- psframeop -------------------------------------------
\def\psframeop{\def\pst@par{}\pst@object{psframeop}}
\def\psframeop@i(#1)#2{{%
\use@par%
\pst@scale{\ss@oplength}%
\pst@scale{\ss@opsep}%
\pst@scale{\ss@opwidth}%
\pst@scale{\pslinewidth}%
\rput(#1){\pst@cross(\ss@oplength;\ss@angle){\ss@opwidth}}%
\pssetlength{\ss@temp@dimA}{2\ss@oplength}%
\psaddtolength{\ss@temp@dimA}{2\ss@opsep}%
\fnode[framesize=\ss@temp@dimA](#1){#2}%
}\ignorespaces}
%--- end psframeop ---------------------------------------


%--- psdisk ----------------------------------------------
\def\psdisk{\def\pst@par{}\pst@object{psdisk}}
\def\psdisk@i(#1)#2{{%
\use@par%
\pscircle*[linewidth=0pt,linecolor=\psfillcolor](#1){#2}%
}\ignorespaces}
%--- end psdisk ------------------------------------------


%--- psring ----------------------------------------------
\def\psring{\def\pst@par{}\pst@object{psring}}
\def\psring@i(#1)#2#3{{%
\use@par%
\pssetlength{\ss@temp@dimA}{#2}%
\pssetlength{\ss@temp@dimB}{#3}%
\psaddtolength{\ss@temp@dimB}{-\ss@temp@dimA}%
\pscircle[dimen=inner,linewidth=\ss@temp@dimB,linecolor=\psfillcolor](#1){\ss@temp@dimA}%
}\ignorespaces}
%--- end psring ------------------------------------------


%--- psdiskc ---------------------------------------------
\def\psdiskc{\def\pst@par{}\pst@object{psdiskc}}
\def\psdiskc@i(#1)(#2,#3)#4{{%
\use@par%
\pssetlength{\ss@temp@dimA}{#2}%
\pssetlength{\ss@temp@dimB}{#3}%
\ifdim\ss@temp@dimA>\ss@temp@dimB%
\pssetlength{\ss@temp@dimC}{1.5\ss@temp@dimA}%
\else%
\pssetlength{\ss@temp@dimC}{1.5\ss@temp@dimB}%
\fi%
\psclip{\rput(#1){\psframe[linewidth=0pt,linecolor=\psfillcolor](-#2,-#3)(#2,#3)}}%
\psring@i(#1){#4}{\ss@temp@dimC}%
\endpsclip%
}\ignorespaces}
%--- end psdiskc -----------------------------------------


%--- psldots ---------------------------------------------
\def\psldots{\def\pst@par{}\pst@object{psldots}}
\def\psldots@i{{%
\use@par%
\pst@scale{\ss@ldotssep}%
\pst@scale{\ss@ldotssize}%
\psdots[dotsize=\ss@ldotssize](-\ss@ldotssep;\ss@angle)(0,0)(\ss@ldotssep;\ss@angle)%
}\ignorespaces}
%--- end psldots -----------------------------------------


%--- psblock ---------------------------------------------
\def\psblock{\def\pst@par{}\pst@object{psblock}}
\def\psblock@i(#1)#2#3{{%
\use@par%
\rput(#1){\rnode{#2}{\psframebox{#3}}}%
}\ignorespaces}
%--- end psblock -----------------------------------------


%--- psfblock --------------------------------------------
\def\psfblock{\def\pst@par{}\pst@object{psfblock}}
\def\psfblock@i(#1)#2#3{{%
\use@par%
\fnode(#1){#2}%
\rput(#1){#3}%
}\ignorespaces}
%--- end psfblock ----------------------------------------


%--- psusampler ------------------------------------------
\def\psusampler{\def\pst@par{}\pst@object{psusampler}}
\def\psusampler@i(#1)#2#3{{%
\use@par%
\psfblock(#1){#2}{\ensuremath{\mathord{\uparrow} #3}}%
}\ignorespaces}
%--- end psusampler --------------------------------------


%--- psdsampler ------------------------------------------
\def\psdsampler{\def\pst@par{}\pst@object{psdsampler}}
\def\psdsampler@i(#1)#2#3{{%
\use@par%
\psfblock(#1){#2}{\ensuremath{\mathord{\downarrow} #3}}%
}\ignorespaces}
%--- end psdsampler --------------------------------------


%--- nclist ----------------------------------------------
\def\nclist{\def\pst@par{}\pst@object{nclist}}
\def\nclist@i#1#2{{%
\use@par%
\def\ss@nc{\csname #1\endcsname}%
\def\ss@prevnode{}%
\@for\ss@for@ind:=#2\do{%
\ifx\empty\ss@prevnode\empty%
\else%
\ss@nc{\ss@prevnode}{\ss@for@ind}%
\fi%
\let\ss@prevnode\ss@for@ind%
}%
}\ignorespaces}
%--- end nclist ------------------------------------------
\endinput 