"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "uppsrc/ScatterDraw/Legend.cpp" 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.

Legend.cpp  (upp-x11-src-13648):Legend.cpp  (upp-x11-src-13659)
#include "ScatterDraw.h" #include "ScatterDraw.h"
int ScatterDraw::NumSeriesLegend() const { int ScatterDraw::NumSeriesLegend() const {
int num = 0; int num = 0;
for (int i = 0; i < series.GetCount(); ++i) { for (int i = 0; i < series.GetCount(); ++i) {
if (series[i].showLegend) const ScatterSeries &serie = series[i];
if (serie.IsDeleted() || serie.opacity == 0)
continue;
if (serie.showLegend)
num++; num++;
} }
return num; return num;
} }
void ScatterDraw::DrawLegend(Draw& w) const { void ScatterDraw::DrawLegend(Draw& w) const {
if (series.IsEmpty()) if (series.IsEmpty())
return; return;
int nlab = NumSeriesLegend(); int nlab = NumSeriesLegend();
if (nlab == 0) if (nlab == 0)
skipping to change at line 35 skipping to change at line 38
Upp::Font boldFont = scaledFont; Upp::Font boldFont = scaledFont;
boldFont.Bold(); boldFont.Bold();
Upp::Font italic = scaledFont; Upp::Font italic = scaledFont;
italic.Italic(); italic.Italic();
int xWidth = boldFont.GetWidth('X'); int xWidth = boldFont.GetWidth('X');
int lineLen = 4*xWidth; int lineLen = 4*xWidth;
Vector<String> legends; Vector<String> legends;
int legendWidth = 0; int legendWidth = 0;
for (int i = 0; i < series.GetCount(); ++i) { for (int i = 0; i < series.GetCount(); ++i) {
if (series[i].showLegend) { const ScatterSeries &serie = series[i];
String legend = series[i].legend; if (serie.IsDeleted() || serie.opacity == 0)
if (legend.Find('[') < 0 && !series[i].unitsY.IsEmpty()) continue;
legend += " [" + series[i].unitsY + "]"; if (serie.showLegend) {
String legend = serie.legend;
if (legend.Find('[') < 0 && !serie.unitsY.IsEmpty())
legend += " [" + serie.unitsY + "]";
legends.Add(legend); legends.Add(legend);
legendWidth = max<int>(legendWidth, GetTextSizeSpace(lege nd, boldFont).cx); legendWidth = max<int>(legendWidth, GetTextSizeSpace(lege nd, boldFont).cx);
} }
} }
legendWidth += lineLen + 3*xWidth; legendWidth += lineLen + 3*xWidth;
int rowIncSign; int rowIncSign;
int plotWLeg, plotHLeg; int plotWLeg, plotHLeg;
int nlr; int nlr;
int topClip; int topClip;
skipping to change at line 108 skipping to change at line 114
w.Clip(int(plotScaleX*hPlotLeft), topClip, plotWLeg, plotHLeg); w.Clip(int(plotScaleX*hPlotLeft), topClip, plotWLeg, plotHLeg);
if (legendAnchor != TOP) { if (legendAnchor != TOP) {
if (!IsNull(legendFillColor)) if (!IsNull(legendFillColor))
FillRectangle(w, rect, legendFillColor); FillRectangle(w, rect, legendFillColor);
if (!IsNull(legendBorderColor)) if (!IsNull(legendBorderColor))
DrawRectangle(w, rect, textScale, 1, legendBorderColor); DrawRectangle(w, rect, textScale, 1, legendBorderColor);
} }
for(int row = 0, start = 0, i = 0, ireal = 0; row <= nrows; row++) { for(int row = 0, start = 0, i = 0, ireal = 0; row <= nrows; row++) {
for(; ireal < min(start + nlr, nlab); i++) { for(; ireal < min(start + nlr, nlab); i++) {
if (series[i].showLegend) { const ScatterSeries &serie = series[i];
if (serie.IsDeleted() || serie.opacity == 0)
continue;
if (serie.showLegend) {
double lx = rect.left + (ireal - start)*legendWid th + xWidth; double lx = rect.left + (ireal - start)*legendWid th + xWidth;
double ly = (rowIncSign >= 0 ? rect.top : rect.bo ttom) + double ly = (rowIncSign >= 0 ? rect.top : rect.bo ttom) +
rowIncSign*int(rowHeight*(row + 0.6) + loclegendRowSpacing*(row + 0.5)); rowIncSign*int(rowHeight*(row + 0.6) + loclegendRowSpacing*(row + 0.5));
Vector <Pointf> line; Vector <Pointf> line;
double dashLen = GetDashLength(series[i].dash)*te xtScale; double dashLen = GetDashLength(serie.dash)*textSc ale;
double realLineLen = lineLen/dashLen > 1 ? dashLe n*int(lineLen/dashLen) : lineLen; double realLineLen = lineLen/dashLen > 1 ? dashLe n*int(lineLen/dashLen) : lineLen;
line << Pointf(lx, ly) << Pointf(lx + realLineLen , ly); line << Pointf(lx, ly) << Pointf(lx + realLineLen , ly);
if (series[i].opacity > 0 && series[i].seriesPlot if (serie.opacity > 0 && serie.seriesPlot)
) DrawPolylineOpa(w, line, textScale, 1, se
DrawPolylineOpa(w, line, textScale, 1, se rie.thickness, serie.color, serie.dash);
ries[i].thickness, series[i].color, series[i].dash);
Pointf mark_p(lx + xWidth, ly); Pointf mark_p(lx + xWidth, ly);
if (series[i].markWidth >= 1 && series[i].markPlo if (serie.markWidth >= 1 && serie.markPlot)
t) serie.markPlot->Paint(w, plotScaleAvg, ma
series[i].markPlot->Paint(w, plotScaleAvg rk_p, serie.markWidth, serie.markColor,
, mark_p, series[i].markWidth, series[i].markColor, serie.markBorderWidth, serie.mark
series[i].markBorderWidth, series BorderColor);
[i].markBorderColor); Upp::Font &font = serie.primaryY ? boldFont : ita
Upp::Font &font = series[i].primaryY ? boldFont : lic;
italic; DrawText(w, lx + lineLen + xWidth, ly - int((2*ro
DrawText(w, lx + lineLen + xWidth, ly - int((2*ro wAscent)/3), 0, legends[ireal], font, serie.color);
wAscent)/3), 0, legends[ireal], font, series[i].color);
ireal++; ireal++;
} }
} }
start = ireal; start = ireal;
} }
w.End(); w.End();
} }
void ScatterDraw::DrawRainbowPalette(Draw& w) const { void ScatterDraw::DrawRainbowPalette(Draw& w) const {
double plotLeft = plotScaleX*hPlotLeft; double plotLeft = plotScaleX*hPlotLeft;
 End of changes. 6 change blocks. 
21 lines changed or deleted 28 lines changed or added

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