Home » Developing U++ » UppHub » Scatter: FEATURE IDEAS (1 already done)
|
My current Diagram [message #27250 is a reply to message #27249] |
Wed, 07 July 2010 23:23 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
to show what i mean, here is my current diagram, code is bit patchwork, because i was not too experienced both in coding and Upp , so this is beginners level
use DiagramTest
CMeter: a metering / progressbar / value bar setter with mouse, adjustable alignment and appearance (to some way)
CDiagram: base diagram class, supports movable points, zooming (STRG + left mouse), right mouse menu, moving (SHIFT + left mouse), autoscrolling of grid, auto scaling of grid (a bit different to Scatter) and maybe some more stuff. the code is not very cute though. thats why i prefer to switch / port to Scatter, i like the API much better.
FilterDiagramBase: some special diagrams for parametrising equalizers, crossovers, limiters etc.. this is what CDiagram also can be used for, to have a visual representation *and* parametrising in 1 diagram, play around, inspect the code.
the most usable of them is probably CMeter.
|
|
|
|
|
|
Scatter based on Callbacks [message #30206 is a reply to message #27257] |
Wed, 15 December 2010 16:19 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
hey all,
just came up with the idea of further parametrizing plot function, but this leads to usage of callbacks, instead of function pointers. what about that?
current case:
XY para4(double t) {return XY(0,-0.25+0.5*t);}
scatter3.PlotParaFunction(para4,"VLine",LtRed,6,2);
this lets you calculate x and y separated, but what if one wants to specify some parameters, constants etc..?
here Callbacks can be a great deal.
example for a THISBACK, but also thinkable with general static fcuntions with arbitrary signature. as long as Callback1<float> for t is yielded, it alright.
the additional parameters would be stored in CallbackAction anyway.
XY para4(double t, int a, float b) {return XY(a,-0.25*b+0.5*t);}
scatter3.PlotParaFunction(THISBACK2(¶4, 12, 34.2) ),"VLine",LtRed,6,2);
i think Callbacks are much more powerfull here than simple function pointers, though the latter are faster, a neglactible bit..
|
|
|
|
|
|
|
|
|
|
|
Re: Scatter based on Callbacks [message #30236 is a reply to message #30233] |
Fri, 17 December 2010 13:28 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
i'd do this instead for the old api, not to have to hassle with it in the code, simply map old api to new api like that..
inline static void PlotFuncCB(double& y, double x, double (*f)(double)) { y = f(x); }
void PlotFunction(double (*f)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6)
{
PlotFunction(callback1(&PlotFuncCB, f), legend, fcolor, weight);
}
inline static void PlotParamFuncCB(XY& xy, double t, XY (*pf)(double)) { xy = pf(t); }
void PlotParaFunction(XY (*pf)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6,const int& Np=100)
{
PlotParaFunction(callback1(&PlotParamFuncCB, pf), legend, fcolor, weight, Np);
}
-
Attachment: Scatter.rar
(Size: 739.43KB, Downloaded 277 times)
|
|
|
Re: Scatter based on Callbacks [message #30244 is a reply to message #30236] |
Sun, 19 December 2010 21:10 |
|
koldo
Messages: 3368 Registered: August 2008
|
Senior Veteran |
|
|
kohait00 wrote on Fri, 17 December 2010 13:28 | i'd do this instead for the old api, not to have to hassle with it in the code, simply map old api to new api like that..
inline static void PlotFuncCB(double& y, double x, double (*f)(double)) { y = f(x); }
void PlotFunction(double (*f)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6)
{
PlotFunction(callback1(&PlotFuncCB, f), legend, fcolor, weight);
}
inline static void PlotParamFuncCB(XY& xy, double t, XY (*pf)(double)) { xy = pf(t); }
void PlotParaFunction(XY (*pf)(double),const String& legend="", const class::Color& fcolor=Green,const int& weight=6,const int& Np=100)
{
PlotParaFunction(callback1(&PlotParamFuncCB, pf), legend, fcolor, weight, Np);
}
|
Hello Kohait00
I agree. It looks better.
Best regards
Iñaki
|
|
|
|
|
|
Re: Scatter based on Callbacks [message #30280 is a reply to message #30276] |
Tue, 21 December 2010 17:56 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
are you sure you have opened the right archive?
this is inside the above bazaar.rar
//old syntax
double ofunct1(double x){return (0.5*x*x-5);}
double ofunct2(double x){return (-0.5*x*x-5);}
double ofunct3(double x){return 3;}
//new additional syntax
void funct1(double& y, double x){y = (x*x);}
void funct2(double& y, double x){y = (-x*x);}
void funct3(double& y, double x){y = 0;}
void funct1p(double& y, double x, double a, double c){y = a*(x*x)+c;}
void funct3p(double& y, double x, double m){y = m*x;}
class Tab2 : public WithTab2<ParentCtrl> {
public:
typedef Tab2 CLASSNAME;
Tab2();
};
Tab2::Tab2()
{
CtrlLayout(*this);
HSizePos().VSizePos();
scatter2.SetRange(12,60);
scatter2.SetXYMin(-6,-30);
scatter2.SetMajorUnits(2,10);
scatter2.PlotFunction(&ofunct3,"X Axis",Cyan,18);
scatter2.PlotFunction(&ofunct1,"x^2", Color(28,85,255),6);
scatter2.PlotFunction(&ofunct2,"-X^2",Cyan);
scatter2.PlotFunction(STDBACK(funct3),"X Axis",Green,18);
scatter2.PlotFunction(STDBACK(funct1),"x^2", Color(28,85,255),6);
scatter2.PlotFunction(STDBACK(funct2),"-X^2",LtRed);
scatter2.PlotFunction(STDBACK1(funct3p, 3.0),"X Axis",Green,18);
for(int i = 0; i < 5; i++)
scatter2.PlotFunction(STDBACK2(funct1p, 2.0*double(i)/10.0, -10.0+double(i)),"a*x^2+c", Color(28,85,255),6);
}
|
|
|
Goto Forum:
Current Time: Thu May 30 14:24:41 CEST 2024
Total time taken to generate the page: 0.02422 seconds
|