diff --git a/uppsrc/ScatterCtrl/Chart.iml b/uppsrc/ScatterCtrl/Chart.iml new file mode 100644 index 000000000..d2af877d3 --- /dev/null +++ b/uppsrc/ScatterCtrl/Chart.iml @@ -0,0 +1,79 @@ +PREMULTIPLIED +IMAGE_ID(cursor1) +IMAGE_ID(ZoomMinus) +IMAGE_ID(ZoomPlus) +IMAGE_ID(ShapeHandles) +IMAGE_ID(Copy) +IMAGE_ID(RightArrow) +IMAGE_ID(LeftArrow) +IMAGE_ID(Save) +IMAGE_ID(DownArrow) +IMAGE_ID(UpArrow) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,152,105,80,84,87,22,199,65,203,15,58,85,153,153,170,169,154,76,149,21,199,169,73,149,83,154,137,32,90) +IMAGE_DATA(137,226,135,153,170,201,135,36,53,101,88,148,48,33,70,54,25,150,132,61,2,134,96,16,4,23,68,16,162,128,128,128) +IMAGE_DATA(236,8,130,128,2,162,194,19,69,209,184,97,177,67,55,251,46,107,3,13,252,231,220,215,116,79,55,208,208,77,71,101) +IMAGE_DATA(38,156,230,95,77,223,62,191,115,206,189,239,222,251,238,107,173,183,181,222,214,250,21,189,126,105,6,254,111,37,254,74) +IMAGE_DATA(252,149,248,75,97,127,78,189,238,250,87,226,175,196,95,137,255,102,227,47,75,251,13,189,230,177,245,164,50,45,201,128) +IMAGE_DATA(72,85,54,211,190,152,25,51,255,176,176,176,66,249,198,153,207,44,142,209,2,236,250,249,216,121,98,40,171,163,76,25) +IMAGE_DATA(59,43,70,153,146,175,37,19,192,40,21,74,37,239,167,140,215,242,129,114,169,192,27,83,30,101,90,152,87,181,255,119) +IMAGE_DATA(148,124,173,233,248,51,51,154,47,134,148,61,190,113,35,78,235,232,64,123,225,24,243,205,63,86,243,122,31,250,159,241) +IMAGE_DATA(42,196,152,215,180,255,79,99,56,111,222,44,84,151,151,198,176,212,210,18,218,188,245,150,112,121,111,6,252,226,243,145) +IMAGE_DATA(45,2,181,55,131,89,188,92,12,213,55,3,198,191,169,205,64,62,255,82,54,3,229,253,87,109,51,80,127,252,121,74) +IMAGE_DATA(107,101,51,120,237,49,94,229,102,176,100,243,240,240,16,6,4,4,192,201,201,233,197,98,190,123,246,236,185,105,109,109) +IMAGE_DATA(13,3,3,3,153,111,96,96,32,158,61,123,134,163,71,143,226,100,78,27,142,103,183,34,144,228,159,73,186,220,10,191) +IMAGE_DATA(244,102,248,166,53,195,39,165,25,230,230,230,224,56,14,38,38,38,178,201,110,103,103,247,208,215,215,23,199,78,133,227) +IMAGE_DATA(18,215,141,132,146,110,196,147,226,110,117,33,246,102,23,98,138,187,16,93,212,129,168,194,14,216,58,123,195,208,208,16) +IMAGE_DATA(250,250,250,156,124,93,44,223,165,82,41,215,141,139,196,197,50,238,70,39,46,16,23,89,208,129,243,215,218,241,99,94) +IMAGE_DATA(27,220,46,52,204,89,152,172,214,184,219,51,57,165,92,209,127,185,115,196,133,231,182,225,108,78,43,28,35,234,230,240) +IMAGE_DATA(172,143,210,90,25,23,69,92,196,245,14,156,203,39,142,216,179,87,91,17,154,211,130,51,87,90,96,31,94,51,135,63) +IMAGE_DATA(146,218,76,125,236,228,251,200,56,105,173,97,87,89,206,22,132,16,23,156,217,140,211,151,155,97,27,82,61,135,255,62) +IMAGE_DATA(81,160,208,71,105,173,140,59,147,217,194,115,167,50,154,113,34,77,8,235,160,170,57,188,87,156,64,82,107,174,164,214) +IMAGE_DATA(144,108,73,173,167,51,37,220,201,116,33,142,167,10,16,152,34,128,249,201,23,115,248,111,99,26,168,86,73,31,165,181) +IMAGE_DATA(6,177,156,196,157,152,225,142,37,53,193,63,177,17,251,3,43,231,240,46,145,245,138,181,166,179,90,37,92,64,178,0) +IMAGE_DATA(254,196,250,93,106,196,209,248,70,152,249,63,87,224,119,238,220,41,220,189,123,55,62,250,196,80,214,71,86,43,227,142) +IMAGE_DATA(73,185,132,70,248,198,55,96,243,182,191,99,221,186,117,88,179,102,205,11,57,30,249,249,249,216,186,85,7,214,193,85) +IMAGE_DATA(176,164,241,97,125,60,64,117,178,90,205,252,43,241,47,191,231,48,37,173,93,187,22,137,137,137,88,189,122,181,172,134) +IMAGE_DATA(77,155,54,61,220,178,101,203,244,134,13,27,238,206,238,215,108,91,181,106,85,161,182,182,54,99,185,197,124,85,50,249) +IMAGE_DATA(205,224,15,127,222,97,96,243,67,124,145,217,247,41,156,153,119,18,103,118,56,145,51,245,136,231,76,14,93,228,246,185) +IMAGE_DATA(199,112,123,221,162,57,99,151,40,206,208,41,130,51,117,10,46,98,254,242,177,172,124,147,75,28,131,178,57,85,101,228) +IMAGE_DATA(16,90,34,207,127,233,147,194,169,163,127,218,134,42,12,130,153,119,50,167,142,125,122,240,140,34,255,93,34,223,94,124) +IMAGE_DATA(251,54,23,28,157,87,31,148,85,59,233,153,88,7,207,132,26,120,196,85,193,45,250,57,92,46,60,133,115,196,79,112) +IMAGE_DATA(60,255,8,223,132,63,128,253,217,114,184,134,22,14,111,124,255,35,59,54,94,204,110,17,239,159,65,19,146,22,162,170) +IMAGE_DATA(250,58,232,230,148,169,87,60,207,223,46,41,225,188,146,234,160,142,172,79,220,130,201,161,88,9,95,90,202,121,38,212) +IMAGE_DATA(66,29,179,56,118,3,198,174,81,60,95,66,242,136,175,230,219,199,196,147,16,141,139,49,44,18,227,229,200,56,122,135) +IMAGE_DATA(68,232,234,31,69,123,247,8,90,186,134,208,208,62,200,251,125,229,87,0,67,199,243,178,177,101,227,197,108,98,114,18) +IMAGE_DATA(227,20,99,116,66,18,99,96,84,140,190,225,49,116,15,82,156,151,34,116,244,140,242,126,95,30,201,199,95,62,220,251) +IMAGE_DATA(195,30,135,112,238,83,155,16,206,61,182,146,111,23,79,77,97,130,52,78,113,70,88,29,99,98,12,81,156,193,17,49) +IMAGE_DATA(250,135,38,208,51,56,198,251,125,225,157,171,176,168,93,162,158,240,237,147,211,211,188,164,113,198,88,44,177,24,34,170) +IMAGE_DATA(135,175,137,226,49,51,241,204,82,224,191,249,177,130,111,159,146,139,49,49,19,67,42,17,213,52,42,150,240,70,110,233) +IMAGE_DATA(10,188,125,200,61,181,198,255,51,231,20,5,126,251,39,142,41,54,65,165,176,12,40,198,1,191,66,236,247,189,14,211) +IMAGE_DATA(195,217,48,241,186,130,125,30,151,177,215,61,131,114,166,193,208,37,5,159,57,165,128,249,171,177,236,231,183,95,211,235) +IMAGE_DATA(53,152,38,63,198,72,143,137,75,98,125,124,124,150,202,35,190,72,188,24,15,101,98,236,34,188,204,103,33,41,225,85) +IMAGE_DATA(98,149,240,26,229,213,160,191,202,108,169,28,207,106,114,125,151,200,73,217,87,99,203,124,65,46,121,176,53,185,192,108) +IMAGE_DATA(130,168,201,202,56,57,86,153,148,114,11,105,22,171,50,167,164,47,75,205,171,105,127,231,240,11,248,44,100,154,44,68) +IMAGE_DATA(173,69,106,83,149,127,53,38,127,92,254,253,251,6,78,239,232,219,6,111,54,14,175,208,181,200,236,211,179,185,54,177) +IMAGE_DATA(221,182,96,122,135,93,33,118,216,74,244,161,125,17,118,125,125,3,59,29,10,161,103,153,217,175,243,121,216,131,223,254) +IMAGE_DATA(105,23,255,227,216,31,255,230,28,249,164,105,20,79,154,68,116,204,154,134,136,52,58,62,69,199,172,73,58,26,77,160) +IMAGE_DATA(119,80,204,127,22,77,76,161,123,64,140,134,14,209,116,65,69,135,120,159,119,65,207,239,54,253,195,226,61,211,152,170) +IMAGE_DATA(39,141,163,240,73,237,164,163,12,177,228,103,121,242,30,250,134,196,232,34,255,193,209,73,62,238,0,189,11,123,198,81) +IMAGE_DATA(219,62,134,130,199,125,184,241,184,7,250,246,185,99,186,150,89,47,31,19,239,157,220,193,251,48,49,190,115,96,130,142) +IMAGE_DATA(104,98,62,47,203,223,65,181,212,119,140,161,182,77,4,207,120,1,74,43,251,161,103,147,55,205,250,91,81,63,66,124) +IMAGE_DATA(59,239,195,100,125,170,28,157,244,62,52,70,71,45,170,169,127,120,18,141,157,44,183,8,213,173,34,28,138,107,66,74) +IMAGE_DATA(73,59,182,219,228,129,141,85,121,221,48,190,75,106,135,128,234,99,106,238,29,167,220,147,124,238,33,209,20,90,123,39) +IMAGE_DATA(100,108,85,235,40,190,141,109,64,66,113,11,244,14,94,5,27,231,187,213,196,39,182,241,117,91,81,238,131,65,229,176) +IMAGE_DATA(15,121,0,7,210,191,131,239,195,138,218,45,229,228,26,85,131,152,2,1,244,172,115,248,235,115,167,106,16,94,9,205) +IMAGE_DATA(212,47,18,189,123,37,8,225,21,207,36,160,35,191,128,242,53,194,157,158,77,93,163,235,225,28,85,11,215,11,117,136) +IMAGE_DATA(200,173,135,158,213,21,158,47,169,28,148,176,36,9,39,228,99,48,246,208,197,38,190,94,183,232,6,158,115,137,172,33) +IMAGE_DATA(85,35,44,171,6,219,44,51,121,190,248,233,75,98,133,51,18,200,114,243,44,229,117,143,169,231,89,103,226,156,206,87) +IMAGE_DATA(209,99,199,11,4,165,85,98,155,69,6,241,5,40,124,220,15,207,56,33,127,157,85,145,67,248,51,28,79,122,10,93) +IMAGE_DATA(243,52,124,64,227,119,237,81,63,95,171,136,174,85,192,45,243,5,197,230,130,109,232,79,244,12,253,8,186,7,82,241) +IMAGE_DATA(129,125,33,242,42,250,40,191,132,47,169,187,185,160,24,111,19,252,16,71,162,43,136,79,166,250,175,79,231,220,239,37) +IMAGE_DATA(190,73,229,252,86,167,238,227,112,100,57,182,238,79,156,254,235,23,113,13,25,101,221,200,184,211,165,114,255,15,71,220) +IMAGE_DATA(131,199,185,187,120,239,243,200,222,119,118,217,156,126,247,99,223,92,29,243,180,190,237,54,249,52,39,115,249,121,165,103) +IMAGE_DATA(157,141,109,86,89,116,141,46,67,215,34,157,198,42,149,234,77,129,206,87,201,146,188,166,81,3,239,126,124,132,123,213) +IMAGE_DATA(119,103,85,119,235,121,89,21,238,18,191,84,86,233,113,117,129,187,165,2,191,216,221,121,177,199,4,101,188,138,119,205) +IMAGE_DATA(57,188,154,119,91,25,255,6,142,217,90,26,112,139,219,114,63,46,107,122,236,93,234,133,214,116,130,105,58,177,213,125) +IMAGE_DATA(142,84,115,65,42,196,250,31,216,128,150,13,59,143,126,86,251,15,116,241,146,1,0,0,0,0,0,0,0,0,0,0) +IMAGE_END_DATA(2080, 10) diff --git a/uppsrc/ScatterCtrl/PopUpText.cpp b/uppsrc/ScatterCtrl/PopUpText.cpp new file mode 100644 index 000000000..9f7901d59 --- /dev/null +++ b/uppsrc/ScatterCtrl/PopUpText.cpp @@ -0,0 +1,22 @@ + +#include "PopUpText.h" + + +void PopUpInfo::Paint(Draw& w) +{ + Size sz = GetSize(); + if(!IsTransparent()) + w.DrawRect(0, 0, sz.cx, sz.cy, color); + PaintLabel(w, 0, 0, sz.cx, sz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys()); +} + + +PopUpInfo::PopUpInfo(): color(SColorInfo()) +{ + Transparent(false); + NoWantFocus(); + IgnoreMouse(); + SetAlign(ALIGN_CENTER); + SetFrame(BlackFrame()); + opened = false; +} diff --git a/uppsrc/ScatterCtrl/PopUpText.h b/uppsrc/ScatterCtrl/PopUpText.h new file mode 100644 index 000000000..5a93ea875 --- /dev/null +++ b/uppsrc/ScatterCtrl/PopUpText.h @@ -0,0 +1,51 @@ +#ifndef _PopUpText_PopUpText_h +#define _PopUpText_PopUpText_h + +#include + +using namespace Upp; + +class PopUpInfo : public StaticText { + Color color; + bool opened; + +public: + void Paint(Draw& w); + + PopUpInfo& SetFont(Font font) { LabelBase::SetFont(font); return *this; } + PopUpInfo& SetInk(Color color) { LabelBase::SetInk(color); return *this; } + PopUpInfo& SetAlign(int align) { LabelBase::SetAlign(align); return *this; } + PopUpInfo& SetImage(const Image& img, int spc = 0) { LabelBase::SetImage(img, spc); return *this; } + PopUpInfo& SetText(const char *text) { LabelBase::SetText(text); return *this; } + + PopUpInfo& operator=(const char *s) { SetText(s); return *this; } + PopUpInfo& SetColor(const Color& c) { color=c; return *this; } + + PopUpInfo(); + + inline void Appear(Ctrl *owner, const int& x, const int& y, const int& gx=0, const int& gy=0) + { + AppearOnly(owner); + Move(owner, x, y, gx, gy); + } + inline void AppearOnly(Ctrl *owner) + { + if(IsOpen()) Close(); + Ctrl::PopUp(owner); + } + inline void AppearOnlyOpen(Ctrl *owner) + { + if (opened) + return; + AppearOnly(owner); + opened = true; + } + inline void Move(Ctrl *owner, const int& x, const int& y, const int& gx=0, const int& gy=0) + { + SetRect(owner->GetScreenRect().left+x,owner->GetScreenRect().top+y,GetMinSize().cx+8+gx,GetMinSize().cy+4+gy); + } +}; + + +#endif + diff --git a/uppsrc/ScatterCtrl/Scatter.usc b/uppsrc/ScatterCtrl/Scatter.usc new file mode 100644 index 000000000..57cf8ee04 --- /dev/null +++ b/uppsrc/ScatterCtrl/Scatter.usc @@ -0,0 +1,58 @@ +ctrl Scatter { + group "Extra"; + + GetMinSize() {sz.cx=150; sz.cy = 100; return sz; } + GetStdSize() {sz.cx=300; sz.cy = 200; return sz; } + + Frame SetFrame @20; + Color SetColor =:White @1; + Text SetTitle @5; + Font SetFontTitle @6; + Color SetColorTitle =:Black @7; + int H_Border =30 @2; + int V_Border =30 @3; + Color SetPlotAreaColor =:WhiteGray @4; + Text SetLabelX @8; + Text SetLabelY @9; + Font SetFontLabels @10; + Color SetColorLabels=:Black @11; + Color SetAxisColor =:Black @12; + int SetAxisWidth =6 @13; + Color SetGridColor=:Color(102,102,102); + int SetGridWidth=-4; + bool ShowHGrid=true; + bool ShowVGrid=true; + bool showLegend=true; + int SetLegendWeight=80; + + Paint(w) { + r = GetRect(); + w.DrawRect(r, .SetColor); + DrawCtrlFrame(w, r, .SetFrame); + sz = GetSize(); + textsize = GetTextSize(.SetTitle, .SetFontTitle); + if(.SetTitle=="") textsize.cy=0; + HB=0; + if(.H_Border>0) HB=.H_Border; + VB=0; + if(.V_Border>0) VB=.V_Border; + w.DrawRect(HB-1,VB-1+textsize.cy,-2*HB+2+sz.cx,-2*VB+2-textsize.cy+sz.cy,:Gray); + aw=6; + if(.SetAxisWidth >= 6) aw=.SetAxisWidth; + + w.DrawRect(HB-int(aw/6), + VB+textsize.cy, + -2*HB+int(aw/6)+sz.cx, + -2*VB+int(aw/6)-textsize.cy+sz.cy, + .SetAxisColor); + w.DrawRect(HB,VB+textsize.cy,-2*HB+sz.cx,-2*VB-textsize.cy+sz.cy,.SetPlotAreaColor); + + w.DrawText((sz.cx - textsize.cx) / 2, 4, .SetTitle, .SetFontTitle, .SetColorTitle); + lx=GetTextSize(.SetLabelX,.SetFontLabels); + ly=GetTextSize(.SetLabelY,.SetFontLabels); + + w.DrawText(int((sz.cx-lx.cx)/2),sz.cy -(ly.cy+2),.SetLabelX,.SetFontLabels,.SetColorLabels); + w.DrawText(2,int((sz.cy+textsize.cy+ly.cx)/2),900,.SetLabelY,.SetFontLabels,.SetColorLabels); + + } +}; \ No newline at end of file diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.cpp b/uppsrc/ScatterCtrl/ScatterCtrl.cpp new file mode 100644 index 000000000..5d2d7f83f --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.cpp @@ -0,0 +1,425 @@ +#include "ScatterCtrl.h" + +#define IMAGECLASS ScatterImg +#define IMAGEFILE +#include + +ScatterCtrl::MouseBehaviour defaultMouse[] = { + {false, false, false, true , false, 0, false, ScatterCtrl::SHOW_INFO}, + {false, false, false, false, false, 0, true , ScatterCtrl::CONTEXT_MENU}, + {false, false, false, false, true , 0, false, ScatterCtrl::SCROLL}, + {false, false, false, false, false, 1, false, ScatterCtrl::ZOOM_H_RED}, + {false, false, false, false, false, 1, false, ScatterCtrl::ZOOM_V_RED}, + {false, false, false, false, false,-1, false, ScatterCtrl::ZOOM_H_ENL}, + {false, false, false, false, false,-1, false, ScatterCtrl::ZOOM_V_ENL}, + {false, false, false, false, false, 0, false, ScatterCtrl::NO_ACTION}}; + + +#ifdef PLATFORM_WIN32 + +void ScatterCtrl::SaveAsMetafile(const char* file) +{ + GuiLock __; + WinMetaFileDraw wmfd; + wmfd.Create(copyRatio*GetSize().cx, copyRatio*GetSize().cy, "ScatterCtrl", "chart", file); + SetDrawing(wmfd, copyRatio); + wmfd.Close(); +} + +void ScatterCtrl::SaveToClipboard(bool saveAsMetafile) +{ + GuiLock __; + if (saveAsMetafile) { + WinMetaFileDraw wmfd; + wmfd.Create(copyRatio*GetSize().cx, copyRatio*GetSize().cy, "ScatterCtrl", "chart"); + SetDrawing(wmfd, copyRatio); + WinMetaFile wmf = wmfd.Close(); + wmf.WriteClipboard(); + } else { + Image img = GetImage(copyRatio); + WriteClipboardImage(img); + } +} +#else + +void ScatterCtrl::SaveToClipboard(bool) +{ + GuiLock __; + Image img = GetImage(copyRatio); + WriteClipboardImage(img); +} + +#endif + +void ScatterCtrl::Paint(Draw& w) +{ + if (mode == MD_DRAW) + SetDrawing(w, 1); + else { + ImageBuffer ib(GetSize()); + BufferPainter bp(ib, mode); + SetDrawing(bp, 1); + //bp.Translate(0, 0); + w.DrawImage(0, 0, ib); + } +} + +ScatterCtrl &ScatterCtrl::ShowInfo(bool show) +{ + paintInfo = show; + return *this; +} + +void ScatterCtrl::ProcessPopUp(const Point & pt) +{ + double _x = (popLT.x - hPlotLeft)*xRange/(GetSize().cx - (hPlotLeft + hPlotRight)-1) + xMin; + double _y = -(popLT.y - vPlotTop - titleFont.GetHeight())*yRange/(GetSize().cy - (vPlotTop + vPlotBottom + titleFont.GetHeight())+1) + yMin + yRange; + double _y2 = -(popLT.y - vPlotTop - titleFont.GetHeight())*yRange2/(GetSize().cy - (vPlotTop + vPlotBottom + titleFont.GetHeight())+1) + yMin2 + yRange2; + double x = (pt.x - hPlotLeft)*xRange/(GetSize().cx - (hPlotLeft + hPlotRight)-1) + xMin; + double y = -(pt.y - vPlotTop - titleFont.GetHeight())*yRange/(GetSize().cy - (vPlotTop + vPlotBottom + titleFont.GetHeight())+1) + yMin + yRange; + double y2 = -(pt.y - vPlotTop - titleFont.GetHeight())*yRange2/(GetSize().cy - (vPlotTop + vPlotBottom + titleFont.GetHeight())+1) + yMin2 + yRange2; + + double dx = x - _x; + double dy = y - _y; + double dy2 = y2 - _y2; + if(logX) { + x = pow(10.0, x); + _x = pow(10.0, _x); + dx = x - _x; + } + if(logY) { + y = pow(10.0, y); + _y = pow(10.0, _y); + dy = pow(10.0, dy); + } + if(logY2) { + y2 = pow(10.0, y2); + _y2 = pow(10.0, _y2); + dy2 = pow(10.0, dy2); + } + String strx, _strx, dstrx, stry, _stry, dstry; + if (cbModifFormatX) { + cbModifFormatX(strx, 0, x); strx.Replace("\n", " "); + cbModifFormatX(_strx, 0, _x); _strx.Replace("\n", " "); + } else { + strx = VariableFormatX(x); + _strx = VariableFormatX(_x); + } + if (cbModifFormatDeltaX) { + cbModifFormatDeltaX(dstrx, 0, dx); dstrx.Replace("\n", " "); + } else { + dstrx = VariableFormatX(dx); + } + if (cbModifFormatY) { + cbModifFormatY(stry, 0, y); stry.Replace("\n", " "); + cbModifFormatY(_stry, 0, _y); _stry.Replace("\n", " "); + } else { + stry = VariableFormatY(y); + _stry = VariableFormatY(_y); + } + if (cbModifFormatDeltaY) { + cbModifFormatDeltaY(dstry, 0, dy); dstry.Replace("\n", " "); + } else { + dstry = VariableFormatY(dy); + } + String str= popTextX + ": " + _strx; + if (strx != _strx) + str << "; " + popTextX + "': " + strx + "; Δ" + popTextX + ": " + dstrx; + str << "\n" + popTextY + ": " + _stry; + if (stry != _stry) + str << "; " + popTextY + "': " + stry + "; Δ" + popTextY + ": " + dstry; + if (drawY2Reticle) { + String stry2, _stry2, dstry2; + if (cbModifFormatY2) { + cbModifFormatY2(stry2, 0, y2); stry2.Replace("\n", " "); + cbModifFormatY2(_stry2, 0, _y2); _stry2.Replace("\n", " "); + } else { + stry2 = VariableFormatY2(y2); + _stry2 = VariableFormatY2(_y2); + } + if (cbModifFormatDeltaY2) { + cbModifFormatDeltaY2(dstry2, 0, dy2); dstry2.Replace("\n", " "); + } else { + dstry2 = VariableFormatY(dy2); + } + str << "\n" + popTextY2 + ": " + _stry2; + if (stry2 != _stry2) + str << "; " + popTextY2 + ": " + stry2 + "; Δ" + popTextY2 + ": " + dstry2; + } + const Point p2 = pt + offset; + popText.SetText(str).Move(this,p2.x,p2.y); +} + +void ScatterCtrl::DoMouseAction(bool down, Point pt, MouseAction action, int value) +{ + switch (action) { + case SCROLL: Scrolling(down, pt); + break; + case ZOOM_H_ENL: + case ZOOM_H_RED: MouseZoom(value, true, false); + break; + case ZOOM_V_ENL: + case ZOOM_V_RED: MouseZoom(value, false, true); + break; + case SHOW_INFO: LabelPopUp(down, pt); + break; + case CONTEXT_MENU: if(showContextMenu) + MenuBar::Execute(THISBACK(ContextMenu)); + break; + case NO_ACTION:; + } +} + +bool ScatterCtrl::SetMouseBehavior(MouseBehaviour *_mouseBehavior) +{ + if (!_mouseBehavior) + return false; + int i; + for (i = 0; _mouseBehavior[i].action != NO_ACTION && i < MAX_MOUSEBEHAVIOR; ++i) ; + if (i == MAX_MOUSEBEHAVIOR) + return false; + mouseBehavior = _mouseBehavior; + return true; +} + +void ScatterCtrl::ProcessMouse(bool down, Point &pt, bool ctrl, bool alt, bool shift, bool left, bool middle, int middleWheel, bool right) +{ + for (int i = 0; mouseBehavior[i].action != NO_ACTION && i < MAX_MOUSEBEHAVIOR; ++i) { + if (mouseBehavior[i].ctrl == ctrl && mouseBehavior[i].alt == alt && + mouseBehavior[i].shift == shift && mouseBehavior[i].left == left && + mouseBehavior[i].middle == middle && mouseBehavior[i].right == right && + ((mouseBehavior[i].middleWheel == 0) || mouseBehavior[i].middleWheel == ((middleWheel > 0) - (middleWheel < 0)))) + DoMouseAction(down, pt, mouseBehavior[i].action, middleWheel); + } +} + +void ScatterCtrl::LabelPopUp(bool down, Point &pt) +{ + if (down) { + if(paintInfo && hPlotLeft <= pt.x && pt.x <= GetSize().cx - hPlotRight && + (vPlotTop + titleFont.GetHeight()) <= pt.y && pt.y <= GetSize().cy - vPlotBottom) { + popText.AppearOnly(this); + + isLabelPopUp = true; + if (IsNull(popLT)) + popLT = pt; + popRB = pt; + ProcessPopUp(pt); + } + } else { + if(paintInfo && isLabelPopUp) { + popText.Close(); + isLabelPopUp = false; + popLT = popRB = Null; + Refresh(); + } + } +} + +#ifdef PLATFORM_LINUX + #include +#endif + +void ScatterCtrl::Scrolling(bool down, Point &pt, bool isOut) +{ + static Image mouseImg; + if (down) { + if((mouseHandlingX || mouseHandlingY) && hPlotLeft <= pt.x && pt.x <= GetSize().cx - hPlotRight && + (vPlotTop + titleFont.GetHeight()) <= pt.y && pt.y <= GetSize().cy - vPlotBottom) { + butDownX = pt.x; + butDownY = pt.y; + isScrolling = true; + INTERLOCKED { +#ifdef PLATFORM_WIN32 + static Image img = Win32Cursor(IDC_SIZEALL); +#else + static Image img = X11Cursor(XC_fleur); +#endif + mouseImg = Ctrl::OverrideCursor(img); + } + } + } else { + if (isScrolling) { + if (!isOut) + MouseMove(pt, 0); + isScrolling = false; + Ctrl::OverrideCursor(mouseImg); + } + } +} + +void ScatterCtrl::LeftDown(Point pt, dword keyFlags) +{ + ProcessMouse(true, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, true, false, 0, false); +} + +void ScatterCtrl::LeftUp(Point pt, dword keyFlags) +{ + ProcessMouse(false, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, true, false, 0, false); +} + +void ScatterCtrl::MiddleDown(Point pt, dword keyFlags) +{ + ProcessMouse(true, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, false, true, 0, false); +} + +void ScatterCtrl::MiddleUp(Point pt, dword keyFlags) +{ + ProcessMouse(false, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, false, true, 0, false); +} + +void ScatterCtrl::RightDown(Point pt, dword keyFlags) +{ + ProcessMouse(true, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, false, false, 0, true); +} + +void ScatterCtrl::RightUp(Point pt, dword keyFlags) +{ + ProcessMouse(false, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, false, false, 0, true); +} + +void ScatterCtrl::MouseWheel(Point pt, int zdelta, dword keyFlags) +{ + if (zdelta == 0) + return; + ProcessMouse(true, pt, keyFlags & K_CTRL, keyFlags & K_ALT, keyFlags & K_SHIFT, false, false, zdelta, false); +} + +void ScatterCtrl::MouseMove(Point pt, dword) +{ + if (isScrolling) + { + int shiftX = pt.x - butDownX; + if (mouseHandlingX && shiftX != 0) { + double deltaX = shiftX*xRange/(GetSize().cx - (hPlotLeft + hPlotRight) - 1); + xMin -= deltaX; + xMinUnit += deltaX; + AdjustMinUnitX(); + butDownX = pt.x; + } + int shiftY = pt.y - butDownY; + if (mouseHandlingY && shiftY != 0) { + double deltaY = -shiftY*yRange/(GetSize().cy - (vPlotTop + vPlotBottom) - 1); + yMin -= deltaY; + yMinUnit += deltaY; + AdjustMinUnitY(); + if (drawY2Reticle) { + double deltaY2 = -shiftY*yRange2/(GetSize().cy - 2*(vPlotTop + vPlotBottom) - 1); + yMin2 -= deltaY2; + yMinUnit2 += deltaY2; + AdjustMinUnitY2(); + } + butDownY = pt.y; + } + if ((mouseHandlingX && shiftX != 0) || (mouseHandlingY && shiftY != 0)) { + WhenSetXYMin(); + Refresh(); + WhenZoomScroll(); + } + } + if(isLabelPopUp) { + if (paintInfo && hPlotLeft <= pt.x && pt.x <= GetSize().cx - hPlotRight && + (vPlotTop + titleFont.GetHeight()) <= pt.y && pt.y <= GetSize().cy - vPlotBottom) + { + if (IsNull(popLT)) + popLT = pt; + popRB = pt; + popText.AppearOnlyOpen(this); + + ProcessPopUp(pt); + } + } +} + +void ScatterCtrl::MouseLeave() +{ + Point p = Null; + Scrolling(false, p, true); +} + +void ScatterCtrl::MouseZoom(int zdelta, bool hor, bool ver) +{ + double scale = zdelta > 0 ? zdelta/100. : -100./zdelta; + Zoom(scale, mouseHandlingX, mouseHandlingY); +} + +Image ScatterCtrl::CursorImage(Point p, dword keyflags) +{ + if (paintInfo) + return ScatterImg::cursor1(); + return Image::Arrow(); +} + +ScatterCtrl &ScatterCtrl::SetMouseHandling(bool valx, bool valy) +{ + mouseHandlingX = valx; + mouseHandlingY = valy; + return *this; +} + +void ScatterCtrl::ContextMenu(Bar& bar) +{ + if (mouseHandlingX || mouseHandlingY) { + bar.Add(t_("Fit to data"), ScatterImg::ShapeHandles(), THISBACK1(FitToData, mouseHandlingY)); + bar.Add(t_("Zoom +"), ScatterImg::ZoomPlus(), THISBACK3(Zoom, 1/1.2, true, mouseHandlingY)); + bar.Add(t_("Zoom -"), ScatterImg::ZoomMinus(), THISBACK3(Zoom, 1.2, true, mouseHandlingY)); + bar.Add(t_("Scroll Left"), ScatterImg::LeftArrow(), THISBACK2(ScatterDraw::Scroll, -0.2, 0)); + bar.Add(t_("Scroll Right"), ScatterImg::RightArrow(), THISBACK2(ScatterDraw::Scroll, 0.2, 0)); + if (mouseHandlingY) { + bar.Add(t_("Scroll Up"), ScatterImg::UpArrow(), THISBACK2(ScatterDraw::Scroll, 0, -0.2)); + bar.Add(t_("Scroll Down"), ScatterImg::DownArrow(), THISBACK2(ScatterDraw::Scroll, 0, 0.2)); + } + bar.Separator(); + } + bar.Add(t_("Copy"), ScatterImg::Copy(), THISBACK1(SaveToClipboard, false)).Key(K_CTRL_C); + bar.Add(t_("Save to file"), ScatterImg::Save(), THISBACK1(SaveToFile, Null)); +} + +void ScatterCtrl::SaveToFile(String fileName) +{ + GuiLock __; + if (IsNull(fileName)) { + FileSel fs; + + fs.Type("PNG file", "*.png"); + fs.Type("JPEG file", "*.jpg"); + if(!fs.ExecuteSaveAs(t_("Saving plot to PNG or JPEG file"))) { + Exclamation(t_("Plot has not been saved")); + return; + } + fileName = fs; + } + if (GetFileExt(fileName) == ".png") { + PNGEncoder encoder; + encoder.SaveFile(fileName, GetImage(copyRatio)); + } else if (GetFileExt(fileName) == ".jpg") { + JPGEncoder encoder(90); + encoder.SaveFile(fileName, GetImage(copyRatio)); + } else + Exclamation(Format(t_("File format \"%s\" not found"), GetFileExt(fileName))); +} + +ScatterCtrl &ScatterCtrl::AddSeries(ArrayCtrl &data, bool useCols, int idX, int idY, int idZ, int beginData, int numData) +{ + AddSeries(data, useCols, idX, idY, beginData, numData); + return *this; +} + +void ScatterCtrl::InsertSeries(int id, ArrayCtrl &data, bool useCols, int idX, int idY, int idZ, int beginData, int numData) +{ + InsertSeries(id, data, useCols, idX, idY, beginData, numData); +} + +ScatterCtrl::ScatterCtrl() : offset(10,12), copyRatio(3) +{ + paintInfo = mouseHandlingX = mouseHandlingY = isScrolling = isLabelPopUp = false; + popTextX = "x"; + popTextY = "y1"; + popTextY2 = "y2"; + popLT = popRB = Null; + showContextMenu = false; + Color(graphColor); + BackPaint(); + popText.SetColor(SColorFace); + SetMouseBehavior(defaultMouse); +} diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.h b/uppsrc/ScatterCtrl/ScatterCtrl.h new file mode 100644 index 000000000..cfbdcbbd5 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.h @@ -0,0 +1,207 @@ +#ifndef _ScatterCtrl_ScatterCtrl_h +#define _ScatterCtrl_ScatterCtrl_h + +#include "PopUpText.h" +#include +#include + +using namespace Upp; + +class ArrayCtrlSource : public DataSource { +private: + ArrayCtrl *data; + bool useCols; + int idX, idY, idZ; + int beginData; + int numData; + +public: + ArrayCtrlSource() : data(0), useCols(true), idX(0), idY(1), idZ(2), beginData(0), numData(Null) {}; + ArrayCtrlSource(ArrayCtrl &data, bool useCols = true, int idX = 0, int idY = 1, int idZ = 2, int beginData = 0, int _numData = Null) : + data(&data), useCols(useCols), idX(idX), idY(idY), idZ(idZ), beginData(beginData), numData(_numData) + { + if (IsNull(_numData)) { + if (!useCols) + numData = data.GetColumnCount() - beginData; + else + numData = data.GetCount() - beginData; + } + } + virtual inline double z(int id) {return useCols ? data->Get(beginData + id, idZ) : data->Get(idZ, beginData + id);}; + virtual inline double y(int id) {return useCols ? data->Get(beginData + id, idY) : data->Get(idY, beginData + id);}; + virtual inline double x(int id) { + if (IsNull(idX)) + return id; + else + return useCols ? data->Get(beginData + id, idX) : data->Get(idX, beginData + id); + } + virtual inline int GetCount() {return numData;}; +}; + +#include + +class GridCtrlSource : public DataSource { +private: + GridCtrl *data; + bool useCols; + int idX, idY, idZ; + int beginData; + int numData; + +public: + GridCtrlSource() : data(0), useCols(true), idX(0), idY(1), idZ(2), beginData(0), numData(Null) {}; + GridCtrlSource(GridCtrl &data, bool useCols = true, int idX = 0, int idY = 1, int idZ = 2, int beginData = 0, int _numData = Null) : + data(&data), useCols(useCols), idX(idX), idY(idY), idZ(idZ), beginData(beginData), numData(_numData) + { + Init(data, useCols, idX, idY, idZ, beginData, _numData); + } + void Init(GridCtrl &_data, bool _useCols = true, int _idX = 0, int _idY = 1, int _idZ = 2, int _beginData = 0, int _numData = Null) + { + data = &_data; + useCols = _useCols; + idX = _idX; + idY = _idY; + idZ = _idZ; + beginData = _beginData; + numData = _numData; + if (IsNull(_numData)) { + if (!useCols) + numData = data->GetColumnCount() - beginData; + else + numData = data->GetCount() - beginData; + } + } + virtual inline double z(int id) {return useCols ? data->Get(beginData + id, idZ) : data->Get(idZ, beginData + id);}; + virtual inline double y(int id) {return useCols ? data->Get(beginData + id, idY) : data->Get(idY, beginData + id);}; + virtual inline double x(int id) { + if (IsNull(idX)) + return id; + else + return useCols ? data->Get(beginData + id, idX) : data->Get(idX, beginData + id); + } + virtual inline int GetCount() {return numData;}; +}; + +class ScatterCtrl : public StaticRect, public ScatterDraw { +public: + typedef ScatterCtrl CLASSNAME; + ScatterCtrl(); + + enum MouseAction {NO_ACTION = 0, SCROLL, ZOOM_H_ENL, ZOOM_H_RED, ZOOM_V_ENL, ZOOM_V_RED, SHOW_INFO, CONTEXT_MENU}; + + struct MouseBehaviour { + bool ctrl; + bool alt; + bool shift; + bool left; + bool middle; + int middleWheel; + bool right; + MouseAction action; + }; + + #define MAX_MOUSEBEHAVIOR 20 + + bool SetMouseBehavior(MouseBehaviour *_mouseBehavior); + ScatterCtrl& ShowLegend(const bool& show=true); + ScatterCtrl& ShowContextMenu(const bool& show = true) {showContextMenu = show; return *this;} + void SetPopText(const String x, const String y1, const String y2) {popTextX = x; popTextY = y1; popTextY2 = y2;} + ScatterCtrl& SetMouseHandling(bool valx = true, bool valy = false); + ScatterCtrl &ShowInfo(bool show = true); + +#ifdef PLATFORM_WIN32 + void SaveAsMetafile(const char* file); +#endif + void SaveToClipboard(bool saveAsMetafile = false); + void SaveToFile(String fileName = Null); + + virtual void Refresh() {Ctrl::Refresh();}; + virtual Size GetSize() const {return Ctrl::GetSize();}; + + ScatterCtrl& SetColor(const class::Color& _color) {ScatterDraw::SetColor(_color); return *this;}; + ScatterCtrl& SetGridColor(const class::Color& grid_color) {ScatterDraw::SetGridColor(grid_color); return *this;}; + ScatterCtrl& SetGridWidth(const int& grid_width) {ScatterDraw::SetGridWidth(grid_width); return *this;}; + ScatterCtrl& SetPlotAreaColor(const class::Color& p_a_color){ScatterDraw::SetPlotAreaColor(p_a_color); return *this;}; + ScatterCtrl& SetLegendWeight(const int& weight) {ScatterDraw::SetLegendWeight(weight); return *this;}; + ScatterCtrl& SetAxisColor(const class::Color& axis_color) {ScatterDraw::SetAxisColor(axis_color); return *this;}; + ScatterCtrl& SetAxisWidth(const int& axis_width) {ScatterDraw::SetAxisWidth(axis_width); return *this;}; + ScatterCtrl& SetTitle(const String& title) {ScatterDraw::SetTitle(title); return *this;}; + ScatterCtrl& SetTitleFont(const Font& fontTitle) {ScatterDraw::SetTitleFont(fontTitle); return *this;}; + ScatterCtrl& SetTitleColor(const class::Color& colorTitle) {ScatterDraw::SetTitleColor(colorTitle); return *this;}; + ScatterCtrl& SetLabelsFont(const Font& fontLabels) {ScatterDraw::SetLabelsFont(fontLabels); return *this;}; + ScatterCtrl& SetLabelsColor(const class::Color& colorLabels){ScatterDraw::SetLabelsColor(colorLabels); return *this;}; + ScatterCtrl& SetLabelX(const String& _xLabel) {ScatterDraw::SetLabelX(_xLabel); return *this;}; + ScatterCtrl& SetLabelY(const String& _yLabel) {ScatterDraw::SetLabelY(_yLabel); return *this;}; + ScatterCtrl& SetLabelY2(const String& _yLabel) {ScatterDraw::SetLabelY2(_yLabel); return *this;}; + ScatterCtrl& SetPlotAreaMargin(const int hLeft, const int hRight, const int vTop, const int vBottom) + {ScatterDraw::SetPlotAreaMargin(hLeft, hRight, vTop, vBottom); return *this;}; + ScatterCtrl& SetPlotAreaLeftMargin(const int margin) {ScatterDraw::SetPlotAreaLeftMargin(margin);return *this;}; + ScatterCtrl& SetPlotAreaTopMargin(const int margin) {ScatterDraw::SetPlotAreaTopMargin(margin);return *this;}; + ScatterCtrl& SetPlotAreaRightMargin(const int margin) {ScatterDraw::SetPlotAreaRightMargin(margin);return *this;}; + ScatterCtrl& SetPlotAreaBottomMargin(const int margin) {ScatterDraw::SetPlotAreaBottomMargin(margin);return *this;}; + + using ScatterDraw::AddSeries; + ScatterCtrl &AddSeries(ArrayCtrl &data, bool useCols = true, int idX = 0, int idY = 1, int idZ = 2, int beginData = 0, int numData = Null); + using ScatterDraw::InsertSeries; + void InsertSeries(int id, ArrayCtrl &data, bool useCols = true, int idX = 0, int idY = 1, int idZ = 2, int beginData = 0, int numData = Null); + + void SetCopyRatio(int ratio) {copyRatio = ratio;} + int GetCopyRatio() {return copyRatio;} + +private: + bool paintInfo; + Point clickPoint; + PopUpInfo popText; + String popTextX, popTextY, popTextY2; + Point popLT, popRB; + const Point offset; + int copyRatio; + + int butDownX, butDownY; + bool isScrolling, isLabelPopUp; + + bool mouseHandlingX, mouseHandlingY; + bool showContextMenu; + + MouseBehaviour *mouseBehavior; + + void ProcessPopUp(const Point & pt); + + virtual void Paint(Draw& w); + virtual void LeftDown(Point, dword); + virtual void LeftUp(Point, dword); + virtual void MiddleDown(Point, dword); + virtual void MouseMove(Point, dword); + virtual void MiddleUp(Point, dword); + virtual void RightDown(Point, dword); + virtual void RightUp(Point, dword); + virtual void MouseLeave(); + virtual void MouseWheel(Point, int zdelta, dword); + + void DoMouseAction(bool down, Point pt, MouseAction action, int value); + void ProcessMouse(bool down, Point &pt, bool ctrl, bool alt, bool shift, bool left, bool middle, int middleWheel, bool right); + void LabelPopUp(bool down, Point &pt); + void Scrolling(bool down, Point &pt, bool isOut = false); + void MouseZoom(int zdelta, bool hor, bool ver); + + void ContextMenu(Bar& bar); + + virtual Image CursorImage(Point p, dword keyflags); + + template + void SetDrawing(T& w, const int& scale); +}; + +template +void ScatterCtrl::SetDrawing(T& w, const int& scale) { + ScatterDraw::SetDrawing(w, scale); + if (!IsNull(popLT) && popLT != popRB) { + DrawVArrow(w, popLT.x, popLT.y, popLT.x, popRB.y, 1, 4, 15, SColorHighlight()); + DrawHArrow(w, popLT.x, popRB.y, popRB.x, popRB.y, 1, 4, 15, SColorHighlight()); + Ctrl::Refresh(min(popLT.x-4, popRB.x-4), min(popLT.y-4, popRB.y-4), + abs(popRB.x-popLT.x) + 9, abs(popRB.y-popLT.y) + 9); + } +} + +#endif + diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.iml b/uppsrc/ScatterCtrl/ScatterCtrl.iml new file mode 100644 index 000000000..d2af877d3 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.iml @@ -0,0 +1,79 @@ +PREMULTIPLIED +IMAGE_ID(cursor1) +IMAGE_ID(ZoomMinus) +IMAGE_ID(ZoomPlus) +IMAGE_ID(ShapeHandles) +IMAGE_ID(Copy) +IMAGE_ID(RightArrow) +IMAGE_ID(LeftArrow) +IMAGE_ID(Save) +IMAGE_ID(DownArrow) +IMAGE_ID(UpArrow) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,152,105,80,84,87,22,199,65,203,15,58,85,153,153,170,169,154,76,149,21,199,169,73,149,83,154,137,32,90) +IMAGE_DATA(137,226,135,153,170,201,135,36,53,101,88,148,48,33,70,54,25,150,132,61,2,134,96,16,4,23,68,16,162,128,128,128) +IMAGE_DATA(236,8,130,128,2,162,194,19,69,209,184,97,177,67,55,251,46,107,3,13,252,231,220,215,116,79,55,208,208,77,71,101) +IMAGE_DATA(38,156,230,95,77,223,62,191,115,206,189,239,222,251,238,107,173,183,181,222,214,250,21,189,126,105,6,254,111,37,254,74) +IMAGE_DATA(252,149,248,75,97,127,78,189,238,250,87,226,175,196,95,137,255,102,227,47,75,251,13,189,230,177,245,164,50,45,201,128) +IMAGE_DATA(72,85,54,211,190,152,25,51,255,176,176,176,66,249,198,153,207,44,142,209,2,236,250,249,216,121,98,40,171,163,76,25) +IMAGE_DATA(59,43,70,153,146,175,37,19,192,40,21,74,37,239,167,140,215,242,129,114,169,192,27,83,30,101,90,152,87,181,255,119) +IMAGE_DATA(148,124,173,233,248,51,51,154,47,134,148,61,190,113,35,78,235,232,64,123,225,24,243,205,63,86,243,122,31,250,159,241) +IMAGE_DATA(42,196,152,215,180,255,79,99,56,111,222,44,84,151,151,198,176,212,210,18,218,188,245,150,112,121,111,6,252,226,243,145) +IMAGE_DATA(45,2,181,55,131,89,188,92,12,213,55,3,198,191,169,205,64,62,255,82,54,3,229,253,87,109,51,80,127,252,121,74) +IMAGE_DATA(107,101,51,120,237,49,94,229,102,176,100,243,240,240,16,6,4,4,192,201,201,233,197,98,190,123,246,236,185,105,109,109) +IMAGE_DATA(13,3,3,3,153,111,96,96,32,158,61,123,134,163,71,143,226,100,78,27,142,103,183,34,144,228,159,73,186,220,10,191) +IMAGE_DATA(244,102,248,166,53,195,39,165,25,230,230,230,224,56,14,38,38,38,178,201,110,103,103,247,208,215,215,23,199,78,133,227) +IMAGE_DATA(18,215,141,132,146,110,196,147,226,110,117,33,246,102,23,98,138,187,16,93,212,129,168,194,14,216,58,123,195,208,208,16) +IMAGE_DATA(250,250,250,156,124,93,44,223,165,82,41,215,141,139,196,197,50,238,70,39,46,16,23,89,208,129,243,215,218,241,99,94) +IMAGE_DATA(27,220,46,52,204,89,152,172,214,184,219,51,57,165,92,209,127,185,115,196,133,231,182,225,108,78,43,28,35,234,230,240) +IMAGE_DATA(172,143,210,90,25,23,69,92,196,245,14,156,203,39,142,216,179,87,91,17,154,211,130,51,87,90,96,31,94,51,135,63) +IMAGE_DATA(146,218,76,125,236,228,251,200,56,105,173,97,87,89,206,22,132,16,23,156,217,140,211,151,155,97,27,82,61,135,255,62) +IMAGE_DATA(81,160,208,71,105,173,140,59,147,217,194,115,167,50,154,113,34,77,8,235,160,170,57,188,87,156,64,82,107,174,164,214) +IMAGE_DATA(144,108,73,173,167,51,37,220,201,116,33,142,167,10,16,152,34,128,249,201,23,115,248,111,99,26,168,86,73,31,165,181) +IMAGE_DATA(6,177,156,196,157,152,225,142,37,53,193,63,177,17,251,3,43,231,240,46,145,245,138,181,166,179,90,37,92,64,178,0) +IMAGE_DATA(254,196,250,93,106,196,209,248,70,152,249,63,87,224,119,238,220,41,220,189,123,55,62,250,196,80,214,71,86,43,227,142) +IMAGE_DATA(73,185,132,70,248,198,55,96,243,182,191,99,221,186,117,88,179,102,205,11,57,30,249,249,249,216,186,85,7,214,193,85) +IMAGE_DATA(176,164,241,97,125,60,64,117,178,90,205,252,43,241,47,191,231,48,37,173,93,187,22,137,137,137,88,189,122,181,172,134) +IMAGE_DATA(77,155,54,61,220,178,101,203,244,134,13,27,238,206,238,215,108,91,181,106,85,161,182,182,54,99,185,197,124,85,50,249) +IMAGE_DATA(205,224,15,127,222,97,96,243,67,124,145,217,247,41,156,153,119,18,103,118,56,145,51,245,136,231,76,14,93,228,246,185) +IMAGE_DATA(199,112,123,221,162,57,99,151,40,206,208,41,130,51,117,10,46,98,254,242,177,172,124,147,75,28,131,178,57,85,101,228) +IMAGE_DATA(16,90,34,207,127,233,147,194,169,163,127,218,134,42,12,130,153,119,50,167,142,125,122,240,140,34,255,93,34,223,94,124) +IMAGE_DATA(251,54,23,28,157,87,31,148,85,59,233,153,88,7,207,132,26,120,196,85,193,45,250,57,92,46,60,133,115,196,79,112) +IMAGE_DATA(60,255,8,223,132,63,128,253,217,114,184,134,22,14,111,124,255,35,59,54,94,204,110,17,239,159,65,19,146,22,162,170) +IMAGE_DATA(250,58,232,230,148,169,87,60,207,223,46,41,225,188,146,234,160,142,172,79,220,130,201,161,88,9,95,90,202,121,38,212) +IMAGE_DATA(66,29,179,56,118,3,198,174,81,60,95,66,242,136,175,230,219,199,196,147,16,141,139,49,44,18,227,229,200,56,122,135) +IMAGE_DATA(68,232,234,31,69,123,247,8,90,186,134,208,208,62,200,251,125,229,87,0,67,199,243,178,177,101,227,197,108,98,114,18) +IMAGE_DATA(227,20,99,116,66,18,99,96,84,140,190,225,49,116,15,82,156,151,34,116,244,140,242,126,95,30,201,199,95,62,220,251) +IMAGE_DATA(195,30,135,112,238,83,155,16,206,61,182,146,111,23,79,77,97,130,52,78,113,70,88,29,99,98,12,81,156,193,17,49) +IMAGE_DATA(250,135,38,208,51,56,198,251,125,225,157,171,176,168,93,162,158,240,237,147,211,211,188,164,113,198,88,44,177,24,34,170) +IMAGE_DATA(135,175,137,226,49,51,241,204,82,224,191,249,177,130,111,159,146,139,49,49,19,67,42,17,213,52,42,150,240,70,110,233) +IMAGE_DATA(10,188,125,200,61,181,198,255,51,231,20,5,126,251,39,142,41,54,65,165,176,12,40,198,1,191,66,236,247,189,14,211) +IMAGE_DATA(195,217,48,241,186,130,125,30,151,177,215,61,131,114,166,193,208,37,5,159,57,165,128,249,171,177,236,231,183,95,211,235) +IMAGE_DATA(53,152,38,63,198,72,143,137,75,98,125,124,124,150,202,35,190,72,188,24,15,101,98,236,34,188,204,103,33,41,225,85) +IMAGE_DATA(98,149,240,26,229,213,160,191,202,108,169,28,207,106,114,125,151,200,73,217,87,99,203,124,65,46,121,176,53,185,192,108) +IMAGE_DATA(130,168,201,202,56,57,86,153,148,114,11,105,22,171,50,167,164,47,75,205,171,105,127,231,240,11,248,44,100,154,44,68) +IMAGE_DATA(173,69,106,83,149,127,53,38,127,92,254,253,251,6,78,239,232,219,6,111,54,14,175,208,181,200,236,211,179,185,54,177) +IMAGE_DATA(221,182,96,122,135,93,33,118,216,74,244,161,125,17,118,125,125,3,59,29,10,161,103,153,217,175,243,121,216,131,223,254) +IMAGE_DATA(105,23,255,227,216,31,255,230,28,249,164,105,20,79,154,68,116,204,154,134,136,52,58,62,69,199,172,73,58,26,77,160) +IMAGE_DATA(119,80,204,127,22,77,76,161,123,64,140,134,14,209,116,65,69,135,120,159,119,65,207,239,54,253,195,226,61,211,152,170) +IMAGE_DATA(39,141,163,240,73,237,164,163,12,177,228,103,121,242,30,250,134,196,232,34,255,193,209,73,62,238,0,189,11,123,198,81) +IMAGE_DATA(219,62,134,130,199,125,184,241,184,7,250,246,185,99,186,150,89,47,31,19,239,157,220,193,251,48,49,190,115,96,130,142) +IMAGE_DATA(104,98,62,47,203,223,65,181,212,119,140,161,182,77,4,207,120,1,74,43,251,161,103,147,55,205,250,91,81,63,66,124) +IMAGE_DATA(59,239,195,100,125,170,28,157,244,62,52,70,71,45,170,169,127,120,18,141,157,44,183,8,213,173,34,28,138,107,66,74) +IMAGE_DATA(73,59,182,219,228,129,141,85,121,221,48,190,75,106,135,128,234,99,106,238,29,167,220,147,124,238,33,209,20,90,123,39) +IMAGE_DATA(100,108,85,235,40,190,141,109,64,66,113,11,244,14,94,5,27,231,187,213,196,39,182,241,117,91,81,238,131,65,229,176) +IMAGE_DATA(15,121,0,7,210,191,131,239,195,138,218,45,229,228,26,85,131,152,2,1,244,172,115,248,235,115,167,106,16,94,9,205) +IMAGE_DATA(212,47,18,189,123,37,8,225,21,207,36,160,35,191,128,242,53,194,157,158,77,93,163,235,225,28,85,11,215,11,117,136) +IMAGE_DATA(200,173,135,158,213,21,158,47,169,28,148,176,36,9,39,228,99,48,246,208,197,38,190,94,183,232,6,158,115,137,172,33) +IMAGE_DATA(85,35,44,171,6,219,44,51,121,190,248,233,75,98,133,51,18,200,114,243,44,229,117,143,169,231,89,103,226,156,206,87) +IMAGE_DATA(209,99,199,11,4,165,85,98,155,69,6,241,5,40,124,220,15,207,56,33,127,157,85,145,67,248,51,28,79,122,10,93) +IMAGE_DATA(243,52,124,64,227,119,237,81,63,95,171,136,174,85,192,45,243,5,197,230,130,109,232,79,244,12,253,8,186,7,82,241) +IMAGE_DATA(129,125,33,242,42,250,40,191,132,47,169,187,185,160,24,111,19,252,16,71,162,43,136,79,166,250,175,79,231,220,239,37) +IMAGE_DATA(190,73,229,252,86,167,238,227,112,100,57,182,238,79,156,254,235,23,113,13,25,101,221,200,184,211,165,114,255,15,71,220) +IMAGE_DATA(131,199,185,187,120,239,243,200,222,119,118,217,156,126,247,99,223,92,29,243,180,190,237,54,249,52,39,115,249,121,165,103) +IMAGE_DATA(157,141,109,86,89,116,141,46,67,215,34,157,198,42,149,234,77,129,206,87,201,146,188,166,81,3,239,126,124,132,123,213) +IMAGE_DATA(119,103,85,119,235,121,89,21,238,18,191,84,86,233,113,117,129,187,165,2,191,216,221,121,177,199,4,101,188,138,119,205) +IMAGE_DATA(57,188,154,119,91,25,255,6,142,217,90,26,112,139,219,114,63,46,107,122,236,93,234,133,214,116,130,105,58,177,213,125) +IMAGE_DATA(142,84,115,65,42,196,250,31,216,128,150,13,59,143,126,86,251,15,116,241,146,1,0,0,0,0,0,0,0,0,0,0) +IMAGE_END_DATA(2080, 10) diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.t b/uppsrc/ScatterCtrl/ScatterCtrl.t new file mode 100644 index 000000000..d78238f07 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.t @@ -0,0 +1,53 @@ +#ifdef _MSC_VER +#pragma setlocale("C") +#endif +// ScatterCtrl.cpp + +T_("Fit to data") +caES("Ajust a les dades") +esES("Ajustar a los datos") + +T_("Zoom +") +caES("") +esES("") + +T_("Zoom -") +caES("") +esES("") + +T_("Scroll Left") +caES("Moure a l'esquerra") +esES("Mover a la izquierda") + +T_("Scroll Right") +caES("More a la dreta") +esES("Mover a la derecha") + +T_("Scroll Up") +caES("Moure amunt") +esES("Mover arriba") + +T_("Scroll Down") +caES("Moure baix") +esES("Mover abajo ") + +T_("Copy") +caES("Copiar") +esES("Copiar") + +T_("Save to file") +caES("Guardar a fitxer") +esES("Guardar en fichero") + +T_("Saving plot to PNG or JPEG file") +caES("Guardant gr\303\240fic en fitxer PNG o JPEG") +esES("Guardando gr\303\241fico en fichero PNG o JPEG") + +T_("Plot has not been saved") +caES("El gr\303\240fic no s'ha desat") +esES("El gr\303\241fico no ha sido guardado") + +T_("File format \"%s\" not found") +caES("Format \"%s\" no trobat") +esES("Formato \"%s\" no encontrado") + diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.upp b/uppsrc/ScatterCtrl/ScatterCtrl.upp new file mode 100644 index 000000000..0e7a64052 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.upp @@ -0,0 +1,17 @@ +description "Scatter control\377"; + +uses + CtrlLib, + plugin\jpg, + ScatterDraw; + +file + ScatterCtrl.cpp, + ScatterCtrl.h, + ScatterCtrl.t, + ScatterCtrl.usc, + ScatterCtrl.iml, + PopUpText.cpp, + PopUpText.h, + src.tpp; + diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.usc b/uppsrc/ScatterCtrl/ScatterCtrl.usc new file mode 100644 index 000000000..fc7ec2855 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrl.usc @@ -0,0 +1,72 @@ +ctrl ScatterCtrl { + group "Extra"; + + GetMinSize() {sz.cx=150; sz.cy = 100; return sz; } + GetStdSize() {sz.cx=300; sz.cy = 200; return sz; } + + Frame SetFrame; + Color SetColor = :White; + Text SetTitle; + Font SetTitleFont; + Color SetTitleColor = :Black; + int SetPlotAreaLeftMargin = 30; + int SetPlotAreaRightMargin = 30; + int SetPlotAreaTopMargin = 30; + int SetPlotAreaBottomMargin = 30; + Color SetPlotAreaColor = :WhiteGray; + Text SetLabelX; + Text SetLabelY; + Text SetLabelY2; + Font SetLabelsFont; + Color SetLabelsColor= :Black; + Color SetAxisColor = :Black; + int SetAxisWidth = 6; + Color SetGridColor = :Color(102,102,102); + int SetGridWidth = 1; + bool ShowHGrid = true; + bool ShowVGrid = true; + bool ShowLegend = true; + int SetLegendWeight = 80; + bool SetFastViewX = false; + bool SetSequentialXAll = false; + + Paint(w) { + r = GetRect(); + w.DrawRect(r, .SetColor); + DrawCtrlFrame(w, r, .SetFrame); + sz = GetSize(); + textsize = GetTextSize(.SetTitle, .SetTitleFont); + if(.SetTitle=="") + textsize.cy = 0; + w.DrawRect(.SetPlotAreaLeftMargin-1, .SetPlotAreaTopMargin - 1 + textsize.cy, sz.cx - (.SetPlotAreaLeftMargin + .SetPlotAreaRightMargin) + 2, - (.SetPlotAreaTopMargin + .SetPlotAreaBottomMargin) + 2 - textsize.cy + sz.cy, :Gray); + aw = 6; + if(.SetAxisWidth >= 6) + aw = .SetAxisWidth; + + w.DrawRect(.SetPlotAreaLeftMargin - int(aw/6), .SetPlotAreaTopMargin + textsize.cy, + - (.SetPlotAreaLeftMargin + .SetPlotAreaRightMargin) + int(aw/6) + sz.cx, + - (.SetPlotAreaTopMargin + .SetPlotAreaBottomMargin) + int(aw/6) - textsize.cy + sz.cy, + .SetAxisColor); + + gx0 = .SetPlotAreaLeftMargin; + gy0 = .SetPlotAreaTopMargin + textsize.cy; + gwidth = sz.cx - (.SetPlotAreaLeftMargin + .SetPlotAreaRightMargin); + gheight = sz.cy - (.SetPlotAreaTopMargin + .SetPlotAreaBottomMargin) - textsize.cy; + + w.DrawRect(gx0, gy0, gwidth, gheight, .SetPlotAreaColor); + w.DrawLine(gx0, gy0 + gheight, gx0 + gwidth*0.25, gy0 + gheight*0.5, 2, :SLtRed); + w.DrawLine(gx0 + gwidth*0.25, gy0 + gheight*0.5, gx0 + gwidth*0.5, gy0 + gheight*0.75, 2, :SLtRed); + w.DrawLine(gx0 + gwidth*0.5, gy0 + gheight*0.75, gx0 + gwidth*0.75, gy0 + gheight*0.25, 2, :SLtRed); + w.DrawLine(gx0 + gwidth*0.75, gy0 + gheight*0.25, gx0 + gwidth, gy0 + gheight*0.5, 2, :SLtRed); + + w.DrawText((sz.cx - textsize.cx)/2, 4, .SetTitle, .SetTitleFont, .SetTitleColor); + lx = GetTextSize(.SetLabelX, .SetLabelsFont); + ly = GetTextSize(.SetLabelY, .SetLabelsFont); + ly2 = GetTextSize(.SetLabelY2, .SetLabelsFont); + + w.DrawText(int((sz.cx - lx.cx)/2), sz.cy - (ly.cy + 2), .SetLabelX, .SetLabelsFont, .SetLabelsColor); + w.DrawText(2, int((sz.cy + textsize.cy + ly.cx)/2), 900, .SetLabelY, .SetLabelsFont, .SetLabelsColor); + w.DrawText(sz.cx - textsize.cy, int((sz.cy + textsize.cy + ly.cx)/2), 900, .SetLabelY2, .SetLabelsFont, .SetLabelsColor); + } +}; + diff --git a/uppsrc/ScatterCtrl/icon.ico b/uppsrc/ScatterCtrl/icon.ico new file mode 100644 index 000000000..4012786aa Binary files /dev/null and b/uppsrc/ScatterCtrl/icon.ico differ diff --git a/uppsrc/ScatterCtrl/init b/uppsrc/ScatterCtrl/init new file mode 100644 index 000000000..8fd31ff34 --- /dev/null +++ b/uppsrc/ScatterCtrl/init @@ -0,0 +1,6 @@ +#ifndef _ScatterCtrl_icpp_init_stub +#define _ScatterCtrl_icpp_init_stub +#include "CtrlLib/init" +#include "plugin\jpg/init" +#include "ScatterDraw/init" +#endif