增强 bloques tikz 库

增强 bloques tikz 库

如果有人发布有趣的答案,我会让这个问题再开放几天

我偶然发现了 tikz 的 bloques 库(http://www.ctan.org/tex-archive/graphics/pgf/contrib/bloques),发现它非常好,但我很快注意到它缺少一些选项,所以我决定重新设计它/扩展功能。

到目前为止我实现了这个样式文件:

\usepackage{tikz,circuitikz}
\usepgflibrary{shapes.misc}
\usetikzlibrary{calc,arrows,decorations.pathmorphing,backgrounds,positioning,fit,shadows}

\newcommand{\horizdist}{1.5cm}
\newcommand{\verticdist}{1.2cm}
\newcommand{\phasedist}{3.5cm}
\newcommand{\minheight}{0.7cm}
\newcommand{\textsize}{\footnotesize}
\newcommand{\backgroundcolor}{white}
\newcommand{\colortext}{black}
\newcommand{\linecolor}{black}
\newcommand{\dark}{0}
\newcommand{\linetype}{thick}

\newcommand{\bShadow}{\renewcommand{\dark}{1}}
\newcommand{\bColorB}[1]{\renewcommand{\backgroundcolor}{#1}}
\newcommand{\bColorT}[1]{\renewcommand{\colortext}{#1}}
\newcommand{\bColorL}[1]{\renewcommand{\linecolor}{#1}}

\newcommand{\bDownTo}[3]{
    \node[above of=#1, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linetype] (#2) -- (#1);
}

\newcommand{\bUpTo}[3]{
    \node[below of=#1, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linetype] (#2) -- (#1);
}

\newcommand{\bRightTo}[3]{
    \node[left of=#1, node distance=\horizdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linetype] (#2) -- (#1);
}

\newcommand{\bLeftTo}[3]{
    \node[left of=#1, node distance=\horizdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linetype] (#2) -- (#1);
}

\newcommand{\bPlusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin] {};   
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex,\linetype] (#1) -- (#2);          
}

\newcommand{\bPlusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);                
}

\newcommand{\bMinusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin] {};   
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex,\linetype] (#1) -- (#2);          
}

\newcommand{\bMinusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);        
}

\newcommand{\bMinusPlus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusMinus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusMinus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusPlus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of=#1, node distance= \horizdist,\linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of=#1, node distance= \horizdist, thin, draw=gray!50] {}; 
    \node [left of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of = #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bGain}[3]{
    \node [draw=\linecolor, circle, right of = #1, node distance= \horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) { \color{\colortext}\textsize{#3}}; 
    \draw [-latex, \linecolor] (#1)--(#2);
}

\newcommand{\bGainBackDown}[4]{
    \node [draw=\linecolor, circle, below right of = #1, node distance=\horizdist+.1cm, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark},anchor=west] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#2)|-(#3);
    \draw [-latex, \linecolor] (#3)-|(#1);
}

\newcommand{\bGainBackUp}[4]{
    \node [draw=\linecolor, circle, above right of = #1, node distance=\horizdist+.1cm, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark},anchor=west] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#2)|-(#3);
    \draw [-latex, \linecolor] (#3)-|(#1);
}

\newcommand{\bGainBackUpCross}[4]{
    \node [draw=\linecolor, circle, above left of = #1, node distance=\horizdist+.1cm, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark},anchor=east] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(-\horizdist/2,0) -- ($(#2)-(0,\verticdist)$) -- (#2);
}

\newcommand{\bGainBackDownCross}[4]{
    \node [draw=\linecolor, circle, below left of = #1, node distance=\horizdist+.1cm, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark},anchor=east] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(-\horizdist/2,0) -- ($(#2)+(0,\verticdist)$) -- (#2);
}

\newcommand{\bTF}[3]{       
    \node [draw=\linecolor, rectangle, right of = #1, node distance= \horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};    
    \draw [-latex, \linecolor] (#1)--(#2);
}

\newcommand{\bTFForthUpCross}[4]{
    \node [draw=\linecolor, rectangle, above right of = #1, node distance=\horizdist+.1cm, minimum height = \minheight, \linetype, fill=\backgroundcolor,drop shadow={opacity=\dark},anchor=west] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)-(0,\verticdist)$) -- (#2);
}

\newcommand{\bTFForthDownCross}[4]{
    \node [draw=\linecolor, rectangle, below right of = #1, node distance=\horizdist+.1cm, minimum height = \minheight, \linetype, fill=\backgroundcolor,drop shadow={opacity=\dark},anchor=west] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)+(0,\verticdist)$) -- (#2);
}

\newcommand{\bMarkNode}[2]{
    \node[fill=\linecolor,circle,inner sep=0pt,minimum size=.5em,right of = #1, node distance= \horizdist] (#2) {};
    \draw [\linecolor] (#1)--(#2);
}

\newcommand{\bOut}[3]{
    \node[right of=#1, node distance= \horizdist] (#2) {\color{\colortext}\textsize{#3}};
    \draw [-latex, \linecolor] (#1)--(#2);
}

通过这个例子,我能够绘制 RL 负载及其在同步参考系中相应控制的框图(对于那些了解这一点的人来说,但这只是为了举例说明)。

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{bloquesshapes} % above sty file

\begin{document}

\begin{tikzpicture}
    \bShadow
    \node (1) at (0,0) {\color{\colortext}\textsize{$i_{sc\alpha}$}};
    \bMinusUp{1}{2}
    \bDownTo{2}{3}{$i_{s\alpha}$}
    \bMinusPlus{2}{3}
    \bTF{3}{4}{$\dfrac{1}{sl}$}
    \bMarkNode{4}{5}
    \bGainBackUp{3}{5}{6}{$r$}
    \bOut{5}{7}{$i_{s\alpha}$}
    \node (A) at (0,-\phasedist) {\color{\colortext}\textsize{$u_{s\beta}$}};
    \bMinusDown{A}{B}
    \bUpTo{B}{C}{$u_{i\beta}$}
    \bMinusMinus{B}{C}
    \bTF{C}{D}{$\dfrac{1}{sl}$}
    \bMarkNode{D}{E}
    \bGainBackDown{C}{E}{F}{$r$}
    \bOut{E}{G}{$i_{s\beta}$}
    \bGainBackUpCross{E}{3}{H}{$\omega l$}
    \bGainBackDownCross{5}{C}{8}{$\omega l$}
\end{tikzpicture}

\begin{tikzpicture}[>=stealth']
    \bShadow
    \node (1) at (0,0) {\color{\colortext}\textsize{$i_{sc\alpha}$}};
    \bMinusUp{1}{2}
    \bDownTo{2}{3}{$i_{s\alpha}$}
    \bMarkNode{2}{3}
    \bTF{3}{4}{$\frac{1+sT_n}{sT_i}$}
    \bMinusDown{4}{5}
    \bOut{5}{7}{$u_{cm\alpha}$}
    \node (A) at (0,-\phasedist) {\color{\colortext}\textsize{$i_{sc\beta}$}};
    \bMinusDown{A}{B}
    \bUpTo{B}{C}{$i_{s\beta}$}
    \bMarkNode{B}{C}
    \bTF{C}{D}{$\frac{1+sT_n}{sT_i}$}
    \bPlusUp{D}{E}
    \bOut{E}{G}{$u_{cm\beta}$}
    \bTFForthDownCross{3}{E}{H}{$\dfrac{\omega T_n}{sT_i}$}
    \bTFForthUpCross{C}{5}{8}{$\dfrac{\omega T_n}{sT_i}$}
\end{tikzpicture}

\end{document}

我认为图形效果非常好。 插图

我将不胜感激:

  • 有没有关于如何以更简单的方式绘制相同图形的想法
  • 一个\bStart命令,以节点名称、节点位置 (x,y) 和节点标签作为输入(必须找到节点位置的技巧)
  • 修复\bMarkNode(删除粗点周围的空白)
  • $r$$\omega l$节点(垂直对齐)的简单方法
  • 为了获得更大的灵活性,我不得不增加命令的复杂性,使用可变数量的参数,这是块所没有的;欢迎任何想法同一类型的所有形状都采用相同数量的参数

答案1

好的,我想这次我会去的。

  • 绘图命令对我来说似乎足够简单。
  • \bStart我不在乎
  • \bMarkNode用内/外分隔固定
  • 垂直对齐已修复。由于右上图和其他情况很奇怪,我决定这样做:above/below of=, distance=\verticdist, xshift=+-\horizdist
  • 差不多完成了。

这是我目前的样式文件:

\usepackage{tikz,circuitikz}
\usepgflibrary{shapes.misc}
\usetikzlibrary{calc,arrows,decorations.pathmorphing,backgrounds,fit,shadows}

\newcommand{\horizdist}{1.5cm}
\newcommand{\verticdist}{1.2cm}
\newcommand{\phasedist}{3.5cm}
\newcommand{\minheight}{0.7cm}
\newcommand{\textsize}{\footnotesize}
\newcommand{\backgroundcolor}{white}
\newcommand{\colortext}{black}
\newcommand{\linecolor}{black}
\newcommand{\dark}{0}
\newcommand{\linetype}{thick}

\newcommand{\bShadow}{\renewcommand{\dark}{1}}
\newcommand{\bColorB}[1]{\renewcommand{\backgroundcolor}{#1}}
\newcommand{\bColorT}[1]{\renewcommand{\colortext}{#1}}
\newcommand{\bColorL}[1]{\renewcommand{\linecolor}{#1}}

\tikzset{every node/.style={anchor=center, text centered, align=center}}

\newcommand{\bDownTo}[3]{
    \node[above of= #1, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linecolor] (#2) -- (#1);
}

\newcommand{\bDownToGain}[5]{
    \node [draw=\linecolor, circle, above of= #1, node distance= \verticdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};
    \node[above of= #2, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#4) {\textsize{#5}};
    \draw[-latex, \linecolor] (#2) -- (#1);
    \draw[-latex, \linecolor] (#4) -- (#2);
}

\newcommand{\bUpToGain}[5]{
    \node [draw=\linecolor, circle, below of= #1, node distance= \verticdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};
    \node[below of=#2, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#4) {\textsize{#5}};
    \draw[-latex, \linecolor] (#2) -- (#1);
    \draw[-latex, \linecolor] (#4) -- (#2);
}

\newcommand{\bUpTo}[3]{
    \node[below of= #1, node distance=\verticdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linecolor] (#2) -- (#1);
}

\newcommand{\bRightTo}[3]{
    \node[left of= #1, node distance=\horizdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linecolor] (#2) -- (#1);
}

\newcommand{\bLeftTo}[3]{
    \node[left of= #1, node distance=\horizdist, \linetype, fill=\backgroundcolor] (#2) {\textsize{#3}};
    \draw[-latex, \linecolor] (#2) -- (#1);
}

\newcommand{\bPlusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin] {};  
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex,\linecolor] (#1) -- (#2);         
}

\newcommand{\bPlusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);                
}

\newcommand{\bMinusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin] {};  
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex,\linecolor] (#1) -- (#2);         
}

\newcommand{\bMinusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw=gray!50, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);        
}

\newcommand{\bMinusPlus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusPlusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusMinusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusMinusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusPlusDown}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusPlusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusMinusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusMinusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusPlusUp}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusMinus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bMinusMinus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bPlusPlus}[2]{
    \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {};
    \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist, thin, draw=gray!50] {};    
    \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}};
    \draw [-latex, \linecolor] (#1) -- (#2);            
}

\newcommand{\bGain}[3]{
    \node [draw=\linecolor, circle, right of= #1, node distance= \horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};
    \draw [-latex, \linecolor] (#1)--(#2);
}

\newcommand{\bGainForthDown}[3]{
    \node [draw=\linecolor, circle, below of= #1, node distance=\verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};
    \draw [-latex, \linecolor] (#1)|-(#2);
}

\newcommand{\bGainForthUp}[3]{
    \node [draw=\linecolor, circle, above of= #1, node distance=\verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}};
    \draw [-latex, \linecolor] (#1)|-(#2);
}

\newcommand{\bGainBackDown}[4]{
    \node [draw=\linecolor, circle, below of= #1, node distance=\verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) {\color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#2)|-(#3);
    \draw [-latex, \linecolor] (#3)-|(#1);
}

\newcommand{\bGainBackUp}[4]{
    \node [draw=\linecolor, circle, above of= #1, node distance= \verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) {\color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#2)|-(#3);
    \draw [-latex, \linecolor] (#3)-|(#1);
}

\newcommand{\bGainBackUpCross}[4]{
    \node [draw=\linecolor, circle, above of= #1, node distance= \verticdist, xshift=-\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(-\horizdist/2,0) -- ($(#2)-(0,\verticdist)$) -- (#2);
}

\newcommand{\bGainBackDownCross}[4]{
    \node [draw=\linecolor, circle, below of= #1, node distance= \verticdist, xshift=-\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(-\horizdist/2,0) -- ($(#2)+(0,\verticdist)$) -- (#2);
}

\newcommand{\bGainForthUpCross}[4]{
    \node [draw=\linecolor, circle, above of= #1, node distance= \verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)-(0,\verticdist)$) -- (#2);
}

\newcommand{\bGainForthDownCross}[4]{
    \node [draw=\linecolor, circle, below of= #1, node distance= \verticdist, xshift=\horizdist, minimum size = 1.5em, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)+(0,\verticdist)$) -- (#2);
}

\newcommand{\bTF}[3]{       
    \node [draw=\linecolor, rectangle, right of= #1, node distance= \horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}}; 
    \draw [-latex, \linecolor] (#1)--(#2);
}

\newcommand{\bTFForthDown}[3]{      
    \node [draw=\linecolor, rectangle, below of= #1, node distance= \verticdist, xshift=\horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}}; 
    \draw [-latex, \linecolor] (#1)|-(#2);
}

\newcommand{\bTFForthUp}[3]{        
    \node [draw=\linecolor, rectangle, above of= #1, node distance= \verticdist, xshift=\horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}] (#2) {\color{\colortext}\textsize{#3}}; 
    \draw [-latex, \linecolor] (#1)|-(#2);
}

\newcommand{\bTFForthUpCross}[4]{
    \node [draw=\linecolor, rectangle, above of= #1, node distance= \verticdist, xshift=\horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor,drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)-(0,\verticdist)$) -- (#2);
}

\newcommand{\bTFForthDownCross}[4]{
    \node [draw=\linecolor, rectangle, below of= #1, node distance= \verticdist, xshift=\horizdist, minimum height = \minheight, \linetype, fill=\backgroundcolor,drop shadow={opacity=\dark}] (#3) { \color{\colortext}\textsize{#4}};
    \draw [-latex, \linecolor] (#1)|-(#3);
    \draw [-latex, \linecolor] (#3) -- ++(\horizdist/2,0) -- ($(#2)+(0,\verticdist)$) -- (#2);
}

\newcommand{\bMarkNode}[2]{
    \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.5em,right of = #1, node distance= \horizdist] (#2) {};
    \draw [\linecolor] (#1)--(#2);
}

\newcommand{\bJumpNode}[3]{
    \coordinate (#2) at (#3);
    \draw [\linecolor] (#1)--(#2);
}

\newcommand{\bLink}[2]{
    \draw [-latex,\linecolor] (#1)--(#2);
}

\newcommand{\bOut}[3]{
    \node[right of= #1, node distance= \horizdist] (#2) {\color{\colortext}\textsize{#3}};
    \draw [-latex, \linecolor] (#1)--(#2);
}

并通过 3 个例子展示可以(简单地)做什么。

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{bloquesshapes} % the above .sty file

\begin{document}

\begin{tikzpicture}
    \bShadow
    \node (1) at (0,0) {\color{\colortext}\textsize{$i_{sc\alpha}$}};
    \bMinusUp{1}{2}
    \bDownTo{2}{3}{$i_{s\alpha}$}
    \bMinusPlus{2}{3}
    \bTF{3}{4}{$\dfrac{1}{sl}$}
    \bMarkNode{4}{5}
    \bGainBackUp{3}{5}{6}{$r$}
    \bOut{5}{7}{$i_{s\alpha}$}
    \node (A) at (0,-\phasedist) {\color{\colortext}\textsize{$u_{s\beta}$}};
    \bMinusDown{A}{B}
    \bUpTo{B}{C}{$u_{i\beta}$}
    \bMinusMinus{B}{C}
    \bTF{C}{D}{$\dfrac{1}{sl}$}
    \bMarkNode{D}{E}
    \bGainBackDown{C}{E}{F}{$r$}
    \bOut{E}{G}{$i_{s\beta}$}
    \bGainBackUpCross{E}{3}{H}{$\omega l$}
    \bGainBackDownCross{5}{C}{8}{$\omega l$}
\end{tikzpicture}

\begin{tikzpicture}
    \bShadow
    \node (1) at (0,0) {\color{\colortext}\textsize{$i_{sc\alpha}$}};
    \bMinusUp{1}{2}
    \bDownTo{2}{3}{$i_{s\alpha}$}
    \bMarkNode{2}{3}
    \bTF{3}{4}{$\frac{1+sT_n}{sT_i}$}
    \bMinusDown{4}{5}
    \bOut{5}{7}{$u_{cm\alpha}$}
    \node (A) at (0,-\phasedist) {\color{\colortext}\textsize{$i_{sc\beta}$}};
    \bMinusDown{A}{B}
    \bUpTo{B}{C}{$i_{s\beta}$}
    \bMarkNode{B}{C}
    \bTF{C}{D}{$\frac{1+sT_n}{sT_i}$}
    \bPlusUp{D}{E}
    \bOut{E}{G}{$u_{cm\beta}$}
    \bTFForthDownCross{3}{E}{H}{$\dfrac{\omega T_n}{sT_i}$}
    \bTFForthUpCross{C}{5}{8}{$\dfrac{\omega T_n}{sT_i}$}
\end{tikzpicture}

\begin{tikzpicture}
    \bShadow
    \node (1) at ($(0,0)+(0,\verticdist)$) {\color{\colortext}\textsize{$i_{c\alpha}$}};
    \bMinusUp{1}{2}
    \bDownTo{2}{3}{$i_{\alpha}$}
    \bMarkNode{2}{4}
    \bTFForthDown{4}{5}{$\dfrac{1}{sT_e}$}
    \bMarkNode{5}{6}
    \bGain{6}{7}{$k_{Rr}$}
    \bPlusMinusDown{7}{8}
    \coordinate[right of=4, node distance=2*\horizdist] (10);
    \bJumpNode{4}{10}{10}
    \bGain{10}{11}{$k_w$}
    \bMinusPlus{11}{12}
    \bLink{8}{12}
    \bDownToGain{12}{13}{$k_v$}{14}{$u_{i\alpha}$}
    \bOut{12}{15}{$y_{R\alpha}$}
    \node (A) at ($(0,0)+(0,-\phasedist-\verticdist)$) {\color{\colortext}\textsize{$i_{c\beta}$}};
    \bMinusDown{A}{B}
    \bUpTo{B}{C}{$i_{\beta}$}
    \bMarkNode{B}{D}
    \bTFForthUp{D}{E}{$\dfrac{1}{sT_e}$}
    \bMarkNode{E}{F}
    \bGain{F}{G}{$k_{Rr}$}
    \bPlusPlusUp{G}{H}
    \coordinate[right of=D, node distance=2*\horizdist] (J);
    \bJumpNode{D}{J}{J}
    \bGain{J}{K}{$k_w$}
    \bPlusMinus{K}{L}
    \bLink{H}{L}
    \bUpToGain{L}{M}{$k_v$}{N}{$u_{i\beta}$}
    \bOut{L}{O}{$y_{R\alpha}$}
    \bGainForthDownCross{6}{H}{9}{$k_{Ri}$}
    \bGainForthUpCross{F}{8}{I}{$k_{Ri}$}
\end{tikzpicture}

\end{document}

视觉效果如下 3 个例子

相关内容