Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Scatter: FEATURE IDEAS (1 already done)
Re: capsulated Scatter Vectors [message #27249 is a reply to message #26641] Wed, 07 July 2010 23:07 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
hi guys, i managed to 'port' or better say integrate all the stuff that has been done to Scatter so far, so here comes a package again. i havent changed anything else besides this.

next step will be to change the public names and make a wrapper class that is API compatible to current Scatter, if that makes sense.

after that i will start to include the ideas described above..

cheers
  • Attachment: Scatter2.rar
    (Size: 363.78KB, Downloaded 293 times)
My current Diagram [message #27250 is a reply to message #27249] Wed, 07 July 2010 23:23 Go to previous messageGo to next message
kohait00 is currently offline  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 Smile

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.

Re: My current Diagram [message #27251 is a reply to message #27250] Wed, 07 July 2010 23:28 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
index.php?t=getfile&id=2630&private=0
  • Attachment: xover.GIF
    (Size: 31.08KB, Downloaded 791 times)
Re: My current Diagram [message #27252 is a reply to message #27251] Wed, 07 July 2010 23:31 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
index.php?t=getfile&id=2631&private=0
  • Attachment: meter.GIF
    (Size: 20.68KB, Downloaded 809 times)
Re: My current Diagram [message #27257 is a reply to message #27252] Thu, 08 July 2010 11:47 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
ah, it also supports zooming in a different way:
SHIFT + right mouse + moving left = zoom out, move right = zoom in Smile
Scatter based on Callbacks [message #30206 is a reply to message #27257] Wed, 15 December 2010 16:19 Go to previous messageGo to next message
kohait00 is currently offline  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(&para4, 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 #30212 is a reply to message #30206] Wed, 15 December 2010 21:56 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Kohait00

I do not understand well how to call the callback function from inside PlotParaFunction() with the fixed arguments and the variable (t).

There is of course other awful options like including a pointer to a function or a simple callback plus a Array of Values. However yours looks much better Smile.


Best regards
Iñaki
Re: Scatter based on Callbacks [message #30215 is a reply to message #30212] Thu, 16 December 2010 06:58 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
the good thing is, that you wont have to deal with the extra parameters at all Smile since they are simply handled/stored by the CallbackAction (inside the Callback) itseld, Scatter wont even see it, it still thinks it has only a Callback1<float> and calls it like that. the Callback itself will complete the call supplying the additional parameters himself..

i'll try to make a quick demo in Scatter..
Re: Scatter based on Callbacks [message #30216 is a reply to message #30215] Thu, 16 December 2010 07:51 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
here comes a version, it includes only the very few changes needed. i didnt pay attention to make PlotFunction and PlotParamFunction

meanwhile i found out that parametrizing static functions is not yet supported for more than one param. but with THISBACK it works.

just take a look at the Test package.

i'll try to provide the extensions for Callback soon.
  • Attachment: Scatter.rar
    (Size: 739.33KB, Downloaded 271 times)
Re: Scatter based on Callbacks [message #30220 is a reply to message #30216] Thu, 16 December 2010 14:41 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Kohait00

I have done some changes to your code so that it is compatible with existing one Smile Smile.

  • Attachment: Scatter.7z
    (Size: 280.51KB, Downloaded 269 times)


Best regards
Iñaki
Re: Scatter based on Callbacks [message #30221 is a reply to message #30220] Thu, 16 December 2010 14:41 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Some screenshots:
index.php?t=getfile&id=2991&private=0
  • Attachment: dib.PNG
    (Size: 87.76KB, Downloaded 680 times)


Best regards
Iñaki
Re: Scatter based on Callbacks [message #30224 is a reply to message #30221] Thu, 16 December 2010 15:55 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
cool

i'm on extending regrouping Callback code blocks, to have them bit more overviewable. i'll post it later, with that, even static parametrized function callbacks are possible.

Re: Scatter based on Callbacks [message #30225 is a reply to message #30224] Thu, 16 December 2010 17:15 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Smile

Best regards
Iñaki
Re: Scatter based on Callbacks [message #30233 is a reply to message #30225] Fri, 17 December 2010 11:30 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
i've posted the callbacks changes
http://www.ultimatepp.org/forum/index.php?t=msg&goto=302 32&#msg_30232

with them, it's possible to use

scatter3.PlotParaFunction(STDBACK2(para1p, 4.0, 0.25),"Circle",Yellow,6,50);

para1p beeing a non thiscall with 2 additional parameters
Re: Scatter based on Callbacks [message #30236 is a reply to message #30233] Fri, 17 December 2010 13:28 Go to previous messageGo to next message
kohait00 is currently offline  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 270 times)
Re: Scatter based on Callbacks [message #30244 is a reply to message #30236] Sun, 19 December 2010 21:10 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
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 #30249 is a reply to message #30244] Mon, 20 December 2010 13:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Kohait00

New code is not compatible with old one. See the callback functions:

double funct1(double x)			{return (x*x);}	//Old
void funct1(double& y, double x)	{y = (x*x);}	//New


Best regards
Iñaki
Re: Scatter based on Callbacks [message #30250 is a reply to message #30249] Mon, 20 December 2010 13:44 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
dont quite get you here..the provided test application is working with both or isnt it? here comes a fresh rar file, maybe i made some mistake in packing.

this one is my current test package, where both old and new api work..

make sure to use the Callback improvement for this ..see in anther thread ..
  • Attachment: bazaar.rar
    (Size: 739.58KB, Downloaded 273 times)
Re: Scatter based on Callbacks [message #30276 is a reply to message #30250] Tue, 21 December 2010 17:19 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Kohait

The code in bazaar.rar is the same reported:

double funct1(double x)			{return (x*x);}	//Old
void funct1(double& y, double x)	{y = (x*x);}	//New

So the problem remains Sad.


Best regards
Iñaki
Re: Scatter based on Callbacks [message #30280 is a reply to message #30276] Tue, 21 December 2010 17:56 Go to previous messageGo to previous message
kohait00 is currently offline  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);	
}
Previous Topic: LEMON - a Library for Efficient Modeling and Optimization in Networks
Next Topic: Dockind: does not work with latest U++ release.
Goto Forum:
  


Current Time: Thu Mar 28 17:25:59 CET 2024

Total time taken to generate the page: 0.01394 seconds