TikZ & PGF frecce di unione nei diagrammi parallele

  • Creatore
    Topic
  • #81451
    tonegas
    Partecipante
      Up
      0
      Down
      ::


      Ciao ragazzi sto scrivendo delle immagini con pgf e TikZ ed ho il seguente problema.
      Dati due blocchi entità, di diversa grandezza, di un diagramma logico.
      Non riesco a creare più connessioni che risultino parallele che uniscano i suddetti due blocchi.
      Quello che sono riuscito a fare è questo.

      `% Observer/Estimator
      % Author: Dominik Haumann
      \documentclass[landscape,a5paper,11pt]{article}
      \usepackage[utf8x]{inputenc} % utf8 encoding

      \usepackage{tikz}

      \usepackage[active,tightpage]{preview}
      \PreviewEnvironment{tikzpicture}

      \usetikzlibrary{decorations.pathmorphing} % for snake lines
      \usetikzlibrary{matrix} % for block alignment
      \usetikzlibrary{arrows} % for arrow heads
      \usetikzlibrary{calc,intersections,through} % for manimulation of coordinates
      \usetikzlibrary{shapes,calc,arrows,through,intersections}
      \usetikzlibrary{positioning} % per il posizionamento relativo degli oggetti
      \usetikzlibrary{fit} % per fare riquadri su più oggetti

      % TikZ styles for drawing
      \tikzstyle{block} = [draw,rectangle,thick,fill=white,align=flush center,rounded corners]

      \tikzstyle{connector} = [->,thick,rounded corners]

      \begin{document}

      \begin{tikzpicture}[scale=1, auto, >=stealth']
      \matrix[ampersand replacement=\&, row sep=0.6cm, column sep=0.6cm] {
      \node[block](up){Block 1}; \\
      \node[block](down){Block 2 BIG};\\
      };

      \draw [connector] ($(up.south west)!1/5!(up.south east)$) — (down);
      \draw [connector] ($(up.south west)!2/5!(up.south east)$) — (down);
      \draw [connector] ($(up.south west)!3/5!(up.south east)$) — (down);
      \draw [connector] ($(up.south west)!4/5!(up.south east)$) — (down);

      \end{tikzpicture}
      \end{document}
      `
      Quello che vorrei è che le frecce fossero tutte parallele.
      Grazie in anticipo
      Gastone

    Visualizzazione 1 filone di risposte
    • Autore
      Risposte
      • #81452
        Up
        0
        Down
        ::

        tonegas” post=80701Ciao ragazzi sto scrivendo delle immagini con pgf e tkz ed ho il seguente problema.
        Dati due blocchi entità, di diversa grandezza, di un diagramma logico.
        Non riesco a creare più connessioni che risultino parallele che uniscano i suddetti due blocchi.
        Quello che sono riuscito a fare è questo.

        `% Observer/Estimator
        % Author: Dominik Haumann
        \documentclass[landscape,a5paper,11pt]{article}
        \usepackage[utf8x]{inputenc} % utf8 encoding

        \usepackage{tikz}

        \usepackage[active,tightpage]{preview}
        \PreviewEnvironment{tikzpicture}

        \usetikzlibrary{decorations.pathmorphing} % for snake lines
        \usetikzlibrary{matrix} % for block alignment
        \usetikzlibrary{arrows} % for arrow heads
        \usetikzlibrary{calc,intersections,through} % for manimulation of coordinates
        \usetikzlibrary{shapes,calc,arrows,through,intersections}
        \usetikzlibrary{positioning} % per il posizionamento relativo degli oggetti
        \usetikzlibrary{fit} % per fare riquadri su più oggetti

        % TikZ styles for drawing
        \tikzstyle{block} = [draw,rectangle,thick,fill=white,align=flush center,rounded corners]

        \tikzstyle{connector} = [->,thick,rounded corners]

        \begin{document}

        \begin{tikzpicture}[scale=1, auto, >=stealth']
        \matrix[ampersand replacement=\&, row sep=0.6cm, column sep=0.6cm] {
        \node[block](up){Block 1}; \\
        \node[block](down){Block 2 BIG};\\
        };

        \draw [connector] ($(up.south west)!1/5!(up.south east)$) — (down);
        \draw [connector] ($(up.south west)!2/5!(up.south east)$) — (down);
        \draw [connector] ($(up.south west)!3/5!(up.south east)$) — (down);
        \draw [connector] ($(up.south west)!4/5!(up.south east)$) — (down);

        \end{tikzpicture}
        \end{document}
        `
        Quello che vorrei è che le frecce fossero tutte parallele.
        Grazie in anticipo
        Gastone

        In realtà stai usando TikZ e non tkz che è un’altra cosa. 🙂

        Il tuo problema si può risolvere andando a calcolarsi le coordinate del segmento come descritto in in questa discussione. Quindi: `
        % Observer/Estimator
        % Author: Dominik Haumann
        \documentclass[landscape,a5paper,11pt]{article}
        \usepackage[utf8x]{inputenc} % utf8 encoding

        \usepackage{tikz}

        \usepackage[active,tightpage]{preview}
        \PreviewEnvironment{tikzpicture}

        \usetikzlibrary{decorations.pathmorphing} % for snake lines
        \usetikzlibrary{matrix} % for block alignment
        \usetikzlibrary{arrows} % for arrow heads
        \usetikzlibrary{calc,intersections,through} % for manimulation of coordinates
        \usetikzlibrary{shapes,calc,intersections}
        \usetikzlibrary{positioning} % per il posizionamento relativo degli oggetti
        \usetikzlibrary{fit} % per fare riquadri su più oggetti

        % TikZ styles for drawing: tikzstyle è obsololeto
        %\tikzstyle{block} = [draw,rectangle,thick,fill=white,align=flush center,rounded corners]
        %
        %\tikzstyle{connector} = [->,thick,rounded corners]

        \tikzset{block/.style={draw,rectangle,thick,fill=white,align=flush center,rounded corners}}

        \tikzset{connector/.style={->,thick,rounded corners}}

        \begin{document}

        \begin{tikzpicture}[>=stealth']
        \matrix[ampersand replacement=\&, row sep=0.6cm, column sep=0.6cm] {
        \node[block](up){Block 1}; \\
        \node[block](down){Block 2 BIG};\\
        };

        \draw[connector] let \p1= ($(up.south west)!1/5!(up.south east)$), \p2=(down.north) in (\x1,\y1)–(\x1,\y2);
        \draw[connector] let \p1= ($(up.south west)!2/5!(up.south east)$), \p2=(down.north) in (\x1,\y1)–(\x1,\y2);
        \draw[connector] let \p1= ($(up.south west)!3/5!(up.south east)$), \p2=(down.north) in (\x1,\y1)–(\x1,\y2);
        \draw[connector] let \p1= ($(up.south west)!4/5!(up.south east)$), \p2=(down.north) in (\x1,\y1)–(\x1,\y2);

        \end{tikzpicture}
        \end{document}
        `

        Per un esempio di questo tipo credo che la matrice possa essere tranquillamente evitata, come alcune librerie che carichi (e alcune le carichi due volte).

        Ciao
        Claudio

      • #81453
        tonegas
        Partecipante
          Up
          0
          Down
          ::


          Grazie.
          Era proprio quello di cui avevo bisogno.
          Buone vacanze e Buon Natale

      Visualizzazione 1 filone di risposte
      • Devi essere connesso per rispondere a questo topic.

      Go to top