mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-19 06:06:54 -06:00
Scatter: Included new callback functions
git-svn-id: svn://ultimatepp.org/upp/trunk@2912 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9bd0fe112b
commit
d2085bb3bb
2 changed files with 49 additions and 2 deletions
|
|
@ -767,13 +767,13 @@ void Scatter::RemoveAllSeries()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void Scatter::PlotFunction(double (*f)(double), const String& legend, const class::Color& fcolor, const int& weight)
|
||||
{
|
||||
Vector<XY> series;
|
||||
vFunctionData.AddPick(series);
|
||||
|
||||
vAdress.Add(f);
|
||||
vAdressPF.Add(PlotFunc());
|
||||
|
||||
vFColors.Add(fcolor);
|
||||
vFThickness.Add(weight);
|
||||
|
|
@ -782,6 +782,23 @@ void Scatter::PlotFunction(double (*f)(double), const String& legend, const clas
|
|||
vFPattern.Add(LINE_SOLID);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Scatter::PlotFunction(PlotFunc f, const String& legend, const class::Color& fcolor, const int& weight)
|
||||
{
|
||||
Vector<XY> series;
|
||||
vFunctionData.AddPick(series);
|
||||
|
||||
vAdressPF.Add(f);
|
||||
vAdress.Add(fAdress());
|
||||
|
||||
vFColors.Add(fcolor);
|
||||
vFThickness.Add(weight);
|
||||
vFLegend.Add(legend);
|
||||
vFPrimaryY.Add(true);
|
||||
vFPattern.Add(LINE_SOLID);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Scatter::PlotParaFunction(XY (*pf)(double), const String& legend, const class::Color& fcolor, const int& weight,const int& Np)
|
||||
{
|
||||
double t;//t must be choosed between [0,1]
|
||||
|
|
@ -800,6 +817,24 @@ void Scatter::PlotParaFunction(XY (*pf)(double), const String& legend, const cla
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void Scatter::PlotParaFunction(PlotParamFunc pf, const String& legend, const class::Color& fcolor, const int& weight,const int& Np)
|
||||
{
|
||||
double t;//t must be choosed between [0,1]
|
||||
Vector<XY> series;
|
||||
for (int i=0; i<=Np;i++)
|
||||
{
|
||||
t=(double)i/Np;
|
||||
pf(series.Add(), t);
|
||||
}
|
||||
vFColors.Add(fcolor);
|
||||
vFThickness.Add(weight);
|
||||
vFunctionData.AddPick(series);
|
||||
vFPrimaryY.Add(true);
|
||||
vFPattern.Add(LINE_SOLID);
|
||||
vFLegend.Add(legend);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
Scatter &Scatter::SetFunctPattern(const String pattern)
|
||||
{
|
||||
vFPattern[vFPattern.GetCount()-1] = pattern;
|
||||
|
|
@ -1490,7 +1525,13 @@ void Scatter::Plot(Draw& w, const int& scale,const int& l,const int& h)const
|
|||
{
|
||||
double x=xMin+i*(xRange/l);
|
||||
if (vFPrimaryY[j])
|
||||
iy=fround(h*(vAdress[nf](x)-yMin)/yRange);
|
||||
if (vAdressPF[nf] == PlotFunc())
|
||||
iy=fround(h*(vAdress[nf](x)-yMin)/yRange);
|
||||
else {
|
||||
double y;
|
||||
vAdressPF[nf](y, x);
|
||||
iy = fround(h*(y-yMin)/yRange);
|
||||
}
|
||||
else
|
||||
iy=fround(h*(vAdress[nf](x)-yMin2)/yRange2);
|
||||
p1<<Point(i,h-iy);
|
||||
|
|
|
|||
|
|
@ -188,7 +188,12 @@ public:
|
|||
|
||||
const Vector<String> & GetPLegend() const {return vLegend;}
|
||||
const Vector<String> & GetFLegend() const {return vFLegend;}
|
||||
|
||||
typedef Callback2<double&, double> PlotFunc; //y = f(x)
|
||||
typedef Callback2<XY&, double> PlotParamFunc;// (x,y) = f(t)
|
||||
|
||||
void PlotFunction(PlotFunc, const String& legend="", const class::Color& fcolor=Green,const int& weight=6);
|
||||
void PlotParaFunction(PlotParamFunc, const String& legend="", const class::Color& fcolor=Green,const int& weight=6,const int& Np=100);
|
||||
void PlotFunction(double (*f)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6);
|
||||
void PlotParaFunction(XY (*pf)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6,const int& Np=100);
|
||||
|
||||
|
|
@ -273,6 +278,7 @@ private:
|
|||
Vector<String> vFPattern, vPPattern;
|
||||
typedef double (*fAdress)(double);
|
||||
Vector<fAdress> vAdress;
|
||||
Vector<PlotFunc> vAdressPF;
|
||||
Vector<class::Color> vPColors,vFColors;
|
||||
Vector<int> vFThickness,vPThickness;
|
||||
Vector<int> vPWidth;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue