0

Does anyone know how to rotate the oscilloscope AND the signal square at the same time?

This is what I have so far:

enter image description here

As you can see, the signal does not rotate with the oscilloscope, this is what I wrote:

\documentclass[a4paper,12pt]{article}

\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[]{circuitikzgit}

\begin{document}

\begin{center}
    \begin{circuitikz}[rotate=45, transform shape]
    \draw (0,0)node[oscopeshape](osc1){OC 1};
    \end{circuitikz}
\end{center}    

\end{document}

I have tried using \scope and rotating from the node line, but the result is the same, I think this is a bug.

Also, I have used the last release of CircuiTikz, this is were you can get it.

ElSabio
  • 361
  • https://tex.stackexchange.com/questions/45848/rotate-node-text-and-use-relative-positioning-in-tikz?rq=1 – js bibra Jan 05 '20 at 12:29
  • 1
    It's expected behavior - instruments behave like this, there is even an example on the manual, page 49. There is currently no option to avoid this , because I never saw circuits needing that... – Rmano Jan 05 '20 at 16:51
  • 1
    @jsbibra - that do not apply. circuitikz is trying hard to un-rotate text and symbols in Instruments, as explained in detail in the manual, so those nodes behave differently from plain TikZ – Rmano Jan 05 '20 at 17:00
  • thanks for the update – js bibra Jan 06 '20 at 01:21
  • @ElSabio --- I added a switch that will allow the behavior you want that will be in the next version; see https://github.com/circuitikz/circuitikz/pull/350 – Rmano Jan 20 '20 at 18:40
  • Thank you Rmano! – ElSabio Jan 21 '20 at 22:50

4 Answers4

6

It is well known that one has to use transform canvas with great care, and John Kormylo reminds us about some of its side effects. It is also absolutely unnecessary. Here is a trick that always works: use a \savebox.

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[]{circuitikzgit}
\newsavebox\oscopeshape
\sbox\oscopeshape{\tikz{\node[oscopeshape]{};}}
\begin{document}

\begin{center}
    \begin{circuitikz}[rotate=45, transform shape]
    \draw (0,0)node[label=above:OC 1](osc1){\usebox\oscopeshape};
    \end{circuitikz}
\end{center}    
\end{document}

enter image description here

P.S. "always" refers to something that is not done by the viewer. shadings and patterns are examples of things that cannot be transformed with this trick.

  • P.P.S. To me it seems that the side effects of transform canvas are repairable. They seem to be due to a confusion between active and passive transformations. –  Jan 05 '20 at 22:25
5

I doubt that this is bug, it is more missed (unusual) features demands (so far I didn't see electric/electronic schemes with rotated instruments). If you like to rotate ti, you should rotate canvas:

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[]{circuitikz}

\begin{document}
\begin{center}
    \begin{circuitikz}
    \begin{scope}[]
    \draw (0,0)node[oscopeshape,transform canvas={rotate=45}](osc1){OC 1};
    \end{scope}
    \end{circuitikz}
\end{center}
\end{document}

enter image description here

However, this can introduce unexpected problems to overall scheme design ...

Zarko
  • 296,517
  • Yes, it does give an unexpected problem, it deletes the node. – ElSabio Jan 05 '20 at 16:42
  • 1
    Yes, see section 1.7. circuitikz has not been thought for arbitrary rotations --- so yes, everything can happen. – Rmano Jan 05 '20 at 16:56
  • @Rmano, in a some of the next circuitikz release seems to be very welcome to tie node contents of oscopeshape with its border. With this (I assume) will works demands as was given in OP question or can be sloped as for example \draw (0,0) -- node[oscopeshape,sloped] {OC 1} (2,2). Frankly said, so far (in my long ee career) I newer need such way to draw oscilloscopes in my measurement schemes :-) – Zarko Jan 05 '20 at 19:57
  • @Zarko neither I ever saw those in 30+ years teaching electronics. It is not difficult to add; really similar to the rotated numbers in chips... Let's see. If the OP. can add a feature request with an use case in the Github page, all the better... – Rmano Jan 05 '20 at 22:18
5

Not an answer, just showing odd effects of the canvas transform.

\documentclass{standalone}
\usepackage[]{circuitikz}

\begin{document}
    \begin{circuitikz}
    \path (0,1);% for bounding box
    \begin{scope}[transform canvas={rotate=45}]
      \draw (0,0) node[oscopeshape](osc1){OC 1};
      \draw (osc1.in 1) -- ++(0,-1);
      \draw (osc1.in 2) -- ++(0,-1);
      \draw (osc1.left) -- ++(-1,0);
      \draw (osc1.right) -- ++(1,0);
    \end{scope}
    \draw[red] (osc1.in 1) -- ++(0,-1);
    \draw[red] (osc1.in 2) -- ++(0,-1);
    \draw[red] (osc1.left) -- ++(-1,0);
    \draw[red] (osc1.right) -- ++(1,0);
    \end{circuitikz}
\end{document}

demo


Alas, [remember picture] cannot handle rotation either.

\documentclass{standalone}
\usepackage[]{circuitikz}

\newsavebox\oscopeshape
\sbox\oscopeshape{\tikz[remember picture,overlay]{\node[oscopeshape](osc1){OC 1};}}

\begin{document}
  \begin{circuitikz}[remember picture]
    \path (0,1);% for bounding box
    \draw (0,0)node[rotate=45]{\usebox\oscopeshape};
    \draw[red] (0,0) -- (osc1.center);
    \draw (osc1.in 1) -- ++(0,-1);
    \draw (osc1.in 2) -- ++(0,-1);
    \draw (osc1.left) -- ++(-1,0);
    \draw (osc1.right) -- ++(1,0);
  \end{circuitikz}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
0

This is pretty simple, in the case you are just trying to make a rotated element rotate as a whole, like my case hehe.

Just use the package \rotating and include your CircuiTikz there as a figure, that is all.

ElSabio
  • 361
  • 1
    Hmm... But then you can't nest it with other circuits. Nesting tikzpictures is not supported, and will give strange results... – Rmano Jan 05 '20 at 22:20
  • This is true, but in this paricular case, I was trying to rotate a very big circuit to fix into a landscape A4 paper, so once I had everything on vertical, I rotated 90 degrees to fit it in the landscape format. – ElSabio Jan 06 '20 at 20:11