From 2e743e9c108cfe4fdf3ec714e6cdbd35a092f62c Mon Sep 17 00:00:00 2001 From: koldo Date: Sat, 31 Dec 2016 11:44:24 +0000 Subject: [PATCH] ScatterDraw: Improvements proposed by wqcmaster git-svn-id: svn://ultimatepp.org/upp/trunk@10613 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ScatterDraw/PieDraw.cpp | 14 +++++++------- uppsrc/ScatterDraw/PieDraw.h | 2 +- uppsrc/ScatterDraw/ScatterDraw.cpp | 24 ++++++++++++++++++++++-- uppsrc/ScatterDraw/ScatterDraw.h | 4 +++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/uppsrc/ScatterDraw/PieDraw.cpp b/uppsrc/ScatterDraw/PieDraw.cpp index 1803133e3..74f2d1e01 100644 --- a/uppsrc/ScatterDraw/PieDraw.cpp +++ b/uppsrc/ScatterDraw/PieDraw.cpp @@ -78,9 +78,9 @@ Color PieDraw::GetCatColor(const int& index) const { } void PieDraw::PaintPie(Draw& w, int scale) { - Size sz = GetSize(); + Size sz = scale*GetSize(); - w.DrawRect(scale*sz, backColor); + w.DrawRect(sz, backColor); Size textsize; textsize.cx = 0; @@ -101,7 +101,7 @@ void PieDraw::PaintPie(Draw& w, int scale) { if(vValues.IsEmpty()) return; - int alfa0 = -900; + int alfa0 = -900 + (int)pieAngle; int a0 = 0; double sum = 0; for(int i = 0; i < vValues.GetCount(); i++) @@ -142,7 +142,7 @@ void PieDraw::PaintPie(Draw& w, int scale) { alfa0 += fround(3600.0*vValues[i]/sum); } if(showPercent) { - alfa0 = -900; + alfa0 = -900 + (int)pieAngle; for(int i = 0; i < vValues.GetCount(); i++) { a0 = alfa0; alfa0 += fround(3600.0*vValues[i]/sum); @@ -188,9 +188,9 @@ String PieDraw::GetPercent(double a, double total) { return FormatDouble(p, 1) + '%'; } -Drawing PieDraw::GetDrawing() { - DrawingDraw ddw(3*GetSize()); - PaintPie(ddw, 3); +Drawing PieDraw::GetDrawing(int scale) { + DrawingDraw ddw(scale*GetSize()); + PaintPie(ddw, scale); return ddw; } diff --git a/uppsrc/ScatterDraw/PieDraw.h b/uppsrc/ScatterDraw/PieDraw.h index 3680f82cd..afb56b7dd 100644 --- a/uppsrc/ScatterDraw/PieDraw.h +++ b/uppsrc/ScatterDraw/PieDraw.h @@ -50,7 +50,7 @@ public: Color GetCatColor (const int& index)const; int GetCatCount() const {return vColors.GetCount();} - Drawing GetDrawing(); + Drawing GetDrawing(int scale = 3); Image GetImage(int scale = 1); virtual void Refresh() {}; diff --git a/uppsrc/ScatterDraw/ScatterDraw.cpp b/uppsrc/ScatterDraw/ScatterDraw.cpp index c3b24140e..aa77aeedb 100644 --- a/uppsrc/ScatterDraw/ScatterDraw.cpp +++ b/uppsrc/ScatterDraw/ScatterDraw.cpp @@ -386,6 +386,7 @@ void ScatterDraw::ZoomToFit(bool horizontal, bool vertical, double factor) { } + /* double ScatterDraw::GetXMin() { double minx = -DOUBLE_NULL; @@ -792,6 +793,14 @@ double ScatterDraw::GetValueY(int index, int64 idata) { } } + ScatterDraw &ScatterDraw::SetNoPlot(int index) { + ASSERT(IsValid(index)); + + series[index].seriesPlot = NULL; + return *this; +} + + ScatterDraw &ScatterDraw::PlotStyle(SeriesPlot *data) { int index = series.GetCount() - 1; @@ -1003,6 +1012,18 @@ Color ScatterDraw::GetFillColor(int index) const { return series[index].fillColor; } +ScatterDraw &ScatterDraw::SetMarkBorderWidth(int index, double width) { + ASSERT(IsValid(index)); + series[index].markBorderWidth = width; + Refresh(); + return *this; +} + +double ScatterDraw::GetMarkBorderWidth(int index) { + ASSERT(IsValid(index)); + return series[index].markBorderWidth; +} + ScatterDraw &ScatterDraw::SetMarkWidth(int index, double markWidth) { ASSERT(IsValid(index)); series[index].markWidth = markWidth; @@ -1134,8 +1155,7 @@ void ScatterDraw::RemoveAllSeries() { Refresh(); } -Drawing ScatterDraw::GetDrawing(const Size _size) { - int scale = 3; +Drawing ScatterDraw::GetDrawing(const Size _size, int scale) { Size size = IsNull(_size) ? GetSize() : _size; DrawingDraw ddw(scale*size); diff --git a/uppsrc/ScatterDraw/ScatterDraw.h b/uppsrc/ScatterDraw/ScatterDraw.h index 651f86984..8306fd25e 100644 --- a/uppsrc/ScatterDraw/ScatterDraw.h +++ b/uppsrc/ScatterDraw/ScatterDraw.h @@ -327,6 +327,8 @@ public: double GetValueX(int index, int64 idata); double GetValueY(int index, int64 idata); + ScatterDraw &SetNoPlot(int index); + ScatterDraw &PlotStyle() {return PlotStyle(0);}; template ScatterDraw &PlotStyle() {return PlotStyle(new C());}; @@ -425,7 +427,7 @@ public: ScatterDraw& Id(int index, int id); int GetId(int index); - Drawing GetDrawing(const Size size = Null); + Drawing GetDrawing(const Size size = Null, int scale = 3); Image GetImage(int scale = 2); Image GetImage(const Size &size, int scale = 2);