- Questo topic ha 30 risposte, 3 partecipanti ed è stato aggiornato l'ultima volta 13 anni fa da
OldClaudio.
-
CreatoreTopic
-
28 Settembre 2012 alle 20:34 #79355::
Ciao ragazzi!Su consiglio di OldClaudio dato mi qualche mese fa mentre scrivevo la tesi di dottorato, ho deciso di rifare tutte le figure che mi servono e che il mio prof mi aveva fatto fare con xfig, con tikz… ora vi posto l’immagine che sto cercando di rifare per farvi capire il mio problema.

Quei quadrati grandi rappresentano delle classi… ora vorrei fare una macro da poter inserire con coordinate relative e pensavo:
`
\begin{tikzpicture}[class/.style={}]
\draw[thick] (0,0) rectangle (3,-4);
\draw[thin] (0,-1) — (3,-1);
\end{tikzpicture}
`dentro ci vorrei mettere il nome della classe, e il nome dell’oggetto come nell’immagine e poi richiamarlo nel mio disegno con
`
\node [class] (M1) {\texttt{ps\_model}};
`Ma è possibile richiamare una macro con due testi? e come bisogna crearla? è sensato il mio primo pezzo di codice oppure ci sono altri modi per fare macro?
grazie
Marco
-
CreatoreTopic
-
AutoreRisposte
-
-
29 Settembre 2012 alle 4:50 #79356::
warcomeb” post=78472Ciao ragazzi!
Su consiglio di OldClaudio dato mi qualche mese fa mentre scrivevo la tesi di dottorato, ho deciso di rifare tutte le figure che mi servono e che il mio prof mi aveva fatto fare con xfig, con tikz… ora vi posto l’immagine che sto cercando di rifare per farvi capire il mio problema.

Quei quadrati grandi rappresentano delle classi… ora vorrei fare una macro da poter inserire con coordinate relative e pensavo:
`
\begin{tikzpicture}[class/.style={}]
\draw[thick] (0,0) rectangle (3,-4);
\draw[thin] (0,-1) — (3,-1);
\end{tikzpicture}
`dentro ci vorrei mettere il nome della classe, e il nome dell’oggetto come nell’immagine e poi richiamarlo nel mio disegno con
`
\node [class] (M1) {\texttt{ps\_model}};
`Ma è possibile richiamare una macro con due testi? e come bisogna crearla? è sensato il mio primo pezzo di codice oppure ci sono altri modi per fare macro?
grazie
MarcoIn linea di principio l’idea è fattibile: dovresti però probabilmente dare un’occhiata a come attivare del codice con uno stile [tt]/.code[/tt] (55 Key Management sul pgfmanual versione 25 Ottobre 2010).
Esistono però dei tool già pronti per questo tipo di disegni:
Ti consiglio prima di dare un’occhiata ai due pacchetti (non disponibili su CTAN): se non ti soddisfano si può pensare a come sistemare la macro.
Ciao
Claudio
-
29 Settembre 2012 alle 6:22 #79357::
Li ho visti e sembrano ottimi, ma credo che non rispecchino a pieno quello che mi serve… nel senso, il mio non è un vero e proprio diagramma delle classi, è abbastanza misto!!
possiamo ragionare insieme su come fare?? Devo riuscire a convincere il mio prof che xfig è da seppellire… nonostante abbia un MBP nuovo di pacca sta cercando tutti i modi possibili per installarlo nativo su MLion 😐 😐 😐 !!
-
29 Settembre 2012 alle 6:36 #79358::
warcomeb” post=78486Li ho visti e sembrano ottimi, ma credo che non rispecchino a pieno quello che mi serve… nel senso, il mio non è un vero e proprio diagramma delle classi, è abbastanza misto!!
possiamo ragionare insieme su come fare?? Devo riuscire a convincere il mio prof che xfig è da seppellire… nonostante abbia un MBP nuovo di pacca sta cercando tutti i modi possibili per installarlo nativo su MLion 😐 😐 😐 !!Ok! Dai un’occhiata a http://tex.stackexchange.com/questions/64174/automat-within-record; a prima vista ti può sembrare che non c’entri nulla, ma io partirei da una cosa del genere.
Ripensandoci: anche se è un diagramma misto perché non sfruttare lo stesso quei pacchetti? Tanto puoi sempre aggiungere le parti che non sono presenti disegnandole a mano tu. Eviteresti però di perdere un sacco di tempo per definire le forme da usare nelle classi.
Ciao
Claudio
-
29 Settembre 2012 alle 11:18 #79359
-
1 Ottobre 2012 alle 4:37 #79360::
Ho provato a fare qualche modifica e funziona:`
\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={2}{%
\node at ($(#1.north)!0.20!(#1.center)$){#2};
\draw($(#1.north west)!0.50!(#1.west)$)–($(#1.north east)!0.50!(#1.east)$);
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
\NewDocumentCommand{\drawclass}{d() m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}]{};
}
`e lo uso in questo modo (in pratica uguale a come lo hai scritto tu, solo che io aggiungo la label:
`\drawclass{m1}{sc\_module}`ma ho due domande:
1) il nome della classe e la linea verticale che gli sta sotto vorrei che stessero sempre alla stessa distanza e che non vari se io allargo il rettangolo sia in altezza che in larghezza! è sensato mettere una misura assoluta? ma come?
2) il contenuto all’interno di ogni classe, quali modi ci sono per aggiungerlo?grazie mille
Marco
-
1 Ottobre 2012 alle 7:28 #79361::
warcomeb” post=78565Ho provato a fare qualche modifica e funziona:
`
\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={2}{%
\node at ($(#1.north)!0.20!(#1.center)$){#2};
\draw($(#1.north west)!0.50!(#1.west)$)–($(#1.north east)!0.50!(#1.east)$);
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
\NewDocumentCommand{\drawclass}{d() m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}]{};
}
`e lo uso in questo modo (in pratica uguale a come lo hai scritto tu, solo che io aggiungo la label:
`\drawclass{m1}{sc\_module}`ma ho due domande:
1) il nome della classe e la linea verticale che gli sta sotto vorrei che stessero sempre alla stessa distanza e che non vari se io allargo il rettangolo sia in altezza che in larghezza! è sensato mettere una misura assoluta? ma come?
2) il contenuto all’interno di ogni classe, quali modi ci sono per aggiungerlo?grazie mille
MarcoProva così:
`\documentclass[a4paper,11pt]{article}
\usepackage{tikz,xparse}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\pgfmathsetmacro\vertshift{0.2+(\classheight/80)}
\node at ($(#1.north)+(0,0.25)$){#1};
\node at ($(#1.north)!0.95*\vertshift!(#1.center)$){#2};
\draw($(#1.north west)!0.50!(#1.west)$)–($(#1.north east)!0.50!(#1.east)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3cm] \node[draw,fill=black,circle,scale=0.05] (#1) {};}
% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\drawclass(0,0){m1}{sc\_module}{\vdots \\ \texttt{\tikzmark{m1pos}ps\_init()}}
\drawclass(4.5,0){m2}{sc\_module}{\vdots \\ \texttt{\tikzmark{m2pos}ps\_init()}}
\drawclass(9,0){m3}{sc\_module}{\vdots \\ \texttt{\tikzmark{m3pos}ps\_init()}}\draw(m1pos.center)– ($(m1pos)-(0,1)$)-|(m2pos.center)– ($(m2pos)-(0,1)$)-|(m3pos.center);
\end{tikzpicture}
\vspace{6cm}\setclassheight{4}
\setclasswidth{5}
\begin{tikzpicture}[remember picture,overlay]
\drawclass(0,0){m1}{sc\_module}{\vdots \\ \texttt{\tikzmark{m1pos}ps\_init()}}
\drawclass(5.5,0){m2}{sc\_module}{\vdots \\ \texttt{\tikzmark{m2pos}ps\_init()}}
\drawclass(11,0){m3}{sc\_module}{\vdots \\ \texttt{\tikzmark{m3pos}ps\_init()}}\draw(m1pos.center)– ($(m1pos)-(0,3)$)-|(m2pos.center)– ($(m2pos)-(0,3)$)-|(m3pos.center);
\end{tikzpicture}
\end{document}`Ciao
Claudio
-
3 Ottobre 2012 alle 4:22 #79362::
Ciao Claudio, ho provato a fare questo
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\newcommand{\classmark}[1]{%
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3cm] \node[draw,fill=black,circle,scale=0.05] (#1) {};
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]% \draw[help lines,yshift=-15cm] (0,0) grid (18,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\draw(m1init.center) — ($(m1init)-(0,1)$)-|(m2init.center) — ($(m2init)-(0,1)$)-|(m3init.center);
% \draw(m1init.center) — ($(m1init)-(0,1)$)-|(m2init.center);
\end{tikzpicture}
\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
ma succedono cose strane:
1) se commento le help lines le tre righe di congiunzione dei classmark vengono spostate in altre parti della pagina.
2) se metto `\begin{tikzpicture}[scale=0.8,remember picture,overlay]` il disegno va per buona parte fuori della pagina.
3) se metto le help line (ma ovviamente dopo non ci vanno) e provo a disegnare solo una parte delle linee di collegamento (come ad esempio la riga commentata) anche qui questa viene messa in altre parti della pagina.cosa sta succedendo???
grazie
Marco
-
3 Ottobre 2012 alle 6:24 #79363::
warcomeb” post=78628Ciao Claudio, ho provato a fare questo
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\newcommand{\classmark}[1]{%
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3cm] \node[draw,fill=black,circle,scale=0.05] (#1) {};
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]% \draw[help lines,yshift=-15cm] (0,0) grid (18,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\draw(m1init.center) — ($(m1init)-(0,1)$)-|(m2init.center) — ($(m2init)-(0,1)$)-|(m3init.center);
% \draw(m1init.center) — ($(m1init)-(0,1)$)-|(m2init.center);
\end{tikzpicture}
\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
ma succedono cose strane:
1) se commento le help lines le tre righe di congiunzione dei classmark vengono spostate in altre parti della pagina.
2) se metto `\begin{tikzpicture}[scale=0.8,remember picture,overlay]` il disegno va per buona parte fuori della pagina.
3) se metto le help line (ma ovviamente dopo non ci vanno) e provo a disegnare solo una parte delle linee di collegamento (come ad esempio la riga commentata) anche qui questa viene messa in altre parti della pagina.cosa sta succedendo???
grazie
MarcoCiao,
questo codice dovrebbe sistemare tutto:
`
\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\newcommand{\classmark}[1]{%
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3cm] \node[draw,fill=black,circle,scale=0.05] (#1) {};
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
\begin{tikzpicture}[scale=0.8]
\draw[help lines,yshift=-15cm] (0,0) grid (18,15);% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\end{tikzpicture}
% Usare solo le opzioni remember picture, overlay per disegnare le connessioni
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw(m1init.center) — ($(m1init)-(0,1)$)-|(m2init.center) — ($(m2init)-(0,1)$)-|(m3init.center);
\end{tikzpicture}
\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}
` infatti il risultato mi sembra sia quello che ti aspetti:[attachment=478]Immagine_2012-10-03.jpg[/attachment]
Ovviamente elimina pure le help lines. 😉
Il problema, forse, è che nel mio precedente intervento non avevo spiegato nessuna delle modifiche. Il comando che tu hai chiamato [tt]\classmark[/tt] è la famosa macro che serve come marker e può essere inserita facilmente in ogni punto del diagramma. Io l’ho usata per disegnare un pallino a sinistra del testo con uno shift di 0.3cm: ovviamente questo non va bene in caso tu la debba posizionare a destra. Ecco perché conviene cambiare la precedente definizione in:
`
\NewDocumentCommand{\classmark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=0.05] (#2) {};
}
}
` A questo punto se vuoi disegnare il connettore a destra ti basta dire:
`
\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \picsizett{ps\_init()} \classmark[0.3]{m1init}}
` dove [tt][0.3][/tt] è l’argomento facoltativo in cui si introduce lo shift.A parte la disgressione, è importantissimo sapere che quando si adotta questa scelta per disegnare le connessioni, occorre avere due “ambienti” [tt]tikzpicture[/tt]: nel primo si disegna la figura, nel secondo le connessioni. Il primo ambiente non avrà le opzioni [tt]remember picture, overlay[/tt] altrimenti la figura viene spostata chissà dove come capitava a te in precedenza perché disegnata come overlay senza avere una “base” di partenza, mentre la seconda figura che disegna le connessioni deve avere le opzioni [tt]remember picture, overlay[/tt] per poter disegnare le connessioni sulla figura di base. Con [tt]remember picture[/tt] infatti, la figura corrente conosce le coordinate usate nella figura di base. Nota anche che per il corretto processing è necessario compilare due volte.
Ciao
Claudio
Attachments:
You must be logged in to view attached files. -
4 Ottobre 2012 alle 5:11 #79364::
Ciao Claudio, grazie del tuo aiuto.seguendo il tuo consiglio, ho continuato a disegnare le connessioni sul secondo ambiente:
`\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\drawclass(10,-5){pskernel}{ps\_kernel}{\vdots}
\draw (pskernel.north) — (pskernel.south);
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}
`La linea che ho fatto è solo di esempio e non serve a niente. comunque se la metto nel primo ambiente dove ci sono le classi funziona, mentre se la metto nel secondo no.
Lo scopo di questa prova era di fare una freccia che partisse da quella che collega le tre classi sopra ed arrivare accanto alla scritta ps_kernel.Ciao
Marco
-
4 Ottobre 2012 alle 5:38 #79365::
warcomeb” post=78662Ciao Claudio, grazie del tuo aiuto.
seguendo il tuo consiglio, ho continuato a disegnare le connessioni sul secondo ambiente:
`\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\drawclass(10,-5){pskernel}{ps\_kernel}{\vdots}
\draw (pskernel.north) — (pskernel.south);
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}
`La linea che ho fatto è solo di esempio e non serve a niente. comunque se la metto nel primo ambiente dove ci sono le classi funziona, mentre se la metto nel secondo no.
Lo scopo di questa prova era di fare una freccia che partisse da quella che collega le tre classi sopra ed arrivare accanto alla scritta ps_kernel.Ciao
MarcoProva così:
`
\begin{figure*}[tb]
\centering
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\drawclass(10,-5){pskernel}{\classmark[0.3]{pskernelinit} ps\_kernel }{\vdots}
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw (pskernelinit.center) |-($(m2init)-(0,1.25)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}` Ho semplicemente inserito un marker nel titolo (attenzione che tu ne hai ridotto il font con \picsizeett quindi anche il cerchio si è ridotto) e richiamato nell’ambiente delle connessioni.Ciao
Claudio
-
4 Ottobre 2012 alle 11:30 #79366::
Ciao Claudio, scusami se rompo ancora (volendo mi puoi mandare a quel paese e non mi offendo 🙂 ).
Pensavo che forse i classmark per il resto del disegno possono in alcuni casi risultare scomodi… non si potrebbero impostare delle ancore o qualcosa del genere? (ad esempio in ps_kernel il pallino non ci andrebbe, ma ci dovrebbe terminare la freccia)Ciao
Marco
-
4 Ottobre 2012 alle 15:29 #79367::
warcomeb” post=78680Ciao Claudio, scusami se rompo ancora (volendo mi puoi mandare a quel paese e non mi offendo 🙂 ).
Pensavo che forse i classmark per il resto del disegno possono in alcuni casi risultare scomodi… non si potrebbero impostare delle ancore o qualcosa del genere? (ad esempio in ps_kernel il pallino non ci andrebbe, ma ci dovrebbe terminare la freccia)Ciao
MarcoSai che in realtà ci avevo già pensato questa mattina proprio a questo problema? Poi ti ho dato la soluzione “veloce” per mancanza di tempo.
Ci tengo a precisare che i markers definiti con [tt]classmark[/tt] sono esattamente delle ancore a cui si fa riferimento in un secondo momento, quindi tutto ciò prescinde da un eventuale inserimento di frecce. Anche con gli attuali [tt]classmark[/tt] si può definire un segmento con una freccia; questo tipo di markers è stato definito così soltanto per soddisfare l’esigenza di avere dei pallini come mostrava la figura nel primo intervento del filone. Nulla vieta di definirsi un secondo tipo di markers, invisibili. Ecco come credo tu abbia in mente l’esempio:
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=0.05] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
\begin{tikzpicture}[scale=0.8]%\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init}\picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init}\picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init}\picsizett{ps\_init()}}
\setclasswidth{5}
\drawclass(10,-5){pskernel}{\invisiblemark[0]{pskernelinit}ps\_kernel }{\vdots}
\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-| (m3init.center);
\draw[<-,>=latex] (pskernelinit.center) |-($(m2init)-(0,1.25)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}` Nota come il segmento con la freccia in questione sia stato definito:`\draw[<-,>=latex] (pskernelinit.center) |-($(m2init)-(0,1.25)$);` Gli [tt]\invisiblemark[/tt] sono esattamente uguali ai [tt]classmark[/tt] a meno del pallino. Ripeto, comunque, che i markers sono utili in questo caso proprio perché non si conosce a prescindere la posizione del testo a cui si vuole indirizzare la connessione. Se invece ti servivano solo creare delle connessioni a partire dalla forma [tt]classe[/tt] avresti potuto farne a meno.
Ciao
Claudio
-
5 Ottobre 2012 alle 4:48 #79368::
`\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-6){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.3]{m3module} \\
\hline
\end{tabular}
\vdots
}
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}`forse sto impazzendo… ma alcune cose non le capisco. Ho messo la tabella all’interno della classe ps_kernel ma
1) non riesco a trovar nessun modo per distanziarla dalla scritta sopra
2) se ci aggiungo i puntini con \vdots me li sposta tutto a destra (e proprio non ho capito perché
3) Il mark nell’ultima riga della tabella è immenso rispetto a quelli presenti nelle classi sopra, ma non capisco perché dato che le condizioni sono le stesse…Tikz non è proprio semplice come pensavo… 😳 o meglio, i disegni che ho fatto con coordinate assolute mi sono venuti facili e bene al primo colpo, questo invece mi sta facendo dannare!
help me!
Marco
-
5 Ottobre 2012 alle 8:12 #79369::
warcomeb” post=78693`\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-6){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.3]{m3module} \\
\hline
\end{tabular}
\vdots
}
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}`forse sto impazzendo… ma alcune cose non le capisco. Ho messo la tabella all’interno della classe ps_kernel ma
1) non riesco a trovar nessun modo per distanziarla dalla scritta sopra
2) se ci aggiungo i puntini con \vdots me li sposta tutto a destra (e proprio non ho capito perché
3) Il mark nell’ultima riga della tabella è immenso rispetto a quelli presenti nelle classi sopra, ma non capisco perché dato che le condizioni sono le stesse…Tikz non è proprio semplice come pensavo… 😳 o meglio, i disegni che ho fatto con coordinate assolute mi sono venuti facili e bene al primo colpo, questo invece mi sta facendo dannare!
help me!
MarcoSicuramente se pensavi che usare TikZ per disegnare in modo automatico figure come quella di riferimento fosse banale eri fuori strada, ma credo te ne sia reso conto. Ecco perché nel mio ripensandoci ti ri-consigliavo caldamente di sfruttare almeno uno dei due pacchetti per alleggerire il carico di lavoro. Oltretutto ho dato un’occhiata al codice ed è fatto bene, specialmente TikZ-UML, con la definizione delle chiavi che aiuta un sacco. Detto molto onestamente, le mie soluzioni sono tutte dei workaround che, con la definizione di apposite chiavi, sarebbero decisamente migliorabili. Ho già iniziato a studiarle, ma non sono ancora abbastanza sicuro dei miei tentativi. Comunque sia, visto che ormai abbiamo definito un po’ di cose, possiamo andare avanti con questa strada.
Ho ridefinito il comando [tt]\classmark[/tt] in modo tale che sia possibile personalizzare il fattore di scala e, quindi, aumentare o diminuire la dimensione del cerchio. Ovviamente il comando è compatibile con il resto del codice già scritto. Eccone la sintassi:`
\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}
` ora il terzo comando è opzionale con valore di default a 0.05 (in questo c’è compatibilità) per cui se non lo inserisci viene usato il valore di default.L’esempio rivisto (troverai il codice commentato per capire come sistemare la tabella: nulla legato a TikZ, ma semplice codice LaTeX):
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-15cm] (0,0) grid (20,15);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-6){pskernel}{ps\_kernel}{%
\\[2ex] % sposto come voglio il testo
\invisiblemark[0]{addmodule}\picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}\\
\hspace{0.5\classwidth em}\vdots % andando a capo sembra si perda l'allineamento centrale
% per cui sposto di un valore pari a 1/2 della dimensione della classe
}
\end{tikzpicture}\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`I miei fix sono penosi: se fai caso ai warning e li vuoi evitare siamo fritti 😉
Il risultato:
[attachment=484]Immagine_2012-10-05-2.jpg[/attachment]
Ciao
Claudio
Attachments:
You must be logged in to view attached files. -
8 Ottobre 2012 alle 5:01 #79370::
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}\NewDocumentCommand{\anchormark}{o m m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) at (#3){};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) at (#3) {};
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-13cm] (0,0) grid (20,13);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);
% POWERSIM
\nodeat (20,-13.25) {\bigpicsize{Powersim}};
\draw [dashed] (0,-1.5) rectangle (20,-13);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-5.5){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\setclasswidth{3}
\setclassheight{1}\drawclass(4,-7){psconfigure}{ps\_configure}{}
\drawclass(6,-9){psenergy}{ps\_energy\_model}{}
\drawclass(2,-11){psconstant}{\invisiblemark[0]{constantsouth} ps\_constant\_model}{}
% \anchormark[0]{constantsouth}{psconstant.south}
\drawclass(6,-11){pshardware}{ps\_hardware\_model}{}
\drawclass(10,-11){psRTL}{ps\_RTL\_model}{}\draw [->,>=latex] (psconfigure.east) — (pskernel.west|-psconfigure.east);
\setclasswidth{5}
\setclassheight{3}\drawclass(15.5,-10){psmodule}{\invisiblemark[0]{psmoduleclass} ps\_module}{%
{}\\[2ex]
\begin{tabular}{|c|lc|}
\hline
\picsizett{sc\_bit \&} & \picsize{constant} & \classmark[0.2]{modconstant}[0.03] \\
\hline
\picsizett{sc\_bit |} & \picsize{hardware} & \classmark[0.2]{modhardware}[0.03] \\
\hline
\picsizett{sc\_int +} & \picsize{RTL} & \classmark[0.2]{modRTL}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\draw [->,>=latex] (m3module.center) — (m3module.center|-psmoduleclass.center) — (psmoduleclass.center);
\draw [->,>=latex] (modconstant.center) — ($(modconstant.center)+(2.5,0)$) — ($(modconstant.center)+(2.5,-3.5)$) — ($(modconstant.center)+(2.5,-3.5)$)-|(constantsouth.center);
\draw [->,>=latex] (modhardware.center) — ($(modhardware.center)+(2.25,0)$) — ($(modhardware.center)+(2.25,-2.5)$);
\draw [->,>=latex] (modRTL.center) — ($(modRTL.center)+(2,0)$) — ($(modRTL.center)+(2,-1.5)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
Sono andato avanti, ed ovviamente ho incontrato nuovi problemi! 😳
Vi spiego quale è quello attuale: come nella figura postata all’inizio, cerco di collegare il mark dentro alla classe ps_module (constant, RTL, hardware) con la relativa classe.
Vorrei però che si collegasse al south del riquadro. Per questo ho definito il comando \anchormark in modo da potergli passare come cordinata ad esempio psconstant.south (è commentata nel codice) ma questo lo fa dare di matto e la freccia non si sa dove va a finire. cosa sbaglio? non lo posso fare?Ciao e grazie di nuovo
Marco
-
8 Ottobre 2012 alle 6:37 #79371::
warcomeb” post=78784`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}\NewDocumentCommand{\anchormark}{o m m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) at (#3){};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) at (#3) {};
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8]\draw[help lines,yshift=-13cm] (0,0) grid (20,13);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);
% POWERSIM
\nodeat (20,-13.25) {\bigpicsize{Powersim}};
\draw [dashed] (0,-1.5) rectangle (20,-13);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-5.5){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\setclasswidth{3}
\setclassheight{1}\drawclass(4,-7){psconfigure}{ps\_configure}{}
\drawclass(6,-9){psenergy}{ps\_energy\_model}{}
\drawclass(2,-11){psconstant}{\invisiblemark[0]{constantsouth} ps\_constant\_model}{}
% \anchormark[0]{constantsouth}{psconstant.south}
\drawclass(6,-11){pshardware}{ps\_hardware\_model}{}
\drawclass(10,-11){psRTL}{ps\_RTL\_model}{}\draw [->,>=latex] (psconfigure.east) — (pskernel.west|-psconfigure.east);
\setclasswidth{5}
\setclassheight{3}\drawclass(15.5,-10){psmodule}{\invisiblemark[0]{psmoduleclass} ps\_module}{%
{}\\[2ex]
\begin{tabular}{|c|lc|}
\hline
\picsizett{sc\_bit \&} & \picsize{constant} & \classmark[0.2]{modconstant}[0.03] \\
\hline
\picsizett{sc\_bit |} & \picsize{hardware} & \classmark[0.2]{modhardware}[0.03] \\
\hline
\picsizett{sc\_int +} & \picsize{RTL} & \classmark[0.2]{modRTL}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\draw [->,>=latex] (m3module.center) — (m3module.center|-psmoduleclass.center) — (psmoduleclass.center);
\draw [->,>=latex] (modconstant.center) — ($(modconstant.center)+(2.5,0)$) — ($(modconstant.center)+(2.5,-3.5)$) — ($(modconstant.center)+(2.5,-3.5)$)-|(constantsouth.center);
\draw [->,>=latex] (modhardware.center) — ($(modhardware.center)+(2.25,0)$) — ($(modhardware.center)+(2.25,-2.5)$);
\draw [->,>=latex] (modRTL.center) — ($(modRTL.center)+(2,0)$) — ($(modRTL.center)+(2,-1.5)$);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
Sono andato avanti, ed ovviamente ho incontrato nuovi problemi! 😳
Vi spiego quale è quello attuale: come nella figura postata all’inizio, cerco di collegare il mark dentro alla classe ps_module (constant, RTL, hardware) con la relativa classe.
Vorrei però che si collegasse al south del riquadro. Per questo ho definito il comando \anchormark in modo da potergli passare come cordinata ad esempio psconstant.south (è commentata nel codice) ma questo lo fa dare di matto e la freccia non si sa dove va a finire. cosa sbaglio? non lo posso fare?Ciao e grazie di nuovo
MarcoSe devi accedere a specifiche coordinate della forma class, forse ti conviene “ricordare” le coordinate del disegno di base per poterle utilizzare direttamente in fase di definizione delle connessioni. Ho tolto il comando [tt]anchormark[/tt] e il codice diventa:
`
\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8,remember picture]%\draw[help lines,yshift=-13cm] (0,0) grid (20,13);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);
% POWERSIM
\nodeat (20,-13.25) {\bigpicsize{Powersim}};
\draw [dashed] (0,-1.5) rectangle (20,-13);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-5.5){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule}\picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\setclasswidth{3}
\setclassheight{1}\drawclass(4,-7){psconfigure}{ps\_configure}{}
\drawclass(6,-9){psenergy}{ps\_energy\_model}{}
\drawclass(2,-11){psconstant}{ps\_constant\_model}{}
\drawclass(6,-11){pshardware}{ps\_hardware\_model}{}
\drawclass(10,-11){psRTL}{ps\_RTL\_model}{}\draw [->,>=latex] (psconfigure.east) — (pskernel.west|-psconfigure.east);
\setclasswidth{5}
\setclassheight{3}\drawclass(15.5,-10){psmodule}{\invisiblemark[0]{psmoduleclass}ps\_module}{%
{}\\[2ex]
\begin{tabular}{|c|lc|}
\hline
\picsizett{sc\_bit \&} & \picsize{constant} & \classmark[0.2]{modconstant}[0.03] \\
\hline
\picsizett{sc\_bit |} & \picsize{hardware} & \classmark[0.2]{modhardware}[0.03] \\
\hline
\picsizett{sc\_int +} & \picsize{RTL} & \classmark[0.2]{modRTL}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\draw [->,>=latex] (m3module.center) — (m3module.center|-psmoduleclass.center) — (psmoduleclass.center);
\draw [->,>=latex] (modconstant.center) — ($(modconstant.center)+(2.5,0)$) — ($(modconstant.center)+(2.5,-3.7)$) — ($(modconstant.center)+(2.5,-3.7)$)-|(psconstant.south);
\draw [->,>=latex] (modhardware.center) — ($(modhardware.center)+(2.25,0)$) — ($(modhardware.center)+(2.25,-2.7)$) -| (pshardware.south);
\draw [->,>=latex] (modRTL.center) — ($(modRTL.center)+(2,0)$) — ($(modRTL.center)+(2,-1.7)$)-|(psRTL.south);
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}
`Ciao
Claudio
-
10 Ottobre 2012 alle 4:38 #79372::
Vado avanti per piccoli passi:
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{%
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}\tikzset{file/.code n args={2}{%
\draw (0,0) — (0,#2) — (#1,#2);
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8,remember picture]\draw[help lines,yshift=-13cm] (0,0) grid (20,13);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);
% POWERSIM
\nodeat (20,-13.25) {\bigpicsize{Powersim}};
\draw [dashed] (0,-1.5) rectangle (20,-13);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-5.5){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\setclasswidth{3}
\setclassheight{1}\drawclass(4.5,-5.5){psconfigure}{ps\_configure}{}
\drawclass(15.5,-4.5){psresults}{ps\_results}{}
\drawclass(15.5,-6.5){pstrace}{ps\_trace}{}%%%%%%%%%%%%% FILE
\node[file={0.9}{1.5}] at (17,-4.5) {};
%%%%%%%%%%%%%\drawclass(6,-9){psenergy}{ps\_energy\_model}{}
\drawclass(2,-11){psconstant}{ps\_constant\_model}{}
\drawclass(6,-11){pshardware}{ps\_hardware\_model}{}
\drawclass(10,-11){psRTL}{ps\_RTL\_model}{}\draw [->,>=latex] (psconfigure.east) — (pskernel.west|-psconfigure.east);
\draw [<-,>=latex] (psresults.west) — (pskernel.east|-psresults.west);
\draw [<-,>=latex] (pstrace.west) — (pskernel.east|-pstrace.west);\setclasswidth{5}
\setclassheight{3}\drawclass(15.5,-10){psmodule}{\invisiblemark[0]{psmoduleclass} ps\_module}{%
{}\\[2ex]
\begin{tabular}{|c|lc|}
\hline
\picsizett{sc\_bit \&} & \picsize{constant} & \classmark[0.2]{modconstant}[0.03] \\
\hline
\picsizett{sc\_bit |} & \picsize{hardware} & \classmark[0.2]{modhardware}[0.03] \\
\hline
\picsizett{sc\_int +} & \picsize{RTL} & \classmark[0.2]{modRTL}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\draw [->,>=latex] (m3module.center) — (m3module.center|-psmoduleclass.center) — (psmoduleclass.center);
\draw [->,>=latex] (modconstant.center) — ($(modconstant.center)+(2.5,0)$) — ($(modconstant.center)+(2.5,-3.7)$) — ($(modconstant.center)+(2.5,-3.7)$)-|(psconstant.south);
\draw [->,>=latex] (modhardware.center) — ($(modhardware.center)+(2.25,0)$) — ($(modhardware.center)+(2.25,-2.7)$) — ($(modhardware.center)+(2.25,-2.7)$)-|(pshardware.south);
\draw [->,>=latex] (modRTL.center) — ($(modRTL.center)+(2,0)$) — ($(modRTL.center)+(2,-1.7)$) — ($(modRTL.center)+(2,-1.7)$)-|(psRTL.south);;
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
Partendo dal disegno iniziale ho cercato ora di aggiungere i disegnini che rappresentano i file. Ho creato il tikzset file con dentro delle righe di prova, poi l’ho inserito all’interno del disegno dandogli delle coordinate. Purtroppo il simbolino del file viene stampato nella coordinata (0,0)… questo perché all’interno del tikzset ho fatto partire le linee da 0? ma le coordinate inserite all’interno del tikzset non sono relative rispetto a dove dopo viene posizionato il nodo?
Ciao
Marco
-
11 Ottobre 2012 alle 5:16 #79373::
Ho provato un’altra soluzione, ma non mi piace tanto per due motivi:
1) le dimensioni sono “statiche”
2) avendo usato lo scope non posso mettere dei nodi da portare fuori. mi sbaglio?
`\documentclass[a4paper,10pt,twocolumn]{IEEEtran}\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMANDI VARI PER LE IMMAGINI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}\newcommand{\bigpicsize}[1]{\footnotesize{#1}}
\newcommand{\picsize}[1]{\scriptsize{#1}}
\newcommand{\picsizett}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\smallpicsize}[1]{\tiny{#1}}\pgfmathtruncatemacro{\classwidth}{3}
\pgfmathtruncatemacro{\classheight}{2}
\newcommand{\setclasswidth}[1]{\pgfmathtruncatemacro{\classwidth}{#1}}
\newcommand{\setclassheight}[1]{\pgfmathtruncatemacro{\classheight}{#1}}\tikzset{class/.style args={#1 and #2}{%
rectangle,draw,rounded corners,thick,minimum width=#1, minimum height=#2
}
}\tikzset{classinside/.code n args={3}{%
\node at ($(#1.north)+(0,-0.30)$){\picsizett{#2}};
\draw($(#1.north west)+(0,-0.60)$)–($(#1.north east)+(0,-0.60)$);
\node[yshift=-\classheight,text width=\classwidth cm,align=center] at (#1){#3};
}
}% DRAWCLASS
% #1 – Coordinate
% #2 – Label
% #3 – Nome Classe
% #4 – Contenuto
\NewDocumentCommand{\drawclass}{d() m m m}{
\IfNoValueTF{#1}{%true
\node[class=\classwidth cm and \classheight cm,name=#2]{};
}
{%false
\node[class=\classwidth cm and \classheight cm,name=#2]at(#1){};
}
\node[classinside={#2}{#3}{#4}]{};
}\NewDocumentCommand{\classmark}{o m O{0.05}}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[draw,fill=black,circle,scale=#3] (#2) {};
}
}\NewDocumentCommand{\invisiblemark}{o m}{%
\IfNoValueTF{#1}{%true
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=-0.3 cm] \node[scale=0.05] (#2) {};
}
{%false
\tikz[overlay,remember picture,baseline=-0.5ex,xshift=#1 cm] \node[scale=0.05] (#2) {};
}
}% DRAWFILE
% #1 – Coordinate
% #2 – Label
% #3 – Nome File
\NewDocumentCommand{\drawfile}{d() m m}{
\IfNoValueTF{#1}{%true
\begin{scope}[shift={(0,0)}]
\draw (0.25,1) — (-0.75,1) — (-0.75,-1) — (0.75,-1) — (0.75,0.5) — (0.25,1);
\draw (0.25,1)|-(0.75,0.5);
\node at (0,1.2) {\smallpicsize{#3}};
\end{scope}
}{%false
\begin{scope}[shift={(#1)}]
\draw (0.25,1) — (-0.75,1) — (-0.75,-1) — (0.75,-1) — (0.75,0.5) — (0.25,1);
\draw (0.25,1)|-(0.75,0.5);
\node at (0,1.2) {\smallpicsize{#3}};
\end{scope}
}
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}\begin{figure*}[tb]
\centering
% \begin{tikzpicture}[scale=0.8,remember picture,overlay]
\begin{tikzpicture}[scale=0.8,remember picture]\draw[help lines,yshift=-13cm] (0,0) grid (20,13);
% SYSTEMC
\nodeat (18,0.25) {\bigpicsize{SystemC design}};
\draw [dashed] (2,0) rectangle (18,-3);
% POWERSIM
\nodeat (20,-13.25) {\bigpicsize{Powersim}};
\draw [dashed] (0,-1.5) rectangle (20,-13);\drawclass(5,-1.5){m1}{sc\_module}{\vdots \\ \classmark{m1init} \picsizett{ps\_init()}}
\drawclass(10,-1.5){m2}{sc\_module}{\vdots \\ \classmark{m2init} \picsizett{ps\_init()}}
\drawclass(15,-1.5){m3}{sc\_module}{\vdots \\ \classmark{m3init} \picsizett{ps\_init()}}
\setclasswidth{5}
\setclassheight{3}\drawclass(10,-5.5){pskernel}{ps\_kernel}{%
\invisiblemark[0]{addmodule} \picsizett{add\_module\_to\_powersim()} \\[2ex]
\begin{tabular}{|c|l|}
\hline
M1 & \picsizett{ps\_module} for M1 \\
\hline
M2 & \picsizett{ps\_module} for M2 \\
\hline
M3 & \picsizett{ps\_module} for M3 \classmark[0.2]{m3module}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\setclasswidth{3}
\setclassheight{1}\drawclass(4.5,-5.5){psconfigure}{ps\_configure}{}
\drawfile(1,-5.5){fconfigure}{ps\_configure.txt};%FILE\drawclass(15.5,-4.5){psresults}{ps\_results}{}
\drawclass(15.5,-6.5){pstrace}{ps\_trace}{}
\drawfile(19,-4.5){fresults}{ps\_results.txt};%FILE
\drawfile(19,-6.5){ftrace}{ps\_trace.txt};%FILE\drawclass(6,-9){psenergy}{ps\_energy\_model}{}
\drawclass(2,-11){psconstant}{ps\_constant\_model}{}
\drawclass(6,-11){pshardware}{ps\_hardware\_model}{}
\drawclass(10,-11){psRTL}{ps\_RTL\_model}{}\draw [->,>=latex] (psconfigure.east) — (pskernel.west|-psconfigure.east);
\draw [<-,>=latex] (psresults.west) — (pskernel.east|-psresults.west);
\draw [<-,>=latex] (pstrace.west) — (pskernel.east|-pstrace.west);\setclasswidth{5}
\setclassheight{3}\drawclass(15.5,-10){psmodule}{\invisiblemark[0]{psmoduleclass} ps\_module}{%
{}\\[2ex]
\begin{tabular}{|c|lc|}
\hline
\picsizett{sc\_bit \&} & \picsize{constant} & \classmark[0.2]{modconstant}[0.03] \\
\hline
\picsizett{sc\_bit |} & \picsize{hardware} & \classmark[0.2]{modhardware}[0.03] \\
\hline
\picsizett{sc\_int +} & \picsize{RTL} & \classmark[0.2]{modRTL}[0.03] \\
\hline
\end{tabular}
\\[2ex]
\hspace{0.5\classwidth em}\vdots
}\end{tikzpicture}
\begin{tikzpicture}[scale=0.8,remember picture,overlay]
\draw (m1init.center) — ($(m1init)-(0,1.25)$)-|(m2init.center) — ($(m2init)-(0,1.25)$)-|(m3init.center);
\draw [<-,>=latex] (addmodule.center) |-($(m2init)-(0,1.25)$);
\draw [->,>=latex] (m3module.center) — (m3module.center|-psmoduleclass.center) — (psmoduleclass.center);
\draw [->,>=latex] (modconstant.center) — ($(modconstant.center)+(2.5,0)$) — ($(modconstant.center)+(2.5,-3.7)$) — ($(modconstant.center)+(2.5,-3.7)$)-|(psconstant.south);
\draw [->,>=latex] (modhardware.center) — ($(modhardware.center)+(2.25,0)$) — ($(modhardware.center)+(2.25,-2.7)$) — ($(modhardware.center)+(2.25,-2.7)$)-|(pshardware.south);
\draw [->,>=latex] (modRTL.center) — ($(modRTL.center)+(2,0)$) — ($(modRTL.center)+(2,-1.7)$) — ($(modRTL.center)+(2,-1.7)$)-|(psRTL.south);;
\end{tikzpicture}\caption{Scheme of the interaction of Powersim with a SystemC design.}
\label{fig:powersim}
\end{figure*}\end{document}`
come posso migliorarlo? Hai qualche idea Claudio? 😕
Grazie
Marco
-
11 Ottobre 2012 alle 6:18 #79374
-
11 Ottobre 2012 alle 8:50 #79375
-
15 Ottobre 2012 alle 5:44 #79376
-
16 Ottobre 2012 alle 5:29 #79377
-
11 Settembre 2013 alle 13:29 #79378::
Riapro la discussione per un problema che è sorto di recente: In pratica la stessa immagine di cui discutevamo in questo topic la devo mettere in un articolo dove la classe è elsarticle e questa sfora grandemente e soprattutto crea problemi di posizionamento strani all’interno dell’immagine. Ci sono modi per adattare l’immagine a questa nuova classe oppure c’è un modo per generare un pdf di questa immagine in un file a parte e poi inserire quello scalandolo?
Grazie
Marco
Attachments:
You must be logged in to view attached files. -
11 Settembre 2013 alle 15:42 #79379::
Certo; riprendine il codice che avevi preparato, mettilo in un nuovo piccolo documento nel quale specifichi la classe standalone; compila, et voila, ti ritrovi il file pdf con la figura giàsmarginata e che puoi inserire dove ti pare con \includegraphics, e con il fattore di scala che preferisci.Stai solo attento che ridurre una immagine con un fattore di scala più piccolo di 0.8, ti può rendere illeggibili i caratteri più piccoli e le linee più sottili.
-
11 Settembre 2013 alle 16:32 #79380::
Hai diversi metodi in realtà.Il primo è quello che ha illustrato OldClaudio.
Il secondo è di aggiungere [tt]scale=
,transform shape[/tt] nelle opzioni dell’ambiente [tt]tikzpicture[/tt]: con [tt]transform shape[/tt] i nodi vengono scalati correttamente. Il terzo è quello di usare il pacchetto tikzscale.
Il quarto, quello che ultimamente preferisco, è di usare [tt]\resizebox[/tt]:`
\resizebox{\textwidth}{!}{
\begin{tikzpicture}[opzioni]
codice
\end{tikzpicture}
}
` Automaticamente la figura si adatta alla dimensione [tt]\textwidth[/tt] perciò qualsiasi classe usi va bene. Ultimamente mi sono trovato a disegnare circuiti complessi; prima li disegno da soli sulla classe article per comodità e poi li importo nel documento che ha un’altra classe: nessun problema.Ciao
Claudio
-
12 Settembre 2013 alle 5:03 #79381
-
12 Settembre 2013 alle 5:18 #79382
-
12 Settembre 2013 alle 6:36 #79383
-
12 Settembre 2013 alle 6:59 #79384
-
12 Settembre 2013 alle 7:36 #79385::
Be’, in fondo era quelo che ti avevo suggerito inizialmente; funziona alla grande, meglio del resize su un a figura creata direttamente con tikz mediante codice inserito come argomento di \resizebox. la figura pdf viene creata una sola volta, e importata come qualunque altra figura; il codice tikz, anche dentro l’argomento di \resizebox viene ricompilato ogni volta e potrebbe contenere comandi fragili, cos che in effetti ti succede, e i tempi di compilazione si allungano talvolta in modo significativo.
-
-
AutoreRisposte
- Devi essere connesso per rispondere a questo topic.

