%% Package `pst-labo.tex'
%%
%% This program can be redistributed and/or modified under
%% the terms of the LaTeX Project Public License Distributed
%% from CTAN archives in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-labo' is a PSTricks package for 
%%   chemical objects.
%%
%%
%% Authors  :   Denis Girou <Denis.Girou@idris.fr>
%%              Christophe Jorsen <Christophe.Jorssen@free.fr>
%%              Manuel Luque <Mluque5130@aol.com>
%%              Herbert Voss <hvoss@tug.org>
%%
\csname PSTLaboLoaded\endcsname
\let\PSTLaboLoaded\endinput
%
% Require PSTricks, pstcol,pstplot, and multido packages
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTplotLoaded\endinput\else\input pst-plot.tex\fi
\ifx\MultidoLoaded\endinput\else\input multido.tex\fi
\ifx\PSTGradLoaded\endinput\else\input pst-grad.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey.tex\fi
%
\def\fileversion{2.04}
\def\filedate{2015/12/09}
%
\message{`PST-labo8' v\fileversion, \filedate\space (ML/CJ/DG/HV)}
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
%
\pst@addfams{pst-labo}
%
\input random
\input {pst-laboObj}
%
\definecolor{Beige}{cmyk}{0,0,0.1,0.04}
\definecolor{GrisClair}{cmyk}{0,0,0,0.2}
\definecolor{GrisTresClair}{cmyk}{0,0,0,0.1}
\definecolor{OrangeTresPale}{cmyk}{0,0.1,0.3,0}
\definecolor{OrangePale}{cmyk}{0,0.2,0.4,0}
\definecolor{BleuClair}{cmyk}{0.2,0,0,0}
\definecolor{LightBlue}{cmyk}{0.22,0.05,0,0.1}
\definecolor{Copper}{cmyk}{0,0.9,0.9,0.2}
\definecolor{Marron}{cmyk}{0,0.3,0.5,.3}
\SpecialCoor

\newdimen{\BulleX}
\newdimen{\BulleY}
\newdimen\GrenailleX
\newdimen\GrenailleY
\newdimen\TournureX
\newdimen\TournureY
\newdimen\RAYONBULLE
\newdimen\ClouX
\newdimen\ClouY
\newdimen{\pst@FilamentWidth}
\newdimen\pst@dimA
\newcount\lab@AngleRotation


\newif\ifPst@burette
\define@key[psset]{pst-labo}{burette}[true]{\@nameuse{Pst@burette#1}}%
\define@key[psset]{pst-labo}{couleurReactifBurette}{\edef\psk@Burette@CouleurReactif{#1}}%
\define@key[psset]{pst-labo}{niveauReactifBurette}{%
  \pst@cnta=#1\relax 
  \ifnum\pst@cnta>25 
    \typeout{Niveau must be 25 and not `\the\pst@cnta'. Value 25 forced.} \pst@cnta=25 
  \fi%
  \def\psk@burette@niveauReactif{#1}%
}%
\define@key[psset]{pst-labo}{reactifBurette}{\def\psk@Reactif@Burette{#1}}%
\define@key[psset]{pst-labo}{reactifBecher}{\def\psk@Reactif@Becher{#1}}%

\newif\ifpst@dosage@PHmetre
\define@key[psset]{pst-labo}{phmetre}[true]{\@nameuse{pst@dosage@PHmetre#1}}%
%
\define@key[psset]{pst-labo}{couleurReactif}{\edef\psk@pipette@couleurReactif{#1}}%
\define@key[psset]{pst-labo}{niveauReactif}{%
  \pst@cntg=#1\relax
  % tubePenche must be between -65 and 65
  \ifnum\pst@cntg>10 
    \typeout{Niveau must be 10 and not `\the\pst@cntg'. Value 10 forced.} \pst@cntg=10
  \fi
  \def\psk@pipette@niveauReactif{#1}%
}%

\define@key[psset]{pst-labo}{CouleurDistillat}{\def\psk@Distillation@CouleurDistillat{#1}}
\define@key[psset]{pst-labo}{AspectMelange}{\def\psk@Distillation@AspectMelange{#1}}

% Parameters of \TubeEssais
% -------------------------
\newif\ifPst@TubeEssais@bouchon
\define@key[psset]{pst-labo}{bouchon}[true]{\@nameuse{Pst@TubeEssais@bouchon#1}}%
%
\newif\ifPst@TubeEssais@tubeDroit
\define@key[psset]{pst-labo}{tubeDroit}[true]{\@nameuse{Pst@TubeEssais@tubeDroit#1}}

\newif\ifPst@TubeEssais@tubeCoude
\define@key[psset]{pst-labo}{tubeCoude}[true]{\@nameuse{Pst@TubeEssais@tubeCoude#1}}

\newif\ifPst@TubeEssais@tubeCoudeU
\define@key[psset]{pst-labo}{tubeCoudeU}[true]{\@nameuse{Pst@TubeEssais@tubeCoudeU#1}}

\newif\ifPst@TubeEssais@tubeCoudeUB
\define@key[psset]{pst-labo}{tubeCoudeUB}[true]{\@nameuse{Pst@TubeEssais@tubeCoudeUB#1}}

\newif\ifPst@TubeEssais@tubeRecourbe
\define@key[psset]{pst-labo}{tubeRecourbe}[true]{\@nameuse{Pst@TubeEssais@tubeRecourbe#1}}

\newif\ifPst@TubeEssais@tubeRecourbe@Court
\define@key[psset]{pst-labo}{tubeRecourbeCourt}[true]{\@nameuse{Pst@TubeEssais@tubeRecourbe@Court#1}}

\newif\ifPst@TubeEssais@DoubleTube
\define@key[psset]{pst-labo}{doubletube}[true]{\@nameuse{Pst@TubeEssais@DoubleTube#1}}

\newif\ifPst@TubeEssais@Refrigerant@Boulles
\define@key[psset]{pst-labo}{refrigerantBoulles}[true]{\@nameuse{Pst@TubeEssais@Refrigerant@Boulles#1}}

\newif\ifPst@TubeEssais@Pince
\define@key[psset]{pst-labo}{pince}[true]{\@nameuse{Pst@TubeEssais@Pince#1}}%

\newif\ifpst@barbotage
\define@key[psset]{pst-labo}{barbotage}[true]{\@nameuse{pst@barbotage#1}}%

\newif\ifpst@recuperationGaz
\define@key[psset]{pst-labo}{recuperationGaz}[true]{\@nameuse{pst@recuperationGaz#1}}%

\newif\ifpst@tubeSeul
\define@key[psset]{pst-labo}{tubeSeul}[true]{\@nameuse{pst@tubeSeul#1}}%

\newif\ifpst@tubeDegagementDroit
\define@key[psset]{pst-labo}{tubeDegagementDroit}[true]{\@nameuse{pst@tubeDegagementDroit#1}}%

\newif\ifpst@becBunsen
\define@key[psset]{pst-labo}{becBunsen}[true]{\@nameuse{pst@becBunsen#1}}%

\define@key[psset]{pst-labo}{Numero}[true]{\@namedef{pst@Numero}{#1}}%

\newif\ifPst@Etiquette
\define@key[psset]{pst-labo}{etiquette}[true]{\@nameuse{Pst@Etiquette#1}}%

\newif\ifPst@Agitateur@Magnetique
\define@key[psset]{pst-labo}{agitateurMagnetique}[true]{\@nameuse{Pst@Agitateur@Magnetique#1}}%

% Straight or oblique tube
\define@key[psset]{pst-labo}{tubePenche}{%
  \pst@cntg=#1\relax
  % tubePenche must be between -65 and 65
  \ifnum\pst@cntg<-65
    \typeout{Angle must be >=-65 and not `\the\pst@cntg'. Value -65 forced.}%
    \pst@cntg=65
  \fi%
  \ifnum\pst@cntg>65 
    \typeout{Angle must be <=65 and not `\the\pst@cntg'. Value 65 forced.}%
    \pst@cntg=65
  \fi%
  \edef\psk@TubeEssais@tubePenche{\the\pst@cntg}}
% Level of liquids
\define@key[psset]{pst-labo}{niveauLiquide1}{\@namedef{psk@TubeEssais@niveauLiquide1}{#1}}
\define@key[psset]{pst-labo}{niveauLiquide2}{\@namedef{psk@TubeEssais@niveauLiquide2}{#1}}
\define@key[psset]{pst-labo}{niveauLiquide3}{\@namedef{psk@TubeEssais@niveauLiquide3}{#1}}
% Aspect of liquids
\define@key[psset]{pst-labo}{aspectLiquide1}{\@namedef{psk@TubeEssais@aspectLiquide1}{#1}}
\define@key[psset]{pst-labo}{aspectLiquide2}{\@namedef{psk@TubeEssais@aspectLiquide2}{#1}}
\define@key[psset]{pst-labo}{aspectLiquide3}{\@namedef{psk@TubeEssais@aspectLiquide3}{#1}}
% Substance
\define@key[psset]{pst-labo}{substance}{\def\@tempa{#1}\let\psk@TubeEssais@Subtance\@tempa}
%Solides
\define@key[psset]{pst-labo}{solide}{\def\@tempa{#1}\let\psk@TubeEssais@Solide\@tempa}
%
%  0->TUBE  1->BALLON   2->BECHER  3->ERLEN  4->FLACON  5->fioleJauge  6->Verre
\def\pst@@TUBE{tube}
\def\pst@@BALLON{ballon}
\def\pst@@BECHER{becher}
\def\pst@@ERLEN{erlen}
\def\pst@@FLACON{flacon}
\def\pst@@fioleJauge{fioleJauge}
\def\pst@@Verre{verre}
%
\define@key[psset]{pst-labo}{glassType}{%
  \def\pst@tempA{#1}
  \edef\psk@glassType{%
    \ifx\pst@@TUBE\pst@tempA 0 \else                     % TUBE
    \ifx\pst@@BALLON\pst@tempA 1 \else                   % BALLON
    \ifx\pst@@BECHER\pst@tempA 2 \else                   % BECHER
    \ifx\pst@@ERLEN\pst@tempA 3  \else                   % ERLEN
    \ifx\pst@@FLACON\pst@tempA 4 \else                   % FLACON
    \ifx\pst@@fioleJauge\pst@tempA 5 \else               % fioleJauge
    \ifx\pst@@Verre\pst@tempA 6 \else 0                  % Verre
      \typeout{pst-labo: unknown glassType -> #1}
      \typeout{          using type "tube" instead.}
    \fi\fi\fi\fi\fi\fi\fi%                               % default is tube
}}
%
% Default values
\newpsstyle{aspectLiquide1}{linestyle=none,fillstyle=solid,fillcolor=cyan}
\newpsstyle{aspectLiquide2}{linestyle=none,fillstyle=solid,fillcolor=yellow}
\newpsstyle{aspectLiquide3}{linestyle=none,fillstyle=solid,fillcolor=magenta}
\newpsstyle{BilleThreeD}{linestyle=none,fillstyle=gradient,gradmidpoint=0,gradend=white,GradientCircle=true}
\newpsstyle{Champagne}{linestyle=none,fillstyle=solid,fillcolor=Beige}
\newpsstyle{Sang}{linestyle=none,fillstyle=solid,fillcolor=red}
\newpsstyle{Cobalt}{linewidth=0.2,fillstyle=solid,fillcolor=blue}
\newpsstyle{Huile}{linestyle=none,fillstyle=solid,fillcolor=yellow}
\newpsstyle{Vinaigre}{linestyle=none,fillstyle=solid,fillcolor=magenta}
\newpsstyle{Diffusion}{linestyle=none,fillstyle=gradient,gradmidpoint=0}
\newpsstyle{DiffusionMelange2}{fillstyle=gradient,gradbegin=white,gradend=red,gradmidpoint=0,linecolor=red}
\newpsstyle{flammeEtGrille}{linestyle=none,fillstyle=gradient,gradmidpoint=0,gradbegin=OrangePale,gradend=yellow}
\newpsstyle{rayuresJaunes}{fillstyle=hlines,linecolor=yellow,hatchcolor=yellow}
\newpsstyle{DiffusionBleue}{fillstyle=gradient,gradmidpoint=0,linestyle=none,gradbegin=green,gradend=cyan}


\psset[pst-labo]{glassType=tube,bouchon=false,tubeDroit=false,tubeCoude=false,tubePenche=0,substance=\relax,%
  niveauLiquide1=50,aspectLiquide1=aspectLiquide1,%
  niveauLiquide2=0,aspectLiquide2=aspectLiquide2,%
  niveauLiquide3=0,aspectLiquide3=aspectLiquide3,barbotage=false,tubeSeul=false,%
  tubeDegagementDroit=false,becBunsen=true,tubeCoudeU=false,tubeCoudeUB=false,%
  tubeRecourbe=false,tubeRecourbeCourt=false,%
  pince=false,refrigerantBoulles=false,%
  doubletube=false,recuperationGaz=false,Numero={},etiquette=false,%
  agitateurMagnetique=true,solide=\relax,%
  couleurReactif=OrangePale,niveauReactif=2,burette=true,%
  couleurReactifBurette=OrangeTresPale,niveauReactifBurette=20,%
  reactifBurette={},reactifBecher={},phmetre=false,%
  CouleurDistillat=yellow,AspectMelange=DiffusionBleue}
  
%
\def\pstDosage{\pst@object{pst@Dosage}}
\def\pst@Dosage@i{%
  \addbefore@par{dimen=middle}%
  \begin@SpecialObj
  \ifPst@burette
    \ifpst@dosage@PHmetre\pspicture(-5,0)(3,16)\else\pspicture(-2,0)(2,16)\fi
  \else
    \ifpst@dosage@PHmetre\pspicture(-5,0)(3,5)\else\pspicture(-2,0)(2,5)\fi% without any additional object
  \fi
  \rput(0,3.5){\pstBallon}%
  \ifPst@burette\rput(0,4.5){%
    \psclip{\pscustom[linestyle=none]{\pst@burette@corps}}
      \psframe*[linecolor=\psk@Burette@CouleurReactif](-1,-1)(! 1 \the\pst@cnta\space 0.32 mul 2.68 add)
    \endpsclip}
  \fi%
  \psset{linewidth=0.053}%
  \ifPst@burette\rput(0,4.5){\pst@burette@corps\pst@burette@robinet\pst@burette@graduation}\fi%
  \ifpst@dosage@PHmetre\rput(-3,0){\pst@dosage@pHmetre}\fi%
  \ifPst@Agitateur@Magnetique
    \rput(0,1.5){\pst@dosage@aimant}%
    \rput(0,0){\pst@dosage@support}\else\psframe(-1.5,0)(1.5,1.5)%
  \fi%
  \ifPst@burette\uput[0](2,11){\psk@Reactif@Burette}\fi%
  \uput[0](2,3.5){\psk@Reactif@Becher}%
  \endpspicture%
  \end@SpecialObj%
}
%
\def\pstpipette{\pst@object{pst@pipette}}
\def\pst@pipette@i{%
  \addbefore@par{dimen=middle}%
  \begin@SpecialObj
  \pspicture(-1,-1)(1,6)%\psgrid[subgriddiv=0,gridcolor=red]%
  \psclip{%
    \pscustom[linestyle=none]{\pst@pipette@corps\pst@goutte}}
    \psframe*[linecolor=\psk@pipette@couleurReactif](-1,-2)(! 1 \the\pst@cntg\space 2 div)%
  \endpsclip%
  \pst@pipette@corps%
  \pst@goutte%
  \endpspicture
  \end@SpecialObj%
}%

% To show liquids in the eprouvette
\def\pst@Eprouvette@Liquide#1#2#3{%
  \pspolygon[style=#2]%
  (! -4 4.5 #1 mul 100 div #3 cos mul)(-4,-1)(5,-1)(! 5 4.5 #1 mul 100 div #3 cos mul)}
% To show liquids in the tube
\def\pst@TubeEssais@Liquide#1#2#3{%
  \pspolygon[style=#2](! -4 3 #1 mul 100 div #3 cos mul)(-4,-1)(5,-1)(! 5 3 #1 mul 100 div #3 cos mul)}

\def\pstEprouvette{\pst@object{pst@Eprouvette}}
\def\pst@Eprouvette@i{{%
  \addbefore@par{dimen=middle}%
  \begin@SpecialObj
  \pspicture(-2,0)(2,6)
  \psclip{\rput{\psk@TubeEssais@tubePenche}{%
      \pscustom[linestyle=none]{\pst@eprouvette@corps}}}
    \multido{\iLiquide=\@ne+\@ne}{\thr@@}{%
      \ifnum\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname>\z@
        \pst@Eprouvette@Liquide%
        {\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname}%
        {\csname psk@TubeEssais@aspectLiquide\iLiquide\endcsname}
        {\psk@TubeEssais@tubePenche}%
      \fi%
    }%
    \psk@TubeEssais@Subtance
  \endpsclip
  \rput{\psk@TubeEssais@tubePenche}{
    \pst@eprouvette@corps\pst@eprouvette@pied{\psset{linewidth=0.02}\pst@eprouvette@graduation}
    \rput(0,5){\pst@eprouvette@rebord}}
  \endpspicture
  \end@SpecialObj%
}}

\def\pstDistillation{\pst@object{pst@Distillation}}
\def\pst@Distillation@i{\@ifnextchar({\pst@Distillation@ii}{\pst@Distillation@ii(-4,-10)(8,7)}}%
\def\pst@Distillation@ii(#1,#2)(#3,#4){%
  \begin@SpecialObj%
  \pspicture(#1,#2)(#3,#4)
    \rput(-3,-7){\pst@DistillationFractionnee}
  \endpspicture%
  \end@SpecialObj%
}
%
\def\pstEntonnoir{\pst@object{pst@Entonnoir}}
\def\pst@Entonnoir@i{{%
  \addbefore@par{dimen=middle}%
  \begin@SpecialObj%
    \pspicture(-2,-2)(2,5)%\psgrid[subgriddiv=0,gridcolor=red]%
    \rput(0,0){\pstTubeEssais} \rput(0,1.5){\pst@Entonnoir@Corps}%
    \endpspicture%
  \end@SpecialObj%
}}
%
%
\def\pstTubeEssais{\pst@object{pst@TubeEssais}}
\def\pst@TubeEssais@i{{%
  \addbefore@par{dimen=middle}
  \begin@SpecialObj
  \ifPst@TubeEssais@tubeCoude\pspicture(-1,0)(6,4)\else
    \ifnum\psk@TubeEssais@tubePenche=0 \pspicture(-1.5,0)(1.5,4)\else
      \ifnum\psk@TubeEssais@tubePenche>0 \pspicture(-3,0)(1,4)\else
        \ifnum\psk@TubeEssais@tubePenche<0 \pspicture(-1,0)(3,4)\else
          \pspicture(-2,0)(2,4)%
  \fi\fi\fi\fi
%  0->TUBE  1->BALLON   2->BECHER  3->ERLEN  4->FLACON  5->fioleJauge  6->Verre
  \psclip{%
    \rput{\psk@TubeEssais@tubePenche}{%
      \pscustom[linestyle=none]{%
        \ifcase\psk@glassType\pst@TubeEssais@Corps\or  %0
        \pst@ballon\or\pst@Becher@Corps\or\pst@Erlen@Corps\or\pst@Flacon@Corps\or
          \pst@FIOLEJAUGE\or\pst@Verre@Corps\fi}}%
    \psframe[linestyle=none](-3,-1)(! 
      5 3 \@nameuse{psk@TubeEssais@niveauLiquide1}\space mul 100 div
      \psk@TubeEssais@tubePenche\space cos mul)%
  }%
    \multido{\iLiquide=\@ne+\@ne}{\thr@@}{%
      \ifnum\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname>\z@%
        \pst@TubeEssais@Liquide%
        {\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname}%
        {\csname psk@TubeEssais@aspectLiquide\iLiquide\endcsname}%
        {\psk@TubeEssais@tubePenche} 
     \fi%
    }%
    \psk@TubeEssais@Subtance%
    \psk@TubeEssais@Solide%
  \endpsclip%
%  \psk@TubeEssais@Solide%
  \rput{\psk@TubeEssais@tubePenche}(0,0){%
    \ifPst@Etiquette\rput(0,2){\psframebox[linestyle=none,%
      fillstyle=solid,fillcolor=GrisTresClair]{\pst@Numero}}\fi%
    \ifcase\psk@glassType\pst@TubeEssais@Corps\or\pst@ballon\or
      \pst@Becher@Corps\pst@RebordBecher\or
      \pst@Erlen@Corps\psellipse[linewidth=0.07](0,3.5)(0.6,0.1)\or
      \pst@Flacon@Corps\psellipse[linewidth=0.07](0,3.5)(0.6,0.1)\or
      \pst@FIOLEJAUGE\or\pst@Verre@Corps\pst@Verre@Pied%
    \fi
    \ifPst@TubeEssais@tubeDroit\rput(0,3.5){\pst@TubeEssais@Droit}\else
      \ifPst@TubeEssais@tubeCoude\rput(0,3.5){\pst@TubeEssais@Coude}\else
        \ifPst@TubeEssais@tubeCoudeU\rput(0,3.5){\pst@TubeEssais@CoudeU}\else
          \ifPst@TubeEssais@bouchon\rput(0,3.5){\pst@TubeEssais@Bouchon}
    \fi\fi\fi\fi
    \ifPst@TubeEssais@Pince\rput(0,3.2){\pst@TubeEssais@Pince}\fi%
  }%
  \endpspicture%
  \end@SpecialObj%
}}
%
\def\pstChauffageTube{\pst@object{pst@ChauffageTube}}
\def\pst@ChauffageTube@i{%
  \begin@SpecialObj%
  \ifpst@tubeSeul\pspicture(-2,-5)(5,4)\else\pspicture(-3,-5)(10,4)\fi%
  \ifpst@barbotage%
    \rput(2.5,2.5){%
      \pstTubeEssais[tubeCoude=true,tubePenche=-60]}%
      \rput(8.2,-3){\pstTubeEssais[niveauLiquide1=50,tubePenche=30,pince=false,%
        niveauLiquide1=70,glassType=tube,tubeCoude=false,%
        aspectLiquide1=Champagne,substance={\pstBullesChampagne[20]}]}%
  \else%
    \ifcase\psk@glassType
      \ifpst@tubeSeul\rput(1.5,2.5){\psset{tubePenche=-60}\pstTubeEssais}\else%
        \ifPst@TubeEssais@tubeCoude\rput(2,2.5){\psset{tubePenche=-60}\pstTubeEssais}\else%
	  \rput(1,2.5){\psset{tubePenche=-60}\pstTubeEssais}%
      \fi\fi%
      \or\rput(2,2.5){\psset{tubePenche=-60}\pstTubeEssais}% ballon
    \else\rput(1,2.5){\psset{tubePenche=-60}\pstTubeEssais}%
    \fi%
  \fi%
  \ifpst@becBunsen\rput(1,-5){\pst@BecBunsen}\fi%
  \endpspicture%
  \end@SpecialObj%
}%
%%%%%%%%%%%%%%%ù fin ChauffageTube %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  0->TUBE  1->BALLON   2->BECHER  3->ERLEN  4->FLACON  5->fioleJauge  6->Verre
\def\pstChauffageBallon{\pst@object{pst@ChauffageBallon}}
%\def\pst@ChauffageBallon@i{\@ifnextchar(\pst@ChauffageBallon@ii{\pst@ChauffageBallon@iii(\@empty)(\@empty)}}%
%\def\pst@ChauffageBallon@ii(#1){\@ifnextchar({\pst@ChauffageBallon@iii(#1)}{\pst@ChauffageBallon@iii(0,0)(#1)}}
%\def\pst@ChauffageBallon@iii(#1)(#2){%
%  \def\pst@tempA{#1}
\def\pst@ChauffageBallon@i{%
  \begin@SpecialObj
%  \ifx\pst@tempA\@empty% no special coors
    \ifpst@becBunsen\pst@cnth=-5 \else\pst@cnth=1 \fi 
    \ifnum\psk@glassType=2 \pspicture(-2,\pst@cnth)(3,5)\else % becher
      \ifnum\psk@glassType=3 \pspicture(-2,\pst@cnth)(4,6)\else % erlen
        \ifpst@barbotage\pspicture(-2,\pst@cnth)(6,7)\else
          \ifPst@TubeEssais@tubeRecourbe@Court\pspicture(-2,0)(9,8)\else
            \ifPst@TubeEssais@DoubleTube\pspicture(-2,0)(9,8)\else
            \pspicture(-2,\pst@cnth)(4,6)
            \fi  
          \fi
        \fi
      \fi
    \fi
 % \else\pspicture(#1)(#2)\fi
  %\psgrid[subgriddiv=0,gridcolor=red]%
  %\psset{aspectLiquide1=Champagne,substance={\pstBullesChampagne[20]}}%
  \ifpst@recuperationGaz%
    \ifPst@TubeEssais@tubeRecourbe%
        \rput(8,-5){\pst@Cristallisoir\pst@ReposeTube%
           \rput(0,0.7){\pst@TubeRenverse\pstbulles}}\else%
    \ifPst@TubeEssais@tubeRecourbe@Court\pst@becBunsenfalse%
        \rput(6,1){\pst@Cristallisoir\pst@ReposeTube%
          \rput(0,0.7){\pst@TubeRenverse\pstbulles}}\else%
    \ifPst@TubeEssais@DoubleTube\pst@becBunsenfalse%
        \rput(6.2,1){\pst@Cristallisoir\pst@ReposeTube%
          \rput(0,0.7){\pst@TubeRenverse\pstbulles}}%
  \fi\fi\fi\fi%
  \rput(1,3){\pstBallon}%
  \ifpst@barbotage%
    \rput(5.3,-3){\pstTubeEssais[niveauLiquide1=50,niveauLiquide1=70,glassType=tube]}%
  \fi %
  \ifpst@becBunsen\rput(1,-5){\psset{dimen=middle,linewidth=0.053}\pst@BecBunsenGrille}\fi%
  \endpspicture%
  \end@SpecialObj%
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  0->TUBE  1->BALLON   2->BECHER  3->ERLEN  4->FLACON  5->fioleJauge  6->Verre
\def\pstBallon{\pst@object{pst@Ballon}}
\def\pst@Ballon@i{%
  \begin@SpecialObj
  \ifPst@TubeEssais@Refrigerant@Boulles\pspicture(-2,0)(2,12)\else\pspicture(-2,0)(2,4)\fi
  \psclip{\rput{\psk@TubeEssais@tubePenche}{%
    \pscustom[linestyle=none]{%
      \ifcase\psk@glassType\pst@ballon\or\pst@ballon\or\pst@Becher@Corps\or\pst@Erlen@Corps\or
        \pst@Flacon@Corps\else\pst@ballon\fi%  ballon is default
    }%
  }%
  \psframe[linestyle=none](-3,-1)(! 
    4 3
    \@nameuse{psk@TubeEssais@niveauLiquide1}\space mul 100 div
    \psk@TubeEssais@tubePenche\space cos mul)}
  \multido{\iLiquide=\@ne+\@ne}{\thr@@}{%
    \ifnum\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname>\z@
      \pst@TubeEssais@Liquide{\csname psk@TubeEssais@niveauLiquide\iLiquide\endcsname}%
         {\csname psk@TubeEssais@aspectLiquide\iLiquide\endcsname}%
         {\psk@TubeEssais@tubePenche}%
    \fi%
  }%
  \psk@TubeEssais@Subtance
  \psk@TubeEssais@Solide%
  \endpsclip%
  \rput{\psk@TubeEssais@tubePenche}{%
    \ifPst@Etiquette\rput(0,1.5){\psframebox[linestyle=none,fillstyle=solid,%
      fillcolor=GrisTresClair]{\pst@Numero}}%
    \fi%
    \ifcase\psk@glassType\pst@ballon\or\pst@ballon\or\pst@Becher@Corps\pst@RebordBecher\or
      \pst@Erlen@Corps\psellipse[linewidth=0.07](0,3.5)(0.6,0.1)\or
      \pst@Flacon@Corps\psellipse[linewidth=0.07](0,3.5)(0.6,0.1)\else\pst@ballon
    \fi
    \ifPst@TubeEssais@tubeDroit\rput(0,3.5){\pst@TubeEssais@Droit}\else
    \ifPst@TubeEssais@tubeCoude\rput(0,3.5){\pst@TubeEssais@Coude}\else
    \ifPst@TubeEssais@tubeCoudeU\rput(0,3.5){\pst@TubeEssais@CoudeU}\else
    \ifPst@TubeEssais@tubeCoudeUB\rput(0,3.5){\pst@TubeEssais@CoudeUB}\else
    \ifPst@TubeEssais@tubeRecourbe\rput(0,3.5){\pst@TubeRecourbe}\else
    \ifPst@TubeEssais@tubeRecourbe@Court\rput(0,3.5){\pst@TubeRecourbe@Court}\else
    \ifPst@TubeEssais@bouchon\rput(0,3.5){\pst@TubeEssais@Bouchon}\else
    \ifPst@TubeEssais@DoubleTube\rput(0,3.5){\pst@TubeEssais@DoubleTube}\else
    \ifPst@TubeEssais@Refrigerant@Boulles
      \pst@Ballon@Reflux\rput(0,3.5){\pst@Refrigerant@Boulles}\pst@ChauffeBallon
    \fi\fi\fi\fi\fi\fi\fi\fi\fi%
  }
  \endpspicture%
  \end@SpecialObj%
}
%
\def\pstBullesChampagne{\@ifnextchar[{\pst@BullesChampagne@i}{\pst@BullesChampagne@i[25]}}%
\def\pst@BullesChampagne@i[#1]{{%
  \multido{\iBulle=1+1}{#1}{%
    \setrandim{\BulleX}{-1pt}{1pt} 
    \setrandim{\BulleY}{0pt}{2pt}
    \pst@dimA=\BulleY
    \ifdim\BulleY<1pt 
      \multiply\pst@dimA by 3
      \else\ifdim\BulleY<2pt 
        \multiply\pst@dimA by 2
        \else\multiply\pst@dimA by 1
      \fi\fi%
    \rput{\psk@TubeEssais@tubePenche}{%
%      \psdot[dotscale=\pointless\pst@dimh,dotstyle=o](! 
      \pscircle(!
        \pointless\BulleX\space \pointless\BulleY\space 
        \csname psk@TubeEssais@niveauLiquide1\endcsname\space mul 100 div){\BulleY}%
    }%
  }
}}
%  
%%%%%%%%% bulles pour tube renversé %%%%%%%%%%%%%
\def\pstbulles{\@ifnextchar[{\pst@bulles@i}{\pst@bulles@i[25]}}%
\def\pst@bulles@i[#1]{{%  
  \multido{\iBulle=1+1}{#1}{%
    \setrandim{\BulleX}{-0.1pt}{0.1pt} \setrandim{\BulleY}{0.15pt}{3pt}
    \pst@dimh=\BulleY 
    \ifdim\BulleY<1pt \multiply\pst@dimh by 3
      \else
    \ifdim\BulleY<2pt \multiply\pst@dimh by 2
      \else \multiply\pst@dimh by 1
    \fi\fi
  \rput{\psk@TubeEssais@tubePenche}{%
    \psdot[dotscale=\pointless\pst@dimh,dotstyle=o](! \pointless\BulleX\space
  \pointless\BulleY\space 1.5 mul)}}
}}
%
%
\def\pstFilaments{\@ifnextchar[{\pst@Filaments@i}{\pst@Filaments@i[5]}}%
\def\pst@Filaments@i[#1]#2{{%
  \multido{\iFilament=1+1}{#1}{%
    \setrandim{\pst@FilamentWidth}{0pt}{0.05pt}
    \rput{\psk@TubeEssais@tubePenche}{%
    \pscustom[linewidth=\pointless\pst@FilamentWidth,linecolor=#2]{%
      \code{/MyRand rand 2 31 exp div def} 
      \pscurve(! MyRand 1 sub MyRand 2 mul 1 sub) 
              (! MyRand 0.2 add MyRand 2 add)(! MyRand MyRand 1 sub)(! MyRand 0.5 add MyRand 4 add)}}}%
}}
%
\def\pst@Clous@{{%
  \psarc[unit=0.5,linewidth=0.1,linecolor=blue](0,0.5){.4}{190}{260}
  \psline[unit=0.5,linecolor=blue](-0.28,0.2)(0.5,1)}}
%
%
\def\pstClouFer{\@ifnextchar[{\pst@ClouFer@i}{\pst@ClouFer@i[60]}}%
\def\pst@ClouFer@i[#1]{{%
  \multido{\iClou=1+1}{#1}{%
    \setrandim{\ClouX}{-1cm}{1cm} \setrandim{\ClouY}{-.2cm}{0.4cm}
    \setrannum{\lab@AngleRotation}{-90}{90}
    \rput{\psk@TubeEssais@tubePenche}{%
      \rput{\the\lab@AngleRotation}(\ClouX,\ClouY){\pst@Clous@}}}%
}}
%
\def\pst@Cuivre{{
  \psbezier[unit=0.5,linewidth=0.1,linecolor=Copper]%
    (.25,0.25)(-0,0)(-0.25,.25)(0.25,0.75)(0,.5)(-0.25,0.75)(0.25,1.25)(0,1)(-0.25,1.25)(0.25,1.75)}}
%
\def\pstTournureCuivre{\@ifnextchar[{\pst@TournureCuivre@i}{\pst@TournureCuivre@i[30]}}%
\def\pst@TournureCuivre@i[#1]{{%
  \multido{\iTournure=1+1}{#1}{%
    \setrandim{\TournureX}{-1cm}{1cm} \setrandim{\TournureY}{-.2cm}{0.3cm}
    \setrannum{\lab@AngleRotation}{-180}{180}
    \rput{\psk@TubeEssais@tubePenche}{%
      \rput{\the\lab@AngleRotation}(\TournureX,\TournureY){\pst@Cuivre}}}%
}}

%%%%%%%%%%%% grenaille de zinc %%%%%%%%%%%%%%%%%%
\def\pst@Zinc{{%
  \pscurve[unit=0.5,fillstyle=solid,fillcolor=GrisClair](0,0)(-0.25,0.25)(0,.5)(0.25,0.75)(0.5,0.5)(0.15,0.4)(0.,0)}}
%
\def\pstGrenailleZinc{\@ifnextchar[{\pst@GrenailleZinc@i}{\pst@GrenailleZinc@i[25]}}%
\def\pst@GrenailleZinc@i[#1]{{%
  \multido{\iGrenaille=1+1}{#1}{%
    \setrandim{\GrenailleX}{-1cm}{1cm} \setrandim{\GrenailleY}{-.2cm}{0.3cm}
    \setrannum{\lab@AngleRotation}{-180}{180}
    \rput{\psk@TubeEssais@tubePenche}{%
      \rput{\the\lab@AngleRotation}(\GrenailleX,\GrenailleY){\pst@Zinc}}}%
}}

%%%%%%%%%%%%%% Vapeurs %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% Bulles3D%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\pstBilles{\@ifnextchar[{\pst@Billes@i}{\pst@Billes@i[50]}}%
\def\pst@Billes@i[#1]{{%
  \multido{\IBULLE=1+1}{#1}{%
    \setrandim{\BulleX}{-1.5\psunit}{1.5\psunit}
    \setrandim{\BulleY}{0\psunit}{3\psunit}
    \pst@dimh=\BulleY
    \setrandim{\RAYONBULLE}{0.01\psunit}{0.1\psunit}
    \ifdim\BulleY>2\psunit \multiply \RAYONBULLE by 3
      \else\ifdim\BulleY < 2\psunit \ifdim\BulleY >1\psunit \multiply \RAYONBULLE by 2\fi
        \else\multiply \RAYONBULLE by 1
    \fi\fi%
    \rput{\psk@TubeEssais@tubePenche}{%
      %\psset{linestyle=none,fillstyle=gradient,gradmidpoint=0,gradend=white,GradientCircle=true}
      \pscircle[style=BilleThreeD](\BulleX,\BulleY){\RAYONBULLE}}}%
}}
%%%%%%%%%%%%%%%%%%% Bulles2D%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\pstBULLES{\@ifnextchar[{\pst@BULLES@i}{\pst@BULLES@i[50]}}%
\def\pst@BULLES@i[#1]#2{{%
  \multido{\IBULLE=1+1}{#1}{%
    \setrandim{\BulleX}{-1.5\psunit}{1.5\psunit}
    \setrandim{\BulleY}{0\psunit}{3\psunit}
    \pst@dimh=\BulleY
    \setrandim{\RAYONBULLE}{0.01\psunit}{0.1\psunit}
    \ifdim\BulleY>2\psunit \multiply \RAYONBULLE by 3
    \else\ifdim\BulleY < 2\psunit \ifdim\BulleY >1\psunit \multiply \RAYONBULLE by 2\fi
      \else\multiply \RAYONBULLE by 1
    \fi\fi
    \rput{\psk@TubeEssais@tubePenche}{%
      \pscircle[fillstyle=solid,linewidth=0.2\pslinewidth,linecolor=#2](\BulleX,\BulleY){\RAYONBULLE}}}%
}}
\iffalse
%%%%%%%%%% solides %%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\pstTournureCuivre{%
  \rput{\psk@TubeEssais@tubePenche}{\psbezier[linewidth=0.1,linecolor=Copper](.25,0.25)(0,0)
    (-0.25,.25)(0.25,0.75)(0,.5)(-0.25,0.75)(0.25,1.25)(0,1)(-0.25,1.25)(0.25,1.75)}}
\def\pstClouFer{%
  \rput{\psk@TubeEssais@tubePenche}{{\psset{linecolor=blue}
  \psarc[linewidth=0.1](0,0.5){.4}{190}{260} \psline(-0.28,0.2)(0.5,1)}}}
\def\pstGrenailleZinc{%
  \rput{\psk@TubeEssais@tubePenche}{\pscurve[fillstyle=solid,fillcolor=GrisClair]%
  (0,0)(-0.25,0.25)(0,.5)(0.25,0.75)(0.5,0.5)(0.15,0.4)(0.,0)}}
\fi

\catcode`\@=\PstAtCode\relax
\endinput
