是否有任何基于 Windows 的图形编辑器用于 \pgfdeclareshape

是否有任何基于 Windows 的图形编辑器用于 \pgfdeclareshape

在 TeXample 上,Martin Scharrer 贡献了出色的d-触发器将电路图简化为两个步骤的示例

  1. 放置零件:

    % Place FFs  
    \foreach \m in {0,...,\N}  
          \node [shape=dff] (DFF\m) at ($ 3*(\m,0) $) {Bit \#\m};
    
  2. 连接网络

d 触发器使用\pgfdeclareshape命令,涉及 120 行代码。可以将 d 触发器保存在其自己的文件中,如下所示:

\makeatletter  
  % D flip-flops (DFFs) and shift register  
  % Original Author: Martin Scharrer  
  % Data Flip Flip (DFF) shape  
 \pgfdeclareshape{dff}{  
    %... details omitted, available elsewhere  
 }

 % Define styles, etc  
 \tikzset{  
    every dff node/.style=%... details omitted, available elsewhere  
 }  
 \makeatother

这可能是一个艰巨的任务,但有没有一个工具,类似于提克兹,在 Windows 下稳定运行并允许创建和编辑以这种方式保存的图形?

答案1

作为这个问题的临时解决方案,我决定使用 \matrix 命令来定位坐标。最终,我希望看到一个简单的图形实用程序或其他类似的解析器,它可以采用 VHDL 模板或原理图符号并自动生成 IC 的源代码,使用以下内容作为模板:

%% An IC is essentially a matrix with connection points (coordinates) at its upper, lower, left and right edges.
%% The matrix command facilitates this nicely using nodes combined with the label option
%% The matrix command for any IC can be placed in a custom command for reuse: 
%% Use the folllowing as a template
\newcommand{\drawff}[2]{%
    \matrix (DFF#1) [draw,very thick,inner sep=0pt,outer sep=0pt,column sep=2pt,label distance=0.6ex, 
        font=\sffamily\scriptsize,
        ampersand replacement=\&] at #2 {
            % Top Row:
            \& \& \& \& \& \node [coordinate,label=270:R] (R#1) {}; \& \& \& \& \& \&\\
            % Left and right rows:
            \& \& \& \& \& \& \& \& \& \& \& \\[1ex]
            \node [coordinate,label=0:D] (D#1) {};
            \& \& \& \& \& \& \& \& \& \& \& \node [coordinate,label=180:Q] (Q#1) {}; \\[6ex]
            \node [coordinate,label=0:CE] (CE#1) {};
            \& \& \& \& \& \& \& \& \& \& \& \\
            \& \& \& \& \& \& \& \& \& \& \&
                \node [coordinate,label=180:$\overline{\text{Q}}$] (Qb#1) {}; \\
            \node [label=0:$\large >$,anchor=west] (CLK#1) {};
            \& \& \& \& \& \& \& \& \& \& \& \\[1ex]
            % Bottom row:
            \& \& \& \& \& \node [coordinate,label=90:S] (S#1) {}; \& \& \& \& \& \&\\
    } ;
}

一旦定义了符号,操纵网格的图形软件就可以定义 IC 和 I/O 标记的放置坐标。该软件的输出应如下所示:

{[start chain=placements]
%% Place the parts

% D registers, with labels
%% Step 1: anchor placement (a graphical editor should be able to handle this)
    \foreach \m in {0,...,\N}
        \node [coordinate] (tlDFF\m) at ($ 3*(\m,0) $) {};

% 'Reset' port label
    \path (tlDFF0) +(-2,+2.5) coordinate (reset)   node [anchor=east] {reset};

% 'Set' port label
    \path (tlDFF0) +(-2,-2.5) coordinate (set)   node [anchor=east] {set};

% Clock port label
    \path (tlDFF0) +(-2,-3) coordinate (clock) node [anchor=east] {clock};

% Clock enable port label
    \path (tlDFF0) +(-2,-3.5) coordinate (clocken)   node [anchor=east] {clock enable};
}

第三个任务就是简单地将适当的符号放置在坐标处。这只是选择唯一名称并放置形状的问题,如下所示:

\foreach \m in {0,...,\N}
    \drawff{\m}{(tlDFF\m)};

%% annotate the ics as desired
\foreach \m in {0,...,\N}
    \node [fit=(DFF\m),font=\sffamily\scriptsize] {Bit \#\m};

%% Place input and output ports, junctions, etc:
    % data in- and output port
    \path [ultra thick] (D0) -- +(-1,0) node [anchor=east] (in0) {input} ;
    \path [ultra thick] (Q\N) -- +(1,0) node [anchor=west] (out\N) {output};

最后,用电线连接网络。图形例程只需要能够识别用户单击图像中的特定位置时所引用的坐标。可以使用 \chainin 命令完成绘图,类似于下面所示:

{[start chain=nets]
%% Connect the nets

% Connect reset lines
    \chainin (reset);
    {[start branch=reset] 
        \foreach \m in {0,...,\N} 
            \chainin (R\m) [join=with reset by {hv path,tip}];
    }

% Connect FFs (Q1 with D1, etc.)    
\chainin (in0);
\chainin (D0) [join= by ultra thick];

    \foreach \m in {1,...,\N} {[start branch=qd\p\m] % Note that it starts with 1, not 0
        \chainin (Q\p);
        \chainin (D\m) [join=by ultra thick];
        \global\let\p\m
    }

\chainin (Q\N);
\chainin (out\N) [join= by ultra thick];

% Connect set lines
    \chainin (set);
    {[start branch=set] 
        \foreach \m in {0,...,\N} 
            \chainin (S\m) [join=with set by {hv path,tip}];
    }

% Connect clock lines
    \chainin (clock);
    {[start branch=clk]
        \foreach \m in {0,...,\N} 
            \chainin (CLK\m) [join=with clock by {Z path=-0.55,tip}];
    }

% Connect clock-enable lines
    \chainin (clocken);
    {[start branch=clken]
        \foreach \m in {0,...,\N}  
            \chainin (CE\m) [join=with clocken by {Z path=-0.75,tip}];    
    }
}

欢迎报告此事的任何进展!

相关内容