TestScatter2: Added secondary Y axis

git-svn-id: svn://ultimatepp.org/upp/trunk@2127 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2010-02-22 23:33:12 +00:00
parent f437b722ea
commit 3affbc5e56
5 changed files with 124 additions and 27 deletions

View file

@ -339,6 +339,41 @@ void Tab7::RemoveAllFSeries()
scatter7.RemoveAllFSeries();
}
//******************************************************************************************
class Tab8 : public WithTab8<ParentCtrl> {
public:
typedef Tab8 CLASSNAME;
Tab8();
};
Tab8::Tab8()
{
CtrlLayout(*this);
HSizePos().VSizePos();
scatter8.SetRange(13,50, 20);
scatter8.SetMajorUnits(1,10);
scatter8.SetXYMin(0,-20, 1000);
Vector<XY> s1,s2;
s1<<XY(1,-6)<<XY(2,-4)<<XY(3,2)<<XY(4,8)<<XY(5,8)<<XY(6,15)<<XY(7,20)<<XY(8,25)<<XY(9,14)<<XY(10,10)<<XY(11,3)<<XY(12,-11);;
scatter8.AddSeries(s1,"Temperature",true);
s2<<XY(1,1010)<<XY(2,1012)<<XY(3,1015)<<XY(4,1013)<<XY(5,1017)<<XY(6,1018)<<XY(7,1010)<<XY(8,1007)<<XY(9,1003)<<XY(10,1001)<<XY(11,1000)<<XY(12,1002);
scatter8.AddSeries(s2,"Pressure",true,LtRed);
scatter8.SetDataPrimaryY(1, false);
scatter8.SetDrawY2Reticle();
scatter8.Graduation_FormatX(Scatter::MON);
WString sl="Temperature [";
sl.Cat(176);
sl.Cat("C]");
scatter8.SetLabelY(sl);
scatter8.SetLabelY2("Pressure [mBar]");
scatter8.SetMarkStyle(1,Scatter::RECTANGLE);
scatter8.SetMarkWidth(1,24);
}
//******************************************************************************************
@ -351,6 +386,7 @@ class TestScatter2 : public WithTestScatter2Layout<TopWindow> {
Tab5 tab5;
Tab6 tab6;
Tab7 tab7;
Tab8 tab8;
typedef TestScatter2 CLASSNAME;
@ -363,7 +399,7 @@ public:
#ifdef PLATFORM_WIN32
void SaveEMF();
#endif
void SaveClipboard();
};
#endif

View file

@ -3,27 +3,28 @@ LAYOUT(TestScatter2Layout, 504, 392)
ITEM(Button, b1, SetLabel(t_("Print Preview")).LeftPosZ(12, 80).TopPosZ(12, 24))
ITEM(Button, b2, SetLabel(t_("Export as PNG")).LeftPosZ(100, 88).TopPosZ(12, 24))
ITEM(Button, b3, SetLabel(t_("Export as JPEG")).LeftPosZ(196, 84).TopPosZ(12, 24))
ITEM(Button, b5, SetLabel(t_("Copy to Clipboard")).LeftPosZ(376, 96).TopPosZ(12, 24))
ITEM(Button, b4, SetLabel(t_("Export as EMF")).LeftPosZ(288, 80).TopPosZ(12, 24))
END_LAYOUT
LAYOUT(Tab1, 380, 292)
ITEM(Scatter, scatter1, SetTitle(t_("Basic Test")).SetTitleFont(Arial(14).Bold()).HSizePosZ(16, 12).VSizePosZ(16, 16))
ITEM(Scatter, scatter1, SetTitle(t_("Basic Test")).SetTitleFont(SansSerifZ(14).Bold()).HSizePosZ(16, 12).VSizePosZ(16, 16))
END_LAYOUT
LAYOUT(Tab2, 380, 292)
ITEM(Scatter, scatter2, SetTitle(t_("Functions")).SetTitleFont(Arial(14).Bold()).HSizePosZ(16, 12).VSizePosZ(16, 16))
ITEM(Scatter, scatter2, SetTitle(t_("Functions")).SetTitleFont(SansSerifZ(14).Bold()).HSizePosZ(16, 12).VSizePosZ(16, 16))
END_LAYOUT
LAYOUT(Tab3, 384, 284)
ITEM(Scatter, scatter3, SetGridColor(Color(28, 127, 0)).SetColor(Black).SetPlotAreaColor(Black).SetTitle(t_("Parametric functions demo")).SetTitleFont(Arial(14).Bold()).SetTitleColor(White).SetLabelsColor(White).SetAxisColor(Color(28, 212, 0)).SetAxisWidth(12).HSizePosZ(16, 16).VSizePosZ(16, 16))
ITEM(Scatter, scatter3, SetGridColor(Color(28, 127, 0)).SetColor(Black).SetPlotAreaColor(Black).SetTitle(t_("Parametric functions demo")).SetTitleFont(SansSerifZ(14).Bold()).SetTitleColor(White).SetLabelsColor(White).SetAxisColor(Color(28, 212, 0)).SetAxisWidth(12).HSizePosZ(16, 16).VSizePosZ(16, 16))
END_LAYOUT
LAYOUT(Tab4, 400, 316)
ITEM(Scatter, scatter4, SetLegendWeight(200).H_Border(40).V_Border(35).SetTitle(t_("Temperature Average")).SetTitleFont(Arial(14).Bold()).SetLabelX(t_("Month")).HSizePosZ(16, 16).VSizePosZ(16, 16))
ITEM(Scatter, scatter4, SetLegendWeight(200).H_Border(40).V_Border(35).SetTitle(t_("Temperature Average")).SetTitleFont(SansSerifZ(14).Bold()).SetLabelX(t_("Month")).HSizePosZ(16, 16).VSizePosZ(16, 16))
END_LAYOUT
LAYOUT(Tab5, 400, 288)
ITEM(Scatter, scatter5, H_Border(35).V_Border(35).SetTitle(t_("Dynamic")).SetTitleFont(StdFont(14).Bold()).SetLabelX(t_("time[s]")).HSizePosZ(16, 12).VSizePosZ(12, 32))
ITEM(Scatter, scatter5, H_Border(35).V_Border(35).SetTitle(t_("Dynamic")).SetTitleFont(StdFontZ(14).Bold()).SetLabelX(t_("time[s]")).HSizePosZ(16, 12).VSizePosZ(12, 32))
ITEM(Button, b1, SetLabel(t_("Start")).LeftPosZ(16, 42).BottomPosZ(9, 15))
ITEM(Button, b2, SetLabel(t_("Stop")).LeftPosZ(64, 42).BottomPosZ(9, 15))
ITEM(Button, b3, SetLabel(t_("Reset")).LeftPosZ(112, 42).BottomPosZ(9, 15))
@ -34,11 +35,11 @@ LAYOUT(Tab5, 400, 288)
END_LAYOUT
LAYOUT(Tab6, 400, 276)
ITEM(Scatter, scatter6, SetTitle(t_("Logarithmic Scale")).SetTitleFont(StdFont(14).Bold()).HSizePosZ(12, 12).VSizePosZ(16, 12))
ITEM(Scatter, scatter6, SetTitle(t_("Logarithmic Scale")).SetTitleFont(StdFontZ(14).Bold()).HSizePosZ(12, 12).VSizePosZ(16, 12))
END_LAYOUT
LAYOUT(Tab7, 388, 304)
ITEM(Scatter, scatter7, SetTitle(t_("Operations")).SetTitleFont(Courier(16).Bold()).SetLabelX(t_("[x]")).SetLabelY(t_("[y]")).HSizePosZ(12, 12).VSizePosZ(12, 60))
ITEM(Scatter, scatter7, SetTitle(t_("Operations")).SetTitleFont(MonospaceZ(16).Bold()).SetLabelX(t_("[x]")).SetLabelY(t_("[y]")).HSizePosZ(12, 12).VSizePosZ(12, 60))
ITEM(Button, b1, SetLabel(t_("AddSeries")).LeftPosZ(12, 60).BottomPosZ(32, 20))
ITEM(Button, b2, SetLabel(t_("RemoveLastSeries")).LeftPosZ(76, 104).BottomPosZ(32, 20))
ITEM(Button, b3, SetLabel(t_("RemoveFirstSeries")).LeftPosZ(184, 100).BottomPosZ(32, 20))
@ -49,3 +50,7 @@ LAYOUT(Tab7, 388, 304)
ITEM(Button, b8, SetLabel(t_("RemoveAllFunct")).LeftPosZ(288, 88).BottomPosZ(8, 20))
END_LAYOUT
LAYOUT(Tab8, 400, 316)
ITEM(Scatter, scatter8, SetLegendWeight(200).H_Border(50).V_Border(35).SetTitle(t_("Temperature & Pressure Averages")).SetTitleFont(SansSerifZ(14).Bold()).SetLabelX(t_("Month")).HSizePosZ(16, 16).VSizePosZ(16, 16))
END_LAYOUT

View file

@ -1,18 +1,18 @@
description "Bazaar: ScatterChart control test&demo by Andrei-Catalin";
uses
CtrlLib,
Scatter,
Report,
PdfDraw,
plugin\jpg;
file
TestScatter2.h,
main.cpp,
TestScatter2.lay,
TestScatter2.iml;
mainconfig
"" = "GUI";
description "Bazaar: ScatterChart control test&demo by Andrei-Catalin\377";
uses
CtrlLib,
Scatter,
Report,
PdfDraw,
plugin\jpg;
file
TestScatter2.h,
main.cpp,
TestScatter2.lay,
TestScatter2.iml;
mainconfig
"" = "GUI";

8
bazaar/TestScatter2/init Normal file
View file

@ -0,0 +1,8 @@
#ifndef _TestScatter2_icpp_init_stub
#define _TestScatter2_icpp_init_stub
#include "CtrlLib/init"
#include "Scatter/init"
#include "Report/init"
#include "PdfDraw/init"
#include "plugin\jpg/init"
#endif

View file

@ -26,12 +26,15 @@ TestScatter2::TestScatter2()
tc1.Add(tab7, "Operations");
tc1.Add(tab8, "Secondary Y");
b1 <<= THISBACK(Preview);
b2 <<= THISBACK(SavePNG);
b3 <<= THISBACK(SaveJPG);
#ifdef PLATFORM_WIN32
b4 <<= THISBACK(SaveEMF);
#endif
b5 <<= THISBACK(SaveClipboard);
Sizeable().Icon(MyImages::i1());
}
@ -63,6 +66,9 @@ void TestScatter2::Preview()
case 6:
r.DrawDrawing(300,300,tab7.scatter7.GetDrawing().GetSize().cx,tab7.scatter7.GetDrawing().GetSize().cy, tab7.scatter7.GetDrawing());
break;
case 7:
r.DrawDrawing(300,300,tab8.scatter8.GetDrawing().GetSize().cx,tab8.scatter8.GetDrawing().GetSize().cy, tab8.scatter8.GetDrawing());
break;
}
Perform(r);
@ -78,7 +84,7 @@ void TestScatter2::SavePNG()
case 0:
encoder.SaveFile("scatter1.png",tab1.scatter1.GetImage(3));
break;
case 1:
case 1:
encoder.SaveFile("scatter2.png",tab2.scatter2.GetImage(3));
break;
case 2:
@ -96,6 +102,9 @@ void TestScatter2::SavePNG()
case 6:
encoder.SaveFile("scatter7.png",tab7.scatter7.GetImage(3));
break;
case 7:
encoder.SaveFile("scatter8.png",tab8.scatter8.GetImage(3));
break;
}
}
@ -128,6 +137,9 @@ void TestScatter2::SaveJPG()
case 6:
encoder.SaveFile("scatter7.jpg",tab7.scatter7.GetImage(3));
break;
case 7:
encoder.SaveFile("scatter8.jpg",tab8.scatter8.GetImage(3));
break;
}
}
@ -160,10 +172,46 @@ void TestScatter2::SaveEMF()
case 6:
tab7.scatter7.SaveAsMetafile("scatter7.emf");
break;
case 7:
tab8.scatter8.SaveAsMetafile("scatter8.emf");
break;
}
}
#endif
void TestScatter2::SaveClipboard()
{
int ntab=tc1.Get();
switch (ntab)
{
case 0:
tab1.scatter1.SaveToClipboard();
break;
case 1:
tab2.scatter2.SaveToClipboard();
break;
case 2:
tab3.scatter3.SaveToClipboard();
break;
case 3:
tab4.scatter4.SaveToClipboard();
break;
case 4:
tab5.scatter5.SaveToClipboard();
break;
case 5:
tab6.scatter6.SaveToClipboard();
break;
case 6:
tab7.scatter7.SaveToClipboard();
break;
case 7:
tab8.scatter8.SaveToClipboard();
break;
}
}
GUI_APP_MAIN
{
TestScatter2().Run();