"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "uppsrc/ScatterDraw/ScatterDraw.h" between
upp-x11-src-13648.tar.gz and upp-x11-src-13659.tar.gz

About: Ultimate++ is a C++ cross-platform rapid application development framework. Stable release.

ScatterDraw.h  (upp-x11-src-13648):ScatterDraw.h  (upp-x11-src-13659)
skipping to change at line 225 skipping to change at line 225
if (!IsNull(seriesP)) if (!IsNull(seriesP))
seriesPlot = SeriesPlot::Create(seriesP); seriesPlot = SeriesPlot::Create(seriesP);
else else
seriesPlot = 0; seriesPlot = 0;
} }
} }
}; };
class ScatterSeries : public Moveable<ScatterSeries>, public ScatterBasic Series { class ScatterSeries : public Moveable<ScatterSeries>, public ScatterBasic Series {
public: public:
ScatterSeries() : userpD(0), owns(false), serializeData(false), p typedef ScatterSeries CLASSNAME;
D(0) {dataS.Init(&data);}
ScatterSeries() : owns(false), serializeData(false) {dataS.Init(&
data);}
void SetDataSource(DataSource *pointsData, bool ownsData = true) { void SetDataSource(DataSource *pointsData, bool ownsData = true) {
DeletePD(); DeletePD();
pD = userpD = pointsData; pD = pointsData;
owns = ownsData; owns = ownsData;
} }
void SetDataSource() {
pD = userpD;
}
void SetDataSource_Internal(bool copy = true) { void SetDataSource_Internal(bool copy = true) {
pD = &dataS; pD = &dataS;
if (copy) if (copy)
CopyInternal(); CopyInternal();
} }
DataSource &GetDataSource() {return *pD;} DataSource &Data() {
inline DataSource *PointsData() { return *(~pD);}
ASSERT_(!pD || !pD->IsDeleted(), "DataSource in ScatterCt const DataSource &Data() const {return *(~pD);}
rl/Draw has been deleted.\nIt has been probably declared in a function."); bool IsDeleted() const {return ~
return pD; pD == 0;}
} virtual ~ScatterSeries() {DeletePD
~ScatterSeries() {DeletePD();} ();}
void SerializeData(bool ser = true) {serializeData = ser;} void SerializeData(bool ser = true) {serializeData = ser;}
void SerializeFormat(bool ser = false) {serializeFormat = ser;} void SerializeFormat(bool ser = false) {serializeFormat = ser;}
void Xmlize(XmlIO& xio) { void Xmlize(XmlIO& xio) {XmlizeBy
XmlizeByJsonize(xio, *this); Jsonize(xio, *this);}
}
void Jsonize(JsonIO& json) { void Jsonize(JsonIO& json) {
ScatterBasicSeries::Jsonize(json); ScatterBasicSeries::Jsonize(json);
if (json.IsStoring() && userpD) if (json.IsStoring() && pD)
CopyInternal(); CopyInternal();
json("data", data); json("data", data);
if (json.IsLoading()) { if (json.IsLoading()) {
if (!data.IsEmpty()) { if (!data.IsEmpty()) {
pD = &dataS; pD = &dataS;
serializeData = true; serializeData = true;
} }
} }
} }
void Serialize(Stream& s) { void Serialize(Stream& s) {
ScatterBasicSeries::Serialize(s); ScatterBasicSeries::Serialize(s);
if (s.IsStoring() && userpD) if (s.IsStoring() && pD)
CopyInternal(); CopyInternal();
s % data; s % data;
if (s.IsLoading()) { if (s.IsLoading()) {
if (!data.IsEmpty()) { if (!data.IsEmpty()) {
pD = &dataS; pD = &dataS;
serializeData = true; serializeData = true;
} }
} }
} }
private: private:
DataSource *userpD; Ptr<DataSource> pD;
bool owns; bool owns;
Vector<Pointf> data; Vector<Pointf> data;
VectorPointf dataS; VectorPointf dataS;
bool serializeData, serializeFormat; bool serializeData, serializeFormat;
DataSource *pD;
void CopyInternal() { void CopyInternal() {
int64 sz = userpD->GetCount(); int64 sz = pD->GetCount();
data.SetCount(int(sz)); data.SetCount(int(sz));
for (int64 i = 0; i < sz; ++i) { for (int64 i = 0; i < sz; ++i) {
data[int(i)].x = userpD->x(i); data[int(i)].x = pD->x(i);
data[int(i)].y = userpD->y(i); data[int(i)].y = pD->y(i);
} }
} }
void DeletePD() { void DeletePD() {
if(userpD && owns) { if(pD && owns) {
delete userpD; delete pD;
userpD = 0; pD = 0;
} }
} }
}; };
static Color GetNewColor(int index, int version = 1); static Color GetNewColor(int index, int version = 1);
static String GetNewDash(int index); static String GetNewDash(int index);
static MarkPlot *GetNewMarkPlot(int index); static MarkPlot *GetNewMarkPlot(int index);
void WhenPaint(Painter &w) {WhenPainter(w);} void WhenPaint(Painter &w) {WhenPainter(w);}
void WhenPaint(Draw &w) {WhenDraw(w);} void WhenPaint(Draw &w) {WhenDraw(w);}
skipping to change at line 536 skipping to change at line 530
template <class Y> template <class Y>
ScatterDraw &AddSeries(Vector<Y> &yData, double x0, double deltaX) {return _AddSeries(new VectorY<Y>(yData, x0, deltaX));} ScatterDraw &AddSeries(Vector<Y> &yData, double x0, double deltaX) {return _AddSeries(new VectorY<Y>(yData, x0, deltaX));}
template <class Y> template <class Y>
ScatterDraw &AddSeries(Upp::Array<Y> &yData, double x0, double deltaX) { return _AddSeries(new ArrayY<Y>(yData, x0, deltaX));} ScatterDraw &AddSeries(Upp::Array<Y> &yData, double x0, double deltaX) { return _AddSeries(new ArrayY<Y>(yData, x0, deltaX));}
template <class X, class Y> template <class X, class Y>
ScatterDraw &AddSeries(VectorMap<X, Y> &data) {return _AddSeries(new Ve ctorMapXY<X, Y>(data));} ScatterDraw &AddSeries(VectorMap<X, Y> &data) {return _AddSeries(new Ve ctorMapXY<X, Y>(data));}
template <class X, class Y> template <class X, class Y>
ScatterDraw &AddSeries(ArrayMap<X, Y> &data) {return _AddSeries(new Ar rayMapXY<X, Y>(data));} ScatterDraw &AddSeries(ArrayMap<X, Y> &data) {return _AddSeries(new Ar rayMapXY<X, Y>(data));}
DataSource &GetSeries(int index); DataSource &GetDataSource(int index) {ASSERT(IsValid(index));ASSERT(!s
eries[index].IsDeleted()); return series[index].Data();}
bool IsDeletedDataSource(int index) {return series[index].IsDeleted()
;}
ScatterDraw &InsertSeries(int index, double *yData, int numData, double x 0 = 0, double deltaX = 1); ScatterDraw &InsertSeries(int index, double *yData, int numData, double x 0 = 0, double deltaX = 1);
ScatterDraw &InsertSeries(int index, double *xData, double *yData, int nu mData); ScatterDraw &InsertSeries(int index, double *xData, double *yData, int nu mData);
ScatterDraw &InsertSeries(int index, Vector<double> &xData, Vector<double > &yData); ScatterDraw &InsertSeries(int index, Vector<double> &xData, Vector<double > &yData);
ScatterDraw &InsertSeries(int index, Upp::Array<double> &xData, Upp::Arra y<double> &yData); ScatterDraw &InsertSeries(int index, Upp::Array<double> &xData, Upp::Arra y<double> &yData);
ScatterDraw &InsertSeries(int index, Vector<Pointf> &points); ScatterDraw &InsertSeries(int index, Vector<Pointf> &points);
ScatterDraw &InsertSeries(int index, Upp::Array<Pointf> &points); ScatterDraw &InsertSeries(int index, Upp::Array<Pointf> &points);
ScatterDraw &InsertSeries(int index, double (*function)(double)); ScatterDraw &InsertSeries(int index, double (*function)(double));
ScatterDraw &InsertSeries(int index, Pointf (*function)(double), int np, double from = 0, double to = 1); ScatterDraw &InsertSeries(int index, Pointf (*function)(double), int np, double from = 0, double to = 1);
ScatterDraw &InsertSeries(int index, PlotExplicFunc &function); ScatterDraw &InsertSeries(int index, PlotExplicFunc &function);
skipping to change at line 655 skipping to change at line 650
const String GetDash(int index); const String GetDash(int index);
ScatterDraw &Fill(Color color = Null); ScatterDraw &Fill(Color color = Null);
ScatterDraw &MarkColor(Color color = Null); ScatterDraw &MarkColor(Color color = Null);
ScatterDraw &MarkBorderColor(Color color = Null); ScatterDraw &MarkBorderColor(Color color = Null);
ScatterDraw &MarkWidth(double markWidth = 8); ScatterDraw &MarkWidth(double markWidth = 8);
ScatterDraw &MarkBorderWidth(double markWidth = 1); ScatterDraw &MarkBorderWidth(double markWidth = 1);
ScatterDraw &Hide() {series[series.GetCount() - 1].opacity = 0; return *t his;} ScatterDraw &Hide() {series[series.GetCount() - 1].opacity = 0; return *t his;}
ScatterDraw &ShowSeriesLegend(int index, bool show = false); ScatterDraw &ShowSeriesLegend(int index, bool show = false);
ScatterDraw &ShowSeriesLegend(bool show = false) {return ShowSerie sLegend(series.GetCount() - 1, show);} ScatterDraw &ShowSeriesLegend(bool show = false) {return ShowSerie sLegend(series.GetCount() - 1, show);}
bool GetShowSeriesLegend(int index) { return series[index].showLegend;} bool GetShowSeriesLegend(int index) { ASSERT(IsValid(index));ASSERT(!series[index].IsDeleted());return series[index].s howLegend;}
ScatterDraw &Opacity(double opacity = 1) {series[series.GetCount() - 1].o pacity = opacity; return *this;} ScatterDraw &Opacity(double opacity = 1) {series[series.GetCount() - 1].o pacity = opacity; return *this;}
ScatterDraw &Legend(const String legend); ScatterDraw &Legend(const String legend);
ScatterDraw &Legend(int index, const String legend); ScatterDraw &Legend(int index, const String legend);
const String &GetLegend(int index); const String &GetLegend(int index);
ScatterDraw &Units(const String unitsY, const String unitsX = ""); ScatterDraw &Units(const String unitsY, const String unitsX = "");
ScatterDraw &Units(int index, const String unitsY, const String unitsX = ""); ScatterDraw &Units(int index, const String unitsY, const String unitsX = "");
const String GetUnitsX(int index); const String GetUnitsX(int index);
const String GetUnitsY(int index); const String GetUnitsY(int index);
skipping to change at line 760 skipping to change at line 755
double GetMinX() {return xMin;} double GetMinX() {return xMin;}
int GetPlotWidth() {return plotW;} int GetPlotWidth() {return plotW;}
int GetPlotHeight() {return plotH;} int GetPlotHeight() {return plotH;}
double GetPosX(double x) {return plotW*(x - xMin)/xRange;} double GetPosX(double x) {return plotW*(x - xMin)/xRange;}
double GetSizeX(double cx) {return plotW*cx/xRange;} double GetSizeX(double cx) {return plotW*cx/xRange;}
double GetPosY(double y) {return plotH - plotH*(y - yMin)/yRange;} double GetPosY(double y) {return plotH - plotH*(y - yMin)/yRange;}
double GetSizeY(double cy) {return plotH*cy/yRange;} double GetSizeY(double cy) {return plotH*cy/yRange;}
double GetPosY2(double y) {return plotH - plotH*(y - yMin2)/yRange2 ;} double GetPosY2(double y) {return plotH - plotH*(y - yMin2)/yRange2 ;}
double GetSizeY2(double cy) {return plotH*cy/yRange2;} double GetSizeY2(double cy) {return plotH*cy/yRange2;}
double GetRealPosX(int x) {return xMin + (x - hPlotLeft*plotScaleX) double GetRealPosX(double x) {return xMin + (x - hPlotLeft*plotScaleX)
*xRange/plotW;} *xRange/plotW;}
double GetRealPosY(int y) {return yMin + yRange - (y - plotScaleY*v double GetRealPosY(double y) {return yMin + yRange - (y - plotScaleY*v
PlotTop - titleHeight)*yRange/plotH;} PlotTop - titleHeight)*yRange/plotH;}
double GetRealPosY2(int y) {return yMin2 + yRange2 - (y - plotScaleY double GetRealPosY2(double y) {return yMin2 + yRange2 - (y - plotScaleY
*vPlotTop - titleHeight)*yRange2/plotH;} *vPlotTop - titleHeight)*yRange2/plotH;}
double GetScatterPosX(double x) {return (x - xMin)*plotW/xRange + hPlotLe
ft*plotScaleX;}
double GetScatterPosY(double y) {return (yMin + yRange - y)*plotH/yRange
+ plotScaleY*vPlotTop + titleHeight;}
double GetScatterPosY2(double y){return (yMin2 + yRange2 - y)*plotH/yRang
e2 + plotScaleY*vPlotTop + titleHeight;}
double GetScatterDistance(double dx, double dy) {return sqrt(sqr(GetScat
terPosX(dx)) + sqr(GetScatterPosY(dy)));}
double GetScatterDistance2(double dx, double dy) {return sqrt(sqr(GetScat
terPosX(dx)) + sqr(GetScatterPosY2(dy)));}
double GetPixelThickX() {return xRange/plotW;} double GetPixelThickX() {return xRange/plotW;}
double GetPixelThickY() {return yRange/plotH;} double GetPixelThickY() {return yRange/plotH;}
ScatterDraw& SetMouseHandling(bool valx = true, bool valy = false); ScatterDraw& SetMouseHandling(bool valx = true, bool valy = false);
ScatterDraw& SetMouseHandlingLinked(bool valx = true, bool valy = false); ScatterDraw& SetMouseHandlingLinked(bool valx = true, bool valy = false);
bool GetMouseHandlingX() {return mouseHandlingX;} bool GetMouseHandlingX() {return mouseHandlingX;}
bool GetMouseHandlingY() {return mouseHandlingY;} bool GetMouseHandlingY() {return mouseHandlingY;}
ScatterDraw& AddSurf(DataSourceSurf &surf); ScatterDraw& AddSurf(DataSourceSurf &surf);
skipping to change at line 820 skipping to change at line 821
Color& GetRainbowPaletteTextColor() { return rainbowPaletteTextColor;} Color& GetRainbowPaletteTextColor() { return rainbowPaletteTextColor;}
ScatterDraw &AddLabelSeries(Vector<String> &labels, int dx = 0, int dy = 0, Font font = StdFont(), ScatterDraw &AddLabelSeries(Vector<String> &labels, int dx = 0, int dy = 0, Font font = StdFont(),
Alignment align = ALIGN_CENTER, Color col or = Black()) { Alignment align = ALIGN_CENTER, Color col or = Black()) {
int index = series.GetCount() - 1; int index = series.GetCount() - 1;
return AddLabelSeries(index, labels, dx, dy, font, align, color); return AddLabelSeries(index, labels, dx, dy, font, align, color);
} }
ScatterDraw& AddLabelSeries(int index, Vector<String> &labels, int dx = 0 , int dy = 0, Font font = StdFont(), ScatterDraw& AddLabelSeries(int index, Vector<String> &labels, int dx = 0 , int dy = 0, Font font = StdFont(),
Alignment align = ALIGN_CENTER, Color col or = Black()) { Alignment align = ALIGN_CENTER, Color col or = Black()) {
ASSERT(IsValid(index));
ASSERT(!series[index].IsDeleted());
series[index].labels = &labels; series[index].labels = &labels;
series[index].labelsDx = dx; series[index].labelsDx = dx;
series[index].labelsDy = dy; series[index].labelsDy = dy;
series[index].labelsFont = font; series[index].labelsFont = font;
series[index].labelsAlign = align; series[index].labelsAlign = align;
series[index].labelsColor = color; series[index].labelsColor = color;
return *this; return *this;
} }
ScatterDraw& SetDataSource_Internal(bool copy = true) { ScatterDraw& SetDataSource_Internal(bool copy = true) {
for (int i = 0; i < series.GetCount(); ++i) for (int i = 0; i < series.GetCount(); ++i) {
series[i].SetDataSource_Internal(copy); ScatterSeries &serie = series[i];
return *this; if (serie.IsDeleted())
} continue;
ScatterDraw& SetDataSource() { serie.SetDataSource_Internal(copy);
for (int i = 0; i < series.GetCount(); ++i) }
series[i].SetDataSource();
return *this; return *this;
} }
ScatterDraw& SerializeData(bool ser = true) { ScatterDraw& SerializeData(bool ser = true) {
for (int i = 0; i < series.GetCount(); ++i) for (int i = 0; i < series.GetCount(); ++i) {
series[i].SerializeData(ser); ScatterSeries &serie = series[i];
if (serie.IsDeleted())
continue;
serie.SerializeData(ser);
}
return *this; return *this;
} }
ScatterDraw& SerializeFormat(bool ser = true) { ScatterDraw& SerializeFormat(bool ser = true) {
for (int i = 0; i < series.GetCount(); ++i) for (int i = 0; i < series.GetCount(); ++i) {
series[i].SerializeFormat(ser); ScatterSeries &serie = series[i];
if (serie.IsDeleted())
continue;
serie.SerializeFormat(ser);
}
serializeFormat = ser; serializeFormat = ser;
return *this; return *this;
} }
template <class T> template <class T>
void Ize(T& io) { void Ize(T& io) {
if (serializeFormat) { if (serializeFormat) {
int intlegendAnchor = 0, intrainbowAnchor = 0, intsurfRai nbow = 0, intsurfUnitsPos = 0, intsurfLegendPos = 0; int intlegendAnchor = 0, intrainbowAnchor = 0, intsurfRai nbow = 0, intsurfUnitsPos = 0, intsurfLegendPos = 0;
if (io.IsStoring()) { if (io.IsStoring()) {
intlegendAnchor = legendAnchor; intlegendAnchor = legendAnchor;
skipping to change at line 1200 skipping to change at line 1211
int NumSeriesLegend() const; int NumSeriesLegend() const;
int plotW, plotH; int plotW, plotH;
bool labelsChanged; bool labelsChanged;
bool stacked; bool stacked;
bool serializeFormat; bool serializeFormat;
}; };
template <class T> template <class T>
void ScatterDraw::SetDrawing(T& w, bool ctrl) void ScatterDraw::SetDrawing(T& w, bool ctrl) {
{
w.DrawRect(size, graphColor); w.DrawRect(size, graphColor);
titleHeight = !title.IsEmpty() ? fround(min(plotScaleX, plotScaleY)*title Font.GetHeight()) : 0; titleHeight = !title.IsEmpty() ? fround(min(plotScaleX, plotScaleY)*title Font.GetHeight()) : 0;
plotW = size.cx - fround((hPlotLeft + hPlotRight)*plotScaleX); plotW = size.cx - fround((hPlotLeft + hPlotRight)*plotScaleX);
plotH = size.cy - fround((vPlotTop + vPlotBottom)*plotScaleY) - titleHeig ht; plotH = size.cy - fround((vPlotTop + vPlotBottom)*plotScaleY) - titleHeig ht;
Plot(w); Plot(w);
if (!ctrl) { if (!ctrl) {
skipping to change at line 1260 skipping to change at line 1270
Upp::Font fontY2 = fontY; Upp::Font fontY2 = fontY;
fontY2.Italic(); fontY2.Italic();
if (labelsChanged) { if (labelsChanged) {
xLabel = xLabel_base; xLabel = xLabel_base;
yLabel = yLabel_base; yLabel = yLabel_base;
yLabel2 = yLabel2_base; yLabel2 = yLabel2_base;
String yLabelLegends, yLabelLegends2; String yLabelLegends, yLabelLegends2;
Upp::Index<String> xUnits, yUnits, yUnits2; Upp::Index<String> xUnits, yUnits, yUnits2;
for (int i = 0; i < series.GetCount(); ++i) { for (int i = 0; i < series.GetCount(); ++i) {
ScatterSeries &serie = series[i]; const ScatterSeries &serie = series[i];
if (serie.IsDeleted())
continue;
if (serie.primaryY) { if (serie.primaryY) {
if (yLabel.IsEmpty()) { if (yLabel.IsEmpty()) {
if (!yLabelLegends.IsEmpty()) if (!yLabelLegends.IsEmpty())
yLabelLegends << ";"; yLabelLegends << ";";
yLabelLegends << serie.legend; yLabelLegends << serie.legend;
} }
} else { } else {
if (yLabel2.IsEmpty()) { if (yLabel2.IsEmpty()) {
if (!yLabelLegends2.IsEmpty()) if (!yLabelLegends2.IsEmpty())
yLabelLegends2 << ";"; yLabelLegends2 << ";";
skipping to change at line 1516 skipping to change at line 1528
} }
} /*else { } /*else {
double y0 = -plotH*yMinUnit/r + plotH; double y0 = -plotH*yMinUnit/r + plotH;
for(double i = 0; yMinUnit + i*yMajorUnit < yRange; i++) { for(double i = 0; yMinUnit + i*yMajorUnit < yRange; i++) {
double reticleY = y0 + i*r*yRange/yMajorUnit; double reticleY = y0 + i*r*yRange/yMajorUnit;
DrawCircleOpa(w, plotW/2, plotH/2, reticleY, 1, 1 , gridWidth, gridColor, gridDash); DrawCircleOpa(w, plotW/2, plotH/2, reticleY, 1, 1 , gridWidth, gridColor, gridDash);
} }
}*/ }*/
} }
if (!series.IsEmpty()) { try {
try { for (int j = 0; j < series.GetCount(); j++) {
for (int j = 0; j < series.GetCount(); j++) { ScatterSeries &serie = series[j];
if (series[j].opacity == 0 || (!series[j].seriesP if (serie.IsDeleted())
lot && !series[j].markPlot) || continue;
(!series[j].PointsData()->IsExplicit() && DataSource &data = serie.Data();
series[j].PointsData()->GetCount() == 0)) if (serie.opacity == 0 || (!serie.seriesPlot && !serie.ma
continue; rkPlot) ||
Vector<Pointf> points; (!data.IsExplicit() && data.GetCount() == 0))
if (series[j].PointsData()->IsParam()) { continue;
double xmin = 0; Vector<Pointf> points;
double xmax = double(series[j].PointsData if (data.IsParam()) {
()->GetCount()); double xmin = 0;
for (double x = xmin; x <= xmax; x++) { double xmax = double(data.GetCount());
double xx = series[j].PointsData( for (double x = xmin; x <= xmax; x++) {
)->x(x); double xx = data.x(x);
double yy = series[j].PointsData( double yy = data.y(x);
)->y(x); if (IsNull(xx) || IsNull(yy))
if (IsNull(xx) || IsNull(yy)) points << Null;
points << Null; else {
else { int ix = fround(plotW*(xx - xMin)
int ix = fround(plotW*(xx /xRange);
- xMin)/xRange); int iy;
int iy; if (serie.primaryY)
if (series[j].primaryY) iy = fround(plotH*(yy - y
iy = fround(plotH Min)/yRange);
*(yy - yMin)/yRange); else
else iy = fround(plotH*(yy - y
iy = fround(plotH Min2)/yRange2);
*(yy - yMin2)/yRange2); points << Point(ix, plotH - iy);
points << Point(ix, plotH }
- iy); }
} else if (data.IsExplicit()) {
double xmin = xMin - 1;
double xmax = xMin + xRange + 1;
double dx = double(xmax - xmin)/plotW;
for (double xx = xmin; xx < xmax; xx += dx) {
double yy = data.f(xx);
if (IsNull(yy))
points << Null;
else {
int ix = fround(plotW*(xx - xMin)
/xRange);
int iy;
if (serie.primaryY)
iy = fround(plotH*(yy - y
Min)/yRange);
else
iy = fround(plotH*(yy - y
Min2)/yRange2);
points << Point(ix, plotH - iy);
}
}
} else {
int64 imin, imax;
if (serie.sequential) {
imin = imax = Null;
for (int64 i = 0; i < data.GetCount(); ++
i) {
double xx = data.x(i);
if (!IsNull(xx)) {
if (IsNull(imin)) {
if (xx >= xMin)
imin = i;
}
if (IsNull(imax)) {
if (xx >= xMin +
xRange)
imax = i;
}
} }
} }
} else if (series[j].PointsData()->IsExplicit()) if (IsNull(imin))
{ imin = 0;
double xmin = xMin - 1; if (IsNull(imax))
double xmax = xMin + xRange + 1; imax = data.GetCount() - 1;
double dx = double(xmax - xmin)/plotW; } else {
for (double xx = xmin; xx < xmax; xx += d imin = 0;
x) { imax = data.GetCount() - 1;
double yy = series[j].PointsData( }
)->f(xx); double dxpix = 0;
if (IsNull(yy)) if (fastViewX)
dxpix = (data.x(imax) - data.x(imin))/plo
tW;
int npix = 1;
for (int64 i = imin; i <= imax; ) {
double xx, yy;
if (fastViewX && dxpix < 1) {
yy = data.y(i);
if (IsNull(yy)) {
++i;
continue;
}
int64 ii;
double maxv = data.x(imin) + dxpi
x*npix;
double maxY = yy, minY = yy;
for (ii = 1; i + ii < imax && dat
a.x(i + ii) < maxv; ++ii) {
double dd = data.y(i + ii
);
if (IsNull(dd))
continue;
maxY = max(maxY, dd);
minY = min(minY, dd);
}
xx = data.x(i);
if (IsNull(xx)) {
++i;
continue;
}
i += ii;
npix++;
int ix = fround(plotW*(xx - xMin)
/xRange);
int iMax, iMin;
if (serie.primaryY) {
iMax = fround(plotH*(maxY
- yMin)/yRange);
iMin = fround(plotH*(minY
- yMin)/yRange);
} else {
iMax = fround(plotH*(maxY
- yMin2)/yRange2);
iMin = fround(plotH*(minY
- yMin2)/yRange2);
}
points << Point(ix, plotH - iMax)
;
if (iMax != iMin)
points << Point(ix, plotH
- iMin);
} else {
xx = data.x(i);
yy = data.y(i);
++i;
if (IsNull(xx) || IsNull(yy))
points << Null; points << Null;
else { else {
int ix = fround(plotW*(xx - xMin)/xRange); int ix = fround(plotW*(xx - xMin)/xRange);
int iy; int iy;
if (series[j].primaryY) if (serie.primaryY)
iy = fround(plotH *(yy - yMin)/yRange); iy = fround(plotH *(yy - yMin)/yRange);
else else
iy = fround(plotH *(yy - yMin2)/yRange2); iy = fround(plotH *(yy - yMin2)/yRange2);
points << Point(ix, plotH - iy); points << Point(ix, plotH - iy);
} }
} }
}
}
if (!points.IsEmpty() && serie.seriesPlot && serie.thickn
ess > 0)
serie.seriesPlot->Paint(w, points, plotScaleAvg,
serie.opacity,
serie.thickness, serie.color,
serie.dash, plotAreaColor, serie.fillColor, plotW/xRange, plotH/yRange,
plotH*(1 + yMin/yRange), serie.barWidth,
serie.isClosed);
if (serie.markWidth >= 1 && serie.markPlot) {
if (!serie.markPlot->IsMultiPlot()) {
for (int i = 0; i < points.GetCount(); i+
+)
serie.markPlot->Paint(w, plotScal
eAvg, points[i],
serie.markWidth, serie.ma
rkColor,
serie.markBorderWidth, se
rie.markBorderColor);
} else { } else {
int64 imin, imax; for (int64 i = 0; i < data.GetCount(); ++
if (series[j].sequential) { i) {
imin = imax = Null; int ix = fround(plotW*(data.x(i)
for (int64 i = 0; i < series[j].P - xMin)/xRange);
ointsData()->GetCount(); ++i) { int iy;
double xx = series[j].Poi if (serie.primaryY)
ntsData()->x(i); iy = plotH - fround(plotH
if (!IsNull(xx)) { *(data.y(i) - yMin)/yRange);
if (IsNull(imin)) else
{ iy = plotH - fround(plotH
if (xx >= *(data.y(i) - yMin2)/yRange2);
xMin) Vector<int> dataX, dataY;
i Vector<double> dataFixed;
min = i; for (int ii = 0; ii < data.Getznx
} Count(i); ++ii)
if (IsNull(imax)) dataX << fround(plotW*(da
{ ta.znx(ii, i) - xMin)/xRange);
if (xx >= if (serie.primaryY) {
xMin + xRange) for (int ii = 0; ii < dat
i a.GetznyCount(i); ++ii)
max = i; dataY << (plotH -
} fround(plotH*(data.zny(ii, i) - yMin)/yRange));
}
}
if (IsNull(imin))
imin = 0;
if (IsNull(imax))
imax = series[j].PointsData()
->GetCount() - 1;
} else {
imin = 0;
imax = series[j].PointsData()->Ge
tCount() - 1;
}
double dxpix = 0;
if (fastViewX)
dxpix = (series[j].PointsData()->
x(imax) - series[j].PointsData()->x(imin))/plotW;
int npix = 1;
for (int64 i = imin; i <= imax; ) {
double xx, yy;
if (fastViewX && dxpix < 1) {
yy = series[j].PointsData
()->y(i);
if (IsNull(yy)) {
++i;
continue;
}
int64 ii;
double maxv = series[j].P
ointsData()->x(imin) + dxpix*npix;
double maxY = yy, minY =
yy;
for (ii = 1; i + ii < ima
x && series[j].PointsData()->x(i + ii) < maxv; ++ii) {
double dd = serie
s[j].PointsData()->y(i + ii);
if (IsNull(dd))
continue;
maxY = max(maxY,
dd);
minY = min(minY,
dd);
}
xx = series[j].PointsData
()->x(i);
if (IsNull(xx)) {
++i;
continue;
}
i += ii;
npix++;
int ix = fround(plotW*(xx
- xMin)/xRange);
int iMax, iMin;
if (series[j].primaryY) {
iMax = fround(plo
tH*(maxY - yMin)/yRange);
iMin = fround(plo
tH*(minY - yMin)/yRange);
} else {
iMax = fround(plo
tH*(maxY - yMin2)/yRange2);
iMin = fround(plo
tH*(minY - yMin2)/yRange2);
}
points << Point(ix, plotH
- iMax);
if (iMax != iMin)
points << Point(i
x, plotH - iMin);
} else { } else {
xx = series[j].PointsData for (int ii = 0; ii < dat
()->x(i); a.GetznyCount(i); ++ii)
yy = series[j].PointsData dataY << (plotH -
()->y(i); fround(plotH*(data.zny(ii, i) - yMin2)/yRange2));
++i;
if (IsNull(xx) || IsNull(
yy))
points << Null;
else {
int ix = fround(p
lotW*(xx - xMin)/xRange);
int iy;
if (series[j].pri
maryY)
iy = frou
nd(plotH*(yy - yMin)/yRange);
else
iy = frou
nd(plotH*(yy - yMin2)/yRange2);
points << Point(i
x, plotH - iy);
}
} }
for (int ii = 0; ii < data.GetznF
ixedCount(); ++ii)
dataFixed << data.znFixed
(ii, i);
serie.markPlot->Paint(w, plotScal
eAvg, ix, iy, dataX, dataY, dataFixed,
serie.markWidth, serie.ma
rkColor,
serie.markBorderWidth, se
rie.markBorderColor);
} }
} }
if (!points.IsEmpty() && series[j].seriesPlot && }
series[j].thickness > 0) if (serie.labels) {
series[j].seriesPlot->Paint(w, points, pl int dx = int(serie.labelsDx*plotScaleX);
otScaleAvg, series[j].opacity, int dy = int(serie.labelsDy*plotScaleY);
Font fnt = serie.labelsFont;
series[j].thickness, series[j].color, fnt.Height(int(fnt.GetHeight()*min(plotScaleX, pl
otScaleY)));
series[j].dash, plotAreaColor, series[j].fillColor, plotW/xRange, for (int i = 0; i < points.GetCount() && i < seri
plotH/yRange, e.labels->GetCount(); i++) {
String txt = (*(serie.labels))[i];
plotH*(1 + yMin/yRange), series[j].barWidth, Size sz = GetTextSizeSpace(txt, fnt);
int ddy = static_cast<int>(-sz.cy/2.);
series[j].isClosed); int ddx;
switch (serie.labelsAlign) {
if (series[j].markWidth >= 1 && series[j].markPlo case ALIGN_LEFT: ddx = 0;
t) { break;
if (!series[j].markPlot->IsMultiPlot()) { case ALIGN_CENTER: ddx = -sz.cx/2; b
for (int i = 0; i < points.GetCou reak;
nt(); i++) case ALIGN_RIGHT: ddx = -sz.cx; b
series[j].markPlot->Paint reak;
(w, plotScaleAvg, points[i], default: ddx = 0;
series[j].markWid // to avoid warning
th, series[j].markColor,
series[j].markBor
derWidth, series[j].markBorderColor);
} else {
for (int64 i = 0; i < series[j].P
ointsData()->GetCount(); ++i) {
int ix = fround(plotW*(se
ries[j].PointsData()->x(i) - xMin)/xRange);
int iy;
if (series[j].primaryY)
iy = plotH - frou
nd(plotH*(series[j].PointsData()->y(i) - yMin)/yRange);
else
iy = plotH - frou
nd(plotH*(series[j].PointsData()->y(i) - yMin2)/yRange2);
Vector<int> dataX, dataY;
Vector<double> dataFixed;
for (int ii = 0; ii < ser
ies[j].PointsData()->GetznxCount(i); ++ii)
dataX << fround(p
lotW*(series[j].PointsData()->znx(ii, i) - xMin)/xRange);
if (series[j].primaryY) {
for (int ii = 0;
ii < series[j].PointsData()->GetznyCount(i); ++ii)
dataY <<
(plotH - fround(plotH*(series[j].PointsData()->zny(ii, i) - yMin)/yRange));
} else {
for (int ii = 0;
ii < series[j].PointsData()->GetznyCount(i); ++ii)
dataY <<
(plotH - fround(plotH*(series[j].PointsData()->zny(ii, i) - yMin2)/yRange2));
}
for (int ii = 0; ii < ser
ies[j].PointsData()->GetznFixedCount(); ++ii)
dataFixed << seri
es[j].PointsData()->znFixed(ii, i);
series[j].markPlot->Paint
(w, plotScaleAvg, ix, iy, dataX, dataY, dataFixed,
series[j].markWid
th, series[j].markColor,
series[j].markBor
derWidth, series[j].markBorderColor);
}
}
}
if (series[j].labels) {
int dx = int(series[j].labelsDx*plotScale
X);
int dy = int(series[j].labelsDy*plotScale
Y);
Font fnt = series[j].labelsFont;
fnt.Height(int(fnt.GetHeight()*min(plotSc
aleX, plotScaleY)));
for (int i = 0; i < points.GetCount() &&
i < series[j].labels->GetCount(); i++) {
String txt = (*(series[j].labels)
)[i];
Size sz = GetTextSizeSpace(txt, f
nt);
int ddy = static_cast<int>(-sz.cy
/2.);
int ddx;
switch (series[j].labelsAlign) {
case ALIGN_LEFT: ddx = 0;
break;
case ALIGN_CENTER: ddx = -sz
.cx/2; break;
case ALIGN_RIGHT: ddx = -sz
.cx; break;
default: d
dx = 0; // to avoid warning
}
double x = points[i].x + dx + ddx
;
double y = points[i].y + dy + ddy
;
DrawText(w, x, y, 0, txt, fnt, se
ries[j].labelsColor);
} }
double x = points[i].x + dx + ddx;
double y = points[i].y + dy + ddy;
DrawText(w, x, y, 0, txt, fnt, serie.labe
lsColor);
} }
} }
} catch(ValueTypeError error) {
ASSERT_(true, error);
} }
} catch(ValueTypeError error) {
ASSERT_(true, error);
} }
WhenPaint(w); WhenPaint(w);
ClipEnd(w); ClipEnd(w);
w.End(); w.End();
} }
#endif #endif
 End of changes. 33 change blocks. 
306 lines changed or deleted 296 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)