Hallo zusammen, möchte ein interaktives PDF-Formulare erstellen unter anderem habe ich ein paar CheckBoxen und je nachdem welche Box ausgewählt ist, soll eine Graphik angezeigt werden bzw. keine bei nicht Selektion der Boxen.

Ich habe mit insDLJS eine Funktion die den Namen der Box Abfragt, besser wäre es auf checkt zu prüfen. Aber das komm ich noch hin.

Mein Problem ist momentan das Ein- bzw. Ausblenden des tikzpicture. Geht das Überhaupt und wenn ja wie. Am besten wäre es sogar wenn ich den Graphen erst zeichne wenn die entsprechende Box selektiert ist. Würde nämlich die Formel für den Graph vorher mit Werten füttern (Angabe durch den "Benutzer").

Das ist mein mein MiniBeispiel:

Open in Online-Editor
\documentclass[12pt,a4paper]{article} % Use A4 paper with a 12pt font size

\usepackage[left=2.0cm,right=1.0cm,top=1.3cm,bottom=3.0cm,marginparwidth=3.4cm]{geometry} % Adjust page margins
\usepackage[colorlinks=true, pdfborder={0 0 0}, hidelinks]{hyperref}  % this is needed for forms and links within the text
\usepackage{pgfplots} %Required for graph 
\usepackage{eforms}
\usepackage[pdftex]{insdljs}

%_________________________________________________________________________
%the identifier is used create a temporary file which store the packed JavaScript code
\begin{insDLJS}[axxy]{axxy}{Document Level JavaScript}
    function ThrottleType(){        
        console.println('Value id: ' + event.target.name);
        if(event.target.name == "ACD"){                     
                app.alert("AC");    
        }else if (event.target.name == "DCD"){
                app.alert("DC");
        }
    }
\end{insDLJS}

%_________________________________________________________________________

\definecolor{Ocolor}{rgb}{0.95 0.4 0.12}

\newcommand{\XStart}{0,0}
\newcommand{\XStop}{5,0}
\newcommand{\YStart}{0,2}
\newcommand{\YStop}{0,-2}

\newcommand{\drawCoordinateSystem}{
    \draw[step=.5cm, very thin,color=lightgray] (0,-1.5) grid (4.5,1.5);
    \draw [->] (\XStart) -- (\XStop) node[right]{$T$}; 
    \draw [<->](\YStop) -- (\YStart) node[above] {$F$};
}

\newcommand{\drawSIN}{
\begin{tikzpicture}
    \drawCoordinateSystem
    \draw[domain=0:4, ultra thick, Ocolor] plot (\x,{sin(pi*\x r})node[right, above]{$I$};
\end{tikzpicture}}

\newcommand{\drawDC}{
\begin{tikzpicture}
    \drawCoordinateSystem 
    \draw[domain=0:2,  thick, black, ->] (0,1) -- (4.5,1) node[right, above]{$I$} ; 
    \draw[domain=0:2, very thick, Ocolor] (0.,0)
    \foreach \x in {0.0,0.40,...,3.6}
            {(\x,.85) -- (\x+0.20,1.15) -- (\x+0.40,.85)}; 
\end{tikzpicture}
}%end newCommand

\newcommand{\FixedCheckBox}[2][]{\CheckBox[#1,borderwidth=0.5pt, width=0.5cm]{#2}}

%“running in backwards compatibility mode” Compiler Warning
\pgfplotsset{compat=newest,compat/show suggested version=false}

\begin{document}
\begin{Form}
\section{Anwendungen}% 
    \FixedCheckBox[name=ACD, validate={ThrottleType();}] {AC-Drossel}\hspace{2cm}%
    \FixedCheckBox[name=DCD, validate={ThrottleType();}]{DC-Drossel}%

    \begin{center}
        \drawSIN
        %
        \hspace{2cm}
        %
        \drawDC
\end{center}
\end{Form}
\end{document}

gefragt 29 Sep '15, 13:32

loro's gravatar image

loro
3124
Akzeptiert-Rate: 50%

bearbeitet 05 Okt '15, 16:29

cgnieder's gravatar image

cgnieder
22.1k243463

Willkommen auf TeXWelt!

(29 Sep '15, 13:49) saputello

Habe eine Lösung gefunden und auch gleich ein neues Problem - werde dazu aber einen neuen Thread erstellen. Mit dem animate-Paket habe ich es hinbekommen.

Open in Online-Editor
\documentclass[12pt,a4paper]{article} % Use A4 paper with a 12pt font size

\usepackage[left=2.0cm,right=1.0cm,top=1.3cm,bottom=3.0cm,marginparwidth=3.4cm]{geometry} % Adjust page margins
\usepackage[colorlinks=true, pdfborder={0 0 0}, hidelinks]{hyperref}  % this is needed for forms and links within the text
\usepackage{pgfplots} %Required for graph 
\usepackage{eforms}
\usepackage[pdftex]{insdljs}
\usepackage{pifont}%Required for Number in ding
\usepackage{animate}

%_________________________________________________________________________
%the identifier is used create a temporary file which store the packed JavaScript code
\begin{insDLJS}[axxy]{axxy}{Document Level JavaScript}
    function ThrottleType(){        
console.show();
        console.println('-------------');
        console.println('Value id: ' + event.target.name);

        if(this.getField("ACD").Value != 1){
            console.println('Checked');
            %app.alert("An");
        }else
        {
            console.println("`not checked");
        }

        if(event.target.name == "ACD"){

                this.getField("IN").display = display.hidden;
                document.getElementById("DCD").checked = true;

        }else if (event.target.name == "DCD"){
                %app.alert("DCD");
        }else if (event.target.name == "RED"){
                %app.alert("RED");
        }else if (event.target.name == "PFC"){
                %app.alert("PFC");
        }
    }
\end{insDLJS}

%_________________________________________________________________________

\definecolor{Ocolor}{rgb}{0.95 0.4 0.12}

\newcommand{\XStart}{0,0}
\newcommand{\XStop}{5,0}
\newcommand{\YStart}{0,2}
\newcommand{\YStop}{0,-2}

\newcommand{\drawCoordinateSystem}{
    \draw[step=.5cm, very thin,color=lightgray] (0,-1.5) grid (4.5,1.5);
    \draw [->] (\XStart) -- (\XStop) node[right]{$T$}; 
    \draw [<->](\YStop) -- (\YStart) node[above] {$F$};
}

\newcommand{\drawSIN}{
\begin{tikzpicture}
    \drawCoordinateSystem
    \draw[domain=0:4, ultra thick, Ocolor] plot (\x,{sin(pi*\x r})node[right, above]{$I$};
\end{tikzpicture}}

\newcommand{\drawDC}{
\begin{tikzpicture}
    \drawCoordinateSystem 
    \draw[domain=0:2,  thick, black, ->] (0,1) -- (4.5,1) node[right, above]{$I$} ; 
    \draw[domain=0:2, very thick, Ocolor] (0.,0)
    \foreach \x in {0.0,0.40,...,3.6}
            {(\x,.85) -- (\x+0.20,1.15) -- (\x+0.40,.85)}; 
\end{tikzpicture}
}%end newCommand

\newcommand{\drawEmpty}{
\begin{tikzpicture}
    \drawCoordinateSystem
    \draw[domain=0:4, ultra thick, Ocolor] plot (\x,{sin(pi*\x r})node[right, above]{$x$};
\end{tikzpicture}}

\newcommand{\FixedCheckBox}[2][]{\CheckBox[#1,borderwidth=0.5pt, width=0.5cm, value="on"]{#2}}

%“running in backwards compatibility mode” Compiler Warning
\pgfplotsset{compat=newest,compat/show suggested version=false}

\OpenAction{/S /JavaScript /JS (Start();)}

\begin{document}
\begin{Form}
\section{Anwendungen}% 
    \FixedCheckBox[name=ACD, validate={anim.picfield.frameNum=0;ThrottleType();}] {AC-Drossel}\hspace{2cm}%
    \FixedCheckBox[name=DCD, validate={anim.picfield.frameNum=1;}]{DC-Drossel}%
    \FixedCheckBox[name=hal, validate={anim.picfield.frameNum=2;}, checked=true]{Test}

    \begin{center}
        \begin{animateinline}[nomouse,step,label=picfield]{0}
                \drawEmpty
            \newframe
                \drawSIN
            \newframe
                %\hspace{2cm}
                \drawDC
        \end{animateinline}
\end{center}
\end{Form}
\end{document}
Permanenter link

beantwortet 01 Okt '15, 10:54

loro's gravatar image

loro
3124
Akzeptiert-Rate: 50%

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×17
×4
×3
×1

gestellte Frage: 29 Sep '15, 13:32

Frage wurde gesehen: 8,044 Mal

zuletzt geändert: 05 Okt '15, 16:29