\tikzset 코드에 인수를 추가하시겠습니까?

\tikzset 코드에 인수를 추가하시겠습니까?

다음 코드를 살펴보세요.

%%%%%%%%%%%%%%%%%%% MOBILE TOWER %%%%%%%%%%%%%%%%%%%%%
\newcommand{\MBS}[1]{%
\begin{tikzpicture}[]
\node[station] (base) {#1};

%\draw[line join=bevel] (base.110) -- (base.70) -- (base.north west) -- (base.north east) -- cycle;
\draw[line join=bevel] (base.100) -- (base.80) -- (base.110) -- (base.70) -- (base.north west) -- (base.north east);
\draw[line join=bevel] (base.100) -- (base.70) (base.110) -- (base.north east);

% original yshift=.8pt
%\draw[line cap=rect] ([xshift=.5cm,yshift=.3pt] base.north) [antenna=1];
%\draw[line cap=rect] ([yshift=.3pt]ant1 |- base.north) -- node[above,shape=rectangle,inner ysep=+.3333em]{\dots} ([xshift=-.5cm,yshift=.3pt]base.north) [antenna=2];
\draw[line cap=rect] ([xshift=-.1768cm,yshift=.6pt]base.north -| base.right tail) [antenna=1];
\draw[line cap=rect] ([yshift=.6pt]ant1 |- base.north) -- node[above,shape=rectangle,inner ysep=+.3333em]{\dots} ([xshift=.1768cm,yshift=.6pt]base.north -| base.left tail) [antenna=2];

%\draw[line cap=rect] ([yshift=.3pt]ant1 |- base.north) -- ([xshift=-.5cm,yshift=.3pt]base.north) [antenna=2];
%\node at ($(ant1)!0.5!(ant2)$) {\dots};
\end{tikzpicture}
}

다음과 같은 명령을 작성할 수 있습니다.

\draw (-4,0) node[scale=2]{\MBS{a}} ;

중앙에 'a'라는 라벨이 있는 그림을 생성합니다(무선 통신에서 이 다이어그램은 일종의 모바일 타워를 나타냅니다). 이제 다음 코드 조각

%%%%%%%%%%%%%%%%%%%%%% RELAY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{radiation/.style={{decorate,decoration={expanding waves,angle=90,segment length=4pt}}},
         relay/.pic={
        code={\tikzset{scale=5/10}
            \draw[semithick] (0,0) -- (1,4);% left line
            \draw[semithick] (3,0) -- (2,4);% right line
            \draw[semithick] (0,0) arc (180:0:1.5 and -0.5);
            \node[inner sep=4pt] (circ) at (1.5,5.5) {};
            \draw[semithick] (1.5,5.5) circle(8pt);
            \draw[semithick] (1.5,5.5cm-8pt) -- (1.5,4);
            \draw[semithick] (1.5,4) ellipse (0.5 and 0.166);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm+8pt,5.5) -- +(0:2);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm-8pt,5.5) -- +(180:2);
  }}
}

다음과 같은 코드를 작성할 수 있게 해주세요

\path (2,-1.2)  pic[scale=0.5,color=red] {relay};

중앙에 라벨이 없는 형태를 생성하는 것입니다(무선통신에서는 릴레이라고 합니다). 첫 번째 예(모바일 타워)와 유사한 중앙에서 사용자 정의 라벨링을 어떻게 달성합니까?

전체 작업 예제는 다음 코드에 나와 있습니다.

\documentclass[tikz]{standalone}
   \usepackage{ellipsis}
   \usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,shapes.geometric}
\tikzset{naming/.style={align=center,font=\small}}
\tikzset{antenna/.style={insert path={-- coordinate (ant#1) ++(0,0.25) -- +(135:0.25) + (0,0) -- +(45:0.25)}}}
\tikzset{station/.style={naming,draw,shape=dart,shape border rotate=90, minimum width=10mm, minimum height=10mm,outer sep=0pt,inner sep=3pt}}
%\tikzset{mobile/.style={naming,draw,shape=rectangle,minimum width=15mm,minimum height=7.5mm, outer sep=0pt,inner sep=3pt}}
\tikzset{mobile/.style={naming,draw,shape=rectangle,minimum width=12mm,minimum height=6mm, outer sep=0pt,inner sep=3pt}}
%\tikzset{radiation/.style={{decorate,decoration={expanding waves,angle=90,segment length=4pt}}}}

%%%%%%%%%%%%%%%%%%%%%% RELAY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{radiation/.style={{decorate,decoration={expanding waves,angle=90,segment length=4pt}}},
         relay/.pic={
        code={\tikzset{scale=5/10}
            \draw[semithick] (0,0) -- (1,4);% left line
            \draw[semithick] (3,0) -- (2,4);% right line
            \draw[semithick] (0,0) arc (180:0:1.5 and -0.5);
            \node[inner sep=4pt] (circ) at (1.5,5.5) {};
            \draw[semithick] (1.5,5.5) circle(8pt);
            \draw[semithick] (1.5,5.5cm-8pt) -- (1.5,4);
            \draw[semithick] (1.5,4) ellipse (0.5 and 0.166);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm+8pt,5.5) -- +(0:2);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm-8pt,5.5) -- +(180:2);
  }}
}

%%%%%%%%% MOBILE PHONE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\UE}[1]{%
\begin{tikzpicture}[every node/.append style={rectangle,minimum width=0pt}]
\node[mobile] (box) {#1};

\draw ([xshift=.25cm] box.south west) circle (4pt)
      ([xshift=-.25cm]box.south east) circle (4pt);

\fill ([xshift=.25cm] box.south west) circle (1pt)
      ([xshift=-.25cm]box.south east) circle (1pt);

\draw (box.north) [antenna=1];
\end{tikzpicture}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MOBILE BASE STATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\MBS}[1]{%
\begin{tikzpicture}[]
\node[station] (base) {#1};

%\draw[line join=bevel] (base.110) -- (base.70) -- (base.north west) -- (base.north east) -- cycle;
\draw[line join=bevel] (base.100) -- (base.80) -- (base.110) -- (base.70) -- (base.north west) -- (base.north east);
\draw[line join=bevel] (base.100) -- (base.70) (base.110) -- (base.north east);

% original yshift=.8pt
%\draw[line cap=rect] ([xshift=.5cm,yshift=.3pt] base.north) [antenna=1];
%\draw[line cap=rect] ([yshift=.3pt]ant1 |- base.north) -- node[above,shape=rectangle,inner ysep=+.3333em]{\dots} ([xshift=-.5cm,yshift=.3pt]base.north) [antenna=2];
\draw[line cap=rect] ([xshift=-.1768cm,yshift=.6pt]base.north -| base.right tail) [antenna=1];
\draw[line cap=rect] ([yshift=.6pt]ant1 |- base.north) -- node[above,shape=rectangle,inner ysep=+.3333em]{\dots} ([xshift=.1768cm,yshift=.6pt]base.north -| base.left tail) [antenna=2];

%\draw[line cap=rect] ([yshift=.3pt]ant1 |- base.north) -- ([xshift=-.5cm,yshift=.3pt]base.north) [antenna=2];
%\node at ($(ant1)!0.5!(ant2)$) {\dots};
\end{tikzpicture}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%% DIAGRAM STARTS HERE %%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}%[every path/.append style={thick}]
\draw (-4,0) ellipse (8 and 3);
\draw (8,0) ellipse (8 and 3);

\draw (-4,0) node[scale=2]{\MBS{a}} ;
\draw (8,0) node[scale=2,color=red]{\MBS{2}} ;
\path (2,1)  pic[scale=0.5,color=red] {relay};
\path (2,-1.2)  pic[scale=0.5,color=red] {relay};
\draw (1,0) node[scale=.8]{\UE{1}};
\draw (-1,0) node[scale=.8]{\UE{2}};
\end{tikzpicture}
\end{document}

답변1

이 같은?

여기에 이미지 설명을 입력하세요

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{decorations.pathreplacing}


\tikzset{radiation/.style={{decorate,decoration={expanding waves,angle=90,segment length=4pt}}},
         relay/.pic={
        code={\tikzset{scale=5/10}
            \draw[semithick] (0,0) -- (1,4);% left line
            \draw[semithick] (3,0) -- (2,4);% right line
            \draw[semithick] (0,0) arc (180:0:1.5 and -0.5) node[above, midway]{#1};
            \node[inner sep=4pt] (circ) at (1.5,5.5) {};
            \draw[semithick] (1.5,5.5) circle(8pt);
            \draw[semithick] (1.5,5.5cm-8pt) -- (1.5,4);
            \draw[semithick] (1.5,4) ellipse (0.5 and 0.166);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm+8pt,5.5) -- +(0:2);
            \draw[semithick,radiation,decoration={angle=45}] (1.5cm-8pt,5.5) -- +(180:2);
  }}
}

\begin{document}

\begin{tikzpicture}
\path (2,-1.2)  pic[scale=0.5,color=red] {relay=B};
\end{tikzpicture}

\end{document}

관련 정보