[Tex/LaTex] Cut corners off rectangle in TikZ

tikz-pgf

I'd like to reproduce this image using TikZ. The element X can be made simply using a rectangle and the "rounded corners" attribute. But EPN instead has its corners cut off (to form an octagon). Are there any simple commands like rounded corners to do this?

Best Answer

The shape chamfered rectangle already exists in the shapes.misc library:

enter image description here

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}

\begin{document}

\begin{tikzpicture}
\node[draw=red,chamfered rectangle,fill=red!30]
  {some text}; 
\end{tikzpicture}

\end{document}

And some code for the image attached:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,fit,positioning}

\begin{document}

\begin{tikzpicture}[line width=1pt]
\node[draw,rounded corners,minimum size=1cm] 
  (x) {X};
\node[draw,circle,below=2pt of x,minimum size=1cm]
  (y) {Y};
\coordinate (aux) at ([xshift=-60pt]x);    
\node[draw=red,chamfered rectangle,fit={(aux) (x) (y)}]
  {}; 
\end{tikzpicture}

\end{document}

enter image description here

And here's some code for the other component of the image, using the fit library and some layers:

\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,fit,positioning}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{document}

\begin{tikzpicture}[
  common/.style={
    draw,
    line width=1pt,
    fill=yellow!30,
    },
  cal/.style={
    common,
    rounded corners,
    minimum height=1.2cm
  },  
  ca/.style={
    common,
    circle,
    minimum height=1.2cm
  },
  conn/.style={
    draw,
    line width=1pt,
    fill=green!70!black
  },
  frame/.style={
    common,
    draw=red,
    chamfered rectangle
  },
  >=latex  
]
\node[cal] 
  (call) {Calmodulin};
\node[conn,right=of call]
  (gcon) {};
\coordinate[right=of gcon] (aux);
\node[cal,right=of aux] 
  (calr) {Calmodulin};
\node[ca,above=1.5cm of calr.east,anchor=east] 
  (car) {\ce{Ca^{2+}}};
\begin{pgfonlayer}{background}
\node[frame,fit={(aux) (calr) (car)}]
  (frame) {}; 
\end{pgfonlayer}
\node[ca,above right=1cm and -10pt of call] 
  (cal) {\ce{Ca^{2+}}};
\draw[->]
  (gcon) -- (call);  
\draw[->]
  (gcon) -- (frame.west|-calr.west);  
\draw[->]
  (gcon) to[bend left] (cal.south);  
\end{tikzpicture}

\end{document}

enter image description here

Using pics could simplify the code.