(*Charakteristiky nábojů.*)
q10=-1;
q20=1;
q30=0;
qmin=-5;
qmax=5;
deltaq=0.5;
x10=-1;
y10=0;
x20=1;
y20=0;
x30=0;
y30=1;
xmin=-4;
xmax=4;
deltax=0.5;
ymin=-4;
ymax=4;
deltay=0.5;
polomer=0.125;

xgrafmin=-5;
xgrafmax=5;
ygrafmin=-5;
ygrafmax=5;
deltayvypis=0.2;

pocetodstinu=10;

barva=Black;
barvanaboj10=Magenta;
barvanaboj20=Darker[Brown,0.5];
barvanaboj30=Black;
barvanabojplus=Red;
barvanabojminus=Blue;
barvaQzaporne=Green;
barvaQkladne=Orange;
barvavektoru=Red;
tloustka=0.003;
velikostpisma=18;
velikostsipky=0.03;
velikostobrazku=700;

potencial[q_,p_,r_] :=Sum[ ((q[[i]])/(Norm[r-p[[i]]])),{i,Length[q]}];
intenzita[q_,p_,r_]:=Sum[ ((q[[i]](r-p[[i]]))/((Norm[r-p[[i]]])^3)),{i,Length[q]}];
ekviplochy=Table[i,{i,-1,1,(1/pocetodstinu)}];
barvygrafu=Join[Table[Lighter[barvaQzaporne,(i/pocetodstinu)],{i,0,pocetodstinu}],Table[Lighter[barvaQkladne,(i/pocetodstinu)],{i,pocetodstinu,0,-1}]];

Manipulate[
naboj11=Disk[{x1,y1},polomer];
naboj12=Circle[{x1,y1},polomer];
naboj21=Disk[{x2,y2},polomer];
naboj22=Circle[{x2,y2},polomer];
naboj31=Disk[{x3,y3},polomer];
naboj32=Circle[{x3,y3},polomer];
If[q1≠0,
If[q1>0,
barvanaboj1=Lighter[barvanabojplus,((qmax-0.5-q1)/qmax)],
barvanaboj1=Lighter[barvanabojminus,((qmax-0.5+q1)/qmax)]],
barvanaboj1=White];
If[q2≠0,
If[q2>0,
barvanaboj2=Lighter[barvanabojplus,((qmax-0.5-q2)/qmax)],
barvanaboj2=Lighter[barvanabojminus,((qmax-0.5+q2)/qmax)]],
barvanaboj2=White];
If[q3≠0,
If[q3>0,
barvanaboj3=Lighter[barvanabojplus,((qmax-0.5-q3)/qmax)],
barvanaboj3=Lighter[barvanabojminus,((qmax-0.5+q3)/qmax)]],
barvanaboj3=White];
Show[
If[zobrazitpotencial,
ContourPlot[Evaluate[potencial[{q1,q2,q3},{{x1,y1},{x2,y2},{x3,y3}},{x,y}]],{x,xgrafmin,xgrafmax},{y,ygrafmin,ygrafmax},
Contours->ekviplochy,
PlotRange->1,
ClippingStyle->Automatic,
ContourShading->barvygrafu,
Frame->False],
Plot[None,{x,xgrafmin,xgrafmax}]],
If[zobrazitvektoryE,
StreamPlot[intenzita[{q1,q2,q3},{{x1,y1},{x2,y2},{x3,y3}},{x,y}],{x,xgrafmin,xgrafmax},{y,ygrafmin,ygrafmax},
StreamStyle->{Directive[Thickness[1.25tloustka],barvavektoru],Arrowheads[{0,velikostsipky}]}],
Plot[None,{x,xgrafmin,xgrafmax}]],
Graphics[{
If[zobrazitnaboje,
{If[q1≠0,
{{barvanaboj1,naboj11},
{barva,Thickness[tloustka],naboj12}},
Text[""]],
If[q2≠0,
{{barvanaboj2,naboj21},
{barva,Thickness[tloustka],naboj22}},
Text[""]],
If[q3≠0,
{{barvanaboj3,naboj31},
{barva,Thickness[tloustka],naboj32}},
Text[""]],
If[zobrazitpopisQ,
{If[q1≠0,
Text[Style["(Subscript[Q, 1])",barvanaboj10,1.2velikostpisma],{x1,y1+deltayvypis},{Center,Bottom}],
Text[""]],
If[q2≠0,
Text[Style["(Subscript[Q, 2])",barvanaboj20,1.2velikostpisma],{x2,y2+deltayvypis},{Center,Bottom}],
Text[""]],
If[q3≠0,
Text[Style["(Subscript[Q, 3])",barvanaboj30,1.2velikostpisma],{x3,y3+deltayvypis},{Center,Bottom}],
Text[""]]},
Text[""]]},
Text[""]]
}],
Axes->False,
AspectRatio->Automatic,
PlotRange->{{xgrafmin,xgrafmax},{ygrafmin,ygrafmax}},
FormatType->StandardForm,
ImageSize->velikostobrazku],
{{q1,q10,Style["(Subscript[Q, 1])",barvanaboj10,velikostpisma]},qmin,qmax,deltaq,Appearance->"Labeled"},
{{x1,x10,Style["(Subscript[x, 1])",barvanaboj10,velikostpisma]},xmin,xmax,deltax,Appearance->"Labeled"},
{{y1,y10,Style["(Subscript[y, 1])",barvanaboj10,velikostpisma]},ymin,ymax,deltay,Appearance->"Labeled"},
Delimiter,
{{q2,q20,Style["(Subscript[Q, 2])",barvanaboj20,velikostpisma]},qmin,qmax,deltaq,Appearance->"Labeled"},
{{x2,x20,Style["(Subscript[x, 2])",barvanaboj20,velikostpisma]},xmin,xmax,deltax,Appearance->"Labeled"},
{{y2,y20,Style["(Subscript[y, 2])",barvanaboj20,velikostpisma]},ymin,ymax,deltay,Appearance->"Labeled"},
Delimiter,
{{q3,q30,Style["(Subscript[Q, 3])",barvanaboj30,velikostpisma]},qmin,qmax,deltaq,Appearance->"Labeled"},
{{x3,x30,Style["(Subscript[x, 3])",barvanaboj30,velikostpisma]},xmin,xmax,deltax,Appearance->"Labeled"},
{{y3,y30,Style["(Subscript[y, 3])",barvanaboj30,velikostpisma]},ymin,ymax,deltay,Appearance->"Labeled"},
Delimiter,
Item[Style["Zobrazit",velikostpisma,barva],Alignment->Left],
{{zobrazitvektoryE,True,Style["- el. intenzitu",barvavektoru,velikostpisma]},{True,False},ControlType->Checkbox},
{{zobrazitpotencial,True,Style["- el. potenciál",barva,velikostpisma]},{True,False},ControlType->Checkbox},
{{zobrazitnaboje,True,Style["- náboje",barva,velikostpisma]},{True,False},ControlType->Checkbox},
{{zobrazitpopisQ,False,Style["- popis nábojů",barva,velikostpisma]},{True,False},ControlType->Checkbox},
ControlPlacement->Left,
FrameLabel->{Style["© Jaroslav Reichl, 2017",12,Black,FontFamily->Times],"",Style["Elektrická intenzita a elektrický potenciál tří bodových nábojů",25,barva,FontFamily->Times],""}]