#ifndef _TestScatter2_TestScatter2_h #define _TestScatter2_TestScatter2_h #include using namespace Upp; #define LAYOUTFILE #include #define IMAGECLASS MyImages #define IMAGEFILE #include class Tab1 : public WithTab1 { public: typedef Tab1 CLASSNAME; Tab1(); }; Tab1::Tab1() { CtrlLayout(*this); HSizePos().VSizePos(); Vector s1,s2; s1< { 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); } //******************************************************************************************* //old syntax XY opara1(double t) {return XY(0.5*cos(2*M_PI*t),0.5*sin(2*M_PI*t));} //new syntax void para1(XY& xy, double t) {xy = XY(cos(2*M_PI*t),sin(2*M_PI*t));} void para2(XY& xy, double t) {xy = XY(0.5*cos(6*M_PI*t)+3*t-1, 1.5+0.5*sin(6*M_PI*t));} void para3(XY& xy, double t) {xy = XY(3+(0.5+t)*cos(6*M_PI*t),(0.5+t)*sin(6*M_PI*t));} void para4(XY& xy, double t) {xy = XY(0,-0.25+0.5*t);} void para5(XY& xy, double t) {xy = XY(-0.25+0.5*t,0);} void para1p(XY& xy, double t, double a, double b) {xy = XY(a*cos(2*M_PI*t),b*sin(2*M_PI*t));} void para3p(XY& xy, double t, double a) {xy = XY(a+(0.5+t)*cos(6*M_PI*t),(0.5+t)*sin(6*M_PI*t));} class Tab3 : public WithTab3 { public: typedef Tab3 CLASSNAME; Tab3(); }; Tab3::Tab3() { CtrlLayout(*this); HSizePos().VSizePos(); scatter3.SetRange(7,4); scatter3.SetMajorUnits(0.5,0.5); scatter3.SetXYMin(-2,-2); scatter3.PlotParaFunction(&opara1,"Circle",Cyan,6,50); scatter3.PlotParaFunction(STDBACK(para1),"Circle",Yellow,6,50); scatter3.PlotParaFunction(STDBACK(para2),"Coil",White,6,100); scatter3.PlotParaFunction(STDBACK(para3),"Spiral",::Color(56,170,255),6,150); scatter3.PlotParaFunction(STDBACK1(para3p, 2.5),"Spiral",::Color(56,170,255),6,150); scatter3.PlotParaFunction(STDBACK(para4),"VLine",LtRed,6,2); scatter3.PlotParaFunction(STDBACK(para5),"HLine",LtRed,6,2); scatter3.PlotParaFunction(STDBACK2(para1p, 4.0, 0.25),"Circle2",Yellow,6,50); scatter3.PlotParaFunction(STDBACK2(para1p, 2.0, 0.5),"Circle2",Yellow,6,50); scatter3.SetAntialiasing(); } //****************************************************************************************** class Tab4 : public WithTab4 { public: typedef Tab4 CLASSNAME; Tab4(); }; Tab4::Tab4() { CtrlLayout(*this); HSizePos().VSizePos(); scatter4.SetRange(13,50); scatter4.SetMajorUnits(1,10); scatter4.SetXYMin(0,-20); scatter4.SetMouseHandling(true).ShowContextMenu(); Vector s1,s2; s1< { public: typedef Tab5 CLASSNAME; Tab5(); void Animate(); void Start(); void Stop(); void Reset(); void PgDown(); void PgUp(); void Plus(); void Minus(); double t; }; Tab5::Tab5() { CtrlLayout(*this); HSizePos().VSizePos(); scatter5.SetRange(10,100); Vector s1, s2; scatter5.AddSeries(s1,"U-t").Stroke().Mark(0); scatter5.AddSeries(s2,"I-t").Stroke().Mark(0); b1<<=(THISBACK(Start)); b2<<=(THISBACK(Stop)); b3<<=(THISBACK(Reset)); b4<<=(THISBACK(PgDown)); b5<<=(THISBACK(PgUp)); b6<<=(THISBACK(Plus)); b7<<=(THISBACK(Minus)); t=0.0; b2.Disable(); } void Tab5::Animate() { scatter5.AddPoint(0,XY(t,50+20*sin(t)),false); scatter5.AddPoint(1,XY(t,50+30*cos(t))); t+=0.1; if((t-scatter5.GetXMin()) >= scatter5.GetXRange()) scatter5.SetXYMin(scatter5.GetXMin()+2,0); } void Tab5::Start() { SetTimeCallback(-100, THISBACK(Animate)); b1.Disable(); b2.Enable(); } void Tab5::Stop() { KillTimeCallback(); b1.Enable(); b2.Disable(); } void Tab5::Reset() { t=0; Vector s1, s2; scatter5.SetData(0,s1); scatter5.SetData(1,s2); scatter5.SetXYMin(0,0); } void Tab5::PgDown() { scatter5.SetXYMin(scatter5.GetXMin()-5,0); scatter5.Refresh(); } void Tab5::PgUp() { scatter5.SetXYMin(scatter5.GetXMin()+5,0); scatter5.Refresh(); } void Tab5::Plus() { scatter5.SetRange(scatter5.GetXRange()/2,100); scatter5.Refresh(); } void Tab5::Minus() { scatter5.SetRange(scatter5.GetXRange()*2,100); scatter5.Refresh(); } //******************************************************************************************* class Tab6 : public WithTab6 { public: typedef Tab6 CLASSNAME; Tab6(); void FormatX(String& s, int i, double d); }; Tab6::Tab6() { CtrlLayout(*this); HSizePos().VSizePos(); scatter6.SetRange(6,100); scatter6.SetMajorUnits(1,20); scatter6.ShowInfo(); Vector s1; s1< { public: static void f1(double& y, double x); typedef Tab7 CLASSNAME; Tab7(); void AddSeries(); void RemoveLastSeries(); void RemoveFirstSeries(); void RemoveAllSeries(); void AddFunct(); void RemoveFirstFunct(); void RemoveLastFunct(); void RemoveAllFSeries(); }; Tab7::Tab7() { CtrlLayout(*this); HSizePos().VSizePos(); b1<<=THISBACK(AddSeries); b2<<=THISBACK(RemoveLastSeries); b3<<=THISBACK(RemoveFirstSeries); b4<<=THISBACK(RemoveAllSeries); b5<<=THISBACK(AddFunct); b6<<=THISBACK(RemoveLastFunct); b7<<=THISBACK(RemoveFirstFunct); b8<<=THISBACK(RemoveAllFSeries); } void Tab7::AddSeries() { Vector s; ConvertInt ci; int topIndex=(scatter7.GetPData().IsEmpty() ? 0 : (int)ci.Scan(scatter7.GetPLegend().Top().Mid(6))+1); double f=1+topIndex*1.1; s< { public: typedef Tab8 CLASSNAME; Tab8(); void MyFormat(String& s, int i, double d) { s=Format("%Mon",fround(d)); if (!s.IsEmpty()) s << "\n2011"; } void MyFormatDelta(String& s, int i, double d) { s = FormatDouble(d, 1) + " " + t_("months"); } }; Tab8::Tab8() { CtrlLayout(*this); HSizePos().VSizePos(); scatter8.SetRange(13,50,20); scatter8.SetMajorUnits(1,10); scatter8.SetXYMin(0,-20, 1000); scatter8.SetMouseHandling(true, true); Vector s1,s2, s3; s1< { public: typedef Tab9 CLASSNAME; Tab9(); void OnFastView(); void OnSequentialX(); }; void Tab9::OnFastView() { scatter9.SetFastViewX(fastView); } void Tab9::OnSequentialX() { scatter9.SetSequentialXAll(sequentialX); } Tab9::Tab9() { CtrlLayout(*this); HSizePos().VSizePos(); scatter9.SetRange(100000,40).SetXYMin(0, -20); scatter9.SetMouseHandling(true).SetMaxZoom(500000).SetMinZoom(2); Vector s1,s2; for (int t = 0; t < 100000; ++t) { s1< { Tab1 tab1; Tab2 tab2; Tab3 tab3; Tab4 tab4; Tab5 tab5; Tab6 tab6; Tab7 tab7; Tab8 tab8; Tab9 tab9; typedef TestScatter2 CLASSNAME; public: TestScatter2(); void Preview(); void SavePNG(); void SaveJPG(); #ifdef PLATFORM_WIN32 void SaveEMF(); #endif void SaveClipboard(); }; #endif